Reservas de Hosts

Esta é uma API de gerenciamento de reservas de hosts para escopos de redes DHCP.

Listar reservas de hosts

API de listagem de reservas de hosts paginados. Ver documentação de paginação.

GET /api/dhcp/hosts

GET /api/dhcp/hosts?cursor=0&size=15

GET /api/dhcp/hosts?scope=<scope_id>

Exemplo de requisição

GET /api/dhcp/hosts HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.dhcp.types import GetHostsPageRequest

request = GetHostsPageRequest(cursor=0, size=15, scope_id=1)
pages = sdk.dhcp.get_hosts_pages(request)
const pages = sdk.dhcp.getHosts();
const response = await pages.next();
console.log(response.payload);

Exemplo de resposta

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

{
  "cursor": {"current": 0, "next": null, "previous": null},
  "hosts": [
    {
      "id": 1,
      "scope_id": 1,
      "hw_address": "FF:FF:FF:FF:FF:FF",
      "ip_address": "192.168.50.20",
      "hostname": "service.lan",
      "options": [
        {
          "code": 10,
          "custom_id": null,
          "value": "192.168.10.10",
        },
      ],
      "created_at": "2017-10-05T12:20:02.932000+00:00",
      "updated_at": "2017-11-05T12:20:02.932000+00:00",
    }
  ],
}
page = pages.next()
page = pages.previous()

# retornar os itens de uma página
for host in page.payload:
    print(host)

# retornar os itens de todas as páginas
for host in pages:
    print(host)
[
  {
    id: 1,
    scopeId: 1,
    hwAddress: "FF:FF:FF:FF:FF:FF",
    ipAddress: "192.168.50.20",
    hostname: "service.lan",
    options: [
      {
        code: 10,
        customId: null,
        value: "192.168.10.10"
      }
    ],
    createdAt: "2017-10-05T12:20:02Z",
    updatedAt: "2017-11-05T12:20:02Z"
  }
];

Buscar reserva de host

API de busca de uma reserva de host existente.

GET /api/dhcp/hosts/<id>

Exemplo de requisição

GET /api/dhcp/hosts/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dhcp.get_host(id=1)
const response = await sdk.dhcp.getHost({ id: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "scope_id": 1,
  "hw_address": "FF:FF:FF:FF:FF:FF",
  "ip_address": "192.168.50.20",
  "hostname": "service.lan",
  "options": [
    {
      "code": 10,
      "custom_id": null,
      "value": "192.168.10.10",
    },
  ],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00",
}
if response.success:
    return response.payload
{
  id: 1,
  scopeId: 1,
  hwAddress: "FF:FF:FF:FF:FF:FF",
  ipAddress: "192.168.50.20",
  hostname: "service.lan",
  options: [
    {
      code: 10,
      customId: null,
      value: "192.168.10.10",
    },
  ],
  createdAt: "2017-10-05T12:20:02Z",
  updatedAt: "2017-11-05T12:20:02Z",
}

Cadastrar reserva de host

API de cadastro de reserva de host.

POST /api/dhcp/hosts

Exemplo de requisição

POST /api/dhcp/hosts HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "apply": true,
  "scope_id": 1,
  "hw_address": "FF:FF:FF:FF:FF:FF",
  "ip_address": "192.168.50.20",
  "hostname": "service.lan",
  "options": [
    {
      "code": 10,
      "custom_id": null,
      "value": "192.168.10.10",
    },
  ],
}
from itflex_sdk.dhcp.types import CreateHostRequest

request = CreateHostRequest(
            apply=True,
            scope_id=1,
            hw_address="FF:FF:FF:FF:FF:FF",
            ip_address="192.168.50.20",
            hostname="service.lan",
            options=[
              Option(
                code=10,
                custom_id=None,
                value="192.168.10.10",
              ),
            ]
          )
response = sdk.dhcp.create_host(request)
const host = sdk.dhcp.types.Host();
host.apply=true,
host.scopeId=1;
host.hwAddress="FF:FF:FF:FF:FF:FF";
host.ipAddress="192.168.50.20";
host.hostname="service.lan";
host.options: [
  {
    code: 10,
    customId: null,
    value: "192.168.10.10",
  },
];
const response = await sdk.dhcp.createHost(host);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "scope_id": 1,
  "hw_address": "FF:FF:FF:FF:FF:FF",
  "ip_address": "192.168.50.20",
  "hostname": "service.lan",
  "options": [
    {
      "code": 10,
      "custom_id": null,
      "value": "192.168.10.10",
    },
  ],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00",
}
if response.success:
    return response.payload
{
  id: 1,
  scopeId: 1,
  hwAddress: "FF:FF:FF:FF:FF:FF",
  ipAddress: "192.168.50.20",
  hostname: "service.lan",
  options: [
    {
      code: 10,
      customId: null,
      value: "192.168.10.10",
    },
  ],
  createdAt: "2017-10-05T12:20:02Z",
  updatedAt: "2017-11-05T12:20:02Z",
}

Editar reserva de host

API de edição de uma reserva de host existente.

PUT /api/dhcp/hosts/<id>

Exemplo de requisição

PUT /api/dhcp/hosts/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "apply": true,
  "hw_address": "FF:FF:FF:FF:FF:FA",
  "ip_address": "192.168.50.30",
  "hostname": "service.lan",
  "options": [
    {
      "code": 10,
      "custom_id": null,
      "value": "192.168.10.10",
    },
    {
      "code": null,
      "custom_id": 100,
      "value": "8.8.8.8, 8.8.4.4",
    },
  ],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00",
}
from itflex_sdk.dhcp.types import UpdateHostRequest

request = UpdateHostRequest(
            id=1,
            apply=True,
            hw_address="FF:FF:FF:FF:FF:AA",
            ip_address="192.168.50.30",
            hostname="service.lan",
            options=[
              Option(
                code=10,
                custom_id=None,
                value="192.168.10.10",
              ),
              Option(
                code=None,
                custom_id=100,
                value="8.8.8.8, 8.8.4.4",
              ),
            ],
          )
response = sdk.dhcp.update_host(request)
const host = {
  id: 1,
  apply: true,
  hwAddress: "FF:FF:FF:FF:FF:AA",
  ipAddress: "192.168.50.30",
  hostname: "service.lan",
  options: [
    {
      code: 10,
      customId: null,
      value: "192.168.10.10"
    },
    {
      code: null,
      customId: 1,
      value: "8.8.8.8, 8.8.4.4"
    }
  ]
};

const response = await sdk.dhcp.updateHost(host);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "scope_id": 1,
  "hw_address": "FF:FF:FF:FF:FF:FA",
  "ip_address": "192.168.50.30",
  "hostname": "service.lan",
  "options": [
    {
      "code": 10,
      "custom_id": null,
      "value": "192.168.10.10",
    },
    {
      "code": null,
      "custom_id": 100,
      "value": "8.8.8.8, 8.8.4.4",
    },
  ],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:04.932000+00:00",
}
if response.success:
    return response.payload
{
  id: 1,
  scopeId: 1,
  hwAddress: "FF:FF:FF:FF:FF:FF",
  ipAddress: "192.168.50.20",
  hostname: "service.lan",
  options: [
    {
      code: 10,
      customId: null,
      value: "192.168.10.10",
    },
    {
      code: null,
      customId: 1,
      value: "8.8.8.8, 8.8.4.4",
    },
  ],
  createdAt: "2017-10-05T12:20:02Z",
  updatedAt: "2017-11-05T12:20:04Z",
}

Excluir reserva de host

API de exclusão de uma reserva de host existente.

DELETE /api/dhcp/hosts/<id>

Exemplo de requisição

DELETE /api/dhcp/hosts/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dhcp.delete_host(id=1)
const response = await sdk.dhcp.deleteHost({ id: 1 });

Exemplo de resposta

HTTP/1.1 200 OK
Content-Type: application/json
return response.success

Formato dos dados

Parâmetros da url

Parâmetro Tipo
id integer
scope_id integer

Requisição

Parâmetro Tipo Valor Dafault Descrição
id int Identificador da reserva de host
apply bool False Flag para aplicar o provisionamento das reservas de hosts DHCP
scope_id int requerido Identificador do escopo
hw_address string requerido MAC Address que receberá a reserva
ip_address string requerido Define o IP que será reservado
hostname string Nome dos host
options.code int Código da opção DHCP padrão
options.custom_id int Identificador da opção DHCP customizada
options.value string Conteúdo da opção

Resposta

Parâmetro Tipo Descrição
id int Identificador da reserva de host
scope_id int Identificador do escopo
hw_address string MAC Address que receberá a reserva
ip_address string Define o IP que será reservado
hostname string Nome dos host
options.id int Identificador da associação do escopo com conteúdo da opção DHCP
options.code int Código da opção DHCP padrão
options.custom_id int Identificador da opção DHCP customizada
options.value string Conteúdo da opção
created_at datetime Data de criação
updated_at datetime Data de edição