github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/taurusdb/v3/backups/requests.go (about) 1 package backups 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 ) 6 7 var RequestOpts golangsdk.RequestOpts = golangsdk.RequestOpts{ 8 MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"}, 9 } 10 11 // UpdateOptsBuilder allows extensions to add additional parameters to the 12 // Update request. 13 type UpdateOptsBuilder interface { 14 ToBackupUpdateMap() (map[string]interface{}, error) 15 } 16 17 // UpdateOpts contains all the values needed to update a Backup. 18 type UpdateOpts struct { 19 //Keep Days 20 KeepDays *int `json:"keep_days" required:"true"` 21 //Start Time 22 StartTime string `json:"start_time" required:"true"` 23 //Period 24 Period string `json:"period" required:"true"` 25 } 26 27 // ToBackupUpdateMap builds a update request body from UpdateOpts. 28 func (opts UpdateOpts) ToBackupUpdateMap() (map[string]interface{}, error) { 29 return golangsdk.BuildRequestBody(opts, "backup_policy") 30 } 31 32 // Update accepts a UpdateOpts struct and uses the values to update a Backup.The response code from api is 200 33 func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { 34 b, err := opts.ToBackupUpdateMap() 35 if err != nil { 36 r.Err = err 37 return 38 } 39 reqOpt := &golangsdk.RequestOpts{OkCodes: []int{200}, 40 MoreHeaders: RequestOpts.MoreHeaders} 41 _, r.Err = c.Put(resourceURL(c, id), b, nil, reqOpt) 42 return 43 }