Esta é uma API de gerenciamento de escopos de redes DHCP.
API de listagem de escopos paginados. Ver documentação de paginação.
GET /api/dhcp/scopes
GET /api/dhcp/scopes?cursor=0&size=15
Exemplo de requisição
GET /api/dhcp/scopes HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.dhcp.types import GetScopesPageRequest
request = GetScopesPageRequest(cursor=0, size=15)
pages = sdk.dhcp.get_scopes_pages(request)
const pages = sdk.dhcp.getScopes();
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},
"scopes": [
{
"id": 1,
"interface_id": 1,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": [
{
"ip_start": "192.168.10.2",
"ip_end": "192.168.10.50",
}
],
"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 scope in page.payload:
print(scope)
# retornar os itens de todas as páginas
for scope in pages:
print(scope)
[
{
id: 1,
interfaceId: 1,
subnet: "192.168.10.0/24",
tftpNextServer: "",
tftpBootFileName: "",
pools: [
{
ipStart: "192.168.10.2",
ipEnd: "192.168.10.50"
}
],
options: [
{
code: 10,
customId: null,
value: "192.168.10.10"
}
],
createdAt: "2017-10-05T12:20:02Z",
updatedAt: "2017-11-05T12:20:02Z"
}
];
API de busca de um escopo existente.
GET /api/dhcp/scopes/<id>
Exemplo de requisição
GET /api/dhcp/scopes/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dhcp.get_scope(id=1)
const response = await sdk.dhcp.getScope({ id: 1 });
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"interface_id": 1,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": [
{
"ip_start": "192.168.10.2",
"ip_end": "192.168.10.50",
}
],
"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,
interfaceId: 1,
subnet: "192.168.10.0/24",
tftpNextServer: "",
tftpBootFileName: "",
pools: [
{
ipStart: "192.168.10.2",
ipEnd: "192.168.10.50"
}
],
options: [
{
code: 10,
customId: null,
value: "192.168.10.10",
},
],
createdAt: "2017-10-05T12:20:02Z",
updatedAt: "2017-11-05T12:20:02Z",
}
API de cadastro de escopos.
POST /api/dhcp/scopes
Exemplo de requisição
POST /api/dhcp/scopes HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"apply": true,
"interface_id": 1,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": {
"ip_start": "192.168.10.2",
"ip_end": "192.168.10.50",
},
"options": [
{
"code": 10,
"custom_id": null,
"value": "192.168.10.10",
},
],
}
from itflex_sdk.dhcp.types import CreateScopeRequest, Option
request = CreateScopeRequest(
apply=True,
interface_id=1,
subnet="192.168.10.0/24",
tftp_next_server="",
tftp_boot_file_name="",
pools=[
Pool(
ip_start="192.168.10.2",
ip_end="192.168.10.50"
)
],
options=[
Option(
code=10,
custom_id=None,
value="192.168.10.10",
),
]
)
response = sdk.dhcp.create_scope(request)
const scope = sdk.dhcp.types.Scope();
scope.apply: true,
scope.interfaceId: 1;
scope.subnet: "192.168.10.0/24";
scope.tftpNextServer: "",
scope.tftpBootFileName: "",
scope.pools: [
{
ipStart: "192.168.10.2",
ipEnd: "192.168.10.50"
}
];
scope.options: [
{
code: 10,
customId: null,
value: "192.168.10.10",
},
];
const response = await sdk.dhcp.createScope(scope);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"interface_id": 1,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": [
{
"ip_start": "192.168.10.2",
"ip_end": "192.168.10.50"
},
},
"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,
interfaceId: 1,
subnet: "192.168.10.0/24",
tftpNextServer: "",
tftpBootFileName: "",
pools: [
{
ipStart: "192.168.10.2",
ipEnd: "192.168.10.50"
}
],
options: [
{
code: 10,
customId: null,
value: "192.168.10.10",
},
],
createdAt: "2017-10-05T12:20:02Z",
updatedAt: "2017-11-05T12:20:02Z",
}
API de edição de um escopo existente.
PUT /api/dhcp/scopes/<id>
Exemplo de requisição
PUT /api/dhcp/scopes/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"apply": true,
"interface_id": 2,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": [
{
"ip_start": "192.168.10.10",
"ip_end": "192.168.10.40",
}
],
"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 UpdateScopeRequest, Option
request = UpdateScopeRequest(
id=1,
apply=True,
interface_id=2,
subnet="192.168.10.0/24",
tftp_next_server="",
tftp_boot_file_name="",
pools=[
Pool(
ip_start="192.168.10.10",
ip_end="192.168.10.40"
)
],
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_scope(request)
const scope = {
id: 1,
apply: true,
interfaceId: 2,
subnet: "192.168.10.0/24",
tftpNextServer: "",
tftpBootFileName: "",
pools: [
{
ipStart: "192.168.10.10",
ipEnd: "192.168.10.40"
}
]
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.updateScope(scope);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"interface_id": 2,
"subnet": "192.168.10.0/24",
"tftp_next_server": "",
"tftp_boot_file_name": "",
"pools": [
{
"ip_start": "192.168.10.10",
"ip_end": "192.168.10.40",
}
],
"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,
interfaceId: 2,
subnet: "192.168.10.0/24",
tftpNextServer: "",
tftpBootFileName: "",
pools: [
{
ipStart: "192.168.10.10",
ipEnd: "192.168.10.40"
}
],
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",
}
API de exclusão de um escopo existente.
DELETE /api/dhcp/scopes/<id>
Exemplo de requisição
DELETE /api/dhcp/scopes/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dhcp.delete_scope(id=1)
const response = await sdk.dhcp.deleteScope({ id: 1 });
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
return response.success
Parâmetros da url
Parâmetro | Tipo |
---|---|
id | integer |
Requisição
Parâmetro | Tipo | Valor Dafault | Descrição |
---|---|---|---|
id | int | Identificador do escopo | |
apply | bool | False |
Flag para aplicar o provisionamento dos escopos DHCP |
interface_id | int requerido |
Identificador da conexão | |
subnet | string requerido |
Rota para o escopo | |
tftp_next_server | string | Endereço IP do servidor TFTP | |
tftp_boot_file_name | srting | Diretório do arquivo de inicialização do servidor TFTP | |
pools | array<string> | [] |
Lista de intervalos de faixas de IP. Ex: [{ip_start: 192.168.10.2, ip_end: 192.168.10.50}] |
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 do escopo |
interface_id | int | Identificador da conexão |
subnet | string | Rota para o escopo |
tftp_next_server | string | Endereço IP do servidor TFTP |
tftp_boot_file_name | srting | Diretório do arquivo de inicialização do servidor TFTP |
pools | array<string> | Lista de intervalos de faixas de IP. Ex: [{ip_start: 192.168.10.2, ip_end: 192.168.10.50}] |
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 |