# Querying Subnet Pools

#### Function

This API is used to query subnet pools. Pagination query is supported.

#### URI

GET /v2.0/subnetpools

Example:

    GET https://{Endpoint}/v2.0/subnetpools?fields=id&fields=name&fields=prefixes&fields=default_prefixlen&fields=address_scope_id&fields=is_default

Example of querying subnet pools by page

    GET https://{Endpoint}/v2.0/subnetpools?limit=2&marker=03f761e6-eee0-43fc-a921-8acf64c14988&page_reverse=False

#### Request Message

None

#### Response Message

Table 1 Response parameter
Parameter | Type | Description
--- | --- | ---
subnetpools | Array of subnetpool objects | Specifies the subnet pool list. For details, see Table 2.
subnetpools_links | Array of SecuritypoolsLink objects | Shows pagination information about subnet pools. The value of rel will be next and that of href will be a link only when limit is used for filtering and the number of resources exceeds the value of limit or 2000 (default value of limit).

Table 2 subnetpool objects
Attribute | Type | Description
--- | --- | ---
id | String | Specifies the subnet pool ID. This parameter is not mandatory when you query subnet pools.
name | String | Specifies the subnet pool name.
ip_version | Integer | Specifies the IP address version. Supported versions: IPv4 and IPv6
default_quota | Integer | Specifies the upper limit of the prefix space that can be allocated from the subnet pool to the subnet. For IPv4 subnet pools, default_quota is measured in units of /32. For IPv6 subnet pools, default_quota is measured in units of /64.
project_id | String | Specifies the project ID.
created_at | String | Specifies the time (UTC) when the subnet pool is created. Format: yyyy-MM-ddTHH:mm:ss
updated_at | String | Specifies the time (UTC) when the subnet pool rule is updated. Format: yyyy-MM-ddTHH:mm:ss
prefixes | Array of strings | Specifies a list of subnet prefixes that are assigned to the subnet pool. The adjacent prefixes are merged and treated as a single prefix. Each subnet prefix must be unique.
min_prefixlen | Integer | Specifies the minimum number for the prefix of a subnet that can be allocated from the subnet pool. The minimum number for the prefix of an IPv4 subnet is 8, and that of an IPv6 subnet is 64.
address_scope_id | String | Specifies the ID of the address range allocated to the subnet pool. Only the administrator can specify this attribute.
shared | Boolean | Specifies whether the network can be shared to all projects.
tenant_id | String | Specifies the project ID.
default_prefixlen | Integer | Specifies the default prefix to be allocated to a subnet if the cidr or prefixlen is not specified when you create the subnet. The default value is 8 for an IPv4 subnet and 64 for an IPv6 subnet.
max_prefixlen | Integer | Specifies the maximum number for the prefix of a subnet that can be allocated from the subnet pool. The maximum number for the prefix of an IPv4 subnet is 32, and that of an IPv6 subnet is 128.
description | String | Provides supplementary information about the subnet pool.
is_default | Boolean | Specifies whether this is the default subnet pool.
revision_number | Integer | Specifies the revision number of the subnet pool.
tags | Array of strings | Specifies the tags.

Table 3 SubnetpoolsLink objects
Parameter | Type | Description
--- | --- | ---
href | String | Specifies the API link.
rel | String | Specifies the relationship between the API link and the API version.

#### Example:

Example request

    GET https://{Endpoint}/v2.0/subnetpools

Example response

    {
        "subnetpools":
            {
                "min_prefixlen": 64,
                "address_scope_id": null,
                "default_prefixlen": 64,
                "id": "03f761e6-eee0-43fc-a921-8acf64c14988",
                "max_prefixlen": 64,
                "name": "my-subnet-pool-ipv6",
                "default_quota": null,
                "is_default": false,
                "project_id": "9fadcee8aa7c40cdb2114fff7d569c08",
                "tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",
                "prefixes": [
                    "2001:db8:0:2::/64",
                    "2001:db8::/63"
                ],
                "ip_version": 6,
                "shared": false,
                "description": "",
                "revision_number": 2,
                "created_at": "2018-09-20T02:15:34",
                "updated_at": "2018-09-20T02:15:34",
                "tags": []
            },
            {
                "min_prefixlen": 24,
                "address_scope_id": null,
                "default_prefixlen": 25,
                "id": "f49a1319-423a-4ee6-ba54-1d95a4f6cc68",
                "max_prefixlen": 30,
                "name": "my-subnet-pool-ipv4",
                "default_quota": null,
                "is_default": false,
                "project_id": "9fadcee8aa7c40cdb2114fff7d569c08",
                "tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",
                "prefixes": [
                    "10.10.0.0/21",
                    "192.168.0.0/16"
                ],
                "ip_version": 4,
                "shared": false,
                "description": "",
                "revision_number": 2,
                "created_at": "2018-09-20T02:15:34",
                "updated_at": "2018-09-20T02:15:34",
                "tags": []
            }
        ],
        "subnetpools_links": [
           {    "rel": "previous",
                "href": "https://{Endpoint}/v2.0/subnetpools?marker=03f761e6-eee0-43fc-a921-8acf64c14988&page_reverse=True"
            }
        ]
    }

#### Status Code

See Status Codes.

#### Error Code

See Error Codes.

Parent topic: Subnet Pool