CreateDisks

Last updated: 2020-01-13 11:06:47

PDF

1. API Description

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

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

  • This API supports creating a cloud disk with a data disk snapshot so that the snapshot data can be copied to the purchased cloud disk.
  • This API is an async API. A cloud disk ID list will be returned when a request is made successfully, but it does not mean that the creation has been completed. You can call the DescribeDisks API to query cloud disks by DiskId. If a new cloud disk can be found and its state is 'UNATTACHED' or 'ATTACHED', it means that the cloud disk has been created successfully.

A maximum of 20 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: cbs.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some 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, please see the list of regions supported by the product.
DiskType Yes String Type of hard disk medium. Value range:
  • CLOUD_BASIC: Ordinary cloud disk
  • CLOUD_PREMIUM: Premium cloud storage
  • CLOUD_SSD: SSD cloud disk.
  • DiskChargeType Yes String Cloud disk billing method. POSTPAID_BY_HOUR: pay as you go by hour
  • CDCPAID: Billed together with the bound dedicated cluster
    For information about the pricing of each method, see the cloud disk Pricing Overview.
  • Placement Yes Placement The location of the instance. The availability zone and the project that the instance belongs to can be specified using this parameter. If the project is not specified, it will be created under the default project.
    DiskName No String The displayed name of the cloud disk. If it is left empty, the default is “Not named”. The maximum length cannot exceed 60 bytes.
    DiskCount No Integer If the number of cloud disks to be created is left empty, the default is 1. There is a limit to the maximum number of cloud disks that can be created for a single request. For more information, please see CBS Use Limits.
    DiskChargePrepaid No DiskChargePrepaid Relevant parameter settings for the prepaid mode (i.e., monthly subscription). The monthly subscription cloud disk purchase attributes such as usage period and whether or not auto-renewal is set up can be specified using this parameter.
    This parameter is required when creating a prepaid cloud disk. This parameter is not required when creating an hourly postpaid cloud disk.
    DiskSize No Integer Cloud hard disk size (in GB).
  • If SnapshotId is passed, DiskSize cannot be passed. 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 cloud disk Product Types.
  • SnapshotId No String Snapshot ID. If this parameter is specified, the cloud disk is created based on the snapshot. The snapshot type must be a data disk snapshot. The snapshot can be queried in the DiskUsage field in the output parameter through 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 This parameter is used to create an encrypted cloud disk. Its value is always ENCRYPT.
    Tags.N No Array of Tag Cloud disk binding tag.
    Shareable No Boolean The default of optional parameter is False. When True is selected, the cloud disk will be created as a shareable cloud disk.

    3. Output Parameters

    Parameter Name Type Description
    DiskIdSet Array of String List of created cloud disk IDs.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    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. Developer Resources

    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 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

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

    Error Code Description
    InvalidParameter.DiskConfigNotSupported Currently configured cloud disk not supported in current region.
    InvalidParameterValue Invalid parameter value. Parameter value format error or parameter value not supported.
    MissingParameter Missing parameter. Request does not include the required parameter.
    ResourceInsufficient Insufficient Resources
    TradeDealConflict Order conflict.
    UnauthorizedOperation Unauthorized operation