
# 查询路由器列表
#### 功能介绍
查询提交请求的租户有权限操作的所有路由器信息，单次查询最多返回2000条数据，超过2000后会返回分页标记。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=VPC&version=v2&api=NeutronListRouters)中调试该接口。
#### URI
GET /v2.0/routers
样例：
```
GET https://{Endpoint}/v2.0/routers?id={id}&name={name}&admin_state_up={admin_state_up}&tenant_id={tenant_id}&status={status}
```
分页查询样例：
```
GET https://{Endpoint}/v2.0/routers?limit=2&marker=01ab4be1-4447-45fb-94be-3ee787ed4ebe&page_reverse=False
```
参数说明请参见[表1]。
 表1参数说明 
| 名称             | 是否必选 | 参数类型    | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| id             | 否    | String  | 按照路由器的ID过滤查询                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| admin_state_up | 否    | Boolean | 按照路由器的管理状态过滤查询 取值范围：true or false                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| status         | 否    | String  | 按照路由器的状态过滤查询 取值范围：ACTIVE， DOWN，ERROR                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| tenant_id      | 否    | String  | 按照路由器所属的项目ID过滤查询                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| marker         | 否    | String  | 分页查询的起始资源ID，表示从指定资源的下一条记录开始查询。 marker需要和limit配合使用： - 若不传入marker和limit参数，查询结果返回第一页全部资源记录。  - 若不传入marker参数，limit为10，查询结果返回第1\~10条资源记录。  - 若marker为第10条记录的资源ID，limit为10，查询结果返回第11\~20条资源记录。  - 若marker为第10条记录的资源ID，不传入limit参数，查询结果返回第11\~2000条（limit默认值2000）资源记录。   |
| limit          | 否    | Integer | 分页查询每页返回的记录个数，取值范围为0\~2000，默认值2000。 limit需要和marker配合使用，详细规则请见marker的参数说明。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
   
#### 请求参数
无。
#### 请求示例
```
GET https://{Endpoint}/v2.0/routers?limit=1
```
#### 响应参数
表2响应参数 
| 参数名称          | 类型                                                                                    | 说明                                                                                                                                                                                                          |
|:---|:---|:---|
| routers       | Array of [router] objects    | router对象列表，参见[表3]。                                                                                                                                 |
| routers_links | Array of [routers_link] objects | 分页信息，参见[表6]。 只有在使用limit过滤，并且资源个数超过limit或者资源个数超过2000时（limit默认值），该参数的rel和href取值才会显示为next和其对应的link。 |
   
 表3router对象 
| 参数名称                  | 类型                                                                                      | 说明                                                                                        |
|:---|:---|:---|
| id                    | String                                                                                  | 路由器的id 【使用说明】在查询路由器列表时非必选            |
| name                  | String                                                                                  | 路由器的名称。 仅支持数字、字母、_(下划线)、-（中划线）、.（点）。 |
| admin_state_up        | Boolean                                                                                 | 管理状态。 只支持true。                       |
| status                | String                                                                                  | 状态，可以为ACTIVE， DOWN，ERROR。                                                                 |
| tenant_id             | String                                                                                  | 项目ID                                                                                      |
| external_gateway_info | [external_gateway_info] object | 扩展属性：外部网关信息，参见external_gateway_info对象                                                     |
| routes                | Array of [route] objects       | 扩展属性：路由信息列表，参见[routes对象]         |
| project_id            | String                                                                                  | 项目ID，请参见[获取项目ID](https://support.huaweicloud.com/api-vpc/vpc_api_0011.html)。              |
| created_at            | String                                                                                  | 资源创建时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss   |
| updated_at            | String                                                                                  | 资源更新时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss   |
   
 表4external_gateway_info对象 
| 参数名称        | 类型      | 说明                                                                                                                                               |
|:---|:---|:---|
| network_id  | String  | 外部网络的UUID。 外部网络的信息请通过GET /v2.0/networks?router:external=True或neutron net-external-list方式查询。 |
| enable_snat | Boolean | 是否启用SNAT。 默认为false。                                                                         |
   
 表5route对象 
| 参数名称        | 类型     | 说明                                     |
|:---|:---|:---|
| destination | String | IP地址段                                  |
| nexthop     | String | 下一跳IP地址，nexthop仅支持是router所关联的子网范围内IP地址 |
   
 表6routers_link对象 
| 名称   | 参数类型   | 说明              |
|:---|:---|:---|
| href | String | API链接           |
| rel  | String | API链接与该API版本的关系 |
   
#### 响应示例
```
{
    "routers": [
        {
            "id": "01ab4be1-4447-45fb-94be-3ee787ed4ebe",
            "name": "xiaoleizi-tag",
            "status": "ACTIVE",
            "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "admin_state_up": true,
            "external_gateway_info": {
                "network_id": "0a2228f2-7f8a-45f1-8e09-9039e1d09975",
                "enable_snat": false
            },
            "routes": [
                {
                    "destination": "0.0.0.0/0",
                    "nexthop": "172.16.0.124"
                }
            ],
            "created_at": "2018-03-23T09:26:08",
            "updated_at": "2018-08-24T08:49:53"
        }
    ],
    "routers_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/routers?limit=1&marker=01ab4be1-4447-45fb-94be-3ee787ed4ebe"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/routers?limit=1&marker=01ab4be1-4447-45fb-94be-3ee787ed4ebe&page_reverse=True"
        }
    ]
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
