
# 分页查询
#### 功能介绍
Neutron API v2.0提供分页查询功能，通过在list请求的url中添加limit和marker参数实现分页返回列表信息。分页显示的结果以显示对象的id升序排序。
- 若需要访问请求的下一页，需要进行以下两项配置：
  - 在原有访问请求url中将"marker"属性值进行替换。将"marker"取值替换为：在响应消息中"rel"值为"next"时，"href"参数取值中包括的"marker"取值。
  
  - 设置"page_reverse"值为"False"。
   
- 若需要访问请求的上一页，需要进行以下两项配置：
  - 在原有访问请求的url中将"marker"属性值进行替换。将"marker"取值替换为：在响应消息中"rel"值为"previous"时，"href"参数中包括的"marker"取值。
  
  - 设置"page_reverse"值为"True"。
   
 
#### 请求参数
表1请求参数 
| 参数名称         | 类型      | 必选 | 说明                                                    |
|:---|:---|:---|:---|
| limit        | Integer | 否  | 每页显示的条目数量。                                            |
| marker       | String  | 否  | 取值为上一页数据的最后一条记录的id，当marker参数为无效id时，response将响应错误码400。 |
| page_reverse | Boolean | 否  | False/True，是否设置分页的顺序。                                 |
   
#### 请求示例
- page_reverse为False
```
GET https://{Endpoint}/v2.0/networks?limit=2&marker=3d42a0d4-a980-4613-ae76-a2cddecff054&page_reverse=False
```
- page_reverse为True
```
GET https://{Endpoint}/v2.0/vpc/peerings?limit=2&marker=e5a0c88e-228e-4e62-a8b0-90825b1b7958&page_reverse=True
```
#### 响应参数
表2响应参数 
| 参数名称              | 类型                                                                                           | 说明                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|
| {resources}_links | Array of [{resources}_link] objects | 分页信息，参见[表 {resources}_link对象]，{resources}为资源名，包括ports、networks、subnets、routers、firewall_rules、firewall_policies、firewall_groups、security_groups、security_group_rules。 只有在使用limit过滤，并且资源个数超过limit或者资源个数超过2000时（limit默认值），该参数的rel和href取值才会显示为next和其对应的link。 |
   
 表3{resources}_link对象 
| 名称   | 参数类型   | 说明                                                      |
|:---|:---|:---|
| href | String | API链接                                                   |
| rel  | String | API链接用于查询下一页或上一页。此参数的值为next，表示查询下一页；值为previous，表示查询上一页。 |
   
#### 响应示例
- page_reverse为False
```
{
    "networks": [
        {
            "status": "ACTIVE",
            "subnets": [],
            "name": "liudongtest",
            "admin_state_up": false,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "id": "60c809cb-6731-45d0-ace8-3bf5626421a9"
        },
        {
            "status": "ACTIVE",
            "subnets": [
                "132dc12d-c02a-4c90-9cd5-c31669aace04"
            ],
            "name": "publicnet",
            "admin_state_up": true,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "id": "9daeac7c-a98f-430f-8e38-67f9c044e299"
        }
    ],
    "networks_links": [
        {
            "href": "http://192.168.82.231:9696/v2.0/networks?limit=2&marker=9daeac7c-a98f-430f-8e38-67f9c044e299",
            "rel": "next"
        },
        {
            "href": "http://192.168.82.231:9696/v2.0/networks?limit=2&marker=60c809cb-6731-45d0-ace8-3bf5626421a9&page_reverse=True",
            "rel": "previous"
        }
    ]
}
```
- page_reverse为True
```
{
    "peerings_links": [
        {
            "marker": "dd442819-5638-401c-bd48-a82703cf0464",
            "rel": "next"
        },
        {
            "marker": "1e13cbaf-3ce4-413d-941f-66d855dbfa7f",
            "rel": "previous"
        }
    ],
    "peerings": [
        {
            "status": "ACTIVE",
            "accept_vpc_info": {
                "vpc_id": "83a48834-b9bc-4f70-aa46-074568594650",
                "tenant_id": "e41a43bf06e249678413c6d61536eff9"
            },
            "request_vpc_info": {
                "vpc_id": "db8e7687-e43b-4fc1-94cf-16f69f484d6d",
                "tenant_id": "e41a43bf06e249678413c6d61536eff9"
            },
            "name": "peering1",
            "id": "1e13cbaf-3ce4-413d-941f-66d855dbfa7f"
        },
        {
            "status": "ACTIVE",
            "accept_vpc_info": {
                "vpc_id": "83a48834-b9bc-4f70-aa46-074568594650",
                "tenant_id": "e41a43bf06e249678413c6d61536eff9"
            },
            "request_vpc_info": {
                "vpc_id": "bd63cc9e-e7b8-4d4e-a0e9-055031470ffc",
                "tenant_id": "e41a43bf06e249678413c6d61536eff9"
            },
            "name": "peering2",
            "id": "dd442819-5638-401c-bd48-a82703cf0464"
        }
    ]
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
