github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/instances/MigrateFollower.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 MigrateFollowerOpts struct {
    10  	InstanceId string `json:"-"`
    11  	// Specifies the ID of the standby DB instance.
    12  	NodeId string `json:"nodeId"`
    13  	// Specifies the code of the AZ to which the standby DB instance is to be migrated.
    14  	AzCode string `json:"azCode"`
    15  }
    16  
    17  func MigrateFollower(client *golangsdk.ServiceClient, opts MigrateFollowerOpts) (*string, error) {
    18  	b, err := build.RequestBody(opts, "")
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  
    23  	// POST https://{Endpoint}/v3/{project_id}/instances/{instance_id}/migrateslave
    24  	raw, err := client.Post(client.ServiceURL("instances", opts.InstanceId, "migrateslave"), b, nil, &golangsdk.RequestOpts{
    25  		OkCodes: []int{200},
    26  	})
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  
    31  	var res struct {
    32  		WorkflowId string `json:"workflowId"`
    33  	}
    34  	err = extract.Into(raw.Body, &res)
    35  	return &res.WorkflowId, err
    36  }