SDK de Python para la plataforma NEZ (Networking Execution Zone)
Project description
NEZ Python SDK
SDK profesional en Python para interactuar con la plataforma NEZ.
Este proyecto no es un wrapper simple. Su objetivo es abstraer un backend legacy e inconsistente, traduciendo errores, estabilizando payloads y ofreciendo una API de uso clara para el desarrollador.
Que resuelve
- Uso de
access_tokencomo query param en todos los requests. - Traduccion de errores del backend a excepciones Python mas claras.
- Soporte para workflows manuales y workflows definidos por DSL.
- Reautenticacion automatica opcional contra el backend NEZ.
- Pruebas unitarias con
pytesty script integral de validacion.
Requisitos
- Python 3.10 o superior
- Instancia activa de NEZ
- Token valido o credenciales validas para autoauth
Instalacion
pip install -e ".[dev]"
Estructura
nez_sdk/
├── auto_auth.py
├── exceptions.py
├── http_client.py
├── nez.py
├── models/
├── services/
└── utils/
tests/
test_nez_sdk.py
configuration.cfg
Inicio rapido con token
from nez_sdk.nez import Nez
nez = Nez(
base_url="http://localhost:20510/api/v1",
token="tu_access_token"
)
nfrs = nez.nfrs.list()
print("NFRs disponibles:", len(nfrs))
Inicio rapido con autoautenticacion
from nez_sdk.nez import Nez
nez = Nez(base_url="http://localhost:20510/api/v1")
token = nez.authenticate(
user="tu_usuario_o_email",
password="tu_password",
use_gateway=False
)
print("Token obtenido:", token)
La autoautenticacion usa estos endpoints del backend NEZ:
POST /auth/api.php?type=6POST /APIGateway/API.php?type=20
Modelos principales
Los modelos actuales viven en:
nez_sdk.models.model_building_block.BuildingBlocknez_sdk.models.model_stage.Stagenez_sdk.models.model_workflow.Workflownez_sdk.models.model_nfr.NFR
Building Blocks
Crear
from nez_sdk.models.model_building_block import BuildingBlock
bb = BuildingBlock(
name="thumbnail-service",
image="registry.example.com/thumbnail:1.0",
command="python app.py",
description="Procesa imagenes",
port=8080
)
response = nez.buildingblocks.create(bb)
print(response)
Listar
buildingblocks = nez.buildingblocks.list()
for item in buildingblocks:
print(item.id, item.name, item.image)
Actualizar y eliminar
nez.buildingblocks.update("1", bb)
nez.buildingblocks.delete("1")
Nota: los endpoints existen y el SDK los ejecuta, pero el backend NEZ puede responder con 405 u otros errores segun la instancia.
Workflows
Crear workflow manual
from nez_sdk.models.model_stage import Stage
from nez_sdk.models.model_workflow import Workflow
stage = Stage("stage-procesamiento", [bb])
workflow = Workflow("workflow-demo", [stage])
workflow_id = nez.build(workflow)
print(workflow_id)
Endpoints disponibles
nez.workflows.list()
nez.workflows.get("1")
nez.workflows.update("1", workflow)
nez.workflows.delete("1")
nez.workflows.stages("1")
Workflows usando DSL
Puedes definir workflows en configuration.cfg y convertirlos a objetos Python con DSLParser.
Ejemplo
from nez_sdk.utils.dsl_parser import DSLParser
workflow = DSLParser.from_file("configuration.cfg")
print(workflow.name)
print(len(workflow.stages))
workflow_id = nez.build(workflow)
print(workflow_id)
Ejecucion
nez.execution.run("1", platform="docker")
nez.execution.execute("1", puzzle_name="default")
nez.execution.stop("1", puzzle_name="default")
nez.execution.log("1", name="default", folder="/tmp")
Tambien existe la fachada:
nez.execute("1")
Manejo de errores
Excepciones principales:
NezAPIErrorNezAuthErrorNezNotFoundErrorNezValidationErrorNezConnectionErrorNezResponseError
Ejemplo:
from nez_sdk.exceptions import NezAPIError
try:
nez.workflows.update("1", workflow)
except NezAPIError as exc:
print(exc)
Testing
Pruebas unitarias
pytest -q
Script integral/manual
python test_nez_sdk.py
El script test_nez_sdk.py muestra:
- modelos
- DSL
- autoauth
- NFRs
- building blocks
- workflows
- execution
- errores esperados
Demo
Puedes ejecutar el demo de uso general:
python demo_nez_sdk.py
Variables de entorno soportadas por demo_nez_sdk.py y test_nez_sdk.py:
NEZ_BASE_URLNEZ_TOKENNEZ_AUTH_USERNEZ_AUTH_PASSWORDNEZ_AUTH_USE_GATEWAY
Puedes partir de .env.example para configurar tu entorno local.
Documentacion
La documentacion del proyecto usa MkDocs + mkdocstrings.
Instalacion:
pip install -e ".[docs]"
Vista previa local:
mkdocs serve
Build:
mkdocs build --strict
El proyecto incluye un workflow de GitHub Actions para:
- validar y construir la documentacion en
feature/sdk-refactor - desplegar la documentacion en GitHub Pages desde
maino mediante ejecucion manual
Releases y publicacion
El proyecto incluye un workflow de GitHub Actions para:
- construir el paquete Python
- crear automaticamente un Release en GitHub
- publicar automaticamente en PyPI cuando se cree un tag de version
Flujo esperado:
git tag v1.0.1
git push origin v1.0.1
La publicacion en PyPI esta preparada para funcionar con Trusted Publishing usando la accion oficial pypa/gh-action-pypi-publish.
Estado actual
Este SDK ya cubre:
- endpoints documentados del PDF
- autoautenticacion
- traduccion robusta de errores
- pruebas unitarias con alta cobertura
La principal fuente de inestabilidad sigue siendo el backend NEZ, no la estructura base del SDK.
Autor
Desarrollado por Ricardo Prieto Ortega
Correo: prieto.ortega.20035@itsmante.edu.mx
GitHub: https://github.com/RicardoPrietoOrtega
LinkedIn: https://www.linkedin.com/in/ricardo-prieto-ortega/
Institucion: Instituto Tecnologico Superior de El Mante (TEC MANTE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nez_sdk-1.0.0.tar.gz.
File metadata
- Download URL: nez_sdk-1.0.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
593d83fe3f75bef9c50e737b104353e5004454a6597946a907db0cbdd234c8b2
|
|
| MD5 |
a7fc9dd023a01146a52ad34f3d22effe
|
|
| BLAKE2b-256 |
94679ccdd9dd0311422c938a10ec5fc7871004264bb13871609e9f1ecb21c3cf
|
Provenance
The following attestation bundles were made for nez_sdk-1.0.0.tar.gz:
Publisher:
publish.yml on jub-ecosystem/nez-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nez_sdk-1.0.0.tar.gz -
Subject digest:
593d83fe3f75bef9c50e737b104353e5004454a6597946a907db0cbdd234c8b2 - Sigstore transparency entry: 1205856368
- Sigstore integration time:
-
Permalink:
jub-ecosystem/nez-sdk@eda25e3fde593edbda84099b089b55b6d1fd5153 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/jub-ecosystem
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eda25e3fde593edbda84099b089b55b6d1fd5153 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nez_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nez_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89792e022203a4017428a97076ede4cce7f74aa8b4c7c1516fb9c7f4dd0f466a
|
|
| MD5 |
cf49c8dc18e17725ced2717dc2647a39
|
|
| BLAKE2b-256 |
2cf353b9600bee130caa8719f517216efad48d6211b69fc2ea7741b69d8d368f
|
Provenance
The following attestation bundles were made for nez_sdk-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on jub-ecosystem/nez-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nez_sdk-1.0.0-py3-none-any.whl -
Subject digest:
89792e022203a4017428a97076ede4cce7f74aa8b4c7c1516fb9c7f4dd0f466a - Sigstore transparency entry: 1205856396
- Sigstore integration time:
-
Permalink:
jub-ecosystem/nez-sdk@eda25e3fde593edbda84099b089b55b6d1fd5153 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/jub-ecosystem
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eda25e3fde593edbda84099b089b55b6d1fd5153 -
Trigger Event:
push
-
Statement type: