enterprise_ai.approvals
Source: sdks/python/src/enterprise_ai/approvals/__init__.py. Back to the Python SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class ApprovalsClient
/v1/approvals.
Resource
ApprovalsClient.cancel
cancel(approval_id: str, reason: str) -> Any
Cancel an approval request. Withdraws a pending request. Allowed to its requester, a tenant_admin or a security_officer (403 forbidden otherwise, the refusal being audited). The request ends cancelled and its subject reacts as to a refusal: a waiting run fails (approval_cancelled), a pending break glass grant or mandate is rejected. A request that is no longer pending answers 409 approval_closed. Writes the audit event approval.cancel with the reason. The answer carries run_state when a run is attached.
Route: /v1/approvals/{approval_id}/cancel (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier (UUID) of the approval request. | |
reason | str | yes | Why the request is withdrawn, 3 to 2000 characters. Written to the audit trail. |
Returns: Any. Decoded JSON answer of the operation "Cancel an approval request".
Raises: the typed errors of the transport (Errors).
ApprovalsClient.check
check(approval_id: str) -> Any
Get an approval request. Returns one approval request with its decisions (approver, decision, comment, date) and approvals_count. A pending request past its expiry is marked expired and its waiting run is failed. Open to any member of the tenant. Answers 404 approval_not_found.
Route: /v1/approvals/{approval_id} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier (UUID) of the approval request. |
Returns: Any. Decoded JSON answer of the operation "Get an approval request".
Raises: the typed errors of the transport (Errors).
ApprovalsClient.create
create(action: str, resource_type: str, resource_id: str | None = None, reason: str | None = None, run_id: str | None = None, idempotency_key: str | None = None, **extra: Any) -> Any
Request an approval. Creates a pending approval request. Needs tenant_admin, developer, agent, security_officer or finops.
Route: /v1/approvals (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
action | str | yes | Action to approve, 1 to 200 characters, for example tool.call, promotion, break_glass or mandate. | |
resource_type | str | yes | Type of the resource concerned, 1 to 100 characters, for example tool or model. | |
resource_id | str | None | None | no | Identifier of the resource concerned, optional. |
reason | str | None | None | no | Why the approval is requested, shown to the approvers (empty by default). |
run_id | str | None | None | no | Agent run waiting for the decision, optional. It resumes on approval and fails on refusal, expiry or cancellation. |
idempotency_key | str | None | None | no | Idempotency-Key header: a retry with the same key replays the first answer. |
**extra | Any | no | Extra fields merged into the request body. |
Returns: Any. Decoded JSON answer of the operation "Request an approval".
Raises: the typed errors of the transport (Errors).
ApprovalsClient.decide
decide(approval_id: str, decision: str, comment: str | None = None) -> Any
Approve or reject a request. Records the decision of the caller on a pending request.
Route: /v1/approvals/{approval_id}/decide (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier (UUID) of the approval request. | |
decision | str | yes | approve or reject. | |
comment | str | None | None | no | Comment kept with the decision (empty by default). |
Returns: Any. Decoded JSON answer of the operation "Approve or reject a request".
Raises: ValueError, the typed errors of the transport (Errors).
ApprovalsClient.get
get(approval_id: str) -> Any
Get an approval request. Returns one approval request with its decisions (approver, decision, comment, date) and approvals_count. A pending request past its expiry is marked expired and its waiting run is failed. Open to any member of the tenant. Answers 404 approval_not_found.
Route: /v1/approvals/{approval_id} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier (UUID) of the approval request. |
Returns: Any. Decoded JSON answer of the operation "Get an approval request".
Raises: the typed errors of the transport (Errors).
ApprovalsClient.list
list(status: str | None = None, **page: Any) -> Any
List the approval requests. Lists the approval requests of the tenant, newest first, paginated, optionally filtered by status. Pending requests past their expiry are marked expired first. Each item carries its decisions and approvals_count. Open to any member of the tenant.
Route: /v1/approvals (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
status | str | None | None | no | Only the requests in this status: pending, approved, rejected, expired or cancelled. |
**page | Any | no | Pagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor. |
Returns: Any. Decoded JSON answer of the operation "List the approval requests".
Raises: the typed errors of the transport (Errors).
ApprovalsClient.wait
wait(approval_id: str, timeout: float = 3600.0, interval: float = 2.0, sleep: Any = time.sleep) -> dict[str, Any]
Poll until the approval reaches a final state (sync client only).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier of the approval to watch. | |
timeout | float | 3600.0 | no | Maximum wait in seconds (default 3600); past it approval_timeout is raised. |
interval | float | 2.0 | no | Seconds between two reads of the approval (default 2). |
sleep | Any | time.sleep | no | Function called with interval between two reads (default time.sleep); replace it in tests. |
Returns: dict[str, Any]. The approval as read by get, once its status is approved, rejected, expired or cancelled.
Raises: EaiError, TypeError.
ApprovalsClient.wait_async
async wait_async(approval_id: str, timeout: float = 3600.0, interval: float = 2.0) -> dict[str, Any]
Async poll until the approval reaches a final state.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
approval_id | str | yes | Identifier of the approval to watch. | |
timeout | float | 3600.0 | no | Maximum wait in seconds (default 3600); past it approval_timeout is raised. |
interval | float | 2.0 | no | Seconds between two reads of the approval (default 2). |
Returns: dict[str, Any]. The approval once its status is approved, rejected, expired or cancelled.
Raises: EaiError.
Functions
confirm_cancelled
confirm_cancelled(answer: Any) -> Any
Return a cancelled approval only when the server reports the cancelled status.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
answer | Any | yes | Answer of POST /v1/approvals/{id}/cancel to check. |
Returns: Any. The same answer, unchanged; otherwise approval_cancel_unconfirmed is raised.
Raises: EaiError.