Files
fn_registry/functions/infra/metabase_create_card.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

101 lines
2.9 KiB
Markdown

---
name: metabase_create_card
kind: function
lang: go
domain: infra
version: "1.0.0"
purity: impure
signature: "func MetabaseCreateCard(client MetabaseClient, name string, datasetQuery map[string]any, display string, collectionID int, description string) (map[string]any, error)"
description: "Crea una nueva card/pregunta en Metabase con query SQL nativa o MBQL. Endpoint: POST /api/card."
tags: [metabase, card, question, create, api, pendiente-usar]
uses_functions: []
uses_types: [MetabaseClient_go_infra]
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [fmt]
params:
- name: client
desc: "cliente MetabaseClient autenticado"
- name: name
desc: "nombre de la pregunta/card"
- name: datasetQuery
desc: "estructura de query SQL nativa o MBQL (structured query)"
- name: display
desc: "tipo de visualizacion (table, bar, line, pie, scalar, etc.)"
- name: collectionID
desc: "ID de la coleccion destino (0 = root collection)"
- name: description
desc: "descripcion de la pregunta o vacio"
output: "mapa con los detalles de la card creada incluyendo su ID"
tested: false
tests: []
test_file_path: ""
file_path: "functions/infra/metabase_create_card.go"
---
## Ejemplo
```go
// Crear pregunta con SQL nativo
card, err := MetabaseCreateCard(client, "Revenue by Month", map[string]any{
"database": 1,
"type": "native",
"native": map[string]any{
"query": "SELECT date_trunc('month', created_at) as month, SUM(total) as revenue FROM orders GROUP BY 1 ORDER BY 1",
},
}, "line", 5, "Monthly revenue trend")
// Crear pregunta con MBQL (structured query)
card, err := MetabaseCreateCard(client, "Order Count", map[string]any{
"database": 1,
"type": "query",
"query": map[string]any{
"source-table": 4,
"aggregation": []any{[]any{"count"}},
},
}, "scalar", 0, "Total number of orders")
```
## Notas
### Parametros para un LLM
| Parametro | Tipo | Requerido | Descripcion |
|-----------|------|-----------|-------------|
| client | MetabaseClient | si | Cliente autenticado |
| name | string | si | Nombre de la pregunta |
| datasetQuery | map[string]any | si | Query. Ver estructura abajo |
| display | string | si | Tipo de visualizacion |
| collectionID | int | no | ID de coleccion. 0 = root collection |
| description | string | no | Descripcion. Vacio = sin descripcion |
### Estructura de datasetQuery
**SQL nativo:**
```json
{
"database": <database_id>,
"type": "native",
"native": {"query": "SELECT ..."}
}
```
**MBQL (structured):**
```json
{
"database": <database_id>,
"type": "query",
"query": {
"source-table": <table_id>,
"aggregation": [["count"]],
"breakout": [["field", <field_id>, {"temporal-unit": "month"}]],
"filter": ["=", ["field", <field_id>, null], "value"]
}
}
```
### Valores de display
table, bar, line, pie, scalar, area, row, combo, funnel, map, scatter, waterfall, progress, gauge