Routers API reference
See https://docs.openstack.org/api-ref/network/.
In these methods, {router_id} is the ID of the router, "router_name" is the name of the router, "external_network_id" is the ID of the external network to be used as the router's gateway, "subnet_id" is the ID of the subnet to be added as an interface to the router, and "port_id" is the ID of the port to be added as an interface to the router. These methods allow you to list existing routers, show details of a specific router, create a new router, update an existing router, delete a router, add or remove interfaces to or from a router, and set or clear the external gateway for a router in the Network service.
List routers#
GET /v2.0/routersReturns 200 OK. The response wraps the list under a routers key.
Show router details#
GET /v2.0/routers/{router_id}Returns 200 OK. The response wraps the router under a router key.
Create a router#
POST /v2.0/routersRequest body
{
"router": {
"name": "router_name",
"admin_state_up": true,
"external_gateway_info": {
"network_id": "external_network_id"
}
}
}Returns 201 Created. The response wraps the new router under a router key.
Update a router#
PUT /v2.0/routers/{router_id}Request body
{
"router": {
"name": "new_router_name",
"admin_state_up": false
}
}Returns 200 OK. The response wraps the updated router under a router key.
Delete a router#
DELETE /v2.0/routers/{router_id}Returns 204 No Content with an empty body.
Add interface to router#
PUT /v2.0/routers/{router_id}/add_router_interfaceRequest body (using a subnet ID)
{
"subnet_id": "subnet_id"
}Request body (using a port ID)
{
"port_id": "port_id"
}Returns 200 OK. The response body is flat: the service does not wrap it under a router key. When you pass port_id, the service resolves subnet_id from that port.
{
"id": "ROUTER_ID",
"tenant_id": "PROJECT_ID",
"port_id": "PORT_ID",
"network_id": "NETWORK_ID",
"subnet_id": "SUBNET_ID",
"subnet_ids": ["SUBNET_ID"]
}Remove interface from router#
PUT /v2.0/routers/{router_id}/remove_router_interfaceRequest body (using a subnet ID)
{
"subnet_id": "subnet_id"
}Request body (using a port ID)
{
"port_id": "port_id"
}Returns 200 OK. The response body is flat, matching the shape that add_router_interface returns.
{
"id": "ROUTER_ID",
"tenant_id": "PROJECT_ID",
"port_id": "PORT_ID",
"network_id": "NETWORK_ID",
"subnet_id": "SUBNET_ID",
"subnet_ids": ["SUBNET_ID"]
}External gateway for router#
PUT /v2.0/routers/{router_id}Request body
{
"router": {
"external_gateway_info": {
"network_id": "external_network_id"
}
}
}Returns 200 OK. The response wraps the router under a router key.
Clear external gateway from router#
PUT /v2.0/routers/{router_id}Request body
{
"router": {
"external_gateway_info": null
}
}Returns 200 OK. The response wraps the router under a router key.