CreateDisks

Last updated: 2019-09-09 20:17:34

PDF

1. API Description

Domain name for API request: cbs.tencentcloudapi.com.

This API (CreateDisks) is used to create one or more cloud disks.

  • For prepaid cloud disks, the required amount for the purchased cloud disk will be pre-deducted. Make sure your account balance is sufficient before calling this API.
  • You can specify a data disk snapshot while creating a cloud disk. In this case, the snapshot data will be duplicate to the newly created cloud disk.
  • This API is an asynchronous API. A cloud disk ID list will be returned when the creation request is issued successfully, but the cloud disk is not created immediately. You can call the API DescribeDisks to query the cloud disk by DiskId. If the cloud disk can be found and its status is 'UNATTACHED' or 'ATTACHED', the cloud disk is created successfully.

Default request rate limit: 20/sec.

Note: This API supports finance AZs. As finance AZs and non-finance AZs are isolated, when accessing the services in a finance AZ (with the common parameter Region specifying a financial availability zone), it is necessary to specify a domain name with the finance AZ, preferably in the same region as specified in Region.

2. Input Parameters

The list below contains only the API request parameters and certain common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: CreateDisks
Version Yes String Common parameter. The value used for this API: 2017-03-12
Region Yes String Common parameter. For more information, see List of Regions supported by the product.
DiskType Yes String Type of disk medium. Value range:
  • CLOUD_BASIC: HDD cloud storage
  • CLOUD_PREMIUM: Premium cloud storage
  • CLOUD_SSD: SSD cloud storage
  • DiskChargeType Yes String The cloud disk billing method.
  • PREPAID: Prepaid, monthly subscription
  • POSTPAID_BY_HOUR: Postpaid by hour (pay as you go)
  • CDCPAID: Dedicated cluster payment
    For information on the pricing models, see cloud disk Pricing Overview.
  • Placement Yes Placement The location of the instance. This parameter is used to specify the availability zone and the project to which the instance belongs. If the project is not specified, the instance is created in the default project.
    DiskName No String The display name of the cloud disk. If it is left empty, the default is "not named". The maximum length is 60 bytes.
    DiskCount No Integer The number of cloud disks to create. If it is left empty, the default is 1. For the maximum number of cloud disks that can be created in one request, please see CBS Use Limits.
    DiskChargePrepaid No DiskChargePrepaid Specifies the billing information of monthly subscription cloud disks, including the validity period, auto-renewal status and more.
    This parameter is required for monthly subscription cloud disks. Ignore this parameter if you want to create pay-as-you-go cloud disks.
    DiskSize No Integer Cloud disk size (in GB).
  • If SnapshotId is specified, DiskSize can not be specified at the same time. In this case, the size of the cloud disk is the size of the snapshot.
  • To pass SnapshotId and DiskSize at the same time, the size of the disk must be larger than or equal to the size of the snapshot.
  • For information about the size range of cloud disks, see Product Types.
  • SnapshotId No String Snapshot ID. If this parameter is specified, the cloud disk is created based on the snapshot. Please note that the snapshot must be a data disk snapshot. You can query whether the snapshot is a data disk snapshot using the API DescribeSnapshots.
    ClientToken No String A string to ensure the idempotency of the request, which is generated by the client. Each request shall have a unique string with a maximum of 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be ensured.
    Encrypt No String Indicates whether to encrypt the cloud disk. Its value is always ENCRYPT.
    Tags.N No Array of Tag The tags bound to a cloud disk.
    Shareable No Boolean Indicates whether the cloud disk is a shared cloud disk. True: shared cloud disk. False: not a shared cloud disk. The default value is False.

    3. Output Parameters

    Parameter Name Type Description
    DiskIdSet Array of String A list of IDs of the created cloud disks.
    RequestId String Unique ID of the request. Each request returns a unique ID. The RequestId is required to troubleshoot issues.

    4. Samples

    Sample 1. Purchasing a Cloud Disk

    Purchase a 50GB HDD cloud disk in Guangzhou Zone 2 for one month, assign it to project 0, and enable expiry notification and auto-renewal for it.

    Input Sample Code

    https://cbs.tencentcloudapi.com/?Action=CreateDisks
    &DiskType=CLOUD_BASIC
    &DiskCount=1
    &DiskSize=50
    &Placement.Zone=ap-guangzhou-2
    &Placement.ProjectId=0
    &DiskChargeType=PREPAID
    &DiskChargePrepaid.Period=1
    &DiskChargePrepaid.RenewFlag=NOTIFY_AND_AUTO_RENEW
    &<Common request parameters>

    Output Sample Code

    {
      "Response": {
        "DiskIdSet": [
          "disk-lzrg2pwi"
        ],
        "RequestId": "6a57da9a-2049-7182-2de3-5a1f8014ccfd"
      }
    }

    Sample 2. Creating a Cloud Disk Based on a Snapshot

    Specify a snapshot to create a cloud disk. The DiskSize parameter is not specified, so the size of the purchased cloud disk equals to that of the snapshot. The snapshot data are copied to the purchased cloud disk.

    Input Sample Code

    https://cbs.tencentcloudapi.com/?Action=CreateDisks
    &DiskType=CLOUD_BASIC
    &DiskCount=1
    &SnapshotId=snap-iepc4w3h
    &Placement.Zone=ap-guangzhou-2
    &Placement.ProjectId=0
    &DiskChargeType=PREPAID
    &DiskChargePrepaid.Period=1
    &DiskChargePrepaid.RenewFlag=NOTIFY_AND_AUTO_RENEW
    &<Common request parameters>

    Output Sample Code

    {
      "Response": {
        "DiskIdSet": [
          "disk-6rz0ilvu"
        ],
        "RequestId": "5e93a212-ca01-0fdc-eedd-5a1fce5e83e6"
      }
    }

    Sample 3. Creating a Pay-as-you-go Cloud Disk

    Create a 100GB pay-as-you-go premium cloud disk in the Guangzhou Zone 3.

    Input Sample Code

    https://cbs.tencentcloudapi.com/?Action=CreateDisks
    &DiskType=CLOUD_PREMIUM
    &DiskCount=1
    &Placement.Zone=ap-guangzhou-3
    &Placement.ProjectId=0
    &DiskChargeType=POSTPAID_BY_HOUR
    &DiskName=postPayDisk
    &DiskSize=100
    &<Common request parameters>

    Output Sample Code

    {
      "Response": {
        "DiskIdSet": [
          "disk-ecjc4cpw"
        ],
        "RequestId": "fe2274fa-eaec-4009-807b-6ffc00963fec"
      }
    }

    5. Resources for Developers

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

    SDK

    TencentCloud API 3.0 comes with SDKs that support multiple programming languages and make it easier to call the APIs.

    Command line tools

    6. Error Codes

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

    Error Code Description
    InvalidParameter.DiskConfigNotSupported The configured cloud disk is not supported in the region.
    InvalidParameterValue Invalid parameter value. Parameter value is in an incorrect format or is not supported.
    MissingParameter Missing parameter. A required parameter is missing in the request.
    ResourceInsufficient Insufficient resource
    TradeDealConflict Order conflict.
    UnauthorizedOperation Unauthorized operation