CreateIpv4Block

1. API Description

This API is used to create one or more IPv4 CIDR blocks.

Prerequisites

Note

  • If you create a subscription CIDR block, the amount required will be pre-deducted. If the balance is insufficient, the request will fail. If you create a pay-as-you-go CIDR block, please ensure your account balance is sufficient before calling this API.

  • Vouchers can be used for fee deduction in instance creation. See Vouchers for more details.

  • This API is an async API. A CIDR block ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the CIDR block will be CREATING during the creation. You can use DescribeCidrBlocks to query the status of the CIDR block. If the status changes from Creating to Available, it means that the CIDR block has been created successfully; CREATE_FAILED means the CIDR block has been created failed. Any operations on the instances are not allowed while creating.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter NameRequiredTypeDescription

zoneId

Yes

String

Zone ID to which the CIDR blocks belong.

name

No

String

CIDR block name to be displayed.

This parameter can contain up to 64 characters.

chargeType

Yes

String

CIDR block pricing model.

  • PREPAID: subscription

  • POSTPAID: pay-as-you-go

chargePrepaid

No

Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the chargeType is PREPAID.

netmask

Yes

Integer

Netmasks you want to purchase.

Value range: [1,32].

You can find the available netmasks in the response by calling DescribeAvailableIpv4Resource.

amount

No

Integer

Quantity of IPv4 CIDR blocks you want to purchase.

Default value: 1.

resourceGroupId

No

String

Resource group ID where the CIDR blocks reside.

If an available VLAN exists in the specified zone, this parameter will be ignored. The created CIDR blocks will be added to the resource group of the VLAN.

3. Output Parameters

Parameter NameTypeDescription

requestId

String

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

orderNumber

String

Number of order.

cidrBlockIds

Array of String

List of CIDR block IDs.

4. Code Example

Create a postpaid IPv4 CIDR block example1 with the netmask of 29 **** in IST-B, belonging to Default Resource Group.

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

Request:
{
  "zoneId": "IST-B",
  "name": "example1",
  "chargeType": "POSTPAID",
  "netmask": 29
}

Response:
{
  "requestId": "T135376EE-7090-4773-B81E-7FB38358B656",
  "response": {
    "requestId": "T135376EE-7090-4773-B81E-7FB38358B656",
    "orderNumber": "orderNum",
    "cidrBlockIds": [
      "cidrBlockId"
    ]
  }
}

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

404

INVALID_ZONE_NOT_FOUND

Zone not found.

403

OPERATION_DENIED_NETMASK_OUT_OF_STOCK

Netmask out of stock.

403

RESOURCE_INSUFFICIENT_PRODUCT_SOLD_OUT

Resources sold out.

Last updated