github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/csbs/v1/policies/Update.go (about) 1 package policies 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 // UpdateOpts contains the values used when updating a backup policy. 9 type UpdateOpts struct { 10 // Backup policy description 11 // The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<). 12 Description string `json:"description,omitempty"` 13 // Backup policy name 14 // The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-). 15 Name string `json:"name,omitempty"` 16 // Backup objects 17 Resources []Resource `json:"resources,omitempty"` 18 // Scheduling period. A backup policy has only one backup period. 19 ScheduledOperations []ScheduledOperationToUpdate `json:"scheduled_operations,omitempty"` 20 } 21 22 type Resource struct { 23 // ID of the object to be backed up 24 Id string `json:"id" required:"true"` 25 // Entity object type of backup objects 26 // The value is fixed at OS::Nova::Server (ECSs). 27 Type string `json:"type" required:"true"` 28 // Backup object name 29 Name string `json:"name" required:"true"` 30 // Additional information about the backup object 31 ExtraInfo interface{} `json:"extra_info,omitempty"` 32 } 33 34 type ScheduledOperationToUpdate struct { 35 // Scheduling period description 36 // The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<). 37 Description string `json:"description,omitempty"` 38 // Whether the backup policy is enabled 39 // The default value is true. If it is set to false, automatic scheduling is disabled but manual scheduling is supported. 40 Enabled bool `json:"enabled"` 41 // Scheduling period name 42 // The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-). 43 Name string `json:"name,omitempty"` 44 // Scheduling period parameter 45 OperationDefinition OperationDefinition `json:"operation_definition,omitempty"` 46 // Scheduling policy 47 Trigger Trigger `json:"trigger,omitempty"` 48 // Scheduling period ID 49 Id string `json:"id" required:"true"` 50 } 51 52 // Update allows backup policies to be updated. call the Extract method on the UpdateResult. 53 func Update(c *golangsdk.ServiceClient, policyId string, opts UpdateOpts) (*BackupPolicy, error) { 54 b, err := build.RequestBody(opts, "policy") 55 if err != nil { 56 return nil, err 57 } 58 59 // PUT https://{endpoint}/v1/{project_id}/policies/{policy_id} 60 raw, err := c.Put(c.ServiceURL("policies", policyId), b, nil, &golangsdk.RequestOpts{ 61 OkCodes: []int{200}, 62 }) 63 return extra(err, raw) 64 }