Skip to main content

SAGACE Package - Auxiliary package for developing integrations with the SAGACE system.

Project description

SAGACE Python SDK

Latest Release pipeline status coverage report

Visão Geral

O SAGACE Python SDK é um SDK para interação com o sistema SAGACE, que fornece funcionalidades de autenticação, gerenciamento de tokens e comunicação com APIs REST.

Funcionalidades

  • Autenticação Segura: Implementação de autenticação via API.
  • Cliente API: Interface para envio de requisições HTTP.
  • Gerenciamento de Tokens: Armazenamento em memória, arquivo ou Redis.
  • Exceções Personalizadas: Tratamento de erros e falhas comuns.
  • Testes Automatizados: Cobertura de testes unitários para todas as funcionalidades principais.

Requisitos

Antes de instalar o SDK, certifique-se de que possui os seguintes requisitos:

  • Python 3.8+
  • pip atualizado
  • Redis (opcional, se for utilizar armazenamento de token via Redis)

Instalação

Para instalar a versão mais recente do SAGACE Python SDK, utilize:

pip install sagace-sdk

Se estiver instalando a partir do código-fonte:

git clone https://github.com/ampereconsultoria/sagace-python-sdk.git
cd sagace-python-sdk
pip install -r requirements.txt

Uso

Autenticação

Para autenticar e obter um token:

from sagace.auth.application.authentication_use_case import AuthenticationUseCase

auth_use_case = AuthenticationUseCase()
token = auth_use_case.authenticate("usuario", "senha")
print("Token obtido:", token)

Requisição para a API

Exemplo de requisição GET usando o APIClient:

from sagace.core.http_api_client import HttpApiClient

api = HttpApiClient(token)
response = api.get("/endpoint/desejado")
print(response.json())

Armazenamento de Token

O SDK permite armazenar tokens em diferentes formatos:

Memória

from sagace.core.storage.memory_storage import MemoryStorage

storage = MemoryStorage()
storage.save(token)
print("Token armazenado em memória!")

Arquivo

from sagace.core.storage.file_storage import FileStorage

storage = FileStorage("token.json")
storage.save(token)
print("Token salvo no arquivo token.json!")

Redis

from sagace.core.storage.redis_storage import RedisStorage

storage = RedisStorage()
storage.save(token)
print("Token armazenado no Redis!")

Estrutura do Projeto

sagace-sdk/
├── sagace/
│   ├── auth/
│   │   ├── application/
│   │   │   ├── authentication_use_case.py
│   │   ├── domain/
│   │   │   ├── authentication_repository.py
│   │   ├── infrastructure/
│   │   │   ├── authentication_api.py
│   │   ├── interfaces/
│   │       ├── authentication_service.py
│   ├── core/
│   │   ├── api_client.py
│   │   ├── http_api_client.py
│   │   ├── token.py
│   │   ├── token_storage.py
│   │   ├── storage/
│   │       ├── file_storage.py
│   │       ├── memory_storage.py
│   │       ├── redis_storage.py
│   ├── exceptions/
│   │   ├── application/
│   │   │   ├── application_error.py
│   │   ├── domain/
│   │   │   ├── api_request_error.py
│   │   │   ├── domain_error.py
│   │   │   ├── permission_denied_error.py
│   │   │   ├── token_expired_error.py
│   │   ├── infrastructure/
│   │   │   ├── authentication_error.py
│   │   │   ├── infrastructure_error.py
│   │   ├── interfaces/
│   │       ├── interface_error.py
│   ├── samples/
│   │   ├── basic_autentication.py
│
├── tests/               # Testes unitários
│   ├── auth/
│   │   ├── test_authentication_api.py
│   │   ├── test_authentication_use_case.py
│   ├── core/
│   │   ├── test_api_client.py
│   │   ├── test_http_api_client.py
│   │   ├── storage/
│   │       ├── test_file_storage.py
│   │       ├── test_memory_storage.py
│   │       ├── test_redis_storage.py
│   ├── exceptions/
│   │   ├── test_domain_exceptions.py
│   │   ├── test_infrastructure_exceptions.py
│
├── docs/                # Documentação Sphinx
│   ├── conf.py
├── setup.py             # Script de instalação do pacote
├── requirements.txt     # Dependências do projeto
├── README.md            # Documentação principal
├── LICENSE              # Licença do projeto

Testes

Para rodar os testes unitários:

pytest tests/

Contribuição

Se desejar contribuir para o projeto, siga os passos:

  1. Clone o repositório:
    git clone https://github.com/ampereconsultoria/sagace-python-sdk.git
    
  2. Crie um branch para sua contribuição:
    git checkout -b minha-contribuicao
    
  3. Implemente e documente suas mudanças.
  4. Execute os testes para garantir que tudo funciona corretamente.
  5. Crie um Pull Request para revisão.

Licença

Este projeto está licenciado sob a MIT License. Consulte o arquivo LICENSE para mais detalhes.

Contato

Para suporte e dúvidas:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sagace-0.1.4.tar.gz (184.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sagace-0.1.4-py2.py3-none-any.whl (37.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sagace-0.1.4.tar.gz.

File metadata

  • Download URL: sagace-0.1.4.tar.gz
  • Upload date:
  • Size: 184.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for sagace-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7fddc73b801601e54e1c81485fd64e127029770944d7c6f229670438e12f8843
MD5 991aed0bbc8765b4be5860a1e785a121
BLAKE2b-256 b30ff96571c1c5c8751c4cae092fdf9e0a14995779ab44445c2eae1ec281df1e

See more details on using hashes here.

File details

Details for the file sagace-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: sagace-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for sagace-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 778d2f20ce16f50aecbe6b78c6fbed14038804557772173b6afecdd20d3c0762
MD5 57d2d20ffe645554b49502d84204cc3a
BLAKE2b-256 79c0bd0467878899b0756bc9ea79a918a2507455f12a01e37c84419102c61d44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page