Skip to main content

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:

Metadata

Release files for sagace 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sagace 0.1.4
File Size Uploaded Provenance Actions
sagace-0.1.4.tar.gz 184.2 kB Without provenance Details for sagace-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sagace 0.1.4
File Interpreter ABI Platform Actions
sagace-0.1.4-py2.py3-none-any.whl Python 2, Python 3 none any Details for sagace-0.1.4-py2.py3-none-any.whl

Total release size: 221.3 kB

Release files / sagace-0.1.4.tar.gz

Download URL sagace-0.1.4.tar.gz
Size 184.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7fddc73b801601e54e1c81485fd64e127029770944d7c6f229670438e12f8843
BLAKE2b-256 checksum
How to use checksums
b30ff96571c1c5c8751c4cae092fdf9e0a14995779ab44445c2eae1ec281df1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / sagace-0.1.4-py2.py3-none-any.whl

Download URL sagace-0.1.4-py2.py3-none-any.whl
Size 37.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
778d2f20ce16f50aecbe6b78c6fbed14038804557772173b6afecdd20d3c0762
BLAKE2b-256 checksum
How to use checksums
79c0bd0467878899b0756bc9ea79a918a2507455f12a01e37c84419102c61d44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for sagace 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page