Updated on 2024-03-05 GMT+08:00

Creating a DCS Instance

Function

This API is used to create a DCS instance billed in pay-per-use mode.

URI

POST /v1.0/{project_id}/instances

Table 1 describes the parameter.
Table 1 Parameter description

Parameter

Type

Mandatory

Description

project_id

String

Yes

Project ID. For details on how to obtain the value of this parameter, see Obtaining a Project ID.

Request

Request parameters

Table 2 describes the request parameters.

Table 2 Parameter description

Parameter

Type

Mandatory

Description

name

String

Yes

DCS instance name.

An instance name can contain letters, digits, underscores (_), and hyphens (-) and must start with a letter.

When you create only one instance at a time, the value of this parameter can contain 4 to 64 characters. When you create more than one instance at a time, the value of Name can contain 4 to 56 characters. These instances are named in the format of "name-n", in which n starts from 000 and is incremented by 1. For example, if you create two instances and set name to dcs_demo, the two instances are respectively named as dcs_demo-000 and dcs_demo-001.

description

String

No

Brief description of the DCS instance.

The description supports up to 1024 characters.

NOTE:

The backslash (\) and quotation mark (") are special characters for JSON messages. When using these characters in a parameter value, add the escape character (\) before the characters, for example, \\ and \".

engine

String

Yes

Cache engine. Options: Redis or Memcached.

engine_version

String

Yes

Cache engine version. If the cache engine is Redis, the value can be 3.0, 4.0, or 5.0. If the cache engine is Memcached, this parameter is optional and can be left blank.

capacity

Float

Yes

Cache capacity. Unit: GB.

  • Redis 3.0: For a single-node or master/standby DCS instance, the value can be 2, 4, 8, 16, 32, or 64. For a Proxy Cluster DCS instance, the value can be 64, 128, 256, 512, or 1024.
  • Redis 4.0 or 5.0: For a single-node or master/standby DCS instance, the value can be 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 32, or 64. For a Redis Cluster DCS instance, the value can be 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, or 1024.
  • For a single-node or master/standby DCS Memcached instance, the value can be 2, 4, 8, 16, 32, or 64.

no_password_access

String

Yes

An indicator of whether a DCS instance can be accessed in password-free mode.

  • true: indicates that a DCS instance can be accessed without a password.
  • false: indicates that a DCS instance can be accessed only after password authentication.

Default value: false.

password

String

No

Password of a DCS instance.

NOTE:

If no_password_access is set to false or not set, the request must contain the password parameter.

The password of a DCS Redis instance must meet the following complexity requirements:

  • Can contain 8 to 32 characters.
  • Must be different from the old password.
  • Contains at least three of the following character types:
    • Lowercase letters
    • Uppercase letters
    • Digits
    • Special characters (`~!@#$%^&*()-_=+\|[{}]:'",<.>/?)

access_user

String

No

If the cache engine is Redis, you do not need to set this parameter.

If the cache engine is Memcached, this parameter is available only when no_password_access is set to false, indicating that you need to access the DCS instance in password mode.

A username can contain 1 to 64 characters, including letters, digits, underscores (_), and hyphens (-), and must start with a letter.

NOTE:
  • This parameter is optional when the cache engine is Memcached.
  • If the cache engine is Redis, you do not need to set this parameter.

vpc_id

String

Yes

VPC ID.

Obtain the value by using either of the following methods:

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

security_group_id

String

Yes

ID of the security group which the instance belongs to.

Obtain the value by using 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: Call the API for querying security groups. For details, see Querying Security Groups.

subnet_id

String

Yes

Network ID of the subnet.

Obtain the value by using either of the following methods:

  • Method 1: Log in to VPC console and click the target subnet on the Subnets tab page. You can view the network ID on the displayed page.
  • Method 2: Call the API for querying subnets. For details, see Querying Subnets.

available_zones

Array

Yes

ID of the AZ where the cache node resides and which has available resources. For details on how to obtain the value, see Querying AZ Information. Check whether the AZ has available resources.

Master/Standby, Proxy Cluster, and Redis Cluster DCS instances support cross-AZ deployment. You can specify an AZ for the standby node. When specifying AZs for nodes, use commas (,) to separate multiple AZs. For details, see the example request.

product_id

String

Yes

ID of the product that can be created. For details, see Querying Service Specifications.

NOTE:

When obtaining the product ID from the product specifications, ensure that the billing mode specified in the product ID is the same as the selected billing mode. For example, to buy a master/standby DCS Redis 3.0 instance billed in pay-per-use mode, you can search for the product ID corresponding to the record whose charging_type is Hourly and spec_code is dcs.master_standby in the response message.

instance_backup_policy

JSON

No

Backup policy.

This parameter is available for master/standby and cluster DCS instances. For details, see Table 4 and Table 5.

enable_publicip

Boolean

No

An indicator of whether to enable public access for a DCS Redis instance.

  • true: enable.
  • false: disable.

publicip_id

String

No

ID of the elastic IP address bound to a DCS Redis instance.

This parameter is mandatory if public access is enabled (that is, enable_publicip is set to true).

enable_ssl

Boolean

No

An indicator of whether to enable SSL for public access to a DCS Redis instance.

  • true: enable.
  • false: disable.

maintain_begin

String

No

Time at which the maintenance time window starts.

Format: HH:mm:ss.

  • The start time and end time of the maintenance time window must indicate the time segment of a supported maintenance time window. For details on how to query the time segments of supported maintenance time windows, see Querying Maintenance Time Window.
  • The start time must be set to 22:00:00, 02:00:00, 06:00:00, 10:00:00, 14:00:00, or 18:00: 00.
  • Parameters maintain_begin and maintain_end must be set in pairs. If parameter maintain_start is left blank, parameter maintain_end is also blank. In this case, the system automatically set the start time to 02:00:00.

maintain_end

String

No

Time at which the maintenance time window ends.

Format: HH:mm:ss.

  • The start time and end time of the maintenance time window must indicate the time segment of a supported maintenance time window. For details on how to query the time segments of supported maintenance time windows, see Querying Maintenance Time Window.
  • The end time is four hours later than the start time. For example, if the start time is 22:00:00, the end time is 02:00:00.
  • Parameters maintain_begin and maintain_end must be set in pairs. If parameter maintain_end is left blank, parameter maintain_start is also blank. In this case, the system automatically set the end time to 06:00:00.

enterprise_project_id

String

No

Enterprise project ID.

enterprise_project_name

String

No

Enterprise project name.

instance_num

Integer

No

Number of instances to be created in batches. This parameter is available for DCS Redis and Memcached instances.

Default value: 1.

Value range: 1–100.

private_ip

String

No

IP address that is manually specified for a DCS instance. This parameter is available for DCS Redis and Memcached instances.

tags

Array of objects

No

Instance tag key and value. For details, see Table 3.

port

Integer

No

Port customization, which is supported only by Redis 4.0 and Redis 5.0 instances and not by Redis 3.0 and Memcached instances.

If this parameter is not sent or is left empty when you create a Redis 4.0 or 5.0 instance, the default port 6379 will be used. To customize a port, specify a port number in the range from 1 to 65535.

rename_commands

JSON

No

Critical command renaming, which is supported only by Redis 4.0 and Redis 5.0 instances and not by Redis 3.0 and Memcached instances.

If this parameter is not sent or is left empty when you create a Redis 4.0 or 5.0 instance, no critical command will be renamed. Currently, only COMMAND, KEYS, FLUSHDB, FLUSHALL, and HGETALL commands can be renamed.

Table 3 tags parameters

Parameter

Mandatory

Type

Description

key

No

String

Tag key, which

  • Cannot be left blank.
  • Must be unique.
  • Can contain a maximum of 36 characters.

value

No

String

Tag value, which

  • Is mandatory when action is set to create and optional when action is set to delete.
  • Can contain a maximum of 43 characters.
Table 4 instance_backup_policy parameter description

Parameter

Type

Mandatory

Description

save_days

Integer

No

This parameter is mandatory when backup_type is set to manual.

Retention period.

Unit: day.

Value range: 1–7.

backup_type

String

No

Backup type.

Options:

  • auto: automatic backup.
  • manual: manual backup.

The default value is manual.

periodical_backup_plan

JSON

Yes

Backup plan. For details, see Table 5.

Table 5 periodical_backup_plan parameter description

Parameter

Type

Mandatory

Description

begin_at

String

Yes

Time at which backup starts.

"00:00-01:00" indicates that backup starts at 00:00:00.

period_type

String

Yes

Interval at which backup is performed.

Currently, only weekly backup is supported.

backup_at

Array

Yes

Day in a week on which backup starts.

Value range: 1–7, where 1 indicates Monday and 7 indicates Sunday.

timezone_offset

String

No

Time zone in which backup is performed.

Value range: GMT–12:00 to GMT+12:00. If this parameter is left blank, the current time zone of the DCS-Server VM is used by default.

Example request

Request URL:

POST https://{dcs_endpoint}/v1.0/{project_id}/instances
  • Example:
    Creating a DCS Redis instance
    {
        "name": "dcs-APITest",
        "description": "Test",
        "engine": "Redis",
        "engine_version": "3.0",
        "capacity": 2,
        "enterprise_project_id": "0",
        "enterprise_project_name": "default",
        "no_password_access": false,
        "access_user": "",
        "password": "********",
        "vpc_id": "0402ea19-5457-4032-9d1b-eb48b98f6c66",
        "security_group_id": "4b95a790-5cfc-463d-8de5-42199e55371c",
        "subnet_id": "a3bd29e4-d5bc-414c-a79a-1f35ee4ead88",
        "available_zones": [
            "12c47a78666b4e438cd0c692b9860387"
        ],
        "maintain_begin": "02:00",
        "maintain_end": "06:00",
        "product_id": "dcs.master_standby-h",
        "enable_publicip": false,
        "publicip_id": "",
        "enable_ssl": false,
        "private_ip": "",
        "instance_num": 1
    }
  • Example:

    Creating a pay-per-use, master/standby DCS Redis instance with tags, a customized port, renamed commands, and cross-AZ deployment

    {
    	"name": "dcs-demo",
    	"engine": "Redis",
    	"engine_version": "4.0",
    	"capacity": 2,
    	"no_password_access": true,
    	"vpc_id": "c5cd009b-9ba9-41f2-9a26-2b8c3f3ffd39",
    	"subnet_id": "7e95c4d6-d7af-424c-a3cf-2be10968fe81",
    	"product_id": "redis.ha.au1.large.2-h",
    	"available_zones": ["ae04cf9d61544df3806a3feeb401b204",	"d573142f24894ef3bd3664de068b44b0"],
    	"security_group_id": "d57fad27-e3e9-43b7-9498-0a698ab63b27",
    	"port": "4040",
            "rename_commands": 
             {
               "keys":"keys001",
               "flushdb":"flushdb001",
               "flushall":"flushall001"
             },
    	"tags": [{
    	"key": "dcs001",
    	"value": "002"
    },
    {
    	"key": "dcs003",
    	"value": "004"
    }]
    }
  • Example:

    Creating a master/standby DCS Memcached instance with backup policies

    {
        "name": "dcs-a11b",
        "description": "Create an instance",
        "engine": "Memcached",
        "engine_version": "",
        "capacity": 2,
        "password": "XXXXXX",
        "vpc_id": "27d99e17-42f2-4751-818f-5c8c6c03ff16",
        "security_group_id": "1477393a-29c9-4de5-843f-18ef51257c8e",
        "subnet_id": "ec2f34b9-20eb-4872-85bd-bea9fc943129",
        "available_zones": [
            "1d7b939b382c4c3bb3481a8ca10da769"
        ],
        "product_id": "XXXXXX",
        "instance_backup_policy": {
            "save_days": 1,
            "backup_type": "auto",
            "periodical_backup_plan": {
                "begin_at": "00:00-01:00",
                "period_type": "weekly",
                "backup_at": [
                    1,
                    2,
                    3,
                    4,
                    5,
                    6,
                    7
                ]
            }
        },
        "maintain_begin": "22:00:00",
        "maintain_end": "02:00:00",
        "no_password_access": "true",
        "access_user": "",
        "timezone_offset":""
    }

Response

Response parameters

Table 6 describes the response parameters.
Table 6 Parameter description

Parameter

Type

Description

instance_id

String

DCS instance ID.

If instances are created in batches, multiple instance IDs are returned, which are separated by commas (,).

NOTE:

This parameter is used for compatibility with earlier versions. The instance IDs listed in this parameter are consistent with the instances listed in instances.

instances

JSON

DCS instance list. For details, see Table 7.

Table 7 Parameter description of the instances array

Parameter

Type

Description

instance_id

String

DCS instance ID.

instance_name

String

DCS instance name.

{
    "instances": [
        {
            "instance_id": "3c49fd6b-fc7c-419e-9644-b6cce008653f",
            "instance_name": "dcs-test005"
        }
    ],
    "instance_id": "3c49fd6b-fc7c-419e-9644-b6cce008653f"
}

Status Code

Table 8 describes the status code of successful operations. For details about other status codes, see Table 1.

Table 8 Status code

Status Code

Description

200

DCS instance created successfully.