github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/opengauss/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 //DifferentialPeriod 26 DifferentialPeriod string `json:"differential_period" required:"true"` 27 } 28 29 // ToBackupUpdateMap builds a update request body from UpdateOpts. 30 func (opts UpdateOpts) ToBackupUpdateMap() (map[string]interface{}, error) { 31 return golangsdk.BuildRequestBody(opts, "backup_policy") 32 } 33 34 // Update accepts a UpdateOpts struct and uses the values to update a Backup.The response code from api is 200 35 func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { 36 b, err := opts.ToBackupUpdateMap() 37 if err != nil { 38 r.Err = err 39 return 40 } 41 reqOpt := &golangsdk.RequestOpts{OkCodes: []int{200}, 42 MoreHeaders: RequestOpts.MoreHeaders} 43 _, r.Err = c.Put(resourceURL(c, id), b, nil, reqOpt) 44 return 45 }