AssociateSubnetInstances

AssociateSubnetInstances

1. API Description

This API is used to add one or more instances into a subnet and assign private IPs to instances.

Note

  • This API is an async API. A request ID is returned after the request is sent. However, it does not mean the binding has been completed. You can use DescribeSubnets to query the status of privateIpStatus.

    • If the status is BINDED, it means that the private IP has been bound.

    • If the status is BINDING, it means that the private IP is being bound.

    • If the status is UNBINDING, it means that the private IP is being unbound.

  • Only operations on instances in RUNNING status are supported.

  • Instances can only be added into the subnet in the same zone.

  • The status of subnet should be AVAILABLE and there are still available private IPs in it.

  • Generally, an instance can only be added into one subnet. If the instance is already in other subnet, the request will fail. However, if you do need to add one instance into two or more subnets, please contact Zenlayer Support.

  • Batch operations are supported. Each request can add up to 100 instances.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter NameRequiredTypeDescription

subnetId

Yes

String

Subnet ID.

subnetInstanceList

Yes

List of instances.

3. Output Parameters

Parameter NameTypeDescription

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Code Example

Add instance into a subnet and assign a private IP to it.

POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: AssociateSubnetInstances
<Common Request Params>

Request:
{
  "subnetId": "833049815985166808",
  "subnetInstanceList": [
    {
      "instanceId": "820653960707704280",
      "privateIpAddress": "10.0.0.2"
    }
  ]
}

Response:
{
  "requestId": "TD3AA7771-C9C1-4EC2-A743-FD934710CEB6",
  "response": {
    "requestId": "TD3AA7771-C9C1-4EC2-A743-FD934710CEB6"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.​

HTTP Status CodeError CodeDescription

403

OPERATION_DENIED_INSTANCE_NOT_SUPPORT_SUBNET

Operations on adding the instance into a subnet not supported.

403

OPERATION_DENIED_INSTANCE_NOT_RUNNING

Only operations on instances in RUNNING status are supported.

404

INVALID_SUBNET_NOT_FOUND

Subnet not found.

403

OPERATION_DENIED_SUBNET_STATUS_NOT_SUPPORT

Subnet status not supported.

403

OPERATION_DENIED_DIFFERENT_ZONE

Instances can only be added into the subnet in the same zone.

403

OPERATION_DENIED_SUBNET_EXIST_INSTANCE

Instance already exists in the subnet.

400

INVALID_PARAMETER_DUPLICATE_LAN_IP

Duplicated private IPs assigned to instances.

400

INVALID_PARAMETER_LAN_IP_NOT_SUPPORT

Private IP ended with .1 cannot be assigned.

403

OPERATION_DENIED_IP_ASSOCIATED_INSTANCE

Unavailable private IP. This has already been assigned to an instance.

403

OPERATION_DENIED_SUBNET_NOT_REPEAT_INSTANCE

Duplicated instances in the subnet.

Last updated