Skip to content

Commit

Permalink
Merge pull request #44 from surajsub/master
Browse files Browse the repository at this point in the history
Update the volume client to be more in line like the instance client
  • Loading branch information
surajsub authored Jul 9, 2020
2 parents 3fd9456 + c44f5e4 commit 45c2441
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions clients/instance/ibm-pi-volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,46 @@ func (f *IBMPIVolumeClient) Get(id, powerinstanceid string, timeout time.Duratio
return resp.Payload, nil
}

// CreateVolume
func (f *IBMPIVolumeClient) CreateVolume(create_vol_defs *p_cloud_volumes.PcloudCloudinstancesVolumesPostParams, powerinstanceid string, timeout time.Duration) (*models.Volume, error) {

log.Printf("Calling the Create Volume method ")
params := p_cloud_volumes.NewPcloudCloudinstancesVolumesPostParamsWithTimeout(timeout).WithCloudInstanceID(powerinstanceid).WithBody(create_vol_defs.Body)
resp, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesPost(params, ibmpisession.NewAuth(f.session, powerinstanceid))

if err != nil {
return nil, errors.ToError(err)
}
return resp.Payload, nil
}

// UpdateVolume

func (f *IBMPIVolumeClient) UpdateVolume(update_vol_defs *p_cloud_volumes.PcloudCloudinstancesVolumesPutParams, powerinstanceid string, timeout time.Duration) (*models.Volume, error) {

log.Printf("Calling the Create Volume method ")
params := p_cloud_volumes.NewPcloudCloudinstancesVolumesPutParamsWithTimeout(timeout).WithCloudInstanceID(powerinstanceid).WithBody(update_vol_defs.Body)
resp, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesPut(params, ibmpisession.NewAuth(f.session, powerinstanceid))

if err != nil {
return nil, errors.ToError(err)
}
return resp.Payload, nil
}

// DeleteVolume
func (f *IBMPIVolumeClient) DeleteVolume(id string, powerinstanceid string, timeout time.Duration) error {

params := p_cloud_volumes.NewPcloudCloudinstancesVolumesDeleteParamsWithTimeout(timeout).WithCloudInstanceID(powerinstanceid).WithVolumeID(id)
_, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid))
if err != nil {
return errors.ToError(err)
}
return nil
}

//Create
// TO be Deprecated

func (f *IBMPIVolumeClient) Create(volumename string, volumesize float64, volumetype string, volumeshareable bool, powerinstanceid string, timeout time.Duration) (*models.Volume, error) {

Expand Down

0 comments on commit 45c2441

Please sign in to comment.