Skip to content

Commit

Permalink
Merge pull request #11 from surajsub/master
Browse files Browse the repository at this point in the history
Added a new client for SystemPools - Compatible with IBM Power Cloud API
  • Loading branch information
surajsub authored Apr 20, 2020
2 parents 90aca2c + b6e2e10 commit 36b0490
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions clients/instance/ibm-pi-system-pools.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 36b0490

Please sign in to comment.