Esta é uma API de gerenciamento de usuários.
API de listagem de usuários paginados. Ver documentação de paginação.
Exemplo de requisição
GET /api/users HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.auth.types import GetUsersPageRequest
request = GetUsersPageRequest(cursor=0, size=15)
pages = sdk.auth.get_users_pages(request)
const pages = sdk.auth.getUsersPages();
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},
"users": [
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
],
}
page = pages.next()
page = pages.previous()
# retornar os itens de uma página
for user in page.users:
print(user)
# retornar os itens de todas as páginas
for user in pages:
print(user)
[
{
id: 1,
username: "admin",
fullname: "Administrador",
email: "admin@email.com",
superuser: true,
roles: []
}
];
API de busca de um usuário existente.
id
Exemplo de requisição
GET /api/users/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.auth.types import GetUserRequest
request = GetUserRequest(id=1)
response = sdk.auth.get_user(request)
const response = await sdk.auth.getUser({ id: 1 });
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
if response.success:
return response.user
{
id: 1,
username: "admin",
fullname: "Administrador",
email: "admin@email.com",
superuser: true,
roles: [
{
id: 1,
name: "Users management",
scopes: []
},
]
}
API de busca de informações pessoais de um usuário autenticado na aplicação.
Exemplo de requisição
GET /api/user/info HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
response = sdk.auth.get_user_info(request)
const response = await sdk.auth.getUserInfo();
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
if response.success:
return response.user
{
id: 1,
username: "admin",
email: "admin@email.com",
fullname: "User Test",
superuser: false,
roles: [
{
id: 1,
name: "Users management",
scopes: []
},
],
}
API de cadastro de usuários.
Exemplo de requisição
POST /api/users HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test",
"password": "admin123",
"superuser": false,
"roles": [1],
}
from itflex_sdk.auth.types import CreateUserRequest
request = CreateUserRequest(
username="admin",
email="user@email.com",
fullname="User Test",
password="admin123",
superuser=False,
roles=[1],
)
response = sdk.auth.create_user(request)
const user = sdk.auth.types.User();
user.username = "docs";
user.email = "docs@mail.com";
user.fullname = "Docs Sample";
user.password = "hard_password";
user.superuser = false;
user.roles = [2];
const response = sdk.auth.createUser(user);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
if response.success:
return response.user
{
id: 2,
username: "docs",
email: "docs@mail.com",
fullname: "Docs Sample",
password: "hard_password",
superuser: false,
roles: [
{
id: 2,
name: "Docs role",
scopes: [{ name: "auth.users", read: true, write: true }]
}
]
}
API de edição de um usuário existente.
id
Exemplo de requisição
PUT /api/users/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"email": "admin@email.com",
"fullname": "User Test Updated",
"password": "admin123",
"superuser": false,
"roles": [1],
}
from itflex_sdk.auth.types import UpdateUserRequest
request = UpdateUserRequest(
id=1,
email="admin@email.com",
fullname="User Test Updated",
password="admin123",
superuser=False,
)
response = sdk.auth.update_user(request)
const user = {
id: 1,
username: "docs",
email: "docs@email.com",
fullname: "Docs Sample Edited",
password: "hard_password",
roles: [2]
};
const response = await sdk.auth.updateUser(user);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test Updated",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
if response.success:
return response.user
{
id: 2,
username: "docs",
email: "docs@email.com",
fullname: "Docs Sample Edited",
password: "hard_password",
superuser: false,
roles: [
{
id: 2,
name: "Docs role",
scopes: [{ name: "auth.users", read: true, write: true }]
}
]
}
API de edição de informações pessoais de um usuário autenticado na aplicação.
Exemplo de requisição
PUT /api/user/info HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
{
"fullname": "User Test Updated",
"current_password": "admin123",
"password": "admin123updated",
}
from itflex_sdk.auth.types import UpdateUserInfoRequest
request = UpdateUserInfoRequest(
fullname="User Test Updated",
current_password="admin123",
password="admin123updated",
)
response = sdk.auth.update_user_info(request)
const user = {
fullname: "User Test Updated",
currentPassword: "admin123",
password: "admin123updated",
};
const response = await sdk.auth.updateUserInfo(user);
console.log(response.payload);
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"username": "admin",
"email": "admin@email.com",
"fullname": "User Test Updated",
"superuser": false,
"roles": [
{
"id":1,
"name":"Users management",
},
],
}
if response.success:
return response.user
{
id: 1,
username: "admin",
email: "admin@email.com",
fullname: "User Test Updated",
superuser: false,
roles: [
{
id:1,
name:"Users management",
scopes: [{ name: "auth.users", read: true, write: true }]
},
],
}
API de exclusão de um usuário existente.
id
Exemplo de requisição
DELETE /api/users/1 HTTP/1.1
Host: api.exemplo.com
Accept: application/json
Authorization: Bearer <Access-Token>
from itflex_sdk.auth.types import DeleteUserRequest
request = DeleteUserRequest(id=1)
response = sdk.auth.delete_user(request)
const response = await sdk.auth.deleteUser({ id: 2 });
Exemplo de resposta
HTTP/1.1 200 OK
Content-Type: application/json
return response.success:
Parâmetros da url
Parâmetro | Tipo | Descrição |
---|---|---|
id | integer | Identificador do usuário |
Requisição
Parâmetro | Tipo | Valor Dafault | Descrição |
---|---|---|---|
id | integer | Identificador do usuário | |
fullname | stringrequerido | Nome completo do usuário | |
username | stringrequerido único | Nome de usuário | |
stringrequerido único | E-mail do usuário | ||
password | stringrequerido | Senha | |
superuser | boolean | False |
Flag que identidica se o usuário tem permissões de superusuário |
roles | Array<integer> | Identificadores dos perfils de permissões do usuário |
Resposta
Parâmetro | Tipo | Descrição |
---|---|---|
id | integer | Identificador do usuário |
fullname | string | Nome completo do usuário |
username | string | Nome de usuário |
string | E-mail do usuário | |
superuser | boolean | Flag que identidica se o usuário tem permissões de superusuário |
roles | Array<Role> | Perfils de permissões do usuário |