github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/gaussdb/v3/instance/ChangeSpec.go (about) 1 package instance 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 type UpdateSpecOpts struct { 10 // Instance ID, which is compliant with the UUID format. 11 InstanceId string 12 // Specification change information. 13 ResizeFlavor ResizeFlavor `json:"resize_flavor"` 14 // Whether the order will be automatically paid after yearly/monthly instances are changed. 15 // true: The order will be automatically paid from your account. The default value is true. 16 // false: The order will be manually paid. 17 IsAutoPay *string `json:"is_auto_pay,omitempty"` 18 } 19 20 type ResizeFlavor struct { 21 // Specification code 22 SpecCode string `json:"spec_code"` 23 } 24 25 func UpdateInstance(client *golangsdk.ServiceClient, opts UpdateSpecOpts) (*InstanceSpecResponse, error) { 26 b, err := build.RequestBody(opts, "") 27 if err != nil { 28 return nil, err 29 } 30 31 // POST https://{Endpoint}/mysql/v3/{project_id}/instances/{instance_id}/action 32 raw, err := client.Post(client.ServiceURL("instances", opts.InstanceId, "action"), b, nil, &golangsdk.RequestOpts{ 33 OkCodes: []int{200, 201}, 34 }) 35 if err != nil { 36 return nil, err 37 } 38 39 var res InstanceSpecResponse 40 err = extract.Into(raw.Body, &res) 41 return &res, err 42 } 43 44 type InstanceSpecResponse struct { 45 // Job ID for changing instance specifications. 46 // This parameter is returned only when you change the specifications of a pay-per-use instance. 47 JobId string `json:"job_id"` 48 // Order ID for changing instance specifications. 49 // This parameter is returned only when you change the specification of a yearly/monthly instance. 50 OrderId string `json:"order_id"` 51 }