github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/gaussdb/v3/instance/UpdateName.go (about)

     1  package instance
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  )
     7  
     8  type UpdateNameOpts struct {
     9  	// Instance ID, which is compliant with the UUID format.
    10  	InstanceId string
    11  	// Instance name
    12  	// Instances of the same type can have same names under the same tenant.
    13  	// The name consists of 4 to 64 characters and starts with a letter.
    14  	// It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_).
    15  	Name string `json:"name"`
    16  }
    17  
    18  func UpdateName(client *golangsdk.ServiceClient, opts UpdateNameOpts) (*string, error) {
    19  	b, err := build.RequestBody(opts, "")
    20  	if err != nil {
    21  		return nil, err
    22  	}
    23  
    24  	// PUT https://{Endpoint}/mysql/v3/{project_id}/instances/{instance_id}/name
    25  	raw, err := client.Put(client.ServiceURL("instances", opts.InstanceId, "name"), b, nil, &golangsdk.RequestOpts{
    26  		OkCodes: []int{200, 201},
    27  	})
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  	return extraJob(err, raw)
    32  }