tencent cloud

Feedback

DescribeSubnets

Last updated: 2023-08-18 14:27:57

1. API Description

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

This API is used to query the list of subnets.

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: DescribeSubnets.
Version Yes String Common Params. The value used for this API: 2019-07-19.
Region No String Common Params. This parameter is not required for this API.
SubnetIds.N No Array of String Subnet instance ID, such as subnet-pxir56ns. Each request supports a maximum of 100 instances. SubnetIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filter. SubnetIds and Filters cannot be specified at the same time.
subnet-id - String - Subnet instance name.
subnet-name - String - Subnet name. Only fuzzy query by a single value is supported.
cidr-block - String - Subnet IP address range, such as 192.168.1.0. Only fuzzy query by a single value is supported.
vpc-id - String - VPC instance ID, such as vpc-f49l6u0z.
vpc-cidr-block - String - VPC IP address range, such as 192.168.1.0. Only fuzzy query by a single value is supported.
region - String - ECM region.
zone - String - AZ.
tag-key - String - Required: no - Filter by tag key.
tag:tag-key - String - Required: no - Filter by tag key-value pair.
Offset No String Offset
Limit No String Number of returned results.
EcmRegion No String ECM region
Sort No String Sorting method. time: sort in reverse chronological order; default: sort by network planning.

3. Output Parameters

Parameter Name Type Description
TotalCount Integer Number of eligible instances.
SubnetSet Array of Subnet Subnet object.
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 Querying subnet list

Input Example

https://ecm.tencentcloudapi.com/?Action=DescribeSubnets
&Filters.0.Name=subnet-id
&Filters.0.Values.0=subnet-ae71tjp6
&EcmRegion=ap-hangzhou-ecm
&<Common request parameters>

Output Example

{
    "Response": {
        "SubnetSet": [
            {
                "NetworkAclId": "",
                "RouteTableId": "rtb-cahjl2qq",
                "VpcId": "vpc-hqhu0suj",
                "EnableBroadcast": false,
                "Zone": "ap-hangzhou-ecm-1",
                "Ipv6CidrBlock": "",
                "Region": "ap-hangzhou-ecm",
                "SubnetName": "subnet_test",
                "AvailableIpAddressCount": 253,
                "IsRemoteVpcSnat": false,
                "SubnetId": "subnet-ae71tjp6",
                "InstanceCount": 0,
                "VpcCidrBlock": "192.168.0.0/18",
                "TagSet": [
                    {
                        "Value": "hangzhou",
                        "Key": "city"
                    }
                ],
                "CreatedTime": "2020-08-14 11:38:33",
                "ZoneName": "Hangzhou Zone 1",
                "CidrBlock": "192.168.1.0/24",
                "IsDefault": false,
                "VpcIpv6CidrBlock": ""
            }
        ],
        "TotalCount": 1,
        "RequestId": "6e863039-2a22-4a98-8577-93823b250674"
    }
}

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
FailedOperation.InternalOperationFailure Internal error.
InvalidParameter.Coexist The parameters cannot be specified at the same time.
InvalidParameter.InvalidDataFormat The data format is incorrect.
InvalidParameterValue The parameter value is incorrect.
InvalidParameterValue.FilterLimitExceeded The value of the Filter parameter exceeds the limit.
InvalidParameterValue.InvalidFilter The filter is invalid.
InvalidParameterValue.InvalidRegion The ECM region is invalid.
InvalidParameterValue.LimitExceeded The parameter value exceeds the limit.
InvalidParameterValue.Malformed The input parameter format is invalid.
InvalidParameterValue.Range The parameter value is not in the specified range.
ResourceNotFound The resource does not exist.
UnauthorizedOperation.ForbiddenOperation You don't have the permission to perform this operation.