Clientes OpenVPN

Esta é uma API de gerenciamento de clientes OpenVPN.

Listar Clientes OpenVPN

API de listagem de clientes OpenVPN.

GET /api/networks/openvpn/clients

Exemplo de requisição

GET /api/networks/openvpn/clients HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.networks.get_openvpn_clients()
print(response.payload)
const resp = await sdk.networks.getOpenVPNClients();
console.log(resp.payload);

Exemplo de resposta

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

{
  "openvpn_clients": [
    {
      "id": 1,
      "name": "ovpn-client-test-vpn",
      "enabled": true,
      "protocol": "tcp",
      "remotes": [
        {
          "address": "192.168.0.211",
          "port": 8444
        },
        {
          "address": "myvpn.example.com",
          "port": 8444
        }
      ],
      "connection_state": "up",
      "created_at": "2018-10-01T12:20:02Z",
      "updated_at": "2018-10-01T12:20:02Z",
    },
    {
      "id": 2,
      "name": "ovpn-client-another-vpn",
      "enabled": false,
      "protocol": "udp",
      "remotes": [
        {
          "address": "myvpn.example.com",
          "port": 9123
        }
      ],
      "connection_state": "down",
      "created_at": "2018-10-02T08:35:22Z",
      "updated_at": "2018-10-02T08:35:22Z",
    },
  ],
}
[
    OpenvpnClient(
        id=1,
        name="ovpn-client-test-vpn",
        enabled=True,
        protocol="tcp",
        remotes=[
            Remote(
                address="192.168.0.211",
                port=8444
            ),
            Remote(
                address="myvpn.example.com",
                port=8444
            )
        ],
        created_at=DateTime(2018, 10, 1, 12, 20, 2, 585058, tzinfo=Timezone('+00:00')),
        updated_at=DateTime(2018, 10, 1, 12, 20, 2, 585058, tzinfo=Timezone('+00:00'))
    ),
    OpenvpnClient(
        id=2,
        name="ovpn-client-another-vpn",
        enabled=False,
        protocol="udp",
        remotes=[
            Remote(
                address="myvpn.example.com",
                port=9123
            )
        ],
        connection_state="down",
        created_at=DateTime(2018, 10, 2, 8, 35, 22, 585058, tzinfo=Timezone('+00:00')),
        updated_at=DateTime(2018, 10, 2, 8, 35, 22, 585058, tzinfo=Timezone('+00:00'))
    )
]
[
  {
    id: 1,
    name: "ovpn-client-test-vpn",
    enabled: true,
    protocol: "tcp",
    remotes: [
      {
        address: "192.168.0.211",
        port: 8444
      },
      {
        address: "myvpn.example.com",
        port: 8444
      }
    ],
    connectionState: "up",
    created_at: "2018-10-01T12:20:02Z",
    updated_at: "2018-10-01T12:20:02Z"
  },
  {
    id: 2,
    name: "ovpn-client-another-vpn",
    enabled: false,
    protocol: "udp",
    remotes: [
      {
        address: "myvpn.example.com",
        port: 9123
      }
    ],
    connectionState: "down",
    created_at: "2018-10-02T08:35:22Z",
    updated_at: "2018-10-02T08:35:22Z"
  }
];

Buscar Cliente OpenVPN

API de busca de um cliente OpenVPN.

GET /api/networks/openvpn/clients/id

Exemplo de requisição

GET /api/networks/openvpn/clients/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.networks.types import GetOpenVPNClientRequest

request = GetOpenVPNClientRequest(id=1)
response = sdk.networks.get_openvpn_client(request)
print(response.payload)
const response = await sdk.networks.getOpenVPNClient({ id: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "name": "ovpn-client-test-vpn",
  "enabled": true,
  "protocol": "tcp",
  "remotes": [
    {
      "address": "192.168.0.211",
      "port": 8444
    },
    {
      "address": "myvpn.example.com",
      "port": 8444
    }
  ],
  "connection_state": "up",
  "created_at": "2018-10-01T12:20:02.932000+00:00",
  "updated_at": "2018-10-01T12:20:02.932000+00:00",
}
OpenvpnClient(
    id=1,
    name="ovpn-client-test-vpn",
    enabled=True,
    protocol="tcp",
    remotes=[
        Remote(
            address="192.168.0.211",
            port=8444
        ),
        Remote(
            address="myvpn.example.com",
            port=8444
        )
    ],
    connection_state="up",
    created_at=DateTime(2018, 10, 1, 12, 20, 2, 585058, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2018, 10, 1, 12, 20, 2, 585058, tzinfo=Timezone('+00:00'))
)
{
  id: 1,
  name: "ovpn-client-test-vpn",
  enabled: true,
  protocol: "tcp",
  remotes: [
    {
      "address": "192.168.0.211",
      "port": 8444
    },
    {
      "address": "myvpn.example.com",
      "port": 8444
    }
  ],
  connectionState: "up",
  createdAt: "2018-10-01T12:20:02Z",
  updatedAt: "2018-10-01T12:20:02Z",
}

Cadastrar Cliente OpenVPN

API de cadastro de Cliente OpenVPN.

POST /api/networks/openvpn/clients

Exemplo de requisição

POST /api/networks/openvpn/clients HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "name": "ovpn-client-vpn-1",
  "enabled": true,
  "auth_type": "cert",
  "cert_password": "passclient123",
  "config_type": "files",
  "openvpn_config": "<normal openvpn config>",
  "openvpn_inline_config": "",
  "cert": "cert 000",
  "ca_cert": "ca cert 001",
  "key": "000key",
  "ta_key": "1a1b24",
}
from itflex_sdk.networks.types import CreateOpenVPNClientRequest

request = CreateOpenVPNClientRequest(
    name="ovpn-client-vpn-1",
    enabled=True,
    auth_type="cert",
    cert_password="passclient123",
    config_type="files",
    openvpn_config="<normal openvpn config>",
    openvpn_inline_config="",
    cert="cert 000",
    ca_cert="ca cert 001",
    key="000key",
    ta_key="1a1b24",
)
response = sdk.networks.create_openvpn_client(request)
print(response.payload)
const openvpnClient = sdk.networks.types.OpenVPNClient();
openvpnClient.name = "ovpn-client-vpn-1";
openvpnClient.enabled = true;
openvpnClient.authType = "cert";
openvpnClient.certPassword = "passclient123";
openvpnClient.configType: "files";
openvpnClient.openvpnConfig: "<normal openvpn config>";
openvpnClient.openvpnInlineConfig: "";
openvpnClient.cert = "cert 000";
openvpnClient.caCert = "ca cert 001";
openvpnClient.key = "000key";
openvpnClient.taKey = "1a1b24";

const response = await sdk.networks.createOpenVPNClient(openvpnClient);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 3,
  "name": "ovpn-client-vpn-1",
  "enabled": true,
  "protocol": "tcp",
  "remotes": [
    {
      "address": "200.189.10.23",
      "port": 10394
    },
  ],
  "created_at": "2018-10-01T17:52:23.932000+00:00",
  "updated_at": "2018-10-01T17:52:23.932000+00:00",
}
OpenvpnClient(
    id=2,
    name="ovpn-client-vpn-1",
    enabled=True,
    protocol="tcp",
    remotes=[
        Remote(
            address="200.189.10.23",
            port=10394
        )
    ],
    created_at=DateTime(2018, 10, 1, 17, 52, 23, 585058, tzinfo=Timezone('+00:00')),
    updated_at=DateTime(2018, 10, 1, 17, 52, 23, 585058, tzinfo=Timezone('+00:00'))
)
{
  id: 3,
  name: "ovpn-client-vpn-1",
  enabled: true,
  protocol: "tcp",
  remotes: [
    {
      "address": "200.189.10.23",
      "port": 10394
    }
  ],
  created_at: "2018-10-01T17:52:23.93Z",
  updated_at: "2018-10-01T17:52:23.93Z",
}

Deletar Cliente OpenVPN

API de remoção de Cliente OpenVPN.

DELETE /api/networks/openvpn/clients/id

Exemplo de requisição

DELETE /api/networks/openvpn/clients/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.networks.types import DeleteOpenVPNClientRequest

request = DeleteOpenVPNClientRequest(id=1)
response = sdk.networks.delete_openvpn_client(request)
const response = await sdk.networks.deleteOpenVPNClient({ id: 2 });

Exemplo de resposta

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

Habilitar ou Desabilitar Cliente OpenVPN

API para habilitar ou desabilitar conexão de Cliente OpenVPN.

PUT /api/networks/openvpn/clients/id/enabled

Exemplo de requisição

PUT /api/networks/openvpn/clients/1/autoconnect/enabled HTTP/1.1
Host: api.exemplo.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <Access-Token>

{
  "enabled": true
}
from itflex_sdk.networks.types import AutoConnectOpenvpnClientRequest

request = AutoConnectOpenvpnClientRequest(
    id=1,
    enabled=True
)
response = sdk.networks.enable_openvpn_client(request)
const response = await sdk.networks.enableOpenVPNClient({
  id: 1,
  enabled: true
});

Exemplo de resposta

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

Formato dos dados

Parâmetros da url

Campo Descrição
id integer

Identificador do cliente OpenVPN

Requisição

Campo Descrição
name stringrequired único

Nome atribuído à conexão

enabled bool

Flag se a conexão está habilitada.

auth_type stringrequired

Define o tipo de autenticação que a conexão vpn irá utilizar.

Valores possiveis:

  • client: a conexão possui autenticação via cliente
  • cert: a conexão possui autenticação via certificado
  • none: a conexão não possui autenticação via cliete ou certificado
username string

Nome de usuário do cliente vpn.

Requerido se o campo auth_type for client, senão é ignorado.

password string

Senha do cliente vpn.

Requerido se o campo auth_type for client, senão é ignorado.

cert_password string

Senha do certificado do cliente.

Requerido se o campo auth_type for cert, senão é ignorado.

config_type stringrequired

Tipo de configuração aplicada (arquivo único ou múltiplos arquivos)

Valores possíveis:

  • files
  • inline
openvpn_inline_config string

Arquivo único com configurações e certificados do cliente OpenVPN.

Requerido se o campo config_type for inline, senão é ignorado.

openvpn_config string

Arquivo de configurações do cliente OpenVPN.

Requerido se o campo config_type for files, senão é ignorado.

cert_ca string

Certificado SSL da CA do servidor que o cliente OpenVPN vai se conectar.

Requerido se o campo config_type for files e se o campo auth_type for cert.
Este campo é ignorado se o campo config_type for inline.

cert string

Certificado SSL do cliente OpenVPN.

Requerido se o campo config_type for files e se o campo auth_type for cert.
Este campo é ignorado se o campo config_type for inline.

key string

Chave privada do cliente OpenVPN.

Requerido se o campo config_type for files e se o campo auth_type for cert.
Este campo é ignorado se o campo config_type for inline.

ta_key string

Chave de autenticação TLS-Auth (TA) no servidor OpenVPN que o cliente vai se conectar.

Campo opcional, nem sempre é necessário a chave TLS-Auth.
Este campo é ignorado se o campo config_type for inline.

Resposta

Campo Descrição
id integer

Identificador do cliente OpenVPN

name string

Nome atribuído à conexão

enabled bool

Flag se a conexão está habilitada.

protocol string

Protocolo da conexão do cliente OpenVPN

remotes array<object>

Endereços de conexão do cliente OpenVPN

connection_state string

Status da conexão

created_at string

Data de criação

Formato: ISO-8601

updated_at string

Data da última edição

Formato: ISO-8601