github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/ecs/v1/auto_recovery/requests.go (about) 1 package auto_recovery 2 3 import ( 4 "log" 5 6 "github.com/huaweicloud/golangsdk" 7 ) 8 9 type UpdateOpts struct { 10 SupportAutoRecovery string `json:"support_auto_recovery" required:"true"` 11 } 12 13 type UpdateOptsBuilder interface { 14 ToAutoRecoveryUpdateMap() (map[string]interface{}, error) 15 } 16 17 func (opts UpdateOpts) ToAutoRecoveryUpdateMap() (map[string]interface{}, error) { 18 return golangsdk.BuildRequestBody(opts, "") 19 } 20 21 func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) error { 22 b, err := opts.ToAutoRecoveryUpdateMap() 23 if err != nil { 24 return err 25 } 26 log.Printf("[DEBUG] update url:%q, body=%#v", updateURL(c, id), b) 27 _, err = c.Put(updateURL(c, id), b, nil, &golangsdk.RequestOpts{ 28 OkCodes: []int{204}, 29 }) 30 return err 31 } 32 33 func Get(c *golangsdk.ServiceClient, id string) (r GetResult) { 34 _, r.Err = c.Get(resourceURL(c, id), &r.Body, nil) 35 return 36 }