创建路由规则
更新时间:2022-12-06
接口描述
本接口用于创建指定路由表的路由规则。
请求结构
Plain Text
1 POST /v1/route/rule HTTP/1.1
2 Host: bec.baidubce.com
3 Authorization: authorization string
4 {
5 "tableId": "tableId",
6 "ipVersion": 4,
7 "sourceAddress": "192.168.0.0/16",
8 "destinationAddress": "192.168.1.0/16",
9 "nexthop": "vmId",
10 "routeType": "CUSTOM",
11 "description": "default"
12 }
注意事项
创建路由规则,有以下几点需要注意:
- 目标网段不能为0.0.0.0/0;
- 新增路由条目的源网段和目标网段,不能与路由表中已有条目源网段和目标网段完全一致。
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
---|---|---|---|---|
tableId | String | 是 | Request Body参数 | 路由表ID |
ipVersion | Integer | 是 | Request Body参数 | 网段类型 |
sourceAddress | String | 是 | Request Body参数 | 源网段 |
destinationAddress | String | 是 | Request Body参数 | 目标网段,不能为0.0.0.0/0 |
nexthop | String | 是 | Request Body参数 | 下一跳ID |
routeType | String | 是 | Request Body参数 | 路由类型CUSTOM, SYSTEM, HAVIP |
description | String | 否 | Request Body参数 | 描述,不超过200字符 |
返回头域
除公共头域,无其它特殊头域。
返回参数
参数名称 | 类型 | 描述 |
---|---|---|
result | boolean | 操作是否成功。true:表示成功;false:表示失败 |
action | String | 删除操作,对应“createRouteRule” |
details | RouteRuleVo | 路由规则信息 |
请求示例
Plain Text
1 POST /v1/route/rule HTTP/1.1
2 Host: bec.baidubce.com
3 Authorization: authorization string
4 {
5 "tableId": "rtb-bkqgpmrl",
6 "ipVersion": 4,
7 "sourceAddress": "192.168.0.0/16",
8 "destinationAddress": "172.16.3.0/24",
9 "nexthop": "vm-0hlzfjgh-1-m-hangzhou-hh97p",
10 "routeType": "CUSTOM",
11 "description": "default"
12 }
13
返回示例
Plain Text
1 HTTP/1.1 200 OK
2 x-bce-request-id: 1214cca7 4ad5 451d 9215 71cb844c0a50
3 Date: Thu, 16 Mar 2021 06:29:48 GMT
4 Content Type: application/json;charset=UTF 8
5 Server: BWS
6 {
7 "result": true,
8 "action": "createRouteRule",
9 "details": {
10 "ruleId": "rtr-jqxvabpy",
11 "tableId": "rtb-bkqgpmrl",
12 "ipVersion": 4,
13 "sourceAddress": "192.168.0.0/16",
14 "destinationAddress": "172.16.3.0/24",
15 "routeType": "CUSTOM",
16 "nexthop": "vm-0hlzfjgh-1-m-hangzhou-hh97p",
17 "description": "default"
18 }
19}
20
Model对象定义
RouteRuleVo
参数名称 | 类型 | 描述 |
---|---|---|
ruleId | String | 路由规则ID |
status | String | 路由规则状态(creating、ready、deleting、timeout) |
tableId | String | 路由表ID |
ipVersion | Integer | 网段类型 |
sourceAddress | String | 源网段 |
destinationAddress | String | 目标网段 |
routeType | RouteType | 路由类型(CUSTOM、SYSTEM、HAVIP) |
nexthop | String | 下一跳ID |
description | String | 描述 |