title | expires_at | tags | ||
---|---|---|---|---|
Routing API Documentation |
never |
|
- Routing API Documentation
- Authorization Token
- Create Router Groups
- Delete Router Groups
- List Router Groups
- Update Router Group
- List TCP Routes
- Create TCP Routes
- Delete TCP Routes
- Subscribe to Events for TCP Routes
- List HTTP Routes (Experimental)
- Create HTTP Routes (Experimental)
- Delete HTTP Routes (Experimental)
- Subscribe to Events for HTTP Routes (Experimental)
Reference documentation for client authors using the Routing API manually.
To obtain an token from UAA, use the uaac
CLI for UAA.
-
Install the
uaac
CLI:gem install cf-uaac
-
Set the UAA target:
uaac target uaa.example.com
-
Retrieve the OAuth token using credentials for registered OAuth client:
uaac token client get routing_api_client
-
Display the
access_token
, which can be used as the Authorization header tocurl
the Routing API:uaac context
POST /routing/v1/router_groups
A bearer token for an OAuth client with routing.router_groups.write
scope is
required.
A JSON-encoded object for the modified router group. The name
and type
fields must be included, and reservable_ports
must be included if type
is
tcp.
Object Field | Type | Required? | Description |
---|---|---|---|
name |
string | yes | Name of the router group. |
type |
string | yes | Type of the router group e.g. http or tcp . |
reservable_ports |
string | yes | Comma delimited list of reservable port or port ranges. These ports must fall between 1024 and 65535 (inclusive). |
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/router_groups -X POST -d '{"name": "my-router-group", "type": "http"}'
Expected Status 201 Created
A JSON-encoded object for the updated Router Group
.
Object Field | Type | Description |
---|---|---|
guid |
string | GUID of the router group. |
name |
string | External facing port for the TCP route. |
type |
string | Type of the router group e.g. tcp . |
reservable_ports |
string | Comma delimited list of reservable port or port ranges. (For type of TCP ) |
{
"guid": "568c0232-e7c0-47ff-4c8a-bc89b49ade5b",
"name": "my-router-group",
"type": "http"
"reservable_ports": ""
}
DELETE /routing/v1/router_groups/:guid
A bearer token for an OAuth client with routing.router_groups.write
scope is required.
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/router_groups/:guid -X DELETE'
Expected Status 204 No Content
GET /routing/v1/router_groups
A bearer token for an OAuth client with routing.router_groups.read
scope is required.
Parameter | Type | Description |
---|---|---|
name |
string | Name of the router group |
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/router_groups?name=default-tcp
Expected Status 200 OK
A JSON-encoded array of Router Group
objects.
Object Field | Type | Description |
---|---|---|
guid |
string | GUID of the router group. |
name |
string | External facing port for the TCP route. |
type |
string | Type of the router group e.g. tcp . |
reservable_ports |
string | Comma delimited list of reservable port or port ranges. |
[{
"guid": "abc123",
"name": "default-tcp",
"reservable_ports":"1024-65535",
"type": "tcp"
}]
To update a Router Group's reservable_ports
field with a new port range.
PUT /routing/v1/router_groups/:guid
:guid
is the GUID of the router group to be updated.
A bearer token for an OAuth client with routing.router_groups.write
scope is required.
A JSON-encoded object for the modified router group. Only the reservable_ports
field may be updated.
Object Field | Type | Required? | Description |
---|---|---|---|
reservable_ports |
string | yes | Comma delimited list of reservable port or port ranges. These ports must fall between 1024 and 65535 (inclusive). |
Warning: If routes are registered for ports that are not in the new range, modifying your load balancer to remove these ports will result in backends for those routes becoming inaccessible.
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/router_groups/abc123 -X PUT -d '{"reservable_ports":"9000-10000"}'
Expected Status 200 OK
A JSON-encoded object for the updated Router Group
.
Object Field | Type | Description |
---|---|---|
guid |
string | GUID of the router group. |
name |
string | External facing port for the TCP route. |
type |
string | Type of the router group e.g. tcp . |
reservable_ports |
string | Comma delimited list of reservable port or port ranges. |
{
"guid": "abc123",
"name": "default-tcp",
"reservable_ports":"9000-10000",
"type": "tcp"
}
GET /routing/v1/tcp_routes
A bearer token for an OAuth client with routing.routes.read
scope is required.
Parameter | Type | Description |
---|---|---|
isolation_segment |
string | Name of the isolation segment. If this parameter is included but a value is not given, then tcp routes registered without a specified isolation segment will be returned. |
# returns all tcp routes
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/tcp_routes
# filter for routes from multiple isolation segments
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/tcp_routes?isolation_segment=is1&isolation_segment=is2
# filter for routes without a specified isolation segment
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/tcp_routes?isolation_segment=
# filter for routes from multiple isolation segments and from the unspecified isolation segment
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/tcp_routes?isolation_segment=&isolation_segment=is1&isolation_segment=is2
Expected Status 200 OK
A JSON-encoded array of TCP Route
objects.
Object Field | Type | Description |
---|---|---|
router_group_guid |
string | GUID of the router group associated with this route. |
backend_port |
integer | Backend port. Must be greater than 0. |
backend_ip |
string | IP address of backend. |
backend_tls_port |
integer | Backend TLS port. If 0, backend TLS is disabled. If nil, backend TLS is not something the client knows about. |
instance_id |
string | Instance ID of the backend, used for TLS validation when backend TLS is enabled. |
port |
integer | External facing port for the TCP route. |
modification_tag |
object | See Modification Tags. |
ttl |
integer | Time to live, in seconds. The mapping of backend to route will be pruned after this time. |
isolation_segment |
string | Isolation segment for the route. |
[{
"router_group_guid": "xyz789",
"backend_ip": "10.1.1.12",
"backend_port": 60000,
"backend_tls_port": 60001,
"instance_id", "91860bfe-ecff-480d-8df4-0d1eb0295b04",
"port": 5200,
"modification_tag": {
"guid": "cbdhb4e3-141d-4259-b0ac-99140e8998l0",
"index": 10
},
"ttl": 120,
"isolation_segment": ""
}]
As routes have a TTL, clients must register routes periodically to keep them active.
POST /routing/v1/tcp_routes/create
A bearer token for an OAuth client with routing.routes.write
scope is required.
A JSON-encoded array of TCP Route
objects for each route to register.
Object Field | Type | Required? | Description |
---|---|---|---|
router_group_guid |
string | yes | GUID of the router group associated with this route. |
port |
integer | yes | External facing port for the TCP route. |
backend_ip |
string | yes | IP address of backend |
backend_port |
integer | yes | Backend port. Must be greater than 0. |
backend_tls_port |
integer | no | Backend TLS port. If 0, indicates no TLS. If not provided, indicates a client that doesn't know about backend TLS port support. Otherwise must be greater than 0. |
instance_id |
string | no | Instance ID of the backend container. Used to validate the TLS cert of a backend. |
ttl |
integer | yes | Time to live, in seconds. The mapping of backend to route will be pruned after this time. Must be greater than 0 seconds and less than the configured value for max_ttl (default 120 seconds). |
modification_tag |
object | no | See Modification Tags. |
isolation_segment |
string | no | Name of the isolation segment for the route. |
backend_sni_hostname |
string | no | Sni backend hostname used for SNI routing. |
curl -vvv -H "Authorization: bearer [uaa token]" -X POST http://api.system-domain.com/routing/v1/tcp_routes/create -d '
[{
"router_group_guid": "xyz789",
"port": 5200,
"backend_ip": "10.1.1.12",
"backend_port": 60000,
"backend_tls_port": 60001,
"instance_id": "91860bfe-ecff-480d-8df4-0d1eb0295b04",
"ttl": 120,
"modification_tag": {
"guid": "cbdhb4e3-141d-4259-b0ac-99140e8998l0",
"index": 1
}
}]'
curl -k -vvv -H "Authorization: bearer $uaa_token" -X POST https://api.system-domain.com/routing/v1/tcp_routes/create -d '
[{
"router_group_guid": "ab1481be-d7f0-4390-6666-3e752e9f92ac",
"port": 1121,
"backend_ip": "10.0.8.5",
"backend_port": 8888,
"backend_tls_port": 60001,
"instance_id": "91860bfe-ecff-480d-8df4-0d1eb0295b04",
"backend_sni_hostname":"teststst.asd.com",
"ttl": 120
}]'
Expected Status 201 CREATED
POST /routing/v1/tcp_routes/delete
A bearer token for an OAuth client with routing.routes.write
scope is required.
A JSON-Encoded array of TCP Route
objects for each route to delete.
Object Field | Type | Required? | Description |
---|---|---|---|
router_group_guid |
string | yes | GUID of the router group associated with this route. |
port |
integer | yes | External facing port for the TCP route. |
backend_ip |
string | yes | IP address of backend |
backend_port |
integer | yes | Backend port. Must be greater than 0. |
backend_tls_port |
integer | no | Backend TLS port. If 0, indicates no TLS. If not provided, indicates a client that doesn't know about backend TLS port support. Otherwise must be greater than 0. |
instance_id |
string | no | Instance ID of the backend container. Used to validate the TLS cert of a backend. |
curl -vvv -H "Authorization: bearer [uaa token]" -X POST http://api.system-domain.com/routing/v1/tcp_routes/delete -d '
[{
"router_group_guid": "xyz789",
"port": 5200,
"backend_ip": "10.1.1.12",
"backend_port": 60000
"backend_tls_port": 60001,
"instance_id": "91860bfe-ecff-480d-8df4-0d1eb0295b04",
}]'
Expected Status 204 NO CONTENT
GET /routing/v1/tcp_routes/events
A bearer token for an OAuth client with routing.routes.read
scope is required.
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/tcp_routes/events
Expected Status 200 OK
The response is a long lived HTTP connection of content type
text/event-stream
as defined by
https://www.w3.org/TR/2012/CR-eventsource-20121211/.
id: 0
event: Upsert
data: {"router_group_guid":"xyz789","port":5200,"backend_port":60000,"backend_tls_port":60001,"instance_id":"91860bfe-ecff-480d-8df4-0d1eb0295b04","backend_ip":"10.1.1.12","modification_tag":{"guid":"abc123","index":1},"ttl":120}
id: 1
event: Upsert
data: {"router_group_guid":"xyz789","port":5200,"backend_port":60000,"backend_tls_port":60001,"instance_id":"91860bfe-ecff-480d-8df4-0d1eb0295b04","backend_ip":"10.1.1.12","modification_tag":{"guid":"abc123","index":2},"ttl":120}
Experimental - subject to backward incompatible change
GET /routing/v1/routes
A bearer token for an OAuth client with routing.routes.read
scope is required.
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/routes
Expected Status 200 OK
A JSON-encoded array of HTTP Route
objects.
Object Field | Type | Description |
---|---|---|
route |
string | Address, including optional path, associated with one or more backends |
ip |
string | IP address of backend |
port |
integer | Backend port. Must be greater than 0. |
ttl |
integer | Time to live, in seconds. The mapping of backend to route will be pruned after this time. |
log_guid |
string | A string used to annotate routing logs for requests forwarded to this backend. |
route_service_url |
string | When present, requests for the route will be forwarded to this url before being forwarded to a backend. If provided, this url must use HTTPS. |
modification_tag |
object | See Modification Tags. |
[{
"route": "myapp.com/somepath",
"port": 3000,
"ip": "1.2.3.4",
"ttl": 120,
"log_guid": "routing_api",
"modification_tag": {
"guid": "abc123",
"index": 1164
}
}]
Experimental - subject to backward incompatible change
As routes have a TTL, clients must register routes periodically to keep them active.
POST /routing/v1/routes
A bearer token for an OAuth client with routing.routes.write
scope is required.
A JSON-encoded array of HTTP Route
objects for each route to register.
Object Field | Type | Required? | Description |
---|---|---|---|
route |
string | yes | Address, including optional path, associated with one or more backends |
ip |
string | yes | IP address of backend |
port |
integer | yes | Backend port. Must be greater than 0. |
ttl |
integer | yes | Time to live, in seconds. The mapping of backend to route will be pruned after this time. It must be greater than 0 seconds and less than the configured value for max_ttl (default 120 seconds). |
log_guid |
string | no | A string used to annotate routing logs for requests forwarded to this backend. |
route_service_url |
string | no | When present, requests for the route will be forwarded to this url before being forwarded to a backend. If provided, this url must use HTTPS. |
curl -vvv -H "Authorization: bearer [uaa token]" -X POST http://api.system-domain.com/routing/v1/routes -d '[{"route":"myapp.com/somepath", "ip":"1.2.3.4", "port":8089, "ttl":120}]'
Expected Status 201 CREATED
Experimental - subject to backward incompatible change
DELETE /routing/v1/routes
A bearer token for an OAuth client with routing.routes.write
scope is required.
A JSON-encoded array of HTTP Route
objects for each route to delete.
Object Field | Type | Required? | Description |
---|---|---|---|
route |
string | yes | Address, including optional path, associated with one or more backends |
ip |
string | yes | IP address of backend |
port |
integer | yes | Backend port. Must be greater than 0. |
log_guid |
string | no | A string used to annotate routing logs for requests forwarded to this backend. |
route_service_url |
string | no | When present, requests for the route will be forwarded to this url before being forwarded to a backend. If provided, this url must use HTTPS. |
curl -vvv -H "Authorization: bearer [uaa token]" -X DELETE http://api.system-domain.com/routing/v1/routes -d '[{"route":"myapp.com/somepath", "ip":"1.2.3.4", "port":8089, "ttl":120}]'
Expected Status 204 NO CONTENT
Experimental - subject to backward incompatible change
GET /routing/v1/events
A bearer token for an OAuth client with routing.routes.read
scope is required.
curl -vvv -H "Authorization: bearer [uaa token]" http://api.system-domain.com/routing/v1/events
Expected Status 200 OK
The response is a long lived HTTP connection of content type
text/event-stream
as defined by
https://www.w3.org/TR/2012/CR-eventsource-20121211/.
id: 13
event: Upsert
data: {"route":"myapp.com/somepath","port":3000,"ip":"1.2.3.4","ttl":120,"log_guid":"routing_api","modification_tag":{"guid":"abc123","index":1154}}
id: 14
event: Upsert
data: {"route":"myapp.com/somepath","port":3001,"ip":"1.2.3.5","ttl":120,"log_guid":"routing_api","modification_tag":{"guid":"abc123","index":1155}}