Host DNS

Esta é uma API de configuração do host do domínio DNS que será atualizado pelo serviço de SDWAN quando houver uma alteração de status de uma tabela dentro de uma política de roteamento.

Listar hosts

API de listagem de hosts

GET /api/sdwan/dns/zones/dns_zone_id/hosts

Exemplo de requisição

GET /api/sdwan/dns/zones/1/hosts HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.get_dns_hosts(dns_zone_id=1)
print(response.payload)
const response = sdk.sdwan.getDnsHosts({dnsZoneId: 1});
console.log(response.payload);

Exemplo de resposta

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

{
  "dns_hosts": [
    {
      "id": 1,
      "dns_zone_id": 1,
      "enabled": true,      
      "hostname": "git.foo.com.br",
      "ttl": null,
      "policy_routing_id": 1,
      "priorities": [[1, 2], [3]],
      "routing_table_addresses": [
        {"id": 1, "addr": "200.200.198.1"},
        {"id": 2, "addr": "200.172.208.45"},
        {"id": 3, "addr": null},
      ],
      "created_at": "2018-12-13T12:20:02.932000+00:00",
      "updated_at": "2018-12-13T12:20:02.932000+00:00"
    },
    {
      "id": 2,
      "dns_zone_id": 2,
      "enabled": true,      
      "hostname": "git.bar.com.br",
      "ttl": 380,      
      "policy_routing_id": 2,
      "priorities": [[3], [4]],
      "routing_table_addresses": [
        {"id": 3, "addr": "200.200.200.1"},
        {"id": 4, "addr": "189.189.189.2"},
      ],
      "created_at": "2018-12-13T14:15:02.932000+00:00",
      "updated_at": "2018-12-13T14:15:02.932000+00:00"
    }
  ]
}
[
    DnsHost(
        id=1,
        dns_zone_id=1,
        enabled=True,
        hostname="git.foo.com.br",
        ttl=None,
        policy_routing_id=1,
        priorities=[[1, 2], [3]],
        routing_table_addresses=[
            RoutingTableAddress(id=1, addr="200.200.198.1"),
            RoutingTableAddress(id=2, addr="200.172.208.45"),
            RoutingTableAddress(id=3, addr=None),
        ],
        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'))
    ),
    DnsHost(
        id=2,
        dns_zone_id=2,
        enabled=True,        
        hostname="git.bar.com.br",
        ttl=380,
        policy_routing_id=2,
        priorities=[[3], [4]],
        routing_table_addresses=[
            RoutingTableAddress(id=3, addr="200.200.200.1"),
            RoutingTableAddress(id=4, addr="189.189.189.2"),
        ],
        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,
    dnsZoneId: 1,
    enabled: true,
    hostname: "git.foo.com.br",
    ttl: null,
    policyRoutingId: 1,
    priorities: [[1, 2], [3]],
    routingTableAddresses: [
      {"id": 1, "addr": "200.200.198.1"},
      {"id": 2, "addr": "200.172.208.45"},
      {"id": 3, "addr": null},
    ],
    createdAt: "2018-12-13T12:20:02.000Z",
    updatedAt: "2018-12-13T12:20:02.000Z"
  },
  {
    id: 2,
    dnsZoneId: 2,
    enabled: true,
    hostname: "git.bar.com.br",
    ttl: 380,
    policyRoutingId: 2,
    priorities: [[1], [2]],
    routingTableAddresses: [
      {"id": 3, "addr": "200.200.200.1"},
      {"id": 4, "addr": "189.189.189.2"},
    ],
    createdAt: "2018-12-13T14:15:02.000Z",
    updatedAt: "2018-12-13T14:15:02.000Z"
  }
];

Buscar host

API de consulta de um host

GET /api/sdwan/dns/zones/dns_zone_id/hosts/id

Exemplo de requisição

GET /api/sdwan/dns/zones/1/hosts/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.get_dns_host(id=1, dns_zone_id=1)
print(response.payload)
const response = sdk.sdwan.getDnsHost({ id: 1, dnsZoneId: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "dns_zone_id": 1,
  "enabled": true,      
  "hostname": "git.foo.com.br",
  "ttl": null,
  "policy_routing_id": 1,
  "priorities": [[1, 2], [3]],
  "routing_table_addresses": [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
  ],
  "created_at": "2018-12-13T12:20:02.932000+00:00",
  "updated_at": "2018-12-13T12:20:02.932000+00:00"
}
DnsHost(
    id=1,
    dns_zone_id=1,
    enabled=True,
    hostname="git.foo.com.br",
    ttl=None,
    policy_routing_id=1,
    priorities=[[1, 2], [3]],
    routing_table_addresses=[
        RoutingTableAddress(id=1, addr="200.200.198.1"),
        RoutingTableAddress(id=2, addr="200.172.208.45"),
        RoutingTableAddress(id=3, addr=None),
    ],
    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,
  dnsZoneId: 1,
  enabled: true,
  hostname: "git.foo.com.br",
  ttl: null,
  policyRoutingId: 1,
  priorities: [[1, 2], [3]],
  routingTableAddresses: [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
  ],
  createdAt: "2018-12-13T12:20:02.000Z",
  updatedAt: "2018-12-13T12:20:02.000Z"
}

Criar host

API de criação de host

POST /api/sdwan/dns/zones/dns_zone_id/hosts

Exemplo de requisição

POST /api/sdwan/dns/zones/1/hosts HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "enabled": true,
  "hostname": "git.foo.com.br",
  "ttl": null,
  "policy_routing_id": 1,
  "priorities": [[1, 2], [3]],
  "routing_table_addresses": [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
  ],
}
from itflex_sdk.sdwan.types import CreateDnsHostRequest, RoutingTableAddress

request = CreateDnsHostRequest(
    dns_zone_id=1,
    enabled=True,
    hostname="git.foo.com.br",
    ttl=None,
    policy_routing_id=1,
    priorities=[[1, 2], [3]],
    routing_table_addresses=[
        RoutingTableAddress(id=1, addr="200.200.198.1"),
        RoutingTableAddress(id=2, addr="200.172.208.45"),
        RoutingTableAddress(id=3, addr=None),
    ],
)
response = sdk.sdwan.create_dns_host(request)
print(response.payload)
const dnsHost = sdk.sdwan.types.DnsHost();
dnsHost.dnsZoneId = 1;
dnsHost.enabled = true;
dnsHost.hostname = "git.foo.com.br";
dnsHost.ttl = null;
dnsHost.policyRoutingId = 1;
dnsHost.priorities = [[1, 2], [3]];
dnsHost.routingTableAddresses = [
  {"id": 1, "addr": "200.200.198.1"},
  {"id": 2, "addr": "200.172.208.45"},
  {"id": 3, "addr": null},
];

const response = sdk.sdwan.createDnsHost(dnsHost);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "dns_zone_id": 1,
  "enabled": true,      
  "hostname": "git.foo.com.br",
  "ttl": null,
  "policy_routing_id": 1,
  "priorities": [[1, 2], [3]],
  "routing_table_addresses": [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
  ],
  "created_at": "2018-12-14T09:20:02.932000+00:00",
  "updated_at": "2018-12-14T09:20:02.932000+00:00"
}
DnsHost(
    id=1,
    dns_zone_id=1,
    enabled=True,
    hostname="git.foo.com.br",
    ttl=None,
    policy_routing_id=1,
    priorities=[[1, 2], [3]],
    routing_table_addresses=[
        RoutingTableAddress(id=1, addr="200.200.198.1"),
        RoutingTableAddress(id=2, addr="200.172.208.45"),
        RoutingTableAddress(id=3, addr=None),
    ],
    created_at=DateTime(2018, 12, 14, 9, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2018, 12, 14, 9, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  dnsZoneId: 1,
  enabled: true,
  hostname: "git.foo.com.br",
  ttl: null,
  policyRoutingId: 1,
  priorities: [[1, 2], [3]],
  routingTableAddresses: [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
  ],
  createdAt: "2018-12-14T09:20:02.000Z",
  updatedAt: "2018-12-14T09:20:02.000Z"
}

Editar host

API de edição de um host

PUT /api/sdwan/dns/zones/dns_zone_id/hosts/id

Exemplo de requisição

PUT /api/sdwan/dns/zones/1/hosts/1 HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "enabled": true,
  "hostname": "git.foo.com.br",
  "ttl": 350,
  "policy_routing_id": 1,
  "priorities": [[1, 2], [3], [4]],
  "routing_table_addresses": [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
    {"id": 4, "addr": "192.168.36.9"},
  ],
}
from itflex_sdk.sdwan.types import RoutingTableAddress, UpdateDnsHostRequest

request = UpdateDnsHostRequest(
    id=1,
    dns_zone_id=1,
    enabled=True,
    hostname="git.foo.com.br",
    ttl=350,
    policy_routing_id=1,
    priorities=[[1, 2], [3], [4]],
    routing_table_addresses=[
        RoutingTableAddress(id=1, addr="200.200.198.1"),
        RoutingTableAddress(id=2, addr="200.172.208.45"),
        RoutingTableAddress(id=3, addr=None),
        RoutingTableAddress(id=4, addr="192.168.36.9"),
    ],
)
response = sdk.sdwan.update_dns_host(request)
print(response.payload)
const dnsHost = {
  dnsZoneId: 1,
  enabled: true,
  hostname: "git.foo.com.br",
  ttl: 350,
  policyRoutingId: 1,
  priorities: [[1, 2], [3], [4]],
  routingTableAddresses: [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
    {"id": 4, "addr": "192.168.36.9"},
  ],  
};
const response = sdk.sdwan.updateDnsHost(routingRule);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "dns_zone_id": 1,
  "enabled": true,      
  "hostname": "git.foo.com.br",
  "ttl": 350,
  "policy_routing_id": 1,
  "priorities": [[1, 2], [3], [4]],
  "routing_table_addresses": [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
    {"id": 4, "addr": "192.168.36.9"},
  ],
  "created_at": "2018-12-14T09:20:02.932000+00:00",
  "updated_at": "2018-12-14T10:30:02.932000+00:00"
}
DnsHost(
    id=1,
    dns_zone_id=1,
    enabled=True,
    hostname="git.foo.com.br",
    ttl=350,
    policy_routing_id=1,
    priorities=[[1, 2], [3], [4]],
    routing_table_addresses=[
        RoutingTableAddress(id=1, addr="200.200.198.1"),
        RoutingTableAddress(id=2, addr="200.172.208.45"),
        RoutingTableAddress(id=3, addr=None),
        RoutingTableAddress(id=4, addr="192.168.36.9"),
    ],
    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'))
)
{
  dnsZoneId: 1,
  enabled: true,
  hostname: "git.foo.com.br",
  ttl: 350,
  policyRoutingId: 1,
  priorities: [[1, 2], [3], [4]],
  routingTableAddresses: [
    {"id": 1, "addr": "200.200.198.1"},
    {"id": 2, "addr": "200.172.208.45"},
    {"id": 3, "addr": null},
    {"id": 4, "addr": "192.168.36.9"},
  ],  
  createdAt: "2018-12-14T09:20:02.000Z",
  updatedAt: "2018-12-14T10:30:02.000Z"
}

Excluir host

API de exclusão de um host

DELETE /api/sdwan/dns/zones/dns_zone_id/hosts/id

Exemplo de requisição

DELETE /api/sdwan/dns/zones/1/hosts/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.sdwan.delete_dns_host(id=1, dns_zone_id=1)
const response = sdk.sdwan.deleteDnsHost({ id: 1, dnsZoneId: 1 });

Exemplo de resposta

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

Formato dos dados

Parâmetros da url

Campo Descrição
id int

Identificador do host

Requisição

Campo Descrição
id int

Identificador do host.

dns_zone_id intrequerido

Identificador da zona do host.

enabled boolrequerido

Flag que indica se a configuração de host está habilitada.

hostname stringrequerido único

Endereço do hostname que será atualizado.

Deve ser um subendereço da zona do campo dns_zone_id.

ttl int

Tempo de expiração, em segundos, do apontamento DNS.

Quando não for preenchido, usa o tempo configurado para a zona.

Valor padrão: NULL

Valor mínimo: 1

Valor máximo:86400

policy_routing_id intrequerido

Política de roteamento a ser utilizada para o tráfego desta regra.

priorities array<array<int>>requerido

Prioridades do apontamento DNS.

O primeiro nível do array é a prioridade, o segundo nível são os identificadores das tabelas de roteamento que serão usadas na prioridade. Podem ser colocados mais de uma tabela por nível.

Exemplo: a tabela WAN-EMB é representada pelo id=1, a tabela WAN-OI pelo id=2 e a tabela WAN-UNIFIQ pelo id=3.

[
  [1, 3],
  [2],
]

Neste exemplo, a prioridade é que o apontamento seja balanceado entre as tabelas WAN-EMB e WAN-UNIFIQ, e se essas duas tabelas não cumprirem os parâmetros da política associado do campo policy_routing_id, alterar o apontamento para WAN-OI.

routing_table_addresses array<object>requerido

Mapeamento de endereços de todas as tabelas de roteamento presentes no campo priorities.

routing_table_addresses[].id intrequerido

Identificador da tabela de roteamento que será configurado o endereço de apontamento para o host.

routing_table_addresses[].addr string

Endereço IP de apontamento da tabela de roteamento para o host.

Resposta

Campo Descrição
id int

Identificador do host.

dns_zone_id int

Identificador da zona do host.

enabled bool

Flag que indica se a configuração de host está habilitada.

hostname string

Endereço do hostname que será atualizado.

ttl int

Tempo de expiração, em segundos, do apontamento DNS.

policy_routing_id int

Política de roteamento a ser utilizada para o tráfego desta regra.

priorities array<array<int>>

Prioridades do apontamento DNS.

routing_table_addresses array<object>

Mapeamento de endereços para todas as tabelas de roteamento presentes no campo priorities.

routing_table_addresses[].id int

Identificador da tabela de roteamento que será configurado o endereço de apontamento para o host.

routing_table_addresses[].addr string

Endereço IP de apontamento da tabela de roteamento para o host.

created_at string

Data de criação

Formato: ISO-8601

updated_at string

Data da última edição

Formato: ISO-8601