diff --git a/clients/instance/ibm-pi-hostgroups.go b/clients/instance/ibm-pi-host-groups.go similarity index 54% rename from clients/instance/ibm-pi-hostgroups.go rename to clients/instance/ibm-pi-host-groups.go index 4ded770e..7514abdd 100644 --- a/clients/instance/ibm-pi-hostgroups.go +++ b/clients/instance/ibm-pi-host-groups.go @@ -6,7 +6,7 @@ import ( "github.com/IBM-Cloud/power-go-client/helpers" "github.com/IBM-Cloud/power-go-client/ibmpisession" - "github.com/IBM-Cloud/power-go-client/power/client/hostgroups" + "github.com/IBM-Cloud/power-go-client/power/client/host_groups" "github.com/IBM-Cloud/power-go-client/power/models" ) @@ -24,8 +24,11 @@ func NewIBMPHostgroupsClient(ctx context.Context, sess *ibmpisession.IBMPISessio // Get All available hosts func (f *IBMPIHostgroupsClient) GetAvailableHosts() (models.AvailableHostList, error) { - params := hostgroups.NewV1AvailableHostsParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) - resp, err := f.session.Power.Hostgroups.V1AvailableHosts(params, f.session.AuthInfo(f.cloudInstanceID)) + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1AvailableHostsParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) + resp, err := f.session.Power.HostGroups.V1AvailableHosts(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get available hosts for %s: %w", f.cloudInstanceID, err)) } @@ -36,10 +39,13 @@ func (f *IBMPIHostgroupsClient) GetAvailableHosts() (models.AvailableHostList, e return resp.Payload, nil } -// Get all Hostgroups -func (f *IBMPIHostgroupsClient) GetHostgroups() (models.HostgroupList, error) { - params := hostgroups.NewV1HostgroupsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) - resp, err := f.session.Power.Hostgroups.V1HostgroupsGet(params, f.session.AuthInfo(f.cloudInstanceID)) +// Get all HostGroups +func (f *IBMPIHostgroupsClient) GetHostGroups() (models.HostGroupList, error) { + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostGroupsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) + resp, err := f.session.Power.HostGroups.V1HostGroupsGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Hostgroups for %s: %w", f.cloudInstanceID, err)) } @@ -50,10 +56,13 @@ func (f *IBMPIHostgroupsClient) GetHostgroups() (models.HostgroupList, error) { return resp.Payload, nil } -// Create a Hostgroup -func (f *IBMPIHostgroupsClient) CreateHostgroup(body *models.HostgroupCreate) (*models.Hostgroup, error) { - params := hostgroups.NewV1HostgroupsPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body) - resp, err := f.session.Power.Hostgroups.V1HostgroupsPost(params, f.session.AuthInfo(f.cloudInstanceID)) +// Create a HostGroup +func (f *IBMPIHostgroupsClient) CreateHostGroup(body *models.HostGroupCreate) (*models.HostGroup, error) { + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostGroupsPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body) + resp, err := f.session.Power.HostGroups.V1HostGroupsPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Create Hostgroup for %s: %w", f.cloudInstanceID, err)) } @@ -64,10 +73,13 @@ func (f *IBMPIHostgroupsClient) CreateHostgroup(body *models.HostgroupCreate) (* return resp.Payload, nil } -// Update a Hostgroup -func (f *IBMPIHostgroupsClient) UpdateHostgroup(body *models.HostgroupShareOp, id string) (*models.Hostgroup, error) { - params := hostgroups.NewV1HostgroupsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body).WithHostgroupID(id) - resp, err := f.session.Power.Hostgroups.V1HostgroupsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) +// Update a HostGroup +func (f *IBMPIHostgroupsClient) UpdateHostGroup(body *models.HostGroupShareOp, id string) (*models.HostGroup, error) { + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostGroupsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body).WithHostGroupID(id) + resp, err := f.session.Power.HostGroups.V1HostGroupsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Update Hostgroup for %s: %w", f.cloudInstanceID, err)) } @@ -79,9 +91,12 @@ func (f *IBMPIHostgroupsClient) UpdateHostgroup(body *models.HostgroupShareOp, i } // Get a Hostgroup -func (f *IBMPIHostgroupsClient) GetHostgroup(id string) (*models.Hostgroup, error) { - params := hostgroups.NewV1HostgroupsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostgroupID(id) - resp, err := f.session.Power.Hostgroups.V1HostgroupsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) +func (f *IBMPIHostgroupsClient) GetHostGroup(id string) (*models.HostGroup, error) { + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostGroupsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostGroupID(id) + resp, err := f.session.Power.HostGroups.V1HostGroupsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Hostgroup %s for %s: %w", id, f.cloudInstanceID, err)) } @@ -94,8 +109,11 @@ func (f *IBMPIHostgroupsClient) GetHostgroup(id string) (*models.Hostgroup, erro // Get All Hosts func (f *IBMPIHostgroupsClient) GetHosts() (models.HostList, error) { - params := hostgroups.NewV1HostsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) - resp, err := f.session.Power.Hostgroups.V1HostsGet(params, f.session.AuthInfo(f.cloudInstanceID)) + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) + resp, err := f.session.Power.HostGroups.V1HostsGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Hosts for %s: %w", f.cloudInstanceID, err)) } @@ -107,9 +125,12 @@ func (f *IBMPIHostgroupsClient) GetHosts() (models.HostList, error) { } // Create a Host -func (f *IBMPIHostgroupsClient) CreateHost(body *models.HostCreate) (*models.Host, error) { - params := hostgroups.NewV1HostsPostParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithBody(body) - resp, err := f.session.Power.Hostgroups.V1HostsPost(params, f.session.AuthInfo(f.cloudInstanceID)) +func (f *IBMPIHostgroupsClient) CreateHost(body *models.HostCreate) (models.HostList, error) { + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostsPostParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithBody(body) + resp, err := f.session.Power.HostGroups.V1HostsPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Create Hosts for %s: %w", f.cloudInstanceID, err)) } @@ -122,8 +143,11 @@ func (f *IBMPIHostgroupsClient) CreateHost(body *models.HostCreate) (*models.Hos // Get a Host func (f *IBMPIHostgroupsClient) GetHost(id string) (*models.Host, error) { - params := hostgroups.NewV1HostsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id) - resp, err := f.session.Power.Hostgroups.V1HostsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id) + resp, err := f.session.Power.HostGroups.V1HostsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Host %s for %s: %w", id, f.cloudInstanceID, err)) } @@ -136,8 +160,11 @@ func (f *IBMPIHostgroupsClient) GetHost(id string) (*models.Host, error) { // Update a Host func (f *IBMPIHostgroupsClient) UpdateHost(body *models.HostPut, id string) (*models.Host, error) { - params := hostgroups.NewV1HostsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id).WithBody(body) - resp, err := f.session.Power.Hostgroups.V1HostsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) + if f.session.IsOnPrem() { + return nil, fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id).WithBody(body) + resp, err := f.session.Power.HostGroups.V1HostsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Update Host %s for %s: %w", id, f.cloudInstanceID, err)) } @@ -150,8 +177,11 @@ func (f *IBMPIHostgroupsClient) UpdateHost(body *models.HostPut, id string) (*mo // Delete a Host func (f *IBMPIHostgroupsClient) DeleteHost(id string) error { - params := hostgroups.NewV1HostsIDDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id) - resp, err := f.session.Power.Hostgroups.V1HostsIDDelete(params, f.session.AuthInfo(f.cloudInstanceID)) + if f.session.IsOnPrem() { + return fmt.Errorf("operation not supported in satellite location, check documentation") + } + params := host_groups.NewV1HostsIDDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id) + resp, err := f.session.Power.HostGroups.V1HostsIDDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Delete Host %s for %s: %w", id, f.cloudInstanceID, err)) } diff --git a/examples/hostgroups/main.go b/examples/hostgroups/main.go index d1ab8bfa..fbe1baeb 100644 --- a/examples/hostgroups/main.go +++ b/examples/hostgroups/main.go @@ -54,7 +54,7 @@ func main() { } log.Printf("***************[0]****************** %+v \n", getAllAvailableHost) - getHostgroups, err := powerClient.GetHostgroups() + getHostgroups, err := powerClient.GetHostGroups() if err != nil { log.Fatal(err) }