github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/instances/batch.go (about) 1 package instances 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 type BatchOpts struct { 9 // Specifies the ECS ID. 10 Instances []string `json:"instances_id" required:"true"` 11 // Specifies whether to delete an instance when it is removed from an AS group. 12 // Options: 13 // no (default): The instance will not be deleted. 14 // yes: The instance will be deleted. 15 // This parameter takes effect only when the action is set to REMOVE. 16 IsDeleteEcs string `json:"instance_delete,omitempty"` 17 // Specifies an action to be performed on instances in batches. The options are as follows: 18 // ADD: adds instances to the AS group. 19 // REMOVE: removes instances from the AS group. 20 // PROTECT: enables instance protection. 21 // UNPROTECT: disables instance protection. 22 Action string `json:"action,omitempty"` 23 } 24 25 func BatchAction(client *golangsdk.ServiceClient, groupID string, opts BatchOpts) (err error) { 26 b, err := build.RequestBody(opts, "") 27 if err != nil { 28 return 29 } 30 31 // POST /autoscaling-api/v1/{project_id}/scaling_group_instance/{scaling_group_id}/action 32 _, err = client.Post(client.ServiceURL("scaling_group_instance", groupID, "action"), b, nil, &golangsdk.RequestOpts{ 33 OkCodes: []int{204}, 34 }) 35 36 return 37 }