---
name: metabase_get_collection_graph
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def metabase_get_collection_graph(client: MetabaseClient, namespace: str | None = None) -> dict"
description: "Obtiene el grafo de permisos de colecciones de Metabase. Endpoint: GET /api/collection/graph. Soporta namespace opcional para snippet collections. El campo revision es crítico para concurrency control en el PUT posterior."
tags: [metabase, permissions, collections, graph, access-control, api, python]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: client
    desc: "instancia autenticada de MetabaseClient con permisos de superusuario"
  - name: namespace
    desc: "namespace opcional: 'snippets' para snippet collections, None para colecciones regulares"
output: "dict: grafo con revision (int) y groups (group_id -> collection_id -> 'read' | 'write' | 'none'). El campo revision es obligatorio para el PUT."
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/metabase/permissions.py"
---

## Ejemplo

```python
# Colecciones regulares
graph = metabase_get_collection_graph(client)
print("revision:", graph["revision"])
for group_id, colls in graph["groups"].items():
    for coll_id, access in colls.items():
        print(f"group={group_id} collection={coll_id}: {access}")

# Snippet collections
snippet_graph = metabase_get_collection_graph(client, namespace="snippets")
```

## Notas

Siempre hacer GET fresco justo antes del PUT. El `revision` es el mecanismo de concurrency control nativo de Metabase — ver `metabase_update_collection_graph` para el patrón completo. Los niveles de acceso son `"read"`, `"write"` y `"none"`.
