Skip to content

Commit e47062a

Browse files
authored
SDK Support for 4.6.a (#153)
* 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]>
1 parent 4e0d6d5 commit e47062a

File tree

5 files changed

+188
-0
lines changed

5 files changed

+188
-0
lines changed

client/alert.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ func (h *V1Client) UpdateAlert(body *models.V1Channel, projectUID, component, al
3232
return "success", nil
3333
}
3434

35+
// UpdateProjectAlerts update alerts for project.
36+
func (h *V1Client) UpdateProjectAlerts(body *models.V1AlertEntity, projectUID, component string) error {
37+
params := clientv1.NewV1ProjectsUIDAlertUpdateParamsWithContext(h.ctx).WithBody(body).WithUID(projectUID).
38+
WithComponent(component)
39+
_, err := h.Client.V1ProjectsUIDAlertUpdate(params)
40+
return err
41+
}
42+
3543
// GetAlert retrieves an existing alert.
3644
func (h *V1Client) GetAlert(projectUID, component, alertUID string) (*models.V1Channel, error) {
3745
params := clientv1.NewV1ProjectsUIDAlertsUIDGetParamsWithContext(h.ctx).

client/cluster_edge_native.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,41 @@ func (h *V1Client) GetRegistrationToken(tokenName string) (string, error) {
3232
return "", nil
3333
}
3434

35+
// GetRegistrationTokenByUID retrieves an existing registration token by token UID.
36+
func (h *V1Client) GetRegistrationTokenByUID(tokenUID string) (*models.V1EdgeToken, error) {
37+
// ACL scoped to tenant only
38+
params := clientv1.NewV1EdgeTokensUIDGetParams().WithUID(tokenUID)
39+
resp, err := h.Client.V1EdgeTokensUIDGet(params)
40+
if err != nil {
41+
return nil, err
42+
}
43+
token := resp.Payload
44+
if token == nil {
45+
return nil, errors.New("failed to list registration tokens")
46+
}
47+
return resp.Payload, nil
48+
}
49+
50+
// GetRegistrationTokenByName retrieves an existing registration token by name.
51+
func (h *V1Client) GetRegistrationTokenByName(tokenName string) (*models.V1EdgeToken, error) {
52+
// ACL scoped to tenant only
53+
params := clientv1.NewV1EdgeTokensListParams()
54+
resp, err := h.Client.V1EdgeTokensList(params)
55+
if err != nil {
56+
return nil, err
57+
}
58+
tokens := resp.GetPayload()
59+
if tokens == nil {
60+
return nil, errors.New("failed to list registration tokens")
61+
}
62+
for _, token := range tokens.Items {
63+
if token.Metadata.Name == tokenName {
64+
return token, nil
65+
}
66+
}
67+
return nil, nil
68+
}
69+
3570
// CreateRegistrationToken creates a new registration token.
3671
func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, string, error) {
3772
// ACL scoped to tenant only
@@ -46,6 +81,18 @@ func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1Edge
4681
return *res.Payload.UID, token, err
4782
}
4883

84+
// UpdateRegistrationTokenByUID update an existing registration token by uid.
85+
func (h *V1Client) UpdateRegistrationTokenByUID(tokenUID string, body *models.V1EdgeTokenUpdate) error {
86+
// ACL scoped to tenant only
87+
params := clientv1.NewV1EdgeTokensUIDUpdateParamsWithContext(h.ctx).WithUID(tokenUID).
88+
WithBody(body)
89+
_, err := h.Client.V1EdgeTokensUIDUpdate(params)
90+
if err != nil {
91+
return err
92+
}
93+
return nil
94+
}
95+
4996
// DeleteRegistrationToken deletes a registration token by name.
5097
func (h *V1Client) DeleteRegistrationToken(tokenUID string) error {
5198
// ACL scoped to tenant only
@@ -257,3 +304,10 @@ func (h *V1Client) GetNodeStatusMapEdgeNative(configUID, machinePoolName string)
257304
}
258305
return nMap, nil
259306
}
307+
308+
// UpdateRegistrationTokenState set registration token state
309+
func (h *V1Client) UpdateRegistrationTokenState(tokenUID string, body *models.V1EdgeTokenActiveState) error {
310+
params := clientv1.NewV1EdgeTokensUIDStateParams().WithUID(tokenUID).WithBody(body)
311+
_, err := h.Client.V1EdgeTokensUIDState(params)
312+
return err
313+
}

client/cluster_group.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,17 @@ func (h *V1Client) clusterGroupMetadata() ([]*models.V1ObjectScopeEntity, error)
140140
}
141141
return resp.Payload.Items, nil
142142
}
143+
144+
// UpdateSystemClusterGroupPreference updates system cluster group preferences.
145+
func (h *V1Client) UpdateSystemClusterGroupPreference(tenantUID string, body *models.V1TenantEnableClusterGroup) error {
146+
params := clientv1.NewV1TenantPrefClusterGroupUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
147+
_, err := h.Client.V1TenantPrefClusterGroupUpdate(params)
148+
return err
149+
}
150+
151+
// GetSystemClusterGroupPreference get system cluster group preferences.
152+
func (h *V1Client) GetSystemClusterGroupPreference(tenantUID string) (*models.V1TenantEnableClusterGroup, error) {
153+
params := clientv1.NewV1TenantPrefClusterGroupGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
154+
resp, err := h.Client.V1TenantPrefClusterGroupGet(params)
155+
return resp.Payload, err
156+
}

client/developer_setting.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package client
2+
3+
import (
4+
clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1"
5+
"github.com/spectrocloud/palette-sdk-go/api/models"
6+
)
7+
8+
// UpdateDeveloperSetting update a Developer Settings
9+
func (h *V1Client) UpdateDeveloperSetting(tenantUID string, body *models.V1DeveloperCredit) error {
10+
params := clientv1.NewV1TenantDeveloperCreditUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
11+
_, err := h.Client.V1TenantDeveloperCreditUpdate(params)
12+
return err
13+
}
14+
15+
// GetDeveloperSetting retrieves an existing a Developer Settings by tenant UID
16+
func (h *V1Client) GetDeveloperSetting(tenantUID string) (*models.V1DeveloperCredit, error) {
17+
params := clientv1.NewV1TenantDeveloperCreditGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
18+
resp, err := h.Client.V1TenantDeveloperCreditGet(params)
19+
return resp.Payload, err
20+
}

client/platform_setting.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package client
2+
3+
import (
4+
clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1"
5+
"github.com/spectrocloud/palette-sdk-go/api/models"
6+
)
7+
8+
// UpdateSessionTimeout update session timout for platform
9+
func (h *V1Client) UpdateSessionTimeout(tenantUID string, body *models.V1AuthTokenSettings) error {
10+
params := clientv1.NewV1TenantUIDAuthTokenSettingsUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
11+
_, err := h.Client.V1TenantUIDAuthTokenSettingsUpdate(params)
12+
return err
13+
}
14+
15+
// GetSessionTimeout get session timout for platform
16+
func (h *V1Client) GetSessionTimeout(tenantUID string) (*models.V1AuthTokenSettings, error) {
17+
params := clientv1.NewV1TenantUIDAuthTokenSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
18+
resp, err := h.Client.V1TenantUIDAuthTokenSettingsGet(params)
19+
return resp.Payload, err
20+
}
21+
22+
// UpdatePlatformClusterUpgradeSetting update clusters agent upgrade setting for tenant
23+
func (h *V1Client) UpdatePlatformClusterUpgradeSetting(body *models.V1ClusterUpgradeSettingsEntity) error {
24+
params := clientv1.NewV1SpectroClustersUpgradeSettingsParamsWithContext(h.ctx).WithBody(body)
25+
_, err := h.Client.V1SpectroClustersUpgradeSettings(params)
26+
return err
27+
}
28+
29+
// GetPlatformClustersUpgradeSetting get clusters agent upgrade setting for tenant
30+
func (h *V1Client) GetPlatformClustersUpgradeSetting() (*models.V1ClusterUpgradeSettingsEntity, error) {
31+
params := clientv1.NewV1SpectroClustersUpgradeSettingsGetParamsWithContext(h.ctx)
32+
resp, err := h.Client.V1SpectroClustersUpgradeSettingsGet(params)
33+
return resp.Payload, err
34+
}
35+
36+
// UpdateClusterAutoRemediationForTenant update cluster auto remediation for platform
37+
func (h *V1Client) UpdateClusterAutoRemediationForTenant(tenantUID string, body *models.V1NodesAutoRemediationSettings) error {
38+
params := clientv1.NewV1TenantClustersNodesAutoRemediationSettingUpdateParamsWithContext(h.ctx).
39+
WithTenantUID(tenantUID).WithBody(body)
40+
_, err := h.Client.V1TenantClustersNodesAutoRemediationSettingUpdate(params)
41+
return err
42+
}
43+
44+
// GetClusterAutoRemediationForTenant get cluster auto remediation for platform
45+
func (h *V1Client) GetClusterAutoRemediationForTenant(tenantUID string) (*models.V1TenantClusterSettings, error) {
46+
params := clientv1.NewV1TenantClusterSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
47+
resp, err := h.Client.V1TenantClusterSettingsGet(params)
48+
return resp.Payload, err
49+
}
50+
51+
// UpdateClusterAutoRemediationForProject update cluster auto remediation for project
52+
func (h *V1Client) UpdateClusterAutoRemediationForProject(projectUID string, body *models.V1NodesAutoRemediationSettings) error {
53+
params := clientv1.NewV1ProjectClustersNodesAutoRemediationSettingUpdateParamsWithContext(h.ctx).
54+
WithUID(projectUID).WithBody(body)
55+
_, err := h.Client.V1ProjectClustersNodesAutoRemediationSettingUpdate(params)
56+
return err
57+
}
58+
59+
// GetClusterAutoRemediationForProject get cluster auto remediation for project
60+
func (h *V1Client) GetClusterAutoRemediationForProject(projectUID string) (*models.V1ProjectClusterSettings, error) {
61+
params := clientv1.NewV1ProjectClusterSettingsGetParamsWithContext(h.ctx).WithUID(projectUID)
62+
resp, err := h.Client.V1ProjectClusterSettingsGet(params)
63+
return resp.Payload, err
64+
}
65+
66+
// UpdateLoginBanner update login banner details for platform
67+
func (h *V1Client) UpdateLoginBanner(tenantUID string, body *models.V1LoginBannerSettings) error {
68+
params := clientv1.NewV1TenantUIDLoginBannerUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
69+
_, err := h.Client.V1TenantUIDLoginBannerUpdate(params)
70+
return err
71+
}
72+
73+
// GetLoginBanner get login banner details for platform
74+
func (h *V1Client) GetLoginBanner(tenantUID string) (*models.V1LoginBannerSettings, error) {
75+
params := clientv1.NewV1TenantUIDLoginBannerGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
76+
resp, err := h.Client.V1TenantUIDLoginBannerGet(params)
77+
return resp.Payload, err
78+
}
79+
80+
// UpdateFIPSPreference update fips preference for platform
81+
func (h *V1Client) UpdateFIPSPreference(tenantUID string, body *models.V1FipsSettings) error {
82+
params := clientv1.NewV1TenantFipsSettingsUpdateParamsWithContext(h.ctx).WithTenantUID(tenantUID).WithBody(body)
83+
_, err := h.Client.V1TenantFipsSettingsUpdate(params)
84+
return err
85+
}
86+
87+
// GetFIPSPreference get fips preference for platform
88+
func (h *V1Client) GetFIPSPreference(tenantUID string) (*models.V1FipsSettings, error) {
89+
params := clientv1.NewV1TenantFipsSettingsGetParamsWithContext(h.ctx).WithTenantUID(tenantUID)
90+
resp, err := h.Client.V1TenantFipsSettingsGet(params)
91+
return resp.Payload, err
92+
}

0 commit comments

Comments
 (0)