From b6e2e1018fd4ae0f28813a5e95e01c087637481c Mon Sep 17 00:00:00 2001 From: suraj Date: Mon, 20 Apr 2020 17:59:29 -0500 Subject: [PATCH] Added a new client for SystemPools - Compatible with IBM Power Cloud API --- clients/instance/ibm-pi-system-pools.go | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 clients/instance/ibm-pi-system-pools.go diff --git a/clients/instance/ibm-pi-system-pools.go b/clients/instance/ibm-pi-system-pools.go new file mode 100644 index 00000000..531799e0 --- /dev/null +++ b/clients/instance/ibm-pi-system-pools.go @@ -0,0 +1,37 @@ +package instance + +import ( + "github.com/IBM-Cloud/power-go-client/errors" + "github.com/IBM-Cloud/power-go-client/ibmpisession" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools" + "github.com/IBM-Cloud/power-go-client/power/models" + "log" +) + +type IBMPISystemPoolClient struct { + session *ibmpisession.IBMPISession + powerinstanceid string +} + +// NewSnapShotClient ... +func NewIBMPISystemPoolClient(sess *ibmpisession.IBMPISession, powerinstanceid string) *IBMPISystemPoolClient { + return &IBMPISystemPoolClient{ + sess, powerinstanceid, + } +} + +//Get the System Pools +func (f *IBMPISystemPoolClient) Get(powerinstanceid string) (models.SystemPools, error) { + + log.Printf("Calling the System Pools Capacity Method..") + log.Printf("The input cloudinstance id is %s", powerinstanceid) + params := p_cloud_system_pools.NewPcloudSystempoolsGetParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid) + + resp, err := f.session.Power.PCloudSystemPools.PcloudSystempoolsGet(params, ibmpisession.NewAuth(f.session, powerinstanceid)) + + if err != nil || resp.Payload == nil { + log.Printf("Failed to perform the operation... %v", err) + return nil, errors.ToError(err) + } + return resp.Payload, nil +}