Updated on 2025-12-29 GMT+08:00

Examples

Scenarios

Call an API to create a DCS Redis instance that meets the computing and storage requirements of services.

The following presents how to call the API described in Creating a DCS Instance to create a DCS instance. For more information on how to call APIs, see Calling APIs.

Prerequisites

Creating a DCS Redis Instance

The following example shows how to create a DCS instance with the simplest configurations:

{
	"name": "dcs-demo",
	"engine": "Redis",
	"engine_version": "4.0",
	"capacity": 2,
	"no_password_access": true,
	"vpc_id": "c71d9731-9b0c-43e9-ab2a-716af9d9fd55",
	"subnet_id": "1aa8068b-6846-4dae-bc27-bb923ab9b39c",
	"product_id": "00301-31101-0--0",
	"available_zones":["d573142f24894ef3bd3664de068b44b0"],
	}

The parameters in this example indicate a 2 GB DCS Redis 4.0 instance with password-free access.

  • name: a customized DCS instance name.
  • engine: cache engine, which is Redis.
  • engine_version: cache version, for example, 4.0, 5.0, or 6.0.
  • capacity: cache capacity in GB, which can be queried by calling the API described in Querying Product Flavors.
  • no_password_access: whether the instance can be accessed without a password. false: the instance must be accessed with a password. true: the instance is accessed without a password.
  • vpc_id: ID of the VPC where the instance resides. You can query the ID on the VPC console or by calling the API for querying the VPC list.
  • subnet_id: ID of the VPC subnet. You can query the ID on the VPC console or by calling the API for querying the subnet list.
  • product_id: specification ID of the DCS service that is being purchased, which can be queried by calling the API described in Querying Product Flavors.
  • available_zones: ID of the AZ where the cache node resides and which has available resources, which can be queried by calling the API described in Querying AZs.

Creating a DCS Redis Instance with Backup Policies

To create a master/standby or cluster DCS instance with backup policies, add the instance_backup_policy field in the request, which specifies the backup policy and backup plan. The following is an example:

{
	"name": "dcs-demo003",
	"engine": "Redis",
	"engine_version": "4.0",
	"capacity": 2,
	"no_password_access": true,
	"vpc_id": "c71d9731-9b0c-43e9-ab2a-716af9d9fd55",
	"subnet_id": "1aa8068b-6846-4dae-bc27-bb923ab9b39c",
	"product_id": "00301-31101-0--0",
	"available_zones": ["d573142f24894ef3bd3664de068b44b0"],
	"instance_backup_policy": {
	"save_days": 1,
	"backup_type": "auto",
	"periodical_backup_plan": {
		"begin_at": "16:00-17:00",
		"period_type": "weekly",
		"backup_at": ["1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7"],
		"timezone_offset": "+0800"
	}
}
}
  • save_days: number of days that the backup data is retained.
  • backup_type: backup mode. auto: scheduled backup. manual: manual backup.
  • periodical_backup_plan: backup plan, which is detailed in Creating a DCS Instance.