tencent cloud

Feedback

AllocateHosts

Last updated: 2024-10-22 19:33:41

    1. API Description

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

    This API is used to create CDH instances with specified configuration.

    • When HostChargeType is PREPAID, the HostChargePrepaid parameter must be specified.

    A maximum of 10 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: AllocateHosts.
    Version Yes String Common Params. The value used for this API: 2017-03-12.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    Placement Yes Placement Instance location. This parameter is used to specify the attributes of an instance, such as its availability zone and project.
    ClientToken No String A string used to ensure the idempotency of the request.
    HostChargePrepaid No ChargePrepaid Configuration of prepaid instances. You can use the parameter to specify the attributes of prepaid instances, such as the subscription period and the auto-renewal plan. This parameter is required for prepaid instances.
    HostChargeType No String Instance billing model, only monthly or yearly subscription supported. Default value: `PREPAID'.
    HostType No String CDH instance model. Default value: HS1.
    HostCount No Integer Quantity of CDH instances purchased. Default value: 1.
    TagSpecification.N No Array of TagSpecification Tag description. You can specify the parameter to associate a tag with an instance.

    3. Output Parameters

    Parameter Name Type Description
    HostIdSet Array of String IDs of created instances
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Purchasing a monthly subscribed CDH instance

    This example shows you how to purchase a monthly subscribed HS1 CDH instance in Guangzhou Zone 2 for one month, with the auto-renewal enabled.

    Input Example

    POST / HTTP/1.1
    Host: cvm.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: AllocateHosts
    <Common request parameters>
    
    {
        "HostChargeType": "PREPAID",
        "HostCount": "1",
        "Placement": {
            "Zone": "ap-guangzhou-2"
        },
        "HostType": "HS1",
        "HostChargePrepaid": {
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "Period": "1"
        }
    }
    

    Output Example

    {
        "Response": {
            "HostIdSet": [
                "host-lan4lb2k"
            ],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }
    

    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
    InvalidAccount.InsufficientBalance Insufficient account balance.
    InvalidHostId.Malformed Invalid CDH ID. The specified CDH ID has an invalid format. For example, host-1122 has an invalid ID length.
    InvalidParameterValue.Range Invalid parameter value: invalid parameter value range.
    InvalidParameterValue.ZoneNotSupported The availability zone does not support this operation.
    InvalidPeriod Invalid period. Valid values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36]; unit: month.
    InvalidProjectId.NotFound Invalid project ID: the specified project ID does not exist.
    InvalidRegion.NotFound The region cannot be found.
    InvalidZone.MismatchRegion The specified zone does not exist.
    ResourceInsufficient.ZoneSoldOutForSpecifiedInstance The instances of the specified types were sold out in the selected AZs.