-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get the supported storage tiers of a cloud instance (#446)
Signed-off-by: Kishen V <[email protected]>
- Loading branch information
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package instance | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/IBM-Cloud/power-go-client/errors" | ||
"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/p_cloud_storage_tiers" | ||
"github.com/IBM-Cloud/power-go-client/power/models" | ||
) | ||
|
||
// IBMPIStorageTierClient | ||
type IBMPIStorageTierClient struct { | ||
IBMPIClient | ||
} | ||
|
||
// NewIBMPIStorageTierClient | ||
func NewIBMPIStorageTierClient(ctx context.Context, sess *ibmpisession.IBMPISession, cloudInstanceID string) *IBMPIStorageTierClient { | ||
return &IBMPIStorageTierClient{ | ||
*NewIBMPIClient(ctx, sess, cloudInstanceID), | ||
} | ||
} | ||
|
||
// Gets all the storage tiers associated to the cloud instance. | ||
func (f *IBMPIStorageTierClient) GetAll() (models.RegionStorageTiers, error) { | ||
params := p_cloud_storage_tiers.NewPcloudCloudinstancesStoragetiersGetallParams(). | ||
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut). | ||
WithCloudInstanceID(f.cloudInstanceID) | ||
resp, err := f.session.Power.PCloudStorageTiers.PcloudCloudinstancesStoragetiersGetall(params, f.session.AuthInfo(f.cloudInstanceID)) | ||
if err != nil { | ||
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf(errors.GetAllStorageTiersOperationFailed, f.cloudInstanceID, err)) | ||
} | ||
if resp == nil || resp.Payload == nil { | ||
return nil, fmt.Errorf("failed to get all storage tiers") | ||
} | ||
return resp.Payload, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters