5f4f1f7508
Añade campos params y output al frontmatter YAML de las 506 funciones del registry. Cada parámetro tiene descripción semántica (qué representa, unidades, rango típico) y cada función describe qué produce su output. Permite a agentes razonar sobre cadenas de composición (ej: prices → log_return → sharpe_ratio) sin leer código.
55 lines
1.6 KiB
Markdown
55 lines
1.6 KiB
Markdown
---
|
|
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]
|
|
params:
|
|
- name: base_url
|
|
desc: "URL base de Metabase (ej: http://localhost:3000)"
|
|
- name: email
|
|
desc: "correo del usuario para autenticar"
|
|
- name: password
|
|
desc: "contraseña del usuario"
|
|
output: "MetabaseClient: cliente autenticado con token válido por 14 días"
|
|
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
|