github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/instances/ChangeFailoverMode.go (about)

     1  package instances
     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 ChangeFailoverModeOpts struct {
    10  	InstanceId string `json:"-"`
    11  	// Specifies the synchronize model.
    12  	// For MySQL, the value can be any of the following:
    13  	// async: asynchronous
    14  	// semisync: semi-synchronous
    15  	// For PostgreSQL, the value can be any of the following:
    16  	// async: asynchronous
    17  	// sync: synchronous
    18  	Mode string `json:"mode" required:"true"`
    19  }
    20  
    21  func ChangeFailoverMode(client *golangsdk.ServiceClient, opts ChangeFailoverModeOpts) (*ChangeFailoverModeResponse, error) {
    22  	b, err := build.RequestBody(opts, "")
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  
    27  	// PUT /v3/{project_id}/instances/{instance_id}/failover/mode
    28  	raw, err := client.Put(client.ServiceURL("instances", opts.InstanceId, "failover", "mode"), b, nil, &golangsdk.RequestOpts{
    29  		OkCodes: []int{200},
    30  	})
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  
    35  	var res ChangeFailoverModeResponse
    36  	err = extract.Into(raw.Body, &res)
    37  	return &res, err
    38  }
    39  
    40  type ChangeFailoverModeResponse struct {
    41  	// Indicates the DB instance ID.
    42  	InstanceId string `json:"instanceId,omitempty"`
    43  	// Indicates the replication mode.
    44  	ReplicationMode string `json:"replicationMode,omitempty"`
    45  	// Indicates the workflow ID.
    46  	WorkflowId string `json:"workflowId,omitempty"`
    47  }