查询子网列表
功能介绍
查询提交请求的租户的所有子网,
URI
GET /v2.0/subnets
样例:
GET https://{Endpoint}/v2.0/subnets?name={subnet_name}&ip_version={ip_version}&network_id={network_id}&cidr={subnet_cidr_address}&gateway_ip={subnet_gateway}&tenant_id={tenant_id}&enable_dhcp={is_enable_dhcp}
  分页查询样例:
GET https://{Endpoint}/v2.0/subnets?limit=2&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=False
 参数说明请参见表1。
| 
       名称  | 
     
       是否必选  | 
     
       参数类型  | 
     
       说明  | 
    
|---|---|---|---|
| 
       id  | 
     
       否  | 
     
       String  | 
     
       按照子网对应的ID过滤查询  | 
    
| 
       name  | 
     
       否  | 
     
       String  | 
     
       按照子网的名称过滤查询  | 
    
| 
       enable_dhcp  | 
     
       否  | 
     
       Boolean  | 
     
       按照子网是否开启dhcp过滤查询 取值范围:true or false  | 
    
| 
       cidr  | 
     
       否  | 
     
       String  | 
     
       按照子网的cidr过滤查询  | 
    
| 
       network_id  | 
     
       否  | 
     
       String  | 
     
       按照子网所属network_id过滤查询  | 
    
| 
       ip_version  | 
     
       否  | 
     
       String  | 
     
       按照子网的IP协议版本过滤查询  | 
    
| 
       gateway_ip  | 
     
       否  | 
     
       String  | 
     
       按照子网的网关IP过滤查询  | 
    
| 
       tenant_id  | 
     
       否  | 
     
       String  | 
     
       按照子网所属的项目ID过滤查询  | 
    
| 
       marker  | 
     
       否  | 
     
       String  | 
     
       分页查询的起始资源ID,表示从指定资源的下一条记录开始查询。 marker需要和limit配合使用: 
  | 
    
| 
       limit  | 
     
       否  | 
     
       Integer  | 
     
       分页查询每页返回的记录个数,取值范围为0~intmax(2^31-1),默认值2000。 limit需要和marker配合使用,详细规则请见marker的参数说明。  | 
    
请求参数
无。
请求示例
【示例一】
GET https://{Endpoint}/v2.0/subnets?limit=1
  【示例二】
GET https://{Endpoint}/v2.0/subnets?id=011fc878-5521-4654-a1ad-f5b0b5820322
 响应参数
| 
        参数名称  | 
      
        类型  | 
      
        说明  | 
     
|---|---|---|
| 
        subnets  | 
      
        Array of subnet objects  | 
      
        subnet对象列表,参见表3。  | 
     
| 
        subnets_links  | 
      
        Array of subnets_link objects  | 
      
        分页信息,参见表6 。 只有在使用limit过滤,并且资源个数超过limit或者资源个数超过2000时(limit默认值),该参数的rel和href取值才会显示为next和其对应的link。  | 
     
| 
        属性  | 
      
        类型  | 
      
        说明  | 
     
|---|---|---|
| 
        id  | 
      
        String  | 
      
        子网的id 【使用说明】在查询子网列表时非必选  | 
     
| 
        name  | 
      
        String  | 
      
        子网的名称  | 
     
| 
        ip_version  | 
      
        Integer  | 
      
        IP版本 【使用说明】支持4(IPv4)、6(IPv6)  | 
     
| 
        network_id  | 
      
        String  | 
      
        所属网络的id  | 
     
| 
        cidr  | 
      
        String  | 
      
        CIDR格式 【使用说明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三个网段内的地址,掩码长度不能大于28。  | 
     
| 
        gateway_ip  | 
      
        String  | 
      
        网关IP不允许和allocation_pools地址块冲突。 【使用说明】不支持修改。  | 
     
| 
        allocation_pools  | 
      
        Array of allocation_pool objects  | 
      
        可用的IP池,allocation_pool对象参见表3 allocation_pool对象 例如:[ { "start": "10.0.0.2", "end": "10.0.0.251"} ] 每个子网的第1个和最后3个IP地址为系统保留地址。以192.168.1.0/24为例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255这些地址是系统保留地址。 系统预留地址默认不在allocation_pool范围内。 约束:更新时allocation_pool范围不能包含网关和广播地址的所有IP。  | 
     
| 
        dns_nameservers  | 
      
        Array of strings  | 
      
        dns服务器 例如:"dns_nameservers": ["8.xx.xx.8","8.xx.xx.4"]  | 
     
| 
        host_routes  | 
      
        Array of host_route objects  | 
      
        虚拟机静态路由,参见表5 【使用说明】不支持,忽略输入信息  | 
     
| 
        tenant_id  | 
      
        String  | 
      
        项目ID  | 
     
| 
        enable_dhcp  | 
      
        Boolean  | 
      
        是否启动dhcp,false表示不提供dhcp服务的能力 【使用说明】只支持true  | 
     
| 
        project_id  | 
      
        String  | 
      
        项目ID,请参见获取项目ID。  | 
     
| 
        created_at  | 
      
        String  | 
      
        资源创建时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss  | 
     
| 
        updated_at  | 
      
        String  | 
      
        资源更新时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss  | 
     
响应示例
【示例一】
{
    "subnets": [
        {
            "name": "kesmdemeet",
            "cidr": "172.16.236.0/24",
            "id": "011fc878-5521-4654-a1ad-f5b0b5820302",
            "enable_dhcp": true,
            "network_id": "48efad0c-079d-4cc8-ace0-dce35d584124",
            "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "dns_nameservers": [],
            "allocation_pools": [
                {
                    "start": "172.16.236.2",
                    "end": "172.16.236.251"
                }
            ],
            "host_routes": [],
            "ip_version": 4,
            "gateway_ip": "172.16.236.1",
            "created_at": "2018-03-26T08:23:43",
            "updated_at": "2018-03-26T08:23:44"
        }
    ],
    "subnets_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=True"
        }
    ]
}
 {
    "subnets": [
        {
	    "id": "011fc878-5521-4654-a1ad-f5b0b5820322",
	    "name": "elb_alpha_vpc0_subnet0_172_16_0_0_24",
	    "tenant_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "network_id": "3053b502-11b2-4599-bcf4-d9d06b6118b2",
            "ip_version": 6,
	    "cidr": "2001:db8:a583:a0::/64",
            "subnetpool_id": "cb03d100-8687-4c0a-9441-ea568dcae47d",
	    "allocation_pools": [{
	        "start": "2001:db8:a583:a0::2",
		"end": "2001:db8:a583:a0:ffff:ffff:ffff:fffc"
	    }],
	    "gateway_ip": "2001:db8:a583:a0::1",
	    "enable_dhcp": true,
	    "ipv6_ra_mode": "dhcpv6-stateful",
	    "ipv6_address_mode": "dhcpv6-stateful",
	    "description": "",
	    "dns_nameservers": [],
	    "host_routes": [],
	    "project_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "created_at": "2021-07-01T07:59:28",
	    "updated_at": "2021-07-01T07:59:28"
        }
    ],
    "subnets_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&id=011fc878-5521-4654-a1ad-f5b0b5820322&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=True"
        }
    ]
}
 状态码
请参见状态码。
错误码
请参见错误码。