Updated on 2025-08-05 GMT+08:00

Switching the Subnet of an Instance

Function

This API is used to switch the subnet of an instance.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/instances/{instance_id}/resources/subnet

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. For details, see Obtaining a Project ID.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

instance_id

Yes

String

Definition:

Instance ID. It can be viewed on the instance details page on the DCS console.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

action

No

String

Definition:

Instance VPC subnet switch

Constraints:

N/A

Range:

switch: subnet switching

Default Value:

N/A

vpc_id

No

String

Definition:

Target VPC ID

Constraints:

N/A

Range:

N/A

Default Value:

N/A

subnet_id

No

String

Definition:

Target subnet ID

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

job_id

String

Definition:

ID of the task for switching the instance subnet

Range:

N/A

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 401

Table 5 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 404

Table 7 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Example Requests

POST https://{dcs_endpoint}/v2/{project_id}/instances/{instance_id}/resources/subnet

{
  "action" : "switch",
  "vpc_id" : "c0a0a222-bac8-45d9-9d3e-9e7d0f9177c9",
  "subnet_id" : "3e803f66-fbb0-47ad-b6cb-fb87f5bed4aa"
}

Example Responses

Status code: 200

Definition:

Instance subnet switching task delivered.

{
  "job_id" : "8abfa7aa88ad5aa50188aef7ec0936d1"
}

Status code: 400

Invalid request.

{
  "error_code" : "DCS.4062",
  "error_msg" : "Invalid subnet_id parameter in the request."
}

Status Codes

Status Code

Description

200

Definition:

Instance subnet switching task delivered.

400

Invalid request.

401

Invalid authentication information.

403

Rejected request.

404

The requested resource could not be found.

500

Internal service error.

Error Codes

See Error Codes.