CreateDisks

CreateDisks

1. API Description

This API is used to create one or more disks.

Note

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

  • This API is an async API. A disk ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. You can use DescribeDisks to query the status of the disk. If disk has been queried with the Available status, it means that the disk has been created successfully; if disk has been attached to a certain instance while creating, the IN_USE status means attaching successfully.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter NameRequiredTypeDescription

chargeType

Yes

String

Disk 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.

diskName

Yes

String

Disk name to be displayed.

This parameter must start with a number or a letter, containing up to 64 characters. Only letters, numbers, - and periods (.) are supported.

diskSize

Yes

Integer

Storage space.

Unit: GB.

diskCategory

No

String

Disk type.

  • Standard Disk: Hard Disk Drive

  • SSD: Solid State Drive

The default value is Standard Disk. Call DescribeDiskCategory to obtain disk type.

instanceId

No

String

ID of instance to which the disks are attached.

Specify the ID of an instance in the current zone to which the disks are attached.

zoneId

No

String

ID of zone to which thedisk belongs. If instanceId is specified, this parameter is invalid. Call Describezones to obtain zoneId.

diskAmount

No

Integer

Quantity of disks.

Minimum value: 1 (default value);

Maximum value: 50.

resourceGroupId

No

String

Resource group ID.

If the value is null, the disk will be added into default resource group.

3. Output Parameters

Parameter NameTypeDescription

requestId

String

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

diskIds

Array of String

ID List of disks.

orderNumber

String

Number of order.

4. Code Example

Create one or more disks.

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

Request:
{
  "chargeType": "POSTPAID",
  "diskName": "Test-Disk",
  "diskSize": 30,
  "diskAmount": 1,
  "zoneId": "HKG-A"
}

Response:
{
  "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
  "response": {
    "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
    "diskIds": [
      "862857204414550690"
    ],
    "orderNumber": "862857208122313378"
  }
}

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

400

INVALID_ILLEGAL_DISK_SIZE

Disk size exceeds the maximum or minimum limit.

404

INVALID_ZONE_NOT_FOUND

Zone does not exist.

400

LIMIT_EXCEEDED_INSTANCE_CAN_ATTACH

Quantity of attached disks exceeds the maximum limit.

404

INVALID_INSTANCE_NOT_FOUND

Instance to which the disks to be attached does not exist.

400

INVALID_INSTANCE_OR_ZONE_CANNOT_BE_BOTH_EMPTY

Specify at least one of the parameters: instance and zone.

400

INVALID_CHARGE_PREPAID_CAN_NOT_BE_NULL

chargePrepaid is required when the chargeType is PREPAID.

400

INVALID_CHARGE_TYPE

Invalid billing model.

400

INVALID_DISK_CATEGORY_ZONE_NO_SELL

Disk type not for sale in the zone.

400

INVALID_DISK_CATEGORY_ZONE_NOT_SUPPORT

Unavailable disk type in the zone.

Last updated