Skip to content

Commit

Permalink
SDK Support for 4.6.a (#153)
Browse files Browse the repository at this point in the history
* Add support for alert channel updates
* Add support for developer settings
* Add support for platform settings
* Add support for registration token actions
---------

Signed-off-by: Sivaanand Murugesan <[email protected]>
  • Loading branch information
SivaanandM authored Mar 3, 2025
1 parent 4e0d6d5 commit e47062a
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func (h *V1Client) UpdateAlert(body *models.V1Channel, projectUID, component, al
return "success", nil
}

// UpdateProjectAlerts update alerts for project.
func (h *V1Client) UpdateProjectAlerts(body *models.V1AlertEntity, projectUID, component string) error {
params := clientv1.NewV1ProjectsUIDAlertUpdateParamsWithContext(h.ctx).WithBody(body).WithUID(projectUID).
WithComponent(component)
_, err := h.Client.V1ProjectsUIDAlertUpdate(params)
return err
}

// GetAlert retrieves an existing alert.
func (h *V1Client) GetAlert(projectUID, component, alertUID string) (*models.V1Channel, error) {
params := clientv1.NewV1ProjectsUIDAlertsUIDGetParamsWithContext(h.ctx).
Expand Down
54 changes: 54 additions & 0 deletions client/cluster_edge_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,41 @@ func (h *V1Client) GetRegistrationToken(tokenName string) (string, error) {
return "", nil
}

// GetRegistrationTokenByUID retrieves an existing registration token by token UID.
func (h *V1Client) GetRegistrationTokenByUID(tokenUID string) (*models.V1EdgeToken, error) {
// ACL scoped to tenant only
params := clientv1.NewV1EdgeTokensUIDGetParams().WithUID(tokenUID)
resp, err := h.Client.V1EdgeTokensUIDGet(params)
if err != nil {
return nil, err
}
token := resp.Payload
if token == nil {
return nil, errors.New("failed to list registration tokens")
}
return resp.Payload, nil
}

// GetRegistrationTokenByName retrieves an existing registration token by name.
func (h *V1Client) GetRegistrationTokenByName(tokenName string) (*models.V1EdgeToken, error) {
// ACL scoped to tenant only
params := clientv1.NewV1EdgeTokensListParams()
resp, err := h.Client.V1EdgeTokensList(params)
if err != nil {
return nil, err
}
tokens := resp.GetPayload()
if tokens == nil {
return nil, errors.New("failed to list registration tokens")
}
for _, token := range tokens.Items {
if token.Metadata.Name == tokenName {
return token, nil
}
}
return nil, nil
}

// CreateRegistrationToken creates a new registration token.
func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, string, error) {
// ACL scoped to tenant only
Expand All @@ -46,6 +81,18 @@ func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1Edge
return *res.Payload.UID, token, err
}

// UpdateRegistrationTokenByUID update an existing registration token by uid.
func (h *V1Client) UpdateRegistrationTokenByUID(tokenUID string, body *models.V1EdgeTokenUpdate) error {
// ACL scoped to tenant only
params := clientv1.NewV1EdgeTokensUIDUpdateParamsWithContext(h.ctx).WithUID(tokenUID).
WithBody(body)
_, err := h.Client.V1EdgeTokensUIDUpdate(params)
if err != nil {
return err
}
return nil
}

// DeleteRegistrationToken deletes a registration token by name.
func (h *V1Client) DeleteRegistrationToken(tokenUID string) error {
// ACL scoped to tenant only
Expand Down Expand Up @@ -257,3 +304,10 @@ func (h *V1Client) GetNodeStatusMapEdgeNative(configUID, machinePoolName string)
}
return nMap, nil
}

// UpdateRegistrationTokenState set registration token state
func (h *V1Client) UpdateRegistrationTokenState(tokenUID string, body *models.V1EdgeTokenActiveState) error {
params := clientv1.NewV1EdgeTokensUIDStateParams().WithUID(tokenUID).WithBody(body)
_, err := h.Client.V1EdgeTokensUIDState(params)
return err
}
14 changes: 14 additions & 0 deletions client/cluster_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,17 @@ func (h *V1Client) clusterGroupMetadata() ([]*models.V1ObjectScopeEntity, error)
}
return resp.Payload.Items, nil
}

// UpdateSystemClusterGroupPreference updates system cluster group preferences.
func (h *V1Client) UpdateSystemClusterGroupPreference(tenantUID string, body *models.V1TenantEnableClusterGroup) error {
params := clientv1.NewV1TenantPrefClusterGroupUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantPrefClusterGroupUpdate(params)
return err
}

// GetSystemClusterGroupPreference get system cluster group preferences.
func (h *V1Client) GetSystemClusterGroupPreference(tenantUID string) (*models.V1TenantEnableClusterGroup, error) {
params := clientv1.NewV1TenantPrefClusterGroupGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantPrefClusterGroupGet(params)
return resp.Payload, err
}
20 changes: 20 additions & 0 deletions client/developer_setting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package client

import (
clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

// UpdateDeveloperSetting update a Developer Settings
func (h *V1Client) UpdateDeveloperSetting(tenantUID string, body *models.V1DeveloperCredit) error {
params := clientv1.NewV1TenantDeveloperCreditUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantDeveloperCreditUpdate(params)
return err
}

// GetDeveloperSetting retrieves an existing a Developer Settings by tenant UID
func (h *V1Client) GetDeveloperSetting(tenantUID string) (*models.V1DeveloperCredit, error) {
params := clientv1.NewV1TenantDeveloperCreditGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantDeveloperCreditGet(params)
return resp.Payload, err
}
92 changes: 92 additions & 0 deletions client/platform_setting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package client

import (
clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

// UpdateSessionTimeout update session timout for platform
func (h *V1Client) UpdateSessionTimeout(tenantUID string, body *models.V1AuthTokenSettings) error {
params := clientv1.NewV1TenantUIDAuthTokenSettingsUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantUIDAuthTokenSettingsUpdate(params)
return err
}

// GetSessionTimeout get session timout for platform
func (h *V1Client) GetSessionTimeout(tenantUID string) (*models.V1AuthTokenSettings, error) {
params := clientv1.NewV1TenantUIDAuthTokenSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantUIDAuthTokenSettingsGet(params)
return resp.Payload, err
}

// UpdatePlatformClusterUpgradeSetting update clusters agent upgrade setting for tenant
func (h *V1Client) UpdatePlatformClusterUpgradeSetting(body *models.V1ClusterUpgradeSettingsEntity) error {
params := clientv1.NewV1SpectroClustersUpgradeSettingsParamsWithContext(h.ctx).WithBody(body)
_, err := h.Client.V1SpectroClustersUpgradeSettings(params)
return err
}

// GetPlatformClustersUpgradeSetting get clusters agent upgrade setting for tenant
func (h *V1Client) GetPlatformClustersUpgradeSetting() (*models.V1ClusterUpgradeSettingsEntity, error) {
params := clientv1.NewV1SpectroClustersUpgradeSettingsGetParamsWithContext(h.ctx)
resp, err := h.Client.V1SpectroClustersUpgradeSettingsGet(params)
return resp.Payload, err
}

// UpdateClusterAutoRemediationForTenant update cluster auto remediation for platform
func (h *V1Client) UpdateClusterAutoRemediationForTenant(tenantUID string, body *models.V1NodesAutoRemediationSettings) error {
params := clientv1.NewV1TenantClustersNodesAutoRemediationSettingUpdateParamsWithContext(h.ctx).
WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantClustersNodesAutoRemediationSettingUpdate(params)
return err
}

// GetClusterAutoRemediationForTenant get cluster auto remediation for platform
func (h *V1Client) GetClusterAutoRemediationForTenant(tenantUID string) (*models.V1TenantClusterSettings, error) {
params := clientv1.NewV1TenantClusterSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantClusterSettingsGet(params)
return resp.Payload, err
}

// UpdateClusterAutoRemediationForProject update cluster auto remediation for project
func (h *V1Client) UpdateClusterAutoRemediationForProject(projectUID string, body *models.V1NodesAutoRemediationSettings) error {
params := clientv1.NewV1ProjectClustersNodesAutoRemediationSettingUpdateParamsWithContext(h.ctx).
WithUID(projectUID).WithBody(body)
_, err := h.Client.V1ProjectClustersNodesAutoRemediationSettingUpdate(params)
return err
}

// GetClusterAutoRemediationForProject get cluster auto remediation for project
func (h *V1Client) GetClusterAutoRemediationForProject(projectUID string) (*models.V1ProjectClusterSettings, error) {
params := clientv1.NewV1ProjectClusterSettingsGetParamsWithContext(h.ctx).WithUID(projectUID)
resp, err := h.Client.V1ProjectClusterSettingsGet(params)
return resp.Payload, err
}

// UpdateLoginBanner update login banner details for platform
func (h *V1Client) UpdateLoginBanner(tenantUID string, body *models.V1LoginBannerSettings) error {
params := clientv1.NewV1TenantUIDLoginBannerUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantUIDLoginBannerUpdate(params)
return err
}

// GetLoginBanner get login banner details for platform
func (h *V1Client) GetLoginBanner(tenantUID string) (*models.V1LoginBannerSettings, error) {
params := clientv1.NewV1TenantUIDLoginBannerGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantUIDLoginBannerGet(params)
return resp.Payload, err
}

// UpdateFIPSPreference update fips preference for platform
func (h *V1Client) UpdateFIPSPreference(tenantUID string, body *models.V1FipsSettings) error {
params := clientv1.NewV1TenantFipsSettingsUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
_, err := h.Client.V1TenantFipsSettingsUpdate(params)
return err
}

// GetFIPSPreference get fips preference for platform
func (h *V1Client) GetFIPSPreference(tenantUID string) (*models.V1FipsSettings, error) {
params := clientv1.NewV1TenantFipsSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
resp, err := h.Client.V1TenantFipsSettingsGet(params)
return resp.Payload, err
}

0 comments on commit e47062a

Please sign in to comment.