DescribeSubnets

Last updated: 2020-03-06 20:26:24

PDF

1. API Description

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

This API (DescribeSubnets) is used to query the list of subnets.

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

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: vpc.ap-shanghai-fsi.tencentcloudapi.com

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 parameter. The value used for this API: DescribeSubnets.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
SubnetIds.N No Array of String Queries the ID of the subnet instance, such as subnet-pxir56ns. Each request can have a maximum of 100 instances. SubnetIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filter condition. SubnetIds and Filters cannot be specified at the same time.
  • subnet-id - String - (Filter condition) Subnet instance name.
  • vpc-id - String - (Filter condition) VPC instance ID, such as vpc-f49l6u0z.
  • cidr-block - String - (Filter condition) The subnet IP range, such as 192.168.1.0.
  • is-default - Boolean - (Filter condition) Whether it is the default subnet.
  • is-remote-vpc-snat - Boolean - (Filter condition) Whether it is a VPC SNAT address pool subnet.
  • subnet-name - String - (Filter condition) Subnet name.
  • zone - String - (Filter condition) Availability zone.
  • tag-key - String - Required: No - (Filter condition) Filter by tag key.
  • tag:tag-key - String - Required: No - (Filter condition) Filter by tag key-value pair. The tag-key is replaced with the specific tag key. For usage, refer to case 2.
  • Offset No String Offset
    Limit No String The returned quantity

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer The number of instances meeting the filter condition.
    SubnetSet Array of Subnet Subnet object.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Query the subnet list

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSubnets
    &Version=2017-03-12
    &Filters.0.Name=subnet-name
    &Filters.0.Values.0=Guangzhou zone 2 subnet by default
    &Filters.1.Name=vpc-id
    &Filters.1.Values.0=vpc-2at5y1pn
    &Filters.2.Name=subnet-id
    &Filters.2.Values.0=subnet-otu92seu
    &Filters.3.Name=cidr-block
    &Filters.3.Values.0=172.16.16.0
    &Filters.4.Name=is-default
    &Filters.4.Values.0=true
    &<common request parameters>

    Output Example

    {
      "Response": {
        "SubnetSet": [
          {
            "VpcId": "vpc-2at5y1pn",
            "SubnetId": "subnet-otu92seu",
            "SubnetName": "Guangzhou zone 2 subnet by default",
            "CidrBlock": "172.16.16.0/20",
            "Ipv6CidrBlock": "3402:4e00:20:1201::/64",
            "IsDefault": true,
            "IsRemoteVpcSnat": false,
            "EnableBroadcast": false,
            "Zone": "ap-guangzhou-dev-2",
            "RouteTableId": "rtb-l2h8d7c2",
            "TotalIpAddressCount": 4093,
            "AvailableIpAddressCount": 4002,
            "CreatedTime": "2017-04-20 11:30:48"
          }
        ],
        "TotalCount": 1,
        "RequestId": "20569756-56ba-4a13-b545-e1528d5cb239"
      }
    }

    Example2 Query the subnet list with tags

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSubnets
    &Version=2017-03-12
    &Filters.0.Name=tag:city
    &Filters.0.Values.0=shanghai
    &<common request parameters>

    Output Example

    {
      "Response": {
        "SubnetSet": [
          {
            "VpcId": "vpc-2at5y1pn",
            "SubnetId": "subnet-otu92seu",
            "SubnetName": "Guangzhou zone 2 subnet by default",
            "CidrBlock": "172.16.16.0/20",
            "Ipv6CidrBlock": "3402:4e00:20:1201::/64",
            "IsDefault": true,
            "IsRemoteVpcSnat": false,
            "EnableBroadcast": false,
            "Zone": "ap-guangzhou-dev-2",
            "RouteTableId": "rtb-l2h8d7c2",
            "TotalIpAddressCount": 4093,
            "AvailableIpAddressCount": 4002,
            "TagSet": [
              {
                "Key": "city",
                "Value": "shanghai"
              }
            ],
            "CreatedTime": "2017-04-20 11:30:48"
          }
        ],
        "TotalCount": 1,
        "RequestId": "20569756-56ba-4a13-b545-e1528d5cb239"
      }
    }

    5. Developer Resources

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

    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.Coexist The parameters cannot be specified at the same time.
    InvalidParameterValue.Malformed Invalid input parameter format.
    ResourceNotFound The resource does not exist.