github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/groups/action.go (about) 1 package groups 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 type ActionOpts struct { 9 Action string `json:"action" required:"true"` 10 } 11 12 func Enable(client *golangsdk.ServiceClient, id string) error { 13 return doAction(client, id, ActionOpts{ 14 Action: "resume", 15 }) 16 } 17 18 func Disable(client *golangsdk.ServiceClient, id string) error { 19 return doAction(client, id, ActionOpts{ 20 Action: "pause", 21 }) 22 } 23 24 func doAction(client *golangsdk.ServiceClient, id string, opts ActionOpts) error { 25 b, err := build.RequestBody(opts, "") 26 if err != nil { 27 return err 28 } 29 30 _, err = client.Post(client.ServiceURL("scaling_group", id, "action"), &b, nil, &golangsdk.RequestOpts{ 31 OkCodes: []int{204}, 32 }) 33 34 return err 35 }