
# 更新路由器
#### 功能介绍
更新路由器。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=VPC&version=v2&api=NeutronUpdateRouter)中调试该接口。
#### URI
PUT /v2.0/routers/{router_id}
#### 请求参数
表1请求参数 
| 参数名称   | 是否必选 | 类型                                                                        | 说明                                                                                                                                            |
|:---|:---|:---|:---|
| router | 是    | [router] object | router对象，参见[表2]。 更新操作时至少指定一项属性 |
   
 表2router对象 
| 参数名称                  | 是否必选 | 类型                                                                                    | 说明                                                                                                                                                          |
|:---|:---|:---|:---|
| name                  | 否    | String                                                                                | 路由器的名称。 【使用说明】 1-64个字符，仅支持数字、字母、_(下划线)、-（中划线）、.（点）。 |
| admin_state_up        | 否    | Boolean                                                                               | 管理状态。 【取值范围】 只支持true。                               |
| external_gateway_info | 否    | [external_gateway_info] object | 扩展属性：外部网关信息，参见external_gateway_info对象                                                                                                                       |
| routes                | 否    | Array of [route] objects      | 扩展属性：路由信息列表，参见[routes对象]                                                                            |
   
 表3external_gateway_info对象 
| 参数名称       | 是否必选 | 类型     | 说明                                                                                                                                               |
|:---|:---|:---|:---|
| network_id | 否    | String | 外部网络的UUID。 外部网络的信息请通过GET /v2.0/networks?router:external=True或neutron net-external-list方式查询。 |
   
 表4route对象 
| 参数名称        | 是否必选 | 类型     | 说明                                                                                                                               |
|:---|:---|:---|:---|
| destination | 否    | String | IP地址段 【使用说明】 前缀不能和直连路由重复 |
| nexthop     | 否    | String | 下一跳IP地址，nexthop仅支持是router所关联的子网范围内IP地址                                                                                           |
   
#### 请求示例
更新id为f5dbdfe0-86f9-4b0a-9a32-6be143f0a076的路由器，名称更新为router-220。
```
PUT https://{Endpoint}/v2.0/routers/f5dbdfe0-86f9-4b0a-9a32-6be143f0a076
{
    "router": {
           "name": "router-220"
    }
}
```
#### 响应参数
表5响应参数 
| 参数名称   | 类型                                                                       | 说明                                                                        |
|:---|:---|:---|
| router | [router] object | router对象，参见[表6]。 |
   
 表6router对象 
| 参数名称                  | 类型                                                                                      | 说明                                                                                        |
|:---|:---|:---|
| 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   |
   
 表7external_gateway_info对象 
| 参数名称        | 类型      | 说明                                                                                                                                               |
|:---|:---|:---|
| network_id  | String  | 外部网络的UUID。 外部网络的信息请通过GET /v2.0/networks?router:external=True或neutron net-external-list方式查询。 |
| enable_snat | Boolean | 是否启用SNAT。 默认为false。                                                                         |
   
 表8route对象 
| 参数名称        | 类型     | 说明                                     |
|:---|:---|:---|
| destination | String | IP地址段                                  |
| nexthop     | String | 下一跳IP地址，nexthop仅支持是router所关联的子网范围内IP地址 |
   
#### 响应示例
```
{
    "router": {
        "id": "f5dbdfe0-86f9-4b0a-9a32-6be143f0a076",
        "name": "router-220",
        "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": [],
        "created_at": "2018-09-20T02:06:07",
        "updated_at": "2018-09-20T02:06:09"
    }
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
