9e6bea681f
Añade funciones Go stub para la API de Metabase en dominio infra: auth, CRUD de cards, dashboards y users, execute_query y execute_card. Incluye tipo MetabaseClient y helper HTTP compartido. Todas las funciones son impuras con stubs not-implemented.
51 lines
1.7 KiB
Markdown
51 lines
1.7 KiB
Markdown
---
|
|
name: metabase_auth
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: impure
|
|
signature: "func MetabaseAuth(baseURL, email, password string) (MetabaseClient, error)"
|
|
description: "Autentica contra la API de Metabase con email y password. Retorna un MetabaseClient con session token valido por 14 dias (configurable con MAX_SESSION_AGE en Metabase). Endpoint: POST /api/session."
|
|
tags: [metabase, auth, session, api]
|
|
uses_functions: []
|
|
uses_types: [MetabaseClient_go_infra]
|
|
returns: [MetabaseClient_go_infra]
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [bytes, encoding/json, fmt, io, net/http]
|
|
tested: false
|
|
tests: []
|
|
test_file_path: ""
|
|
file_path: "functions/infra/metabase_auth.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
// Autenticar con credenciales
|
|
client, err := MetabaseAuth("http://localhost:3000", "admin@example.com", "password123")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
// client.Token contiene el session token
|
|
|
|
// Alternativa: usar API key directamente
|
|
client := MetabaseNewClient("http://localhost:3000", "mb_api_key_xxxxx")
|
|
```
|
|
|
|
## Notas
|
|
|
|
Dos formas de obtener un MetabaseClient:
|
|
- `MetabaseAuth`: login con email/password, obtiene session token via POST /api/session. Token expira en 14 dias por defecto.
|
|
- `MetabaseNewClient`: usa una API key creada en el admin UI. No expira. Recomendado para automatizacion.
|
|
|
|
El token se envia como header `X-Metabase-Session` en todas las llamadas subsiguientes.
|
|
|
|
### Para un LLM que use estas funciones
|
|
|
|
1. Primero obtener un client con `MetabaseAuth()` o `MetabaseNewClient()`
|
|
2. Pasar el client a todas las funciones CRUD (usuarios, cards, dashboards)
|
|
3. Si recibes error 401, el token expiro — re-autenticar
|
|
4. Rate limiting: Metabase limita intentos de login fallidos
|