Políticas

Esta é uma API de gerenciamento políticas do DBC.

Listar Políticas

API de listagem de políticas do DBC.

GET /api/dbc/policies

Exemplo de requisição

GET /api/dbc/policies HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dbc.get_policies()
print(response.payload)
const response = sdk.dbc.getPolicies();
console.log(response.payload);

Exemplo de resposta

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

{
  "policies": [
    {
      "id": 1,
      "name": "policy01",
      "classes": [
        {
          "id": "default",
          "name": "Default",
          "order": 1,
          "priority_type": "pfifo",
          "priority": 0,
          "rate": 50,
          "ceil": 100,
        },
        {
          "id": "1",
          "name": "class01",
          "order": 2,
          "priority_type": "pfifo",
          "priority": 1,
          "rate": 50,
          "ceil": 100,
        },
      ],
      "created_at": "2017-10-05T12:20:02.932000+00:00",
      "updated_at": "2017-11-05T12:20:02.932000+00:00",
    },
  ]
}
[
    Policy(
        id=1,
        name="policy01",
        classes=[
            Class(
                id="default",
                name="Default",
                order=1,
                priority_type="pfifo",
                priority=0,
                rate=50,
                ceil=100,
            ),
            Class(
                id="1",
                name="class01",
                order=2,
                priority_type="pfifo",
                priority=1,
                rate=50,
                ceil=100,
            ),
        ],
        created_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00')),
        updated_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00'))
    )
]
[
  {
    id: 1,
    name: "policy01",
    classes: [
      {
        id: "default",
        name: "Default",
        order: 1,
        priorityType: "pfifo",
        priority: 0,
        rate: 50,
        ceil: 100
      },
      {
        id: "1",
        name: "class01",
        order: 2,
        priorityType: "pfifo",
        priority: 1,
        rate: 50,
        ceil: 100
      }
    ],
    createdAt: "2017-10-05T15:20:02.000Z",
    updatedAt: "2017-11-05T15:20:02.000Z"
  }
];

Buscar Política

API de busca de uma política existente.

GET /api/dbc/policies/id

Exemplo de requisição

GET /api/dbc/policies/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dbc.get_policy(id=1)
print(response.payload)
const response = sdk.dbc.getPolicy({ id: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "name": "policy01",
  "classes": [
    {
      "id": "1",
      "name": "class01",
      "order": 2,
      "priority_type": "pfifo",
      "priority": 1,
      "rate": 100,
      "ceil": 100,
    },
  ],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00"
}
Policy(
    id=1,
    name="policy01",
    classes=[
        Class(
            id="1",
            name="class01",
            order=2,
            priority_type="pfifo",
            priority=1,
            rate=100,
            ceil=100,
        ),
    ],
    created_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "policy01",
  classes: [
    {
      id: "1",
      name: "class01",
      order: 2,
      priorityType: "pfifo",
      priority: 1,
      rate: 100,
      ceil: 100
    }
  ],
  createdAt: "2017-10-05T15:20:02.000Z",
  updatedAt: "2017-11-05T15:20:02.000Z"
}

Buscar Política com Classes e Regras

API de busca completa da política do DBC contendo a listagem de classes e regras.

GET /api/dbc/policies/id/full

Exemplo de requisição

GET /api/dbc/policies/1/full HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dbc.get_full_policy(id=1)
print(response.payload)
const response = sdk.dbc.getFullPolicy({ id: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "name": "policy01",
  "classes": [
    {
      "id": "1",
      "name": "class01",
      "order": 2,
      "priority_type": "pfifo",
      "priority": 1,
      "rate": 100,
      "ceil": 100,
      "rules": [
        {
          "id": 1,
          "type": "ip",
          "addr_type": "network",
          "addr": "192.168.1.0/24",
          "protocol": null,
          "port_type": null,
          "port": null,
          "protocol": null,
          "src_addr_type": null,
          "src_addr": null,
          "dst_addr_type": null,
          "dst_addr": null,
          "src_port_type": null,
          "src_port": null,
          "dst_port_type": null,
          "dst_port": null,
        },
      ],
    },
  ],
  "createdAt": "2017-10-05T15:20:02.000Z",
  "updatedAt": "2017-11-05T15:20:02.000Z"
}
Policy(
    id=1,
    name="policy01",
    classes=[
        Class(
            id="1",
            name="class01",
            order=2,
            priority_type="pfifo",
            priority=1,
            rate=100,
            ceil=100,
            rules=[
                Rule(
                    id=1,
                    type="ip",
                    addr_type="network",
                    addr="192.168.1.0/24",
                    protocol=None,
                    port_type=None,
                    port=None,
                    protocol=None,
                    src_addr_type=None,
                    src_addr=None,
                    dst_addr_type=None,
                    dst_addr=None,
                    src_port_type=None,
                    src_port=None,
                    dst_port_type=None,
                    dst_port=None,
                ),
            ],
        ),
    ],
    created_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "policy01",
  classes: [
    {
      id: "1",
      name: "class01",
      order: 2,
      priorityType: "pfifo",
      priority: 1,
      rate: 100,
      ceil: 100,
      rules: [
        {
          id: 1,
          type: "ip",
          addrType: "network",
          addr: "192.168.1.0/24",
          protocol: null,
          portType: null,
          port: null,
          protocol: null,
          srcAddr_type: null,
          srcAddr: null,
          dstAddr_type: null,
          dstAddr: null,
          srcPortType: null,
          srcPort: null,
          dstPortType: null,
          dstPort: null,
        },
      ],
    },
  ],
  createdAt: "2017-10-05T15:20:02.000Z",
  updatedAt: "2017-11-05T15:20:02.000Z"
}

Cadastrar Política

API de cadastro de uma politica.

POST /api/dbc/policies

Exemplo de requisição

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

{
  "name": "policy01",
  "apply": false,
}
from itflex_sdk.dbc.types import CreatePolicyRequest

request = CreatePolicyRequest(
    name="policy01",
    apply=False,
)

response = sdk.dbc.create_policy(request)
print(response.payload)
const policy = sdk.dbc.types.Policy();
policy.name = "policy01";
policy.apply = false;

const response = sdk.dbc.createPolicy(policy);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "name": "policy01",
  "classes": [],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00",
}
Policy(
    id=1,
    name="policy01",
    classes=[],
    created_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTIme(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "policy01",
  classes: [],
  createdAt: "2017-10-05T15:20:02.000Z",
  updatedAt: "2017-11-05T15:20:02.000Z"
}

Editar Política

API de edição de uma política existente.

PUT /api/dbc/policies/id

Exemplo de requisição

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

{
  "name": "policy01_updated",
  "apply": false,
}
from itflex_sdk.dbc.types import UpdatePolicyRequest

request = UpdatePolicyRequest(
    id=1,
    name="policy01_updated",
    apply=False,
)

response = sdk.dbc.update_policy(request)
print(response.payload)
const policy = {
  id: 1,
  name: "policy01_updated",
  apply: false,
};
const response = sdk.dbc.updatePolicy(policy);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "name": "policy01_updated",
  "classes": [],
  "created_at": "2017-10-05T12:20:02.932000+00:00",
  "updated_at": "2017-11-05T12:20:02.932000+00:00",
}
Policy(
    id=1,
    name="policy01_updated",
    classes=[],
    created_at=DateTime(2017, 10, 5, 15, 20, 2, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2017, 11, 5, 15, 20, 2, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "policy01_updated",
  classes: [],
  createdAt: "2017-10-05T15:20:02.000Z",
  updatedAt: "2017-11-05T15:20:02.000Z"
}

Excluir Política

API de exclusão de uma política existente.

DELETE /api/dbc/policies/id

Exemplo de requisição

DELETE /api/dbc/policies/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.dbc.delete_policy(id=1)
const response = sdk.dbc.deletePolicy({ id: 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

Idendificador da política

Requisição

Políticas associadas com conexões não podem ser apagadas

Campo Descrição
id int

Idendificador da política

name stringrequired único

Nome da política

apply bool

Flag que indica se as informações serão provisionadas imediatamente após a criação ou edição

Valor padrão: False

Resposta

Campo Descrição
id int

Idendificador da política

name string

Nome da política

classes Array<Class>

Lista de classes da política.

A descrição dos campos do objeto Class pode ser encontrada nas documentações de:

created_at string

Data de criação

Formato: ISO-8601

updated_at string

Data da última edição

Formato: ISO-8601