Skip to content

Commit

Permalink
Implement the backup update-server-policy command
Browse files Browse the repository at this point in the history
  • Loading branch information
ldmberman committed Apr 6, 2016
1 parent 1c248c8 commit e6c2bf0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
23 changes: 23 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions models/backup/serverpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit e6c2bf0

Please sign in to comment.