Creating a DB Instance

Function

This API is used to create a DB instance.

Constraints

This API supports the following DB instances:
  • GaussDB(for Cassandra)
  • GaussDB(for Mongo) cluster instance 3.4 and replica set instance 4.0
  • This API supports both yearly/monthly and pay-per-use DB instances.

URI

  • URI format

    POST /v3/{project_id}/instances

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID of a tenant in a region.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    Mandatory

    Type

    Description

    name

    Yes

    String

    Specifies the instance name, which can be the same as an existing instance name.

    The value must be 4 to 64 characters in length and start with a letter (from A to Z or from a to z). It is case-sensitive and can contain only letters, digits (from 0 to 9), hyphens (-), and underscores (_).

    datastore

    Yes

    Object

    Specifies the database information. For more information, see Table 3.

    region

    Yes

    String

    Specifies the region ID.

    The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

    availability_zone

    Yes

    String

    Specifies the AZ ID.

    For details about the value, see az_status returned in Querying All DB Instance Specifications. Separate multiple AZs by commas (,).

    vpc_id

    Yes

    String

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

    • Method 1: Log in to VPC console and view the VPC ID on the VPC details page.
    • Method 2: Query the VPC ID through the VPC API. For details, see Querying VPCs.

    subnet_id

    Yes

    String

    Specifies the network ID of the subnet. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the subnet ID on the displayed page.
    • Method 2: Query the subnet ID through the VPC API. For details, see Querying Subnets.

    security_group_id

    Yes

    String

    Specifies the security group ID. To obtain the security group ID, perform either of the following methods:

    • 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: Query the security group through the VPC API. For details, see Querying Security Groups.

    password

    Yes

    String

    Specifies the database password.

    The value must be 8 to 32 characters in length and contain uppercase letters (A to Z), lowercase letters (a to z), digits (0 to 9), and special characters, such as ~!@#%^*-_=+?

    You are advised to enter a strong password to improve security, preventing security risks such as brute force cracking.

    mode

    Yes

    String

    Specifies the instance type.

    • GaussDB(for Cassandra) supports the cluster type. The value is "Cluster".
    • GaussDB(for Mongo) 3.4 supports the cluster type. The value is "Sharding".
    • GaussDB(for Mongo) 4.0 supports the replica set type. The value is "ReplicaSet".

    flavor

    Yes

    Array of objects

    Specifies the instance specifications. For more information, see Table 4.

    For details about how to obtain the value, see the response values of flavor in Querying All DB Instance Specifications.

    configuration_id

    No

    String

    Specifies the parameter template ID.

    backup_strategy

    No

    Object

    Specifies the advanced backup policy. For more information, see Table 5.

    enterprise_project_id

    No

    String

    Specifies the enterprise project ID.

    • This parameter is not transferred for users who have not enabled the enterprise multi-project service.
    • If this parameter is not transferred for a user who has enabled the enterprise multi-project service, the value is the default enterprise project.

    To obtain the enterprise project ID, see the id value in the enterprise_project field data structure table in section "Querying the Enterprise Project List" of the Enterprise Management API Reference.

    ssl_option

    No

    String

    Specifies whether to enable or disable SSL.

    Valid value:

    • The value "0" indicates that SSL is disabled by default.
    • The value "1" indicates that SSL is enabled by default.
    • If this parameter is not transferred, SSL is disabled by default.

    charge_info

    No

    Object

    Specifies the billing mode, including yearly/monthly and pay-per-use. The default billing mode is pay-per-use. For details, see Table 6.

    Table 3 datastore field data structure description

    Name

    Mandatory

    Type

    Description

    type

    Yes

    String

    Specifies the database type.

    GaussDB(for Cassandra) and GaussDB(for Mongo) DB instances are supported.

    The value "cassandra" indicates that a GaussDB(for Cassandra) instance is created.

    The value "mongodb" indicates a GaussDB(for Mongo) instance is created.

    version

    Yes

    String

    Specifies the database version.

    The value "3.11" indicates that the GaussDB(for Cassandra) 3.11 is supported.

    The values "3.4" and "4.0" indicate that GaussDB(for Mongo) 3.4 and 4.0 are supported.

    storage_engine

    Yes

    String

    Specifies the storage engine.

    The value "rocksDB" indicates that the GaussDB(for Cassandra) instance supports the RocksDB storage engine.

    The value "rocksDB" indicates that the GaussDB(for Mongo) instance supports the RocksDB storage engine.

    Table 4 flavor field data structure description

    Name

    Mandatory

    Type

    Description

    num

    Yes

    Integer

    Specifies node quantity.

    • The number of GaussDB(for Cassandra) instance nodes ranges from 3 to 12.
    • The number of nodes in a GaussDB(for Mongo) 3.4 cluster instance ranges from 2 to 12. If you create a cross-AZ instance, the minimum number of nodes is 3.
    • The number of nodes in a GaussDB(for Mongo) 4.0 replica set instance is 3.

    size

    Yes

    Integer

    Specifies the storage space. The value must be an integer, in GB.

    For a DB instance, the minimum storage space is 100 GB, and the maximum storage space is related to the instance performance specifications. For details, see DB Instance Specifications.

    storage

    Yes

    String

    Specifies the disk type.

    Valid value: ULTRAHIGH, which indicates the SSD disk.

    spec_code

    Yes

    String

    Specifies the resource specifications code. For details about how to obtain the value, see the response values of spec_code in Querying All DB Instance Specifications.

    Table 5 backup_strategy field data structure description

    Name

    Mandatory

    Type

    Description

    start_time

    Yes

    String

    Specifies the backup time window. Automated backups will be triggered during the backup time window.

    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 any of the following: 00 or 30.

    Example value:

    23:00-00:00

    keep_days

    No

    String

    Specifies the number of days to retain the generated backup files.

    The value ranges from 0 to 35.

    • If this parameter is set to 0, the automated backup policy is not set.
    • If this parameter is not transferred, the automated backup policy is enabled by default. Backup files are stored for seven days by default.
    Table 6 charge_info field data structure description

    Name

    Mandatory

    Type

    Description

    charge_mode

    Yes

    String

    Specifies the billing mode.

    Possible values:

    • prePaid: indicates the yearly/monthly billing mode.
    • postPaid: indicates the pay-per-use billing mode.

    period_type

    No

    String

    Specifies the subscription period.

    Possible values:

    • month: indicates that the subscription unit is month.
    • year: indicates that the subscription unit is year.
    NOTE:

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

    period_num

    No

    String

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

    Possible values:

    • 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.

    is_auto_renew

    No

    String

    Whether automatic renewal is enabled for yearly/monthly DB instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal.

    • true: indicates that the subscription is automatically renewed.
    • false: indicates that the subscription is not automatically renewed. The default value is false.

    is_auto_pay

    No

    String

    When creating a yearly/monthly DB instance, you can specify whether to automatically pay with your account. This parameter does not affect the payment method of automatic renewal.

    • true: indicates that the fee is automatically paid from the account.
    • false: indicates that the fee is manually paid from the account. This payment method is used by default.

The values of region and availability_zone in the request body are only examples. Set them based on the site requirements.

  • Request header
    POST https://GaussDB_NoSQL_Endpoint/v3/{project_id}/instances
  • Example request

    Creating a pay-per-use DB instance:

    { 
      "name": "test-cassandra-01", 
      "datastore": { 
        "type": "cassandra", 
        "version": "3.11", 
        "storage_engine": "rocksDB" 
      }, 
      "region": "aaa", 
      "availability_zone": "bbb,ccc,ddd", 
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", 
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", 
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", 
      "password": "Test@123", 
      "mode": "Cluster", 
      "flavor": [ 
        { 
          "num": 3, 
          "size": 500,
          "storage": "ULTRAHIGH",
          "spec_code": "geminidb.cassandra.4xlarge.4" 
        } 
      ], 
      "backup_strategy": { 
        "start_time": "08:00-09:00", 
        "keep_days": "8" 
      },
      "enterprise_project_id": "0",
      "ssl_option": "1"
    }

    Creating a yearly/monthly DB instance:

    { 
      "name": "test-cassandra-01", 
      "datastore": { 
        "type": "cassandra", 
        "version": "3.11", 
        "storage_engine": "rocksDB" 
      }, 
      "region": "aaa", 
      "availability_zone": "bbb,ccc,ddd", 
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", 
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", 
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", 
      "password": "Test@123", 
      "mode": "Cluster", 
      "flavor": [ 
        { 
          "num": 3, 
          "size": 500,
          "storage": "ULTRAHIGH",
          "spec_code": "geminidb.cassandra.4xlarge.4" 
        } 
      ], 
      "backup_strategy": { 
        "start_time": "08:00-09:00", 
        "keep_days": "8" 
      },
      "enterprise_project_id": "0",
      "ssl_option": "1",
      "charge_info": {
    	  "charge_mode": "prePaid", 
              "period_type": "year",
              "period_num": 3,
              "is_auto_renew": "true",
              "is_auto_pay": "true" 
      }
    }

Responses

  • Parameter description
    Table 7 Parameter description

    Name

    Type

    Description

    id

    String

    Indicates the DB instance ID.

    name

    String

    Same as the request parameter.

    datastore

    Object

    Indicates the database information, which is the same as the request parameter. For more information, see Table 3.

    created

    String

    Indicates the creation time in the following format: yyyy-mm-dd hh:mm:ss.

    status

    String

    Indicates the DB instance status. The value is creating.

    region

    String

    Indicates the region ID, which is the same as the request parameter.

    availability_zone

    String

    Indicates the AZ ID, which is the same as the request parameter.

    vpc_id

    String

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

    subnet_id

    String

    Indicates the network ID of the subnet, which is the same as the request parameter.

    security_group_id

    String

    Indicates the security group ID, which is the same as the request parameter.

    mode

    String

    Indicates the instance type, which is the same as the request parameter.

    flavor

    Array of objects

    Indicates the instance specification, which is the same as the request parameter. For more information, see Table 4.

    backup_strategy

    Object

    Indicates the advanced backup policy, which is the same as the request parameter. For more information, see Table 5.

    enterprise_project_id

    String

    Indicates the enterprise project ID. If the value is 0, the resource belongs to the default enterprise project.

    ssl_option

    String

    Indicates whether to enable SSL, which functions the same as the request parameter.

    job_id

    String

    Indicates the workflow ID for creating an instance. This parameter is returned only when a pay-per-use instance is created.

    order_id

    String

    Indicates the ID of the order for creating the DB instance. This parameter is returned only when you create a yearly/monthly DB instance.

    charge_info

    Object

    Indicates the billing mode, which is the same as the request parameter.

The values of region and availability_zone are used as examples.

  • Response example

    Creating a pay-per-use DB instance:

    { 
      "id": "39b6a1a278844ac48119d86512e0000bin06", 
      "name": "test-cassandra-01", 
      "datastore": { 
        "type": "cassandra", 
        "version": "3.11", 
        "storage_engine": "rocksDB" 
      }, 
      "created": "2019-10-28 14:10:54",
      "status": "creating",
      "region": "aaa", 
      "availability_zone": "bbb,ccc,ddd", 
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", 
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", 
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", 
      "mode": "Cluster", 
      "flavor": [ 
        { 
          "num": 3, 
          "size": 500,
          "storage": "ULTRAHIGH",
          "spec_code": "geminidb.cassandra.4xlarge.4" 
        } 
      ], 
      "backup_strategy": { 
        "start_time": "08:00-09:00", 
        "keep_days": "8" 
      } ,
      "enterprise_project_id": "0",
      "ssl_option": "1",
      "job_id": "c010abd0-48cf-4fa8-8cbc-090f093eaa2f"
    }

    Creating a yearly/monthly DB instance:

    { 
      "id": "39b6a1a278844ac48119d86512e0000bin06", 
      "name": "test-cassandra-01", 
      "datastore": { 
        "type": "cassandra", 
        "version": "3.11", 
        "storage_engine": "rocksDB" 
      }, 
      "created": "2019-10-28 14:10:54",
      "status": "creating",
      "region": "aaa", 
      "availability_zone": "bbb,ccc,ddd", 
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", 
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", 
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", 
      "mode": "Cluster", 
      "flavor": [ 
        { 
          "num": 3, 
          "size": 500,
          "storage": "ULTRAHIGH",
          "spec_code": "geminidb.cassandra.4xlarge.4" 
        } 
      ], 
      "backup_strategy": { 
        "start_time": "08:15-09:15", 
        "keep_days": "8" 
      } ,
      "enterprise_project_id": "0",
      "ssl_option": "1",
      "order_id": "CS20070721568OVO9",
      "charge_info": {
    	  "charge_mode": "prePaid", 
          "period_type": "year",
          "period_num": 3,
          "is_auto_renew": "true",
          "is_auto_pay": "true" 
      }
    }

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.