github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/configurations/Apply.go (about) 1 package configurations 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 // ApplyOpts contains all the instances needed to apply another template. 10 type ApplyOpts struct { 11 // Specifies the parameter template ID. 12 ConfigId string 13 // Specifies the DB instance ID list object. 14 InstanceIDs []string `json:"instance_ids" required:"true"` 15 } 16 17 // Apply is used to apply a parameter template to one or more DB instances. 18 func Apply(client *golangsdk.ServiceClient, opts ApplyOpts) (*ApplyResponse, error) { 19 b, err := build.RequestBody(opts, "") 20 if err != nil { 21 return nil, err 22 } 23 24 // PUT https://{Endpoint}/v3/{project_id}/configurations/{config_id}/apply 25 raw, err := client.Put(client.ServiceURL("configurations", opts.ConfigId, "apply"), b, nil, &golangsdk.RequestOpts{ 26 OkCodes: []int{200, 201, 202}, 27 }) 28 if err != nil { 29 return nil, err 30 } 31 32 var res ApplyResponse 33 err = extract.Into(raw.Body, &res) 34 return &res, err 35 } 36 37 type ApplyResponse struct { 38 // Specifies the parameter template ID. 39 ConfigurationID string `json:"configuration_id"` 40 // Specifies the parameter template name. 41 ConfigurationName string `json:"configuration_name"` 42 // Specifies the result of applying the parameter template. 43 ApplyResults []ApplyResult `json:"apply_results"` 44 // Specifies whether each parameter template is applied to DB instances successfully. 45 Success bool `json:"success"` 46 JobId string `json:"job_id"` 47 } 48 49 type ApplyResult struct { 50 // Indicates the DB instance ID. 51 InstanceID string `json:"instance_id"` 52 // Indicates the DB instance name. 53 InstanceName string `json:"instance_name"` 54 // Indicates whether a reboot is required. 55 RestartRequired bool `json:"restart_required"` 56 // Indicates whether each parameter template is applied to DB instances successfully. 57 Success bool `json:"success"` 58 }