Chelabase
ManagementTables

One role's privileges in a Postgres database

GET
/v1/databases/{id}/branches/{branch_id}/pg-databases/{name}/privileges

The privileges role holds in one Postgres database of a branch (one of the branch's recorded databases), read as the database owner, a page at a time. Without schema: the schemas (paged by name) with the role's schema entries, and the default privileges of those schemas. With schema: every table, view, materialized view, partitioned or foreign table, sequence, function and procedure of it (paged), with the role's entries on it and on its columns, the hub's "all rows" policy for the role, its owner and whether an owner run can act as that owner (owner_settable). Every entry carries its grantor and grant option. Each schema, object and default-privileges row carries acl_hash, a hash over its whole ACL (every grantee; a relation's covers its columns): send it back as expect_acl with a schema change. role=public reads PUBLIC's entries. Member logins and personal logins aren't listed.

Authorization

bearer
AuthorizationBearer <token>

In: header

Path Parameters

id*string

Database id

Formatuuid
branch_id*string

Branch id

Formatuuid
name*string

The Postgres database

Query Parameters

role?string

The grantee whose entries are read (required); public (lower case) reads PUBLIC's.

schema?string

The schema whose objects are listed; without it, the schema list and the default privileges.

after?string

The previous page's next_after.

limit?string

Objects (or schemas) per page, 1 to 500 (default 200).

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/v1/databases/497f6eca-6276-4993-bfeb-53cbbbba6f08/branches/497f6eca-6276-4993-bfeb-53cbbbba6f08/pg-databases/string/privileges"
{  "default_privileges": [    {      "acl_hash": "string",      "for_role": "string",      "grants": [        {          "grantable": true,          "grantee": "public",          "grantor": {            "name": "string",            "oid": 0          },          "privilege": "string"        }      ],      "object": "tables",      "schema": "string"    }  ],  "next_after": "string",  "objects": [    {      "acl_hash": "string",      "all_rows": {        "policy": "string"      },      "columns": [        {          "grants": [            {              "grantable": true,              "grantee": "public",              "grantor": {                "name": "string",                "oid": 0              },              "privilege": "string"            }          ],          "name": "string"        }      ],      "grants": [        {          "grantable": true,          "grantee": "public",          "grantor": {            "name": "string",            "oid": 0          },          "privilege": "string"        }      ],      "identity": "string",      "kind": "table",      "name": "string",      "oid": 0,      "owner": "string",      "owner_settable": true,      "rls_enabled": true,      "schema": "string"    }  ],  "offered": {    "function": [      "string"    ],    "schema": [      "string"    ],    "sequence": [      "string"    ],    "table": [      "string"    ]  },  "role": "string",  "schemas": [    {      "acl_hash": "string",      "grants": [        {          "grantable": true,          "grantee": "public",          "grantor": {            "name": "string",            "oid": 0          },          "privilege": "string"        }      ],      "name": "string",      "owner": "string",      "owner_settable": true    }  ],  "server_version_num": 0}

The database's tables, views and other relations GET

Every relation the table API shows in one Postgres database of a branch (system schemas and Chelabase's own objects left out), with its kind, estimated rows, size and whether the table API edits it (`editable`: ordinary tables only).

Change tables, columns, constraints, indexes, policies, grants and enums POST

Renders the operations to SQL (names quoted, expressions as given, each exactly one SQL expression) and runs them on one of the branch's Postgres databases as the owner (Admin only) or, with `role`, as that role (the SQL editor's session: your member role, then `SET ROLE`), in one transaction with `lock_timeout` (`lock_timeout_ms`, default 5000) and `statement_timeout` (60 s; 15 s for a dry run). A dry run runs the same statements and always rolls back; it evaluates your expressions (defaults, checks, `USING`), so their non-transactional side effects (e.g. `nextval`) remain. A statement that may rewrite a table over `CHELABASE_TABLE_API_DRY_RUN_MAX_BYTES` (default 256 MiB), and every one after it, is only rendered in a dry run (`skipped`), and then `would_succeed` is null. A table the request names that doesn't exist (and no earlier operation creates) is 404 with its `op_index`. Drops end `RESTRICT` and a request with drops returns `dependents`: what `CASCADE` would also remove beyond the request's own drop targets and their parts, and their `hash`. When something depends on a drop and the request confirms no cascade, the dry run and the real run alike answer 409 `has_dependents` with `dependents`, and change nothing. To cascade, send that hash as `cascade.dependents_hash`: the run (dry or real) locks the drop targets' tables, reads the dependents again, and refuses with 409 `dependents_changed` when they differ or when Postgres reports dropping anything but them and the parts of the request's other drop targets (drops that reach each other, e.g. a parent table and its child, need the hash of no dependents); a drop whose target an earlier drop of the request already removed is `skipped` (`already_dropped`). A `CONCURRENTLY` index operation must be the request's only operation: it runs outside a transaction (`statement_timeout` 900 s; a dry run only checks it), can't cascade, and when its build fails after creating its index, that INVALID index is dropped (another index of the same name never is). Postgres errors keep their fields (`op_index`, `sqlstate`, `message`, `detail`, `hint`, `position`; `dry_run: true` on a dry run). Each request is logged with its operation count, never its SQL.