Interfaces

Esta é uma API de gerenciamento de interfaces de rede.

Obs: Esta API não possui cadastro (POST). As Interfaces devem ser previamente cadastradas através da ferramenta Network Manager diretamente no servidor.

Listar Interfaces

API de listagem de interfaces.

GET /api/networks/interfaces

Exemplo de requisição

GET /api/networks/interfaces HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.networks.get_interfaces()
print(response.payload)
const resp = await sdk.networks.getInterfaces();
console.log(resp.payload);

Exemplo de resposta

HTTP/1.1 200 OK
Content-Type: application/json

{
  "interfaces": [
    {
      "id": 1,
      "name": "embratel",
      "description": "test connection",
      "type": "wan",
      "addresses": [
        "192.168.0.110/24",
        "192.168.0.199/24",
      ],
      "gateway": "192.168.0.1",
      "default_route": true,
      "routes": [],
      "iface": "conn01",
      "macaddress": "FF:FF:FF:FF:FF:FF",
      "connection_state": "up",
      "link_state": "up",
      "created_at": "2018-10-01T12:20:02.932000+00:00",
      "updated_at": "2018-10-01T12:20:02.932000+00:00",
    },
    {
      "id": 2,
      "name": "matriz",
      "description": "another test connection",
      "type": "lan",
      "addresses": [
        "10.15.121.102/25",
        "10.15.121.101/25",
        "10.15.121.38/25",
        "10.15.121.45/25",
      ],
      "gateway": "10.15.121.254",
      "default_route": false,
      "routes": [
        {
          "network": "10.15.0.0/24",
          "next_hop": "10.15.0.254"
        }
      ],
      "iface": "conn02",
      "macaddress": "FF:FF:FF:FF:FF:AA",
      "connection_state": "down",
      "link_state": "no_information",
      "created_at": "2018-10-02T08:35:22.130000+00:00",
      "updated_at": "2018-10-02T08:35:22.130000+00:00",
    },
  ],
}
[
  Interface(
    id=1,
    name="embratel",
    description="test connection",
    type="wan",
    addresses=[
      "192.168.0.110/24",
      "192.168.0.199/24"
    ],
    gateway="192.168.0.1",
    default_route=True,
    routes=[],
    iface="conn01",
    macaddress="FF:FF:FF:FF:FF:FF",
    connection_state="up",
    link_state="up",
    created_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00'))
  ),
  Interface(
    id=2,
    name="matriz",
    description="another test connection",
    type="lan",
    addresses=[
      "10.15.121.102/25",
      "10.15.121.101/25",
      "10.15.121.38/25",
      "10.15.121.45/25",
    ],
    gateway="10.15.121.254",
    default_route=False,
    routes=[Route(network="10.15.0.0/24", next_hop="10.15.0.254")],
    iface="conn02",
    macddress="FF:FF:FF:FF:FF:AA",
    connection_state="down",
    link_state="no_information",
    created_at=DateTime(2018, 10, 2, 8, 35, 22, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2018, 10, 2, 8, 35, 22, tzinfo=Timezone('+00:00'))
  )
]
[
  {
    id: 1,
    name: "embratel",
    description: "test connection",
    type: "wan",
    addresses: [
      "192.168.0.110/24",
      "192.168.0.199/24",
    ],
    gateway: "192.168.0.1",
    defaultRoute: true,
    routes: [],
    iface: "conn01",
    macaddress: "FF:FF:FF:FF:FF:FF",
    connectionState: "up",
    linkState: "up",
    createdAt: "2018-10-01T12:20:02Z",
    updatedAt: "2018-10-01T12:20:02Z",
  },
  {
    id: 2,
    name: "matriz",
    description: "another test connection",
    type: "lan",
    addresses: [
      "10.15.121.102/25",
      "10.15.121.101/25",
      "10.15.121.38/25",
      "10.15.121.45/25",
    ],
    gateway: "10.15.121.1",
    defaultRoute: false,
    routes: [
      {
        network: "10.15.0.0/25"
        nextHop: "10.15.0.254"
      }
    ],
    iface: "conn02",
    macaddress: "FF:FF:FF:FF:FF:AA",
    connectionState: "down",
    linkState: "no_information",
    createdAt: "2018-10-02T08:35:22.13Z",
    updatedAt: "2018-10-02T08:35:22.13Z",
  },
]

Buscar Interface

API de busca de uma interface.

GET /api/networks/interfaces/id

Exemplo de requisição

GET /api/networks/interfaces/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.networks.get_interface(id=1)
print(response.payload)
const response = await sdk.networks.getInterface({ id: 1 });
console.log(response.payload);

Exemplo de resposta

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 1,
  "name": "embratel",
  "description": "test connection",
  "type": "wan",
  "addresses": [
    "192.168.0.110/24",
    "192.168.0.199/24",
  ],
  "gateway": "192.168.0.1",
  "default_route": true,
  "routes": [],
  "iface": "conn01",
  "macaddress": "FF:FF:FF:FF:FF:FF",
  "connection_state": "up",
  "link_state": "up",
  "created_at": "2018-10-01T12:20:02.932000+00:00",
  "updated_at": "2018-10-01T12:20:02.932000+00:00",
}
Interface(
  id=1,
  name="embratel",
  description="test connection",
  type="wan",
  addresses=[
    "192.168.0.110/24",
    "192.168.0.199/24"
  ],
  gateway="192.168.0.1",
  default_route=True,
  routes=[],
  iface="conn01",
  macaddress="FF:FF:FF:FF:FF:FF",
  connection_state="up",
  link_state="up",
  created_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00')),
  updated_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "embratel",
  description: "test connection",
  type: "wan",
  addresses: [
    "192.168.0.110/24",
    "192.168.0.199/24",
  ],
  gateway: "192.168.0.1/24",
  defaultRoute: true,
  routes: [],
  iface: "conn01",
  macaddress: "FF:FF:FF:FF:FF:FF",
  connectionState: "up",
  linkState: "up",
  createdAt: "2018-10-01T12:20:02Z",
  updatedAt: "2018-10-01T12:20:02Z",
}

Editar Interface

API de edição dos dados de uma interface.

PUT /api/networks/interfaces/id

Exemplo de requisição

PUT /api/networks/interfaces/1 HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "id": 1,
  "name": "oi",
  "description": "test connection",
  "type": "wan",
  "addresses": [
    "192.168.0.110/24",
    "192.168.0.199/24",
  ],
  "gateway": "192.168.0.254",
  "default_route": true,
  "routes": [
    {
      "network": "172.10.0.0/16",
      "next_hop": "172.10.255.254"
    }
  ],
}
from itflex_sdk.networks.types import UpdateInterfaceRequest, Route

request = UpdateInterfaceRequest(
    id=1,
    name="oi",
    description="test connection",
    type="wan",
    addresses=[
      "192.168.0.110/24",
      "192.168.0.199/24"
    ],
    gateway="192.168.0.1",
    default_route=True,
    routes=[Route(network="172.10.0.0/16", next_hop="172.10.255.254")]
)
response = sdk.networks.update_interface(request)
print(response.payload)
const connection = {
    id: 1,
    name: "oi",
    description: "test connection",
    type: "wan",
    addresses: ["192.168.0.110/24", "192.168.0.199/24"],
    gateway: "192.168.0.1",
    defaultRoute: true,
    routes: [
        {
            network: "172.10.0.0/16",
            nextHop: "172.10.255.254"
        }
    ]
};

const response = await sdk.networks.updateInterface(connection);
console.log(response.payload);

Exemplo de resposta

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 1,
  "name": "oi",
  "description": "test connection",
  "type": "wan",
  "addresses": [
    "192.168.0.110/24",
    "192.168.0.199/24",
  ],
  "gateway": "192.168.0.1",
  "default_route": true,
  "routes": [
    "network": "172.10.0.0/16",
    "next_hop": "172.10.255.254"
  ],
  "iface": "conn01",
  "macaddress": "FF:FF:FF:FF:FF:FF",
  "created_at": "2018-10-01T12:20:02.932000+00:00",
  "updated_at": "2018-10-06T16:53:13.811000+00:00",
}
Interface(
  id=1,
  name="embratel",
  description="test connection",
  type="wan",
  addresses=[
    "192.168.0.110/24",
    "192.168.0.199/24"
  ],
  gateway="192.168.0.1",
  default_route=True,
  routes=[Route(network="172.10.0.0/16", next_hop="172.10.255.254")]
  iface="conn01",
  macaddress="FF:FF:FF:FF:FF:FF",
  created_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00')),
  updated_at=DateTime(2018, 10, 1, 12, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "oi",
  description: "test connection",
  type: "wan",
  addresses: [
    "192.168.0.110/24",
    "192.168.0.199/24",
  ],
  gateway: "192.168.0.1",
  defaultRoute: true,
  routes: [
    {
      network: "172.10.0.0/16",
      nextHop: "172.10.255.254"
    }
  ],
  iface: "conn01",
  macaddress: "FF:FF:FF:FF:FF:FF",
  createdAt: "2018-10-01T12:20:02Z",
  updatedAt: "2018-10-01T12:20:02Z",
}

Formato dos dados

Parâmetros da url

Campo Descrição
id int

Idendificador da interface

Requisição

Campo Descrição
name stringrequired único

Nome atribuído à interface

type stringrequired

Tipo da interface

Valores possíveis: wan, lan, dmz, guest

description string

Descrição sobre a interface

Esta informação é armazenada em banco

address array<string>required

Lista de endereços da interface

Formato: IP/Mask

gateway string

Endereço de gateway padrão

Requerido se type for igual a wan.

default_route bool

Flag se a interface é a rota padrão do sistema

Default: False

routes array<object>

Lista de IPs ou rotas e next hop das mesmas.

Quando o valor do campo for um IP, deve ser informada a máscara da rede no formato IP/Mask.

Resposta

Campo Descrição
id integer

Identificador da interface no banco de dados

name string

Nome atribuído à interface

type string

Tipo da interface

description string

Descrição sobre a interface

address array<string>

Lista de endereços da interface

gateway string

Endereço de gateway padrão

default_route bool

Flag se a interface é a rota padrão do sistema

routes array<object>

Lista de IPs ou rotas e next hop das mesmas.

iface string

Nome da interface de rede física da interface

macaddress string

Endereço MAC da interface de rede física

connection_state string

Status da interface

link_state string

Status da interface física

created_at string

Data de criação

Formato: ISO-8601

updated_at string

Data da última edição

Formato: ISO-8601