Esta é uma API de gerenciamento de tabelas de roteamento de uma conexão de rede. No Linux as tabelas de roteamento representam um conjuto de regras de roteamento que podem ser ativadas por meio de marcações nos pacotes que passam pelo firewall.
API de listagem de tabelas de roteamento
Exemplo de requisição
GET /api/sdwan/routing/tables HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.get_routing_tables()
print(response.payload)
const response = sdk.sdwan.getRoutingTables();
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"routing_tables": [
{
"id": 1,
"name": "routing_table01",
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"interface": "eth0",
"gateway": "192.168.10.1",
"routes": [
{
"type": "include",
"addr": "192.127.2.10",
"nexthop": "192.127.2.200"
},
{
"type": "exclude",
"addr": "192.122.50.0/24",
"nexthop": "192.122.50.200",
}
],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
},
{
"type": "to",
"addr": "192.172.50.20"
}
],
"created_at": "2018-12-13T12:20:02.932000+00:00",
"updated_at": "2018-12-13T12:20:02.932000+00:00"
},
{
"id": 2,
"name": "routing_table02",
"enabled": true,
"table_id": 3,
"connection_id": "iface:2",
"interface": "eth1",
"gateway": "192.168.5.1",
"routes": [],
"rules": [],
"created_at": "2018-12-13T14:15:02.932000+00:00",
"updated_at": "2018-12-13T14:15:02.932000+00:00"
}
]
}
[
RoutingTable(
id=1,
name="routing_table01",
enabled=True,
table_id=2,
connection_id="iface:1",
interface="eth0",
gateway="192.168.10.1",
routes=[
Route(
type="include",
addr="192.127.2.10",
nexthop="192.127.2.200"
),
Route(
type="exclude",
addr="192.122.50.0/24",
nexthop="192.122.50.200",
)
],
rules=[
Rule(
type="from",
addr="192.168.0.0/24"
),
Rule(
type="to",
addr="192.172.50.20"
)
],
created_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00')),
updated_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00'))
),
RoutingTable(
id=2,
name="routing_table02",
enabled=True,
table_id=3,
connection_id="iface:2",
interface="eth1",
gateway="192.168.5.1",
routes=[],
rules=[],
created_at=DateTime(2018, 12, 13, 14, 15, 2, tzinfo=Timezone('+00:00')),
updated_at=DateTime(2018, 12, 13, 14, 15, 2, tzinfo=Timezone('+00:00'))
)
]
[
{
id: 1,
name: "routing_table01",
enabled: true,
tableId: 2,
connectionId: "iface:1",
interface: "eth0",
gateway: "192.168.10.1",
routes: [
{
type: "include",
addr: "192.127.2.10",
nexthop: "192.127.2.200",
},
{
type: "exclude",
addr: "192.122.50.0/24",
nexthop: "192.122.50.200",
}
],
rules: [
{
type: "from",
addr: "192.168.0.0/24"
},
{
type: "to",
addr: "192.172.50.20"
}
],
createdAt: "2018-12-13T12:20:02.000Z",
updatedAt: "2018-12-13T12:20:02.000Z"
},
{
id: 2,
name: "routing_table02",
enabled: true,
tableId: 3,
connectionId: "iface:2",
interface: "eth1",
gateway: "192.168.5.1",
routes: [],
rules: [],
createdAt: "2018-12-13T14:15:02.000Z",
updatedAt: "2018-12-13T14:15:02.000Z"
}
];
API de consulta de tabela de roteamento
id
Exemplo de requisição
GET /api/sdwan/routing/tables/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.get_routing_table(id=1)
print(response.payload)
const response = sdk.sdwan.getRoutingTable({ id: 1 });
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "routing_table01",
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"interface": "eth0",
"gateway": "192.168.10.1",
"routes": [
{
"type": "include",
"addr": "192.127.2.10",
"nexthop": "192.127.2.200"
},
{
"type": "exclude",
"addr": "192.122.50.0/24",
"nexthop": "192.122.50.200",
}
],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
},
{
"type": "to",
"addr": "192.172.50.20"
}
],
"created_at": "2018-12-13T12:20:02.932000+00:00",
"updated_at": "2018-12-13T12:20:02.932000+00:00"
}
RoutingTable(
id=1,
name="routing_table01",
enabled=True,
table_id=2,
connection_id="iface:1",
interface="eth0",
gateway="192.168.10.1",
routes=[
Route(
type="include",
addr="192.127.2.10",
nexthop="192.127.2.200"
),
Route(
type="exclude",
addr="192.122.50.0/24",
nexthop="192.122.50.200",
)
],
rules=[
Rule(
type="from",
addr="192.168.0.0/24"
),
Rule(
type="to",
addr="192.172.50.20"
)
],
created_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00')),
updated_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00')),
)
{
id: 1,
name: "routing_table01",
enabled: true,
tableId: 2,
connectionId: "iface:1",
interface: "eth0",
gateway: "192.168.10.1",
routes: [
{
type: "include",
addr: "192.127.2.10",
nexthop: "192.127.2.200"
},
{
type: "exclude",
addr: "192.122.50.0/24",
nexthop: "192.122.50.200",
}
],
rules: [
{
type: "from",
addr: "192.168.0.0/24"
},
{
type: "to",
addr: "192.172.50.20"
}
],
createdAt: "2018-12-13T12:20:02.000Z",
updatedAt: "2018-12-13T12:20:02.000Z"
}
API de criação de tabela de roteamento
Exemplo de requisição
POST /api/sdwan/routing/tables HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>
{
"name": "routing_table01",
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"routes": [
{
"type": "include",
"addr": "192.127.2.10",
"nexthop": "192.127.2.251"
}
],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
},
{
"type": "to",
"addr": "192.172.50.20"
}
],
"apply": true,
}
from itflex_sdk.sdwan.types import CreateRoutingTableRequest, Route, Rule
request = CreateRoutingTableRequest(
name="routing_table01",
enabled=True,
table_id=2,
connection_id="iface:1",
routes=[
Route(
type="include",
addr="192.127.2.10",
nexthop="192.127.2.251"
)
],
rules=[
Rule(
type="from",
addr="192.168.0.0/24"
),
Rule(
type="to",
addr="192.172.50.20"
),
],
apply=True,
)
response = sdk.sdwan.create_routing_table(request)
print(response.payload)
const routingTable = sdk.sdwan.types.RoutingTable();
routingTable.name = "routing_table01";
routingTable.enabled = true;
routingTable.tableId = 2;
routingTable.connectionId = "iface:1";
routingTable.routes = [
{ type: "include", addr: "192.127.2.10", nexthop: "192.127.2.251" }
];
routingTable.rules = [
{ type: "from", addr: "192.168.0.0/24" },
{type: "to", addr: "192.172.50.20"},
];
routingTable.apply = false;
const response = sdk.sdwan.createRoutingTable(routingTable);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "routing_table01",
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"interface": "eth0",
"gateway": "192.168.10.1",
"routes": [
{
"type": "include",
"addr": "192.127.2.10",
"nexthop": "192.127.2.251"
}
],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
},
{
"type": "to",
"addr": "192.172.50.20"
}
],
"created_at": "2018-12-13T12:20:02.932000+00:00",
"updated_at": "2018-12-13T12:20:02.932000+00:00"
}
RoutingTable(
id=1,
name="routing_table01",
enabled=True,
table_id=2,
connection_id="iface:1",
interface="eth0",
gateway="192.168.10.1",
routes=[
Route(
type="include",
addr="192.127.2.10",
nexthop="192.127.2.251"
)
],
rules=[
Rule(
type="from",
addr="192.168.0.0/24"
),
Rule(
type="to",
addr="192.172.50.20"
)
],
created_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00')),
updated_at=DateTime(2018, 12, 13, 12, 20, 2, tzinfo=Timezone('+00:00'))
)
{
id: 1,
name: "routing_table01",
enabled: true,
tableId: 2,
connectionId: "iface:1",
interface: "eth0",
gateway: "192.168.10.1",
routes: [
{
type: "include",
addr: "192.127.2.10",
nexthop: "192.127.2.251"
}
],
rules: [
{
type: "from",
addr: "192.168.0.0/24"
},
{
type: "to",
addr: "192.172.50.20"
}
],
createdAt: "2018-12-13T12:20:02.000Z",
updatedAt: "2018-12-13T12:20:02.000Z"
}
API de edição de tabela de roteamento
id
Exemplo de requisição
PUT /api/sdwan/routing/tables/3 HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>
{
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"routes": [],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
}
],
"apply": true,
}
from itflex_sdk.sdwan.types import UpdateRoutingTableRequest, Rule
request = UpdateRoutingTableRequest(
id=1,
renabled=True,
table_id=2,
connection_id="iface:1",
routes=[],
rules=[
Rule(
type="from",
addr="192.168.0.0/24"
)
],
apply=True,
)
response = sdk.sdwan.update_routing_table(request)
print(response.payload)
const routingTable = {
id: 1,
enabled: true,
tableId: 2,
connectionId: "iface:1",
routes: [],
rules: [{ type: "from", addr: "192.168.0.0/24" }],
apply: true,
};
const response = sdk.sdwan.updateRoutingTable(routingTable);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "routing_table01",
"enabled": true,
"table_id": 2,
"connection_id": "iface:1",
"interface": "eth0",
"gateway": "192.168.10.1",
"routes": [],
"rules": [
{
"type": "from",
"addr": "192.168.0.0/24"
}
],
"created_at": "2018-12-14T09:20:02.932000+00:00",
"updated_at": "2018-12-14T10:30:02.932000+00:00"
}
RoutingTable(
id=1,
name="routing_table01",
enabled=True,
table_id=2,
connection_id="iface:1",
interface="eth0",
gateway="192.168.10.1",
routes=[],
rules=[
Rule(type="from", addr="192.168.0.0/24")
],
created_at=DateTime(2018, 12, 14, 9, 20, 2, tzinfo=Timezone('+00:00')),
updated_at=DateTime(2018, 12, 14, 10, 30, 2, tzinfo=Timezone('+00:00'))
)
{
id: 1,
name: "routing_table01",
enabled: true,
tableId: 2,
connectionId: "iface:1",
interface: "eth0",
gateway: "192.168.10.1",
routes: [],
rules: [
{ type: "from", addr: "192.168.0.0/24" }
],
createdAt: "2018-12-14T09:20:02.000Z",
updatedAt: "2018-12-14T10:30:02.000Z"
}
API de exclusão de tabela de roteamento
id
Exemplo de requisição
DELETE /api/sdwan/routing/tables/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.delete_routing_table(id=1)
const response = sdk.sdwan.deleteRoutingTable({ id: 1 });
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
API de aplicação de tabelas de roteamento
Exemplo de requisição
POST /api/sdwan/routing/tables/apply HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.apply_routing_tables()
const response = sdk.sdwan.applyRoutingTables();
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
Parâmetros da url
Campo | Descrição |
---|---|
id | int Identificador da tabela de roteamento |
Requisição
Campo | Descrição |
---|---|
name | stringrequerido único Nome da tabela de roteamento. Não editável. Tamanho máximo: 30 caracteres |
enabled | boolrequerido Flag que determina se a tabela de rotemento está habilitada ou desabilitada. |
table_id | intrequerido único Identificador da tabela de roteamento do Linux. Este valor também deve ser usado para realizar a marcação de pacotes via iptables (ação MARK). Deve ser sempre um número entre 2 e 500. |
connection_id | stringúnico Identificador da conexão. Tipos de conexões validas:
|
interface | stringúnico Nome da interface de rede. Requerido se o campo |
gateway | string IP do gateway da interface de rede. Requerido se o campo |
routes | array<object> Lista de rotas que serão alteradas das redes da tabela de roteamento padrão. Valores duplicados nesta lista devem ser removidos automaticamente. Formato:
|
rules | array<object> Lista de regras de roteamento da tabela. Formato:
|
apply | bool Flag que habilitada a aplicação da tabela de roteamento após salvar ou editar. |
Resposta
Campo | Descrição |
---|---|
id | int Identificador da tabela de roteamento |
enabled | bool Flag que determina se a tabela de rotemento está habilitada ou desabilitada. |
table_id | int Identificador da tabela de roteamento do Linux. |
connection_id | string Identificador da conexão. |
interface | string Nome da interface de rede. |
gateway | string IP do gateway da interface de rede. |
routes | array<object> Lista de rotas que serão alteradas das redes da tabela de roteamento padrão. Formato: |
rules | array<object> Lista de regras de roteamento da tabela. Formato: |
created_at | string Data de criação Formato: |
updated_at | string Data da última edição Formato: |