Creating a DB Instance

Function

This API is used to create a GaussDB(for MySQL) instance. Before calling this API:

URI

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

X-Language

No

String

Language.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

charge_info

No

MysqlChargeInfo object

Billing mode, which is pay-per-use (default setting).

region

Yes

String

Region ID.

The value cannot be empty. To obtain this value, see Regions and Endpoints.

name

Yes

String

DB instance name.

Instances of the same type can have same names under the same tenant.

The value consists of 4 to 64 characters and starts with a letter. It is case-sensitive and contains only letters, digits, hyphens (-), and underscores (_).

datastore

Yes

MysqlDatastore object

Database information.

mode

Yes

String

DB instance type, which is case-insensitive. Currently, only the cluster type is supported.

flavor_ref

Yes

String

Specification code. For details, see Querying Database Specifications.

vpc_id

Yes

String

VPC ID. To obtain this value, use either of the following methods:

  • Method 1: Log in to the VPC console and view the VPC ID on the VPC details page.

  • Method 2: See "Querying VPCs" in the Virtual Private Cloud API Reference.

subnet_id

Yes

String

Network ID. To obtain this value, use either of the following methods:

  • Method 1: Log in to the VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.

  • Method 2: See "Querying Subnets" in the Virtual Private Cloud API Reference.

security_group_id

No

String

Security group ID.

If the network ACL is enabled for the subnet used by the created instance, this parameter is optional. If the network ACL is not enabled, this parameter is mandatory.

  • Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.

  • Method 2: See "Querying Security Groups" in the Virtual Private Cloud API Reference.

configuration_id

No

String

Parameter template ID.

password

Yes

String

Database password.

Valid value:

The password consists of 8 to 32 characters and contains at least three types of the following: uppercase letters, lowercase letters, digits, and special characters (~!@#%^*-_=+?).

You are advised to enter a strong password to improve security and prevent security risks such as brute force cracking. If you enter a weak password, the system automatically determines that the password is invalid.

backup_strategy

No

MysqlBackupStrategy object

Automated backup policy.

time_zone

No

String

UTC time zone.

  • If this parameter is not specified, UTC is used by default.

  • If this parameter is specified, the value ranges from UTC-12:00 to UTC+12:00 at the full hour. For example, the parameter can be UTC+08:00 rather than UTC+08:30.

availability_zone_mode

Yes

String

AZ type. The value can be Single or multi.

master_availability_zone

If availability_zone_mode is set to multi, this parameter is mandatory.

If availability_zone_mode is set to single, this parameter cannot be specified.

String

Primary AZ.

slave_count

Yes

Integer

Number of created read replicas. Value: 1 to 9. An instance contains up to 15 read replicas.

tags

No

Array of MysqlTags objects

Tag list. Instances are created based on tag keys and values.

  • {key} indicates the tag key. It must be unique and cannot be empty.

  • {value} indicates the tag value, which can be empty.

To create instances with multiple tag keys and values, separate key-value pairs with commas (,). Up to 10 key-value pairs can be added.

enterprise_project_id

No

String

Enterprise project ID. This parameter is mandatory when the enterprise project is enabled.

dedicated_resource_id

No

String

Dedicated resource pool ID. This parameter is displayed only when the dedicated resource pool is enabled.

Table 4 MysqlChargeInfo

Parameter

Mandatory

Type

Description

charge_mode

Yes

String

Billing mode.

Value: postPaid

period_type

No

String

Subscription period.

Valid value:

  • month: The service is subscribed by month.

  • year: The service is subscribed by year.

    Note

    This parameter is valid and mandatory if charge_mode is set to prePaid.

period_num

No

Integer

Subscription duration. This parameter is valid and mandatory if charge_mode is set to prePaid.

Valid value:

  • When period_type is set to month, the parameter value ranges from 1 to 9.

  • When period_type is set to year, the parameter value ranges from 1 to 3.

Table 5 MysqlDatastore

Parameter

Mandatory

Type

Description

type

Yes

String

DB engine. Currently, only gaussdb-mysql is supported.

version

Yes

String

DB version.

For details about supported DB versions, see Querying Version Information About a DB Engine.

Table 6 MysqlBackupStrategy

Parameter

Mandatory

Type

Description

start_time

Yes

String

Automated backup start time. The automated backup will be triggered within one hour after the time specified by this parameter.

The value cannot be empty. It must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.

  • The HH value must be 1 greater than the hh value.

  • The values of mm and MM must be the same and must be set to 00.

Example value:

21:00-22:00

keep_days

No

String

Automated backup retention days. Value: 1-732.

Table 7 MysqlVolume

Parameter

Mandatory

Type

Description

size

Yes

Integer

Disk size. The default value is 40 GB.

Value: 40 to 128000. The value must be a multiple of 10.

Table 8 MysqlTags

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key. It contains a maximum of 36 Unicode characters. The value cannot be an empty string, a space, or left blank. Only uppercase letters, lowercase letters, digits, hyphens (-), and underscores (_) are allowed.

value

Yes

String

Tag value. It contains a maximum of 43 Unicode characters. It can be an empty string. Only uppercase letters, lowercase letters, digits, periods (.), hyphens (-), and underscores (_) are allowed.

Response Parameters

Status code: 201

Table 9 Response body parameters

Parameter

Type

Description

instance

MysqlInstanceResponse object

Instance information.

job_id

String

DB instance creation task ID.

This parameter is returned only when pay-per-use DB instances are created.

order_id

String

Order ID. This parameter is returned only when yearly/monthly instances are created.

Table 10 MysqlInstanceResponse

Parameter

Type

Description

id

String

Instance ID.

name

String

DB instance name. Instances of the same type can have same names under the same tenant.

The name consists of 4 to 64 characters and starts with a letter. It is case-insensitive and contains only letters, digits, hyphens (-), and underscores (_).

status

String

Instance status. Value: creating.

datastore

MysqlDatastore object

Database information.

mode

String

DB instance type. Currently, only the cluster type is supported.

configuration_id

String

Parameter template ID.

port

String

Database port, which is the same as the request parameter.

backup_strategy

MysqlBackupStrategy object

Automated backup policy.

enterprise_project_id

String

Enterprise project ID.

region

String

Region ID, which is the same as the request parameter.

availability_zone_mode

String

AZ mode, which is the same as the request parameter.

master_availability_zone

String

Primary AZ ID.

vpc_id

String

VPC ID, which is the same as the request parameter.

security_group_id

String

Security group ID, which is the same as the request parameter.

subnet_id

String

Subnet ID, which is the same as the request parameter.

flavor_ref

String

Specification code, which is the same as the request parameter.

charge_info

MysqlChargeInfo object

Billing mode, which is yearly/monthly or pay-per-use (default setting).

Table 11 MysqlDatastore

Parameter

Type

Description

type

String

DB engine.

version

String

DB version.

Table 12 MysqlBackupStrategy

Parameter

Type

Description

start_time

String

Automated backup start time. The automated backup will be triggered within one hour after the time specified by this parameter.

keep_days

String

Backup retention days.

Table 13 MysqlChargeInfo

Parameter

Type

Description

charge_mode

String

Billing mode.

period_type

String

Subscription period.

Valid value:

  • month: The service is subscribed by month.

  • year: The service is subscribed by year.

This parameter is valid and mandatory only when charge_mode is set to prePaid.

period_num

Integer

Subscription duration, which is calculated by month.

This parameter is valid when charge_mode is set to prePaid (this parameter is valid only for yearly/monthly instances).

Status code: 400

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 15 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Request

Note

The value of region in the following is used as an example.

Creating a DB instance

POST https://gaussdb-mysql.eu-de.otc.t-systems.com/mysql/v3/0483b6b16e954cb88930a360d2c4e663/instances

{
  "name" : "gaussdb-mysql-instance1",
  "region" : "xxxx",
  "charge_info" : {
    "charge_mode" : "postPaid"
  },
  "datastore" : {
    "type" : "gaussdb-mysql",
    "version" : "8.0"
  },
  "mode" : "Cluster",
  "flavor_ref" : "gaussdb.mysql.xlarge.arm.8",
  "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
  "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
  "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
  "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
  "password" : "xxxxx",
  "backup_strategy" : {
    "start_time" : "08:00-09:00"
  },
  "availability_zone_mode" : "single",
  "slave_count" : 1,
  "enterprise_project_id" : 0
}

Example Response

Note

The values of region and master_availability_zone are used as examples.

Status code: 201

Success.

{
  "instance" : {
    "id" : "5eebbb4c0f9f4a99b42ed1b6334569aain07",
    "name" : "gaussdb-mysql-instance1",
    "region" : "xxxx",
    "charge_info" : {
      "charge_mode" : "postPaid"
    },
    "datastore" : {
      "type" : "gaussdb-mysql",
      "version" : "8.0"
    },
    "mode" : "Cluster",
    "flavor_ref" : "gaussdb.mysql.xlarge.arm.8",
    "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
    "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
    "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
    "backup_strategy" : {
      "start_time" : "08:00-09:00",
      "keep_days" : 7
    },
    "availability_zone_mode" : "single",
    "slave_count" : 1
  },
  "job_id" : "dff1d289-4d03-4942-8b9f-463ea07c000d"
}

Status Code

For details, see Status Codes.

Error Code

For details, see Error Codes.