Files
fn_registry/functions/infra/metabase_update_dashboard.md
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

3.8 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, 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 params output tested tests test_file_path file_path
metabase_update_dashboard function go infra 1.0.0 impure func MetabaseUpdateDashboard(client MetabaseClient, dashboardID int, fields map[string]any) (map[string]any, error) Actualiza un dashboard en Metabase incluyendo metadata, cards y tabs. El campo dashcards representa el estado completo deseado: cards nuevas con ID negativo, existentes con ID positivo, omitidas se eliminan. Endpoint: PUT /api/dashboard/:id.
metabase
dashboard
update
cards
api
pendiente-usar
MetabaseClient_go_infra
false error_go_core
fmt
name desc
client cliente MetabaseClient autenticado
name desc
dashboardID ID del dashboard a actualizar
name desc
fields mapa con campos a modificar (name, description, dashcards, tabs, archived, etc.)
mapa con los detalles del dashboard actualizado false
functions/infra/metabase_update_dashboard.go

Ejemplo

// Cambiar nombre
MetabaseUpdateDashboard(client, 1, map[string]any{
    "name": "Updated Dashboard",
})

// Agregar una card al dashboard
// Primero obtener las dashcards existentes
dash, _ := MetabaseGetDashboard(client, 1)
existingCards := dash["dashcards"].([]any)

// Construir nuevo array con las existentes + la nueva
dashcards := make([]map[string]any, 0)
for _, dc := range existingCards {
    dashcards = append(dashcards, dc.(map[string]any))
}
// Agregar nueva card (ID negativo = nueva)
dashcards = append(dashcards, map[string]any{
    "id": -1, "card_id": 55, "size_x": 6, "size_y": 4, "col": 0, "row": 0,
})

MetabaseUpdateDashboard(client, 1, map[string]any{
    "dashcards": dashcards,
})

// Archivar dashboard (soft-delete)
MetabaseUpdateDashboard(client, 1, map[string]any{"archived": true})

Notas

Gestion de dashcards (IMPORTANTE)

El array dashcards representa el estado completo deseado del dashboard:

Accion Como hacerlo
Agregar card Incluir con ID negativo (-1, -2, etc.)
Actualizar card Incluir con su ID positivo existente
Eliminar card Omitir del array
No cambiar cards No incluir el campo dashcards

Flujo tipico para agregar una card:

  1. MetabaseGetDashboard para obtener dashcards existentes
  2. Copiar las existentes al nuevo array
  3. Agregar la nueva con ID negativo
  4. Enviar el array completo

Estructura de una dashcard

map[string]any{
    "id":                      -1,              // negativo = nueva, positivo = existente
    "card_id":                 42,              // ID de la card/pregunta
    "size_x":                  6,               // ancho (1-18)
    "size_y":                  4,               // alto
    "col":                     0,               // columna (0-based)
    "row":                     0,               // fila (0-based)
    "dashboard_tab_id":        nil,             // tab (nil = sin tabs)
    "parameter_mappings":      []map[string]any{}, // mapeo de filtros
    "visualization_settings":  map[string]any{},   // settings custom
}

Gestion de tabs

map[string]any{
    "tabs": []map[string]any{
        {"id": 1, "name": "Overview"},           // tab existente
        {"id": -1, "name": "Details"},           // tab nuevo (ID negativo)
    },
}

Campos actualizables

Campo Tipo Descripcion
name string Nombre del dashboard
description string Descripcion
archived bool Archivar/desarchivar
dashcards []map Estado completo de cards
tabs []map Tabs del dashboard
parameters []map Filtros del dashboard
collection_id int Mover a otra coleccion