feat: funciones Python para API Metabase
Añade módulo Python con funciones para la API de Metabase en dominio infra. Incluye cliente HTTP, auth, y CRUD de cards, dashboards y users. Proyecto gestionado con uv (pyproject.toml).
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
---
|
||||
name: metabase_auth
|
||||
kind: function
|
||||
lang: py
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "def metabase_auth(base_url: str, email: str, password: str) -> MetabaseClient"
|
||||
description: "Autentica contra la API de Metabase con email y password. Retorna un MetabaseClient con session token valido por 14 dias. Endpoint: POST /api/session."
|
||||
tags: [metabase, auth, session, api, python]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: [httpx]
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "python/functions/metabase/client.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
from functions.metabase import metabase_auth
|
||||
|
||||
client = metabase_auth("http://localhost:3000", "admin@example.com", "pass")
|
||||
# client listo para usar con todas las funciones CRUD
|
||||
|
||||
# Alternativa con API key:
|
||||
from functions.metabase import MetabaseClient
|
||||
client = MetabaseClient("http://localhost:3000", "mb_api_key_xxxxx")
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Dos formas de obtener un client:
|
||||
- `metabase_auth()`: login con email/password, obtiene session token via POST /api/session
|
||||
- `MetabaseClient(base_url, api_key)`: constructor directo con API key (recomendado para automatizacion)
|
||||
|
||||
El client es un context manager: `with metabase_auth(...) as client:`
|
||||
|
||||
Errores comunes:
|
||||
- 401: credenciales invalidas
|
||||
- Rate limiting en intentos fallidos de login
|
||||
Reference in New Issue
Block a user