forked from IBM-Cloud/power-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathibm-pi-storage-tiers.go
40 lines (34 loc) · 1.36 KB
/
ibm-pi-storage-tiers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
}