Files
fn_registry/functions/infra/metabase_create_card.md
T
egutierrez 9e6bea681f feat: funciones Go para API Metabase y tipo MetabaseClient
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.
2026-03-28 20:32:24 +01:00

2.4 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
metabase_create_card function go infra 1.0.0 impure func MetabaseCreateCard(client MetabaseClient, name string, datasetQuery map[string]any, display string, collectionID int, description string) (map[string]any, error) Crea una nueva card/pregunta en Metabase con query SQL nativa o MBQL. Endpoint: POST /api/card.
metabase
card
question
create
api
MetabaseClient_go_infra
false error_go_core
fmt
false
functions/infra/metabase_create_card.go

Ejemplo

// 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:

{
  "database": <database_id>,
  "type": "native",
  "native": {"query": "SELECT ..."}
}

MBQL (structured):

{
  "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