Clientes Site2User

Esta é uma API de gerenciamento dos clientes OpenVPN Site2User.

Listar clientes

API de listagem de clientes paginados. Ver documentação de paginação.

GET /api/openvpn/clients/site2user
GET /api/openvpn/clients/site2user?cursor=0&size=15&name=client-s2u&instance_id=1&ca_id=1&status=valid

Exemplo de requisição

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

request = GetClientsSite2UserPageRequest(cursor=0, size=15)
pages = sdk.openvpn.get_clients_site2user_pages(request)
const pages = sdk.openvpn.getClientsSite2UserPages();
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},
  "clients": [
    {
      "id": 1,
      "ca_id": 1,
      "instance_id": 1,
      "name": "client-s2u",
      "email": "client_s2u@client.com.br",
      "description": "",
      "ip": "192.168.0.1",
      "push_routes": ["192.168.0.1/24"],
      "expiry_date": "2020-10-05T12:20:02.932000+00:00",
      "expired": false,
      "revoked": false,
      "conn_source_ip": "203.20.5.154",
      "conn_tunnel_ip": "192.168.1.5",
      "conn_status": "connected",
      "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 client in page.clients:
    print(client)

# retornar os itens de todas as páginas
for client in pages:
    print(client)
[
  {
    id: 1,
    caId: 1,
    instanceId: 1,
    name: "client-s2u",
    email: "client_s2u@client.com.br",
    description: "",
    ip: "192.168.0.1",
    pushRoutes: ["192.168.0.1/24"],
    expiryDate: "2020-10-05T12:20:02.932000+00:00",
    expired: false,
    revoked: false,
    connSourceIp: "203.20.5.154",
    connTunnelIp: "192.168.1.5",
    connStatus: "connected",
    createdAt: "2017-10-05T12:20:02.932000+00:00",
    updatedAt: "2017-11-05T12:20:02.932000+00:00"
  }
];

Buscar Cliente

API de busca de cliente.

GET /api/openvpn/clients/site2user/id

Exemplo de requisição

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

request = GetClientSite2UserRequest(id=1)
response = sdk.openvpn.get_client_site2user(request)
const response = await sdk.openvpn.getClientSite2User({ id: 1 });
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "ca_id": 1,
  "instance_id": 1,
  "name": "client-s2u",
  "email": "client_s2u@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.1/24"],
  "expiry_date": "2020-10-05T12:20:02.932000+00:00",
  "expired": false,
  "revoked": false,
  "conn_source_ip": "203.20.5.154",
  "conn_tunnel_ip": "192.168.1.5",
  "conn_status": "connected",
  "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.client
{
  id: 1,
  caId: 1,
  instanceId: 1,
  name: "client-s2u",
  email: "client_s2u@client.com.br",
  description: "",
  ip: "192.168.0.1",
  pushRoutes: ["192.168.0.1/24"],
  expiryDate: "2020-10-05T12:20:02.932000+00:00",
  expired: false,
  revoked: false,
  connSourceIp: "203.20.5.154",
  connTunnelIp: "192.168.1.5",
  connStatus: "connected",
  createdAt: "2017-10-05T12:20:02.932000+00:00",
  updatedAt: "2017-11-05T12:20:02.932000+00:00",
}

Cadastrar Cliente Site2User

API de cadastro de cliente Site2User.

POST /api/openvpn/clients/site2user

Exemplo de requisição

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

{
  "instance_id": 1,
  "name": "client-s2u",
  "email": "client_s2u@client.com.br",
  "password": "clients2upass",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.1/24"],
  "expiration": 500,
}
from itflex_sdk.openvpn.types import CreateClientSite2UserRequest

request = CreateClientSite2UserRequest(
    instance_id=1,
    name="client-s2u",
    email="client_s2u@client.com.br",
    password="clients2upass",
    description="",
    expiration=10,
    ip="192.168.0.1",
    push_routes=["192.168.0.1/24"],
)
response = sdk.openvpn.create_client_site2user(request)
const client = sdk.openvpn.types.ClientSite2User();
client.instanceId = 1;
client.name = "client-s2u";
client.email = "client_s2u@client.com.br";
client.password = "clients2upass";
client.description = "";
client.expiration = 30;
client.ip = "192.168.0.1";
client.pushRoutes = ["192.168.0.1/24"];

const response = await sdk.openvpn.createClientSite2User(client);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "ca_id": 1,
  "instance_id": 1,
  "name": "client-s2u",
  "email": "client_s2u@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.1/24"],
  "expiry_date": "2020-10-05T12:20:02.932000+00:00",
  "expired": false,
  "revoked": false,
  "conn_source_ip": null,
  "conn_tunnel_ip": null,
  "conn_status": null,
  "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.client
{
  id: 1,
  caId: 1,
  instanceId: 1,
  name: "client-s2u",
  email: "client_s2u@client.com.br",
  description: "",
  ip: "192.168.0.1",
  pushRoutes: ["192.168.0.1/24"],
  expiryDate: "2020-10-05T12:20:02.932000+00:00",
  expired: false,
  revoked: false,
  connSourceIp: null,
  connTunnelIp: null,
  connStatus: null,
  createdAt: "2017-10-05T12:20:02.932000+00:00",
  updatedAt: "2017-11-05T12:20:02.932000+00:00",
}

Editar Cliente Site2User

API de edição de cliente Site2User existente.

PUT /api/openvpn/clients/site2user/id

Exemplo de requisição

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

{
  "email": "client_s2u_updated@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.0/24"]
}
from itflex_sdk.openvpn.types import UpdateClientSite2UserRequest

request = UpdateClientSite2UserRequest(
    id=1,
    email="client_s2u_updated@client.com.br",
    description="",
    ip="192.168.0.1"
    push_routes=["192.168.0.0/24"]
)
response = sdk.openvpn.update_client_site2user(request)
const response = await sdk.openvpn.updateClientSite2User({
  id: 1,
  email: "client_s2u_updated@client.com.br",
  description: "",
  ip: "192.168.0.1",
  pushRoutes: ["192.168.0.0/24"]
});
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "ca_id": 1,
  "instance_id": 1,
  "name": "client-s2u",
  "email": "client_s2u_updated@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.1/24"],
  "expiry_date": "2020-10-05T12:20:02.932000+00:00",
  "expired": false,
  "revoked": false,
  "conn_source_ip": null,
  "conn_tunnel_ip": null,
  "conn_status": null,
  "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.client
{
  id: 1,
  caId: 1,
  instanceId: 1,
  name: "client-s2u",
  email: "client_s2u_updated@client.com.br",
  description: "",
  ip: "192.168.0.1",
  pushRoutes: ["192.168.0.1/24"],
  expiryDate: "2020-10-05T12:20:02.932000+00:00",
  expired: false,
  revoked: false,
  connSourceIp: null,
  connTunnelIp: null,
  connStatus: null,
  createdAt: "2017-10-05T12:20:02.932000+00:00",
  updatedAt: "2017-11-05T12:20:02.932000+00:00",
}

Revogar Cliente Site2User

API de revogação de cliente site2user.

DELETE /api/openvpn/clients/site2user/id

Exemplo de requisição

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

request = RevokeClientSite2UserRequest(id=2)
response = sdk.openvpn.revoke_client_site2user(request)
const response = sdk.openvpn.revokeClientSite2User({ id: 2 });
console.log(response);

Exemplo de resposta

HTTP/1.1 200 OK
Content-Type: application/json
return response.success

Importar Cliente Site2User

API de importação de cliente Site2User.

POST /api/openvpn/clients/site2user/import

Exemplo de requisição

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

{
  "instance_id": 1,
  "email": "client_s2u@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["10.5.0.0/16"],
  "key": "<key>",
  "cert": "<cert>",
  "revoked": true,
  "revoked_date": "2018-10-05T12:20:02Z",
}
from itflex_sdk.openvpn.types import ImportClientSite2UserRequest

request = ImportClientSite2UserRequest(
    instance_id=1,
    description="",
    ip="192.168.0.1",
    push_routes=["10.5.0.0/16"],
    key="<key>",
    cert="<cert>",
    revoked=True,
    revoked_date="2018-10-05T12:20:02Z",
)
response = sdk.openvpn.import_client_site2user(request)
const client = sdk.openvpn.types.ImportClientSite2User();
client.instanceId = 1;
client.description = "";
client.ip = "192.168.0.1";
client.pushRoutes = ["10.5.0.0/16"];
client.key = "<key>";
client.cert = "<cert>";
client.revoked = true;
client.revokedDate = "2018-10-05T12:20:02Z";

const response = await sdk.openvpn.importClientSite2User(client);
console.log(response.payload);

Exemplo de resposta

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

{
  "id": 1,
  "ca_id": 1,
  "instance_id": 1,
  "name": "client-s2u",
  "email": "client_s2u@client.com.br",
  "description": "",
  "ip": "192.168.0.1",
  "push_routes": ["192.168.0.1/24"],
  "expiry_date": "2020-10-05T12:20:02.932000+00:00",
  "expired": false,
  "revoked": false,
  "conn_source_ip": null,
  "conn_tunnel_ip": null,
  "conn_status": null,
  "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.client
{
  id: 1,
  caId: 1,
  instanceId: 1,
  name: "client-s2u",
  email: "client_s2u@client.com.br",
  description: "",
  ip: "192.168.0.1",
  pushRoutes: ["192.168.0.1/24"],
  expiryDate: "2020-10-05T12:20:02.932000+00:00",
  expired: false,
  revoked: false,
  connSourceIp: null,
  connTunnelIp: null,
  connStatus: null,
  createdAt: "2017-10-05T12:20:02.932000+00:00",
  updatedAt: "2017-11-05T12:20:02.932000+00:00",
}

Download certificado cliente OpenVPN Site2User

API de download do certificado com configuração de cliente OpenVPN Site2User.

GET /api/openvpn/downloads/client_id

Exemplo de requisição

GET /api/openvpn/downloads/1 HTTP/1.1
Host: api.exemplo.com
Authorization: Bearer <Access-Token>

HTTP/1.1 200 OK
content-type: application/zip

Formato dos dados

Parâmetros da url

Parâmetro Tipo Descrição
id integer Identificador do cliente
name string Nome do cliente
ca_id integer Identificador da CA
instance_id integer Identificador da instância
status string Estado do certificado do cliente
Valores possíveis:
valid: retorna somente os clientes com certificados SSL válidos, ou seja, os clientes com certificados que ainda não expiraram ou não foram revogados
expired: retorna somente os clientes com certificados SSL expirados
revoked: retorna somente os clientes com certificados SSL revogados

Obs: Ao dexar o campo status vazio, a API retorna a listagem de todos os clientes com certificados SSL, ou seja, clientes com certificados válidos, expirados e revogados.

Requisição

Parâmetro Tipo Valor Default Descrição
instance_id integer requerido Identificador da instância openvpn
name string requerido Nome do cliente.
Caracteres permitidos: A-Z a-z 0-9 - .
Tamanho máximo: 30
email string requerido Email do cliente
password string opcional Senha do certificado do cliente
description string Descrição do cliente
ip string Ip do cliente
push_routes list string Rotas do cliente
expiration int requirido Numero em dias de validade do cliente

Resposta

Parâmetro Tipo Descrição
id integer Identificador do Cliente
ca_id integer Identificador da CA openvpn
instance_id integer Identificador da instância openvpn
name string Nome do cliente
email string Email do cliente
description string Descrição do cliente
ip string Ip do cliente
push_routes list string Rotas do cliente
expiry_date string Data de expiração do cliente
revoked boolean Status de revogado do cliente
expired boolean Status de expirado do cliente
conn_source_ip string IP de origem da conexão do cliente openvpn
conn_tunnel_ip string IP do cliente openvpn na rede VPN do certificado
conn_status string Status da conexão openvpn
Valores possíveis: connected, disconnected
created_at datetime Data de criação
updated_at datetime Data de edição