diff --git a/client/cluster.go b/client/cluster.go index a62321ed..261363c8 100644 --- a/client/cluster.go +++ b/client/cluster.go @@ -313,3 +313,13 @@ func (h *V1Client) DownloadLogs(uid string, logFetcherUID string) (io.Writer, er return logfile, nil } + +// UpdatePauseAgentUpgradeSettingCluster updates the upgrade settings of a specific cluster to pause the agent upgrade process. +func (h *V1Client) UpdatePauseAgentUpgradeSettingCluster(upgradeSetting *models.V1ClusterUpgradeSettingsEntity, clusterUID string) error { + params := clientv1.NewV1SpectroClustersUIDUpgradeSettingsParamsWithContext(h.ctx).WithUID(clusterUID).WithBody(upgradeSetting) + _, err := h.Client.V1SpectroClustersUIDUpgradeSettings(params) + if err != nil { + return err + } + return nil +} diff --git a/client/cluster_host_config.go b/client/cluster_host_config.go index f09dc340..61bf7326 100644 --- a/client/cluster_host_config.go +++ b/client/cluster_host_config.go @@ -13,3 +13,15 @@ func (h *V1Client) UpdateClusterHostConfig(uid string, config *models.V1HostClus _, err := h.Client.V1HostClusterConfigUpdate(params) return err } + +// ApplyClusterHostConfig applies the specified host configuration to the cluster identified by the given UID. +func (h *V1Client) ApplyClusterHostConfig(uid string, config *models.V1HostClusterConfigEntity) error { + policy, err := h.GetClusterScanConfig(uid) + if err != nil { + return err + } + if policy == nil { + return h.UpdateClusterHostConfig(uid, config) + } + return h.UpdateClusterHostConfig(uid, config) +} diff --git a/client/cluster_profile_import.go b/client/cluster_profile_import.go index 5c9e597a..b3713b96 100644 --- a/client/cluster_profile_import.go +++ b/client/cluster_profile_import.go @@ -2,6 +2,7 @@ package client import ( "github.com/go-openapi/runtime" + "github.com/spectrocloud/palette-api-go/models" clientv1 "github.com/spectrocloud/palette-api-go/client/v1" "github.com/spectrocloud/palette-sdk-go/client/apiutil" @@ -18,3 +19,15 @@ func (h *V1Client) CreateClusterProfileImport(importFile runtime.NamedReadCloser } return *resp.Payload.UID, nil } + +// ClusterProfileExport retrieves and exports a cluster profile by its unique identifier. +func (h *V1Client) ClusterProfileExport(uid string) (*models.V1ClusterProfile, error) { + // no need to switch request context here as /v1/clusterprofiles/{uid} works for profile in any scope. + params := clientv1.NewV1ClusterProfilesGetParamsWithContext(h.ctx).WithUID(uid) + success, err := h.Client.V1ClusterProfilesGet(params) + if err != nil { + return nil, err + } + return success.Payload, nil + +} diff --git a/client/node_actions.go b/client/node_actions.go index 40516e36..9c973a15 100644 --- a/client/node_actions.go +++ b/client/node_actions.go @@ -5,6 +5,9 @@ import ( "github.com/spectrocloud/palette-api-go/models" ) +// GetMaintenanceStatus defines a function type that retrieves the maintenance status of a machine. +type GetMaintenanceStatus func(string, string, string) (*models.V1MachineMaintenanceStatus, error) + // ToggleMaintenanceOnNode updates maintenance configuration for a node. func (h *V1Client) ToggleMaintenanceOnNode(nodeMaintenance *models.V1MachineMaintenance, cloudType, configUID, machineName, nodeID string) error { params := clientv1.NewV1CloudConfigsMachinePoolsMachineUIDMaintenanceUpdateParamsWithContext(h.ctx). @@ -18,6 +21,11 @@ func (h *V1Client) ToggleMaintenanceOnNode(nodeMaintenance *models.V1MachineMain return err } +// GetNodeMaintenanceStatus retrieves the maintenance status of a specific node. +func (h *V1Client) GetNodeMaintenanceStatus(fn GetMaintenanceStatus, ConfigUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) { + return fn(ConfigUID, machineName, nodeID) +} + // GetNodeMaintenanceStatusAws retrieves maintenance status for an AWS IaaS node. func (h *V1Client) GetNodeMaintenanceStatusAws(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) { params := clientv1.NewV1CloudConfigsAwsPoolMachinesUIDGetParamsWithContext(h.ctx). diff --git a/client/tenant.go b/client/tenant.go index 1b87f314..82551aad 100644 --- a/client/tenant.go +++ b/client/tenant.go @@ -8,6 +8,7 @@ func (h *V1Client) GetTenantUID() (string, error) { if err != nil { return "", err } + if resp == nil { return "", errors.New("empty response received from GetUsersInfo()") } diff --git a/client/user.go b/client/user.go index a870a83e..d61e9810 100644 --- a/client/user.go +++ b/client/user.go @@ -33,6 +33,7 @@ func (h *V1Client) AuthRefreshToken(token string) (*models.V1UserToken, error) { // GetUsersInfo retrieves the authenticated user info. func (h *V1Client) GetUsersInfo() (*models.V1UserInfo, error) { params := clientv1.NewV1UsersInfoGetParamsWithContext(h.ctx) + resp, err := h.Client.V1UsersInfoGet(params) if err != nil { return nil, err diff --git a/go.mod b/go.mod index 8b4a4282..b34b03d3 100644 --- a/go.mod +++ b/go.mod @@ -41,3 +41,5 @@ require ( golang.org/x/sys v0.22.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +//replace github.com/spectrocloud/palette-api-go => ../palette-api-go