Apply Private IP for ENI

Last updated: 2017-12-26 15:46:53

1. API Description

This API (AssignPrivateIpAddresses) is used to apply for the private IP of ENI.
Domain for API request: vpc.api.qcloud.com

1) An ENI can only be bound to limited IP addresses. For more information on VPC resource restrictions, refer to VPC Usage Restrictions.
2) You can specify the private IP address to be applied. Private IP address type cannot be the primary IP. The primary IP already exists and cannot be modified. The private IP must be in the subnet of the ENI, and cannot be occupied.
3) You can apply for one or multiple auxiliary private IPs on the ENI. The API will return a specified number of auxiliary private IPs in the subnet segment of the ENI.

2. Input Parameters

The following request parameter list only provides API request parameters. Common request parameters need to be added when the API is called. For more information, refer to Common Request Parameters. The Action field for this API is AssignPrivateIpAddresses.

Parameter Name Required Type Description
vpcId Yes String Virtual private cloud ID of ENI, for example: vpc-7t9nf3pu
networkInterfaceId Yes String ENI ID, for example: eni-m6dyj72l
privateIpAddressSet.n No Array Specify the IP address to be applied when applying for private IP. You can specify primary IP. Optional.
privateIpAddressSet.n.primary Yes Bool Primary IP or not, can only set one primary IP.
privateIpAddressSet.n.privateIpAddress Yes String Specified private IP address.
secondaryPrivateIpAddressCount No Int (Optional) Specify the quantity of private IPs. The IP will be automatically generated by the system.

3. Output Parameters

Parameter Name Type Description
code Int Error code. 0: Succeeded; other values: Failed.
message String Error message
taskId Int Task ID. The operation result can be queried with taskId. For more information, refer to API for Querying Task Execution Result.

4. Error Code Table

The following error code list only provides the business logic error codes for this API. For additional common error codes, refer to VPC Error Codes.

Error code Description
InvalidVpc.NotFound VPC does not exist. Please check the information you entered. You can query the VPC via the DescribeVpcEx API
InvalidNetworkInterface.NotFound ENI does not exist. Please check the information you entered. You can query the ENI via the DescribeNetworkInterfaces API
InvalidPrivateIpAddress.InUse This private IP already in use

5. Example

Input


https://vpc.api.qcloud.com/v2/index.php?Action=AssignPrivateIpAddresses
&<Common request parameters>
&vpcId=vpc-7t9nf3pu
&networkInterfaceId=eni-m6dyj72l
&secondaryPrivateIpAddressCount=1

Output

{
    "code": 0,
    "message": "",
    "codeDesc": "Success",
    "data":
        {
            "taskId": 16284
        }
}