Note:
This is a legacy API which has been hidden and will no longer be updated. We recommend using the new VPC API 3.0 which is standardized and faster.
This API (CreateVpc) is used to create VPCs.
Domain name for API request: vpc.api.qcloud.com
Below is a list of API request parameters. You need to add common request parameters to your request when calling this API. For more information, see the Common Request Parameters page. The Action field for this API is CreateVpc.
Parameter name | Required | Type | Description |
---|---|---|---|
vpcName | Yes | String | VPC name, which cannot exceed 60 characters. |
cidrBlock | Yes | String | VPC IP address range. Available values: 10.0.0.0/16, 172.16.0.0/16, 192.168.0.0/16, and their subnets. For more information, see the document about VPC IP ranges. |
subnetSet.n | No | Array | Subnet information array. You can create subnets while creating a VPC. This parameter is optional. |
subnetSet.n.subnetName | No | String | Subnet name, which cannot exceed 60 characters. |
subnetSet.n.cidrBlock | No | String | Subnet IP range. It must fall within the VPC IP address range. Subnet IP address ranges must not overlap with each other within the same VPC. |
subnetSet.n.zoneId | No | String | ID of the availability zone in which the subnet resides. You can set up disaster recovery across availability zones by choosing different availability zones for different subnets. For more information, see VPC Availability Zones. |
Parameter name | Type | Description |
---|---|---|
code | Int | Common error code. 0: Successful; other values: Failed. For more information, see Common Error Codes on the “Error Codes” page. |
message | String | Module error message, which depends on the API. |
vpcId | String | vpcId assigned by the system, for example: gz_vpc_226. |
unVpcId | String | Unified ID assigned by the system, for example: vpc-2ari9m7h. This ID is derived from the vpcId. The system supports both IDs for compatibility, but the unified ID is recommended. |
vpcCreateTime | String | Creation time of the VPC, for example: 2015-11-06 11:33:52. |
subnetSet.n | Array | Subnet information, which is returned when a subnet is added. |
subnetSet.n.subnetId | String | Subnet ID assigned by the system, for example: subnetId_GZ_23. |
subnetSet.n.unSubnetId | String | Unified subnet ID assigned by the system, for example: subnet-5gu2jxf4. This ID is derived from the vpcId. The system supports both IDs for compatibility. |
subnetSet.n.routeTableId | String | ID of the default route table bound to the subnet, for example: gz_rtb_8751. |
subnetSet.n.subnetName | String | Subnet name. |
subnetSet.n.cidrBlock | String | Subnet IP range, for example: 192.168.0.0/25. |
subnetSet.n.zoneId | String | ID of the availability zone (numeric-type parameter) in which the subnet resides, for example: 200001. |
subnetSet.n.zone | String | ID of the availability zone (string-type parameter) in which the subnet resides, for example: ap-guangzhou-1. |
routeTableSet.n | Array | Route table information. By default, a subnet is associated with the default route table. |
routeTableSet.n.routeTableId | String | The route table ID assigned by the system, for example: gz_rtb_8751. |
routeTableSet.n.routeTableType | Int | Route table type. 0: Ordinary route table; 1: Default route table. |
routeTableSet.n.routeTableName | String | Route table name. |
The following error codes only include business logic error codes for this API.
Error code | Description |
---|---|
InvalidVpcName | Invalid VPC name. This name cannot exceed 60 characters. |
InvalidVpcCidr | VPC CIDR is invalid. Available values for VPC CIDR: 10.0.0.0/16, 172.16.0.0/16, 192.168.0.0/16, and their subnets. For more information, see the document about VPC IP ranges. |
VpcLimitExceeded | The limit of requested VPC resources for the specific region has been reached. To request more resources, contact customer service. For more information on VPC resource limits, see VPC Use Limits. |
InvalidVpc.NotFound | Invalid VPC. This error code indicates that the VPC does not exist. In this case, verify whether the resource information that you entered is correct. |
Input
https://vpc.api.qcloud.com/v2/index.php?Action=CreateVpc &<Common request parameters> &vpcName=bbbtest &cidrBlock=192.168.0.0/16 &subnetSet.0.subnetName=wikitest &subnetSet.0.cidrBlock=192.168.1.0/24 &subnetSet.0.zoneId=800001
Output
{
"code": 0,
"message": "",
"vpcId": "gz_vpc_266",
"uniqVpcId": "vpc-2ari9m7h",
"vpcCreateTime": "2015-11-06 11:33:52",
"subnetSet": [
{
"subnetId": "gz_subnet_18720",
"unSubnetId": "subnet-5gu2jxf4",
"routeTableId": "gz_rtb_8751",
"subnetName": "wikitest",
"cidrBlock": "192.168.1.0/24",
"zoneId": 800001
}
],
"routeTableSet": [
{
"routeTableId": "gz_rtb_8751",
"routeTableType": 1,
"routeTableName": "Default"
}
]
}
Was this page helpful?