tencent cloud

文档反馈

CreateDisks

最后更新时间:2023-06-21 15:01:18

1. API Description

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

This API is used to create 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 async. 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 status is UNATTACHED or ATTACHED, the cloud disk has been created successfully.

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

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

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 Params. The value used for this API: CreateDisks.
Version Yes String Common Params. The value used for this API: 2017-03-12.
Region No String Common Params. This parameter is not required for this API.
Placement Yes Placement Location of the instance. You can use this parameter to specify the attributes of the instance, such as its availability zone and project. If no project is specified, the default project will be used.
DiskChargeType Yes String Cloud disk billing mode. POSTPAID_BY_HOUR: Pay-as-you-go by hour
  • CDCPAID: Billed together with the bound dedicated cluster
    For more information on the pricing in each mode, see Pricing Overview.
  • DiskType Yes String Cloud disk media type. Valid values:
  • CLOUD_BASIC: HDD Cloud Storage
  • CLOUD_PREMIUM: Premium Cloud Disk
  • CLOUD_BSSD: Balanced SSD
  • CLOUD_SSD: SSD
  • CLOUD_HSSD: Enhanced SSD
  • CLOUD_TSSD: ulTra SSD.
  • DiskName No String Cloud disk name. If it is not specified, "Unnamed" will be used by default. The maximum length is 60 bytes.
    Tags.N No Array of Tag Tags bound to the cloud disk.
    SnapshotId No String Snapshot ID. If this parameter is specified, the cloud disk will be created based on the snapshot. The snapshot must be a data disk snapshot. To query the type of a snapshot, call the DescribeSnapshots API and see the DiskUsage field in the response.
    DiskCount No Integer Number of cloud disks to be created. If it is not specified, 1 will be used by default. There is an upper limit on the maximum number of cloud disks that can be created in a single request. For more information, see Use Limits.
    ThroughputPerformance No Integer Extra performance purchased for a cloud disk.
    This optional parameter is only valid for ulTra SSD (CLOUD_TSSD) and Enhanced SSD (CLOUD_HSSD).
    DiskSize No Integer Cloud disk size in GB.
  • DiskSize is not required if SnapshotId is specified. In this case, the size of the cloud disk will be equal to that of the snapshot.
  • If you specify both SnapshotId and DiskSize, the specified disk size cannot be smaller than the snapshot size.
  • For the value range of cloud disk size, see Cloud Disk Types.
  • Shareable No Boolean Optional parameter. Default value: False. If True is specified, the new cloud disk will be shared.
    ClientToken No String A unique string supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
    Encrypt No String This parameter is used to create encrypted cloud disks. It is fixed at ENCRYPT.
    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.
    DeleteSnapshot No Integer Whether to delete the associated non-permanently reserved snapshots upon deletion of the source cloud disk. 0: No (default value). 1: Yes. To check whether a snapshot is permanently reserved, see the IsPermanent field returned by the DescribeSnapshots API.
    AutoMountConfiguration No AutoMountConfiguration Specifies whether to automatically attach and initialize the newly created data disk.
    DiskBackupQuota No Integer Specifies the cloud disk backup point quota.
    BurstPerformance No Boolean Specifies whether to enable disk bursting.

    3. Output Parameters

    Parameter Name Type Description
    DiskIdSet Array of String ID list of the created cloud disks. Note: This field may return null, indicating that no valid values can be obtained.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Purchasing a cloud disk with basic parameters

    This example shows you how to purchase a prepaid 50 GB HDD cloud disk in Guangzhou Zone 2 for one month, assign it to project 0, get a notification upon expiration, and enable automatic renewal for it.

    Input Example

    POST / HTTP/1.1
    Host: cbs.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateDisks
    <Common request parameters>
    
    {
        "Placement": {
            "ProjectId": "0",
            "Zone": "ap-guangzhou-2"
        },
        "DiskChargeType": "PREPAID",
        "DiskCount": "1",
        "DiskType": "CLOUD_HSSD",
        "ThroughputPerformance": "100",
        "DiskSize": "500",
        "DiskChargePrepaid": {
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "Period": "1"
        }
    }
    

    Output Example

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

    Example2 Creating an hourly pay-as-you-go cloud disk

    This example shows you how to create an hourly pay-as-you-go 100 GB premium cloud disk in Guangzhou Zone 3.

    Input Example

    POST / HTTP/1.1
    Host: cbs.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateDisks
    <Common request parameters>
    
    {
        "DiskName": "postPayDisk",
        "Placement": {
            "ProjectId": "0",
            "Zone": "ap-guangzhou-3"
        },
        "DiskChargeType": "POSTPAID_BY_HOUR",
        "DiskCount": "1",
        "DiskType": "CLOUD_PREMIUM",
        "DiskSize": "100"
    }
    

    Output Example

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

    Example3 Creating a cloud disk by using a snapshot

    This example shows you how to create a cloud disk by specifying a snapshot without specifying DiskSize. In this example, the size of the new cloud disk is the same as that of the snapshot, and the snapshot data will be copied to the new cloud disk.

    Input Example

    POST / HTTP/1.1
    Host: cbs.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateDisks
    <Common request parameters>
    
    {
        "Placement": {
            "ProjectId": "0",
            "Zone": "ap-guangzhou-2"
        },
        "DiskChargeType": "PREPAID",
        "DiskCount": "1",
        "DiskType": "CLOUD_BASIC",
        "DiskChargePrepaid": {
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "Period": "1"
        },
        "SnapshotId": "snap-iepc4w3h"
    }
    

    Output Example

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

    5. Developer Resources

    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
    InternalError.ComponentError Dependent component request failed. Please contact customer service.
    InvalidAccount.InsufficientBalance Insufficient account balance
    InvalidParameter.DiskConfigNotSupported Currently configured cloud disk not supported in current region.
    InvalidParameter.ProjectIdNotExist The project ID does not exist.
    InvalidParameterValue Invalid parameter value.
    InvalidParameterValue.LimitExceeded Number of parameter values exceeds the limit.
    InvalidSnapshotId.NotFound The ‘SnapshotId’ entered does not exist.
    MissingParameter Missing parameter.
    ResourceBusy The resource is busy. Try again later.
    ResourceInsufficient Insufficient resources.
    TradeDealConflict Order conflict.
    UnauthorizedOperation The operation is unauthorized.
    UnauthorizedOperation.NotCertification Payment failed as the account has not completed identity verification.
    UnauthorizedOperation.NotHavePaymentRight No payment permission.
    UnauthorizedOperation.RoleNotExists The authorization role does not exist.