Skip to content

Commit

Permalink
Volume Group Snapshot Modify Fix
Browse files Browse the repository at this point in the history
- When modifing a volume group snapshot, if the protection policy id
  field is set it will cause the API to fail. Created a seperate method
  for VGsnapshotModify with a different body.
  • Loading branch information
doriac11 committed Feb 13, 2024
1 parent d82b09b commit bbb6c09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type Client interface {
GetVolumeGroups(ctx context.Context) ([]VolumeGroup, error)
CreateVolumeGroup(ctx context.Context, createParams *VolumeGroupCreate) (CreateResponse, error)
CreateVolumeGroupSnapshot(ctx context.Context, volumeGroupID string, createParams *VolumeGroupSnapshotCreate) (resp CreateResponse, err error)
ModifyVolumeGroupSnapshot(ctx context.Context, modifyParams *VolumeGroupSnapshotModify, id string) (resp EmptyResponse, err error)
UpdateVolumeGroupProtectionPolicy(ctx context.Context, id string, params *VolumeGroupChangePolicy) (resp EmptyResponse, err error)
RemoveMembersFromVolumeGroup(ctx context.Context, params *VolumeGroupMembers, id string) (EmptyResponse, error)
AddMembersToVolumeGroup(ctx context.Context, params *VolumeGroupMembers, id string) (EmptyResponse, error)
Expand Down
16 changes: 16 additions & 0 deletions volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ func (c *ClientIMPL) CreateVolumeGroupSnapshot(ctx context.Context, volumeGroupI
return resp, WrapErr(err)
}

// ModifyVolumeGroup modifies existing volume group snapshot
func (c *ClientIMPL) ModifyVolumeGroupSnapshot(ctx context.Context,
modifyParams *VolumeGroupSnapshotModify, id string,
) (resp EmptyResponse, err error) {
_, err = c.APIClient().Query(
ctx,
RequestConfig{
Method: "PATCH",
Endpoint: volumeGroupURL,
ID: id,
Body: modifyParams,
},
&resp)
return resp, WrapErr(err)
}

// GetVolumeGroupSnapshot query and return specific snapshot by id
func (c *ClientIMPL) GetVolumeGroupSnapshot(ctx context.Context, snapID string) (resVol VolumeGroup, err error) {
qp := getVolumeGroupDefaultQueryParams(c)
Expand Down
8 changes: 8 additions & 0 deletions volume_group_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ type VolumeGroupModify struct {
ExpirationTimestamp *string `json:"expiration_timestamp,omitempty"`
}

// VolumeGroupSnapshotModify modifies existing Volume Group Snapshot Similar to volume group modify without protection policy since this is an invalid field for VolumeGroupSnapshot
type VolumeGroupSnapshotModify struct {
Description string `json:"description"`
Name string `json:"name,omitempty"`
IsWriteOrderConsistent bool `json:"is_write_order_consistent,omitempty"`
ExpirationTimestamp *string `json:"expiration_timestamp,omitempty"`
}

type VolumeGroupChangePolicy struct {
ProtectionPolicyID string `json:"protection_policy_id"`
}
Expand Down

0 comments on commit bbb6c09

Please sign in to comment.