Esta é uma API de gerenciamento modelos de instâncias OpenVPN, ou seja, templates de configuração de instâncias.
API de listagem de modelos de instâncias paginados. Ver documentação de paginação.
GET /api/openvpn/instances/models
GET /api/openvpn/instances/models?cursor=0&size=15
Exemplo de requisição
GET /api/openvpn/instances/models HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.openvpn.types import GetInstanceModelsPageRequest
request = GetInstanceModelsPageRequest(cursor=0, size=15)
pages = sdk.openvpn.get_instance_models_pages(request)
const pages = sdk.openvpn.getInstanceModelsPages();
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},
"instance_models": [
{
"id": 1,
"name": "instance_model_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
"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 instance_model in page.instance_models:
print(instance_model)
# retornar os itens de todas as páginas
for instance_model in pages:
print(instance_model)
[
{
id: 1,
name: "instance_model_01",
template: "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
createdAt: "2017-10-05T15:20:02.000Z",
updatedAt: "2017-11-05T15:20:02.000Z"
}
];
API de busca de um modelo de instância existente.
GET /api/openvpn/instances/models/<id>
Exemplo de requisição
GET /api/openvpn/instances/models/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.openvpn.types import GetInstanceModelRequest
request = GetInstanceModelRequest(id=1)
response = sdk.openvpn.get_instance_model(request)
const response = sdk.openvpn.getInstanceModel({ id: 1 });
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "instance_model_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
"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.instance_model
{
id: 1,
name: "instance_model_01",
template: "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
createdAt: "2017-10-05T15:20:02.000Z",
updatedAt: "2017-11-05T15:20:02.000Z"
}
API de busca de um modelo de instância default.
O template retornado por esta API é utilizado no cadastro de instâncias OpenVPN caso o campo de referência do modelo de instância não seja informado. O template retornado por essa API também pode ser utilizado como base ao cadastrar um novo modelo de instância.
GET /api/openvpn/instances/models/default
Exemplo de requisição
GET /api/openvpn/instances/models/default HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.openvpn.get_default_instance_model()
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": null,
"name": "default",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
"created_at": null,
"updated_at": null,
}
if response.success:
return response.instance_model
API de cadastro de modelo de instância.
POST /api/openvpn/instances/models
Exemplo de requisição
POST /api/openvpn/instances/models HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"name": "instance_model_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
}
from itflex_sdk.openvpn.types import CreateInstanceModelRequest
request = CreateInstanceModelRequest(
name="instance_model_01",
template="local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
)
response = sdk.openvpn.create_instance_model(request)
const instanceModel = sdk.openvpn.types.InstanceModel();
instanceModel.name = "instance_model_01";
instanceModel.template = "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}";
const response = sdk.openvpn.createInstanceModel(instanceModel);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "instance_model_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
"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.instance_model
{
id: 1,
name: "instance_model_01",
template: "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
createdAt: "2017-10-05T15:20:02.000Z",
updatedAt: "2017-11-05T15:20:02.000Z"
}
API de edição de um modelo de instância existente.
PUT /api/openvpn/instances/models/<id>
Exemplo de requisição
PUT /api/openvpn/instances/models/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"name": "instance_model_updated_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
}
from itflex_sdk.openvpn.types import UpdateInstanceModelRequest
request = UpdateInstanceModelRequest(
id=1,
name="instance_model_01",
template="local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
)
response = sdk.openvpn.update_instance_model(request)
const instanceModel = {
id: 1,
name: "instance_model_updated_01",
template="local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
}
const response = sdk.openvpn.updateInstanceModel(instanceModel)
console.log(response.payload)
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "instance_model_updated_01",
"template": "local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
"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.instance_model
{
id: 1,
name: "instance_model_updated_01",
template="local 0.0.0.0\nport {{ port }}\nproto {{ proto }}",
}
API de exclusão de um modelo de instância existente.
DELETE /api/openvpn/instances/models/<id>
Exemplo de requisição
DELETE /api/openvpn/instances/models/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.openvpn.types import DeleteInstanceModelRequest
request = DeleteInstanceModelRequest(id=2)
response = sdk.openvpn.delete_instance_model(request)
const response = sdk.openvpn.deleteInstanceModel({ id: 2 });
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 | integer | Identificador do modelo de instância | |
name | string requerido |
Nome do modelo de instância | |
template | string requerido |
Template do modelo de instância |
Resposta
Parâmetro | Tipo | Descrição |
---|---|---|
id | integer | Identificador do modelo de instância |
name | string | Nome do modelo de instância |
template | string | Template do modelo de instância |
created_at | datetime | Data de criação |
updated_at | datetime | Data de edição |