tencent cloud

Feedback

CreateDBInstanceHour

Last updated: 2023-03-20 10:55:17

1. API Description

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

This API is used to create a pay-as-you-go TencentDB for MongoDB instance.

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: CreateDBInstanceHour.
Version Yes String Common Params. The value used for this API: 2019-07-25.
Region No String Common Params. This parameter is not required for this API.
Memory Yes Integer Instance memory size in GB
Volume Yes Integer Instance disk size in GB
ReplicateSetNum Yes Integer Number of replica sets
- Number of the replica set instances to be created. Valid value: 1.
- Number of sharded cluster instances to be created. You can get the specific purchasable specifications through the DescribeSpecInfo API.
NodeNum Yes Integer The number of nodes in each replica set. You can get the specific purchasable specifications through the DescribeSpecInfo API.
MongoVersion Yes String Version information. You can get the specific purchasable specifications through the DescribeSpecInfo API.
- MONGO_36_WT:MongoDB 3.6 WiredTiger storage engine
- MONGO_40_WT:MongoDB 4.0 WiredTiger storage engine
- MONGO_42_WT:MongoDB 4.2 WiredTiger storage engine
- MONGO_44_WT:MongoDB 4.4 WiredTiger storage engine
MachineCode Yes String Machine type
- HIO: High IO
- HIO10G: 10-Gigabit high IO
GoodsNum Yes Integer Number of instances. Value range: 1-10.
Zone Yes String AZ information in the format of ap-guangzhou-2
- For more information, query through the DescribeSpecInfo API.
- If multi-AZ deployment is enabled, this parameter refers to the primary AZ and must be one of the values of AvailabilityZoneList.
ClusterType Yes String Instance architecture type
- REPLSET: Replica set
- SHARD: Sharded cluster
VpcId No String VPC ID
SubnetId No String VPC subnet ID. If VpcId is set, then SubnetId will be required.
Password No String Instance password
- If it is left empty, the password is in the default format of "instance ID+@+root account UIN". For example, if the instance ID is "cmgo-higv73ed" and the root account UIN "100000001", the instance password will be "cmgo-higv73ed@100000001".
- The custom password must contain 8-32 characters in at least two of the following types: letters, digits, and symbols (!@#%^*()_).
ProjectId No Integer Project ID. If it is left empty, Default project will be used.
Tags.N No Array of TagInfo Instance tag information
Clone No Integer Instance type. Valid values:
- 1: Primary instance
- 3: Read-only instance
- 4: Disaster recovery instance
Father No String Parent instance ID. It is required if the Clone is 3 or 4, that is, read-only instance or disaster recovery instance
SecurityGroup.N No Array of String Security group
RestoreTime No String Rollback time of the cloned instance
- This parameter is required for a cloned instance in the format of 2021-08-13 16:30:00.
- Time range for rollback: You can roll back data in the last 7 days.
InstanceName No String Instance name, which can contain up to 60 letters, digits, and symbols (_-).
AvailabilityZoneList.N No Array of String List of multi-AZ deployed nodes. For more information, query through the DescribeSpecInfo API.
- Nodes of a multi-AZ instance must be deployed across three AZs. Most nodes of the cluster can’t be deployed in the same AZ. For example, a three-node sharded cluster instance does not support deploying two or more nodes in the same AZ.
- MongoDB 4.2 and later versions do not support multi-AZ deployment.
- Read-only and disaster recovery instances do not support multi-AZ deployment.
-Instances in the classic network do not support multi-AZ deployment.
MongosCpu No Integer Number of Mongos CPU cores
- This parameter is not required for a sharded cluster instance of MongoDB 3.6 WiredTiger or later.
- If this parameter is not configured, the mongos specification will be configured based on the mongod specification, and the default specification is free of charge.
MongosMemory No Integer Mongos memory size
- This parameter is not required for a sharded cluster instance of MongoDB 3.6 WiredTiger or later.
- If this parameter is not configured, the mongos specification will be configured based on the mongod specification, and the default specification is free of charge.
MongosNodeNum No Integer Number of Monogs
- This parameter is not required for a sharded cluster instance of MongoDB 3.6 WiredTiger or later.
- If this parameter is not configured, the mongos specification will be configured based on the mongod specification, and the default specification is free of charge.
ReadonlyNodeNum No Integer Number of read-only nodes. Value range: 0-5.
ReadonlyNodeAvailabilityZoneList.N No Array of String AZ of read-only nodes, which is required when ReadonlyNodeNum is not 0 in cross-AZ instance deployment.
HiddenZone No String AZ where the hidden node resides, which is required in cross-AZ instance deployment.

3. Output Parameters

Parameter Name Type Description
DealId String Order ID
InstanceIds Array of String List of IDs of the created instances
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a pay-as-you-go TencentDB instance

This example shows you how to create a v4.0 instance. To create instances on other versions, you need to specify the version as instructed in the input parameter description.

Input Example

POST / HTTP/1.1
Host: mongodb.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDBInstanceHour
<Common request parameters>

{
    "Zone": "ap-guangzhou-3",
    "GoodsNum": "1",
    "Clone": "1",
    "Memory": "4",
    "ClusterType": "REPLSET",
    "Volume": "250",
    "NodeNum": "2",
    "ReplicateSetNum": "1",
    "MachineCode": "HIO10G",
    "MongoVersion": "MONGO_40_WT"
}

Output Example

{
    "Response": {
        "RequestId": "eaf9b19d-5ad4-4ca2-9fc4-a319aeb9181f",
        "DealId": "20190709160000003502416120946732",
        "InstanceIds": [
            "cmgo-m26c6jsf"
        ]
    }
}

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
InvalidParameter Parameter error
InvalidParameter.PermissionDenied The current subaccount has no permission to perform this operation.
InvalidParameterValue.ClusterTypeError Invalid instance type.
InvalidParameterValue.InvalidTradeOperation Billing error. Corresponding purchase/renewal/configuration change operations are not allowed for the current instance.
InvalidParameterValue.MachineTypeError Incorrect model.
InvalidParameterValue.MongoVersionError The instance version is incorrect.
InvalidParameterValue.PasswordRuleFailed The password is non-compliant.
InvalidParameterValue.PostPaidInstanceBeyondLimit The number of postpaid instances in a single region exceeds the limit.
InvalidParameterValue.ProjectNotFound The project does not exist.
InvalidParameterValue.RegionError Invalid region
InvalidParameterValue.ReplicaSetNumError Incorrect number of replica sets (shards).
InvalidParameterValue.SpecNotOnSale Incorrect purchasable specification.
InvalidParameterValue.StatusAbnormal The instance is in a status where operations are not allowed.
InvalidParameterValue.TagNotFound The specified tag was not found.
InvalidParameterValue.VpcIdOrSubnetIdNotFound The VPC (subnet) was not found.
InvalidParameterValue.ZoneClosed Instances are not purchasable in this AZ.
InvalidParameterValue.ZoneError Invalid availability zone
UnsupportedOperation.VersionNotSupport The current version does not support the operation.