|
| 1 | +package instance |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/IBM-Cloud/power-go-client/errors" |
| 8 | + "github.com/IBM-Cloud/power-go-client/helpers" |
| 9 | + |
| 10 | + "github.com/IBM-Cloud/power-go-client/ibmpisession" |
| 11 | + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_tiers" |
| 12 | + "github.com/IBM-Cloud/power-go-client/power/models" |
| 13 | +) |
| 14 | + |
| 15 | +// IBMPIStorageTierClient |
| 16 | +type IBMPIStorageTierClient struct { |
| 17 | + IBMPIClient |
| 18 | +} |
| 19 | + |
| 20 | +// NewIBMPIStorageTierClient |
| 21 | +func NewIBMPIStorageTierClient(ctx context.Context, sess *ibmpisession.IBMPISession, cloudInstanceID string) *IBMPIStorageTierClient { |
| 22 | + return &IBMPIStorageTierClient{ |
| 23 | + *NewIBMPIClient(ctx, sess, cloudInstanceID), |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +// Gets all the storage tiers associated to the cloud instance. |
| 28 | +func (f *IBMPIStorageTierClient) GetAll() (models.RegionStorageTiers, error) { |
| 29 | + params := p_cloud_storage_tiers.NewPcloudCloudinstancesStoragetiersGetallParams(). |
| 30 | + WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut). |
| 31 | + WithCloudInstanceID(f.cloudInstanceID) |
| 32 | + resp, err := f.session.Power.PCloudStorageTiers.PcloudCloudinstancesStoragetiersGetall(params, f.session.AuthInfo(f.cloudInstanceID)) |
| 33 | + if err != nil { |
| 34 | + return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf(errors.GetAllStorageTiersOperationFailed, f.cloudInstanceID, err)) |
| 35 | + } |
| 36 | + if resp == nil || resp.Payload == nil { |
| 37 | + return nil, fmt.Errorf("failed to get all storage tiers") |
| 38 | + } |
| 39 | + return resp.Payload, nil |
| 40 | +} |
0 commit comments