diff --git a/init.go b/init.go index 00120bf..8a4f39e 100644 --- a/init.go +++ b/init.go @@ -3353,6 +3353,29 @@ func init() { }, }, }) + registerCommandBase(&backup.UpdateServerPolicy{}, &backup.ServerPolicy{}, commands.CommandExcInfo{ + Verb: "PATCH", + Url: "https://api-va1.backup.ctl.io/clc-backup-api/api/accountPolicies/{AccountPolicyId}/serverPolicies/{ServerPolicyId}", + Resource: "backup", + Command: "update-server-policy", + Help: help.Command{ + Brief: []string{"Updates the given backup policy of the given server"}, + Arguments: []help.Argument{ + { + "--account-policy-id", + []string{"Required. The ID of the account policy the server policy is bound to"}, + }, + { + "--server-policy-id", + []string{"Required. The ID of the server policy to update"}, + }, + { + "--status", + []string{"Required. A new status value. 'ACTIVE' or 'INACTIVE'"}, + }, + }, + }, + }) } func registerCommandBase(inputModel interface{}, outputModel interface{}, info commands.CommandExcInfo) { diff --git a/models/backup/serverpolicy.go b/models/backup/serverpolicy.go index 2a6643f..8859931 100644 --- a/models/backup/serverpolicy.go +++ b/models/backup/serverpolicy.go @@ -71,6 +71,28 @@ func (g *GetStoredData) Validate() error { return nil } +type UpdateServerPolicy struct { + AccountPolicyId string `URIParam:"yes" valid:"required"` + ServerPolicyId string `URIParam:"yes" valid:"required"` + Operations []UpdateServerPolicyOperation `argument:"ignore" json:"operations"` + Status string `json:"-" oneOf:"ACTIVE,INACTIVE" valid:"required"` +} + +func (u *UpdateServerPolicy) Validate() error { + u.Operations = append(u.Operations, UpdateServerPolicyOperation{ + Op: "replace", + Path: "/status", + Value: u.Status, + }) + return nil +} + +type UpdateServerPolicyOperation struct { + Op string `json:"op"` + Path string `json:"path"` + Value string `json:"value"` +} + type GetRestoreDetails struct { AccountPolicyId string `URIParam:"yes" valid:"required"` ServerPolicyId string `URIParam:"yes" valid:"required"`