Skip to main content

enterprise_ai.approvals

Source: sdks/python/src/enterprise_ai/approvals/__init__.py. Back to the Python SDK reference index.

note

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).

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier (UUID) of the approval request.
reasonstryesWhy 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).

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier (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).

NameTypeDefaultRequiredDescription
actionstryesAction to approve, 1 to 200 characters, for example tool.call, promotion, break_glass or mandate.
resource_typestryesType of the resource concerned, 1 to 100 characters, for example tool or model.
resource_idstr | NoneNonenoIdentifier of the resource concerned, optional.
reasonstr | NoneNonenoWhy the approval is requested, shown to the approvers (empty by default).
run_idstr | NoneNonenoAgent run waiting for the decision, optional. It resumes on approval and fails on refusal, expiry or cancellation.
idempotency_keystr | NoneNonenoIdempotency-Key header: a retry with the same key replays the first answer.
**extraAnynoExtra 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).

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier (UUID) of the approval request.
decisionstryesapprove or reject.
commentstr | NoneNonenoComment 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).

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier (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).

NameTypeDefaultRequiredDescription
statusstr | NoneNonenoOnly the requests in this status: pending, approved, rejected, expired or cancelled.
**pageAnynoPagination 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).

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier of the approval to watch.
timeoutfloat3600.0noMaximum wait in seconds (default 3600); past it approval_timeout is raised.
intervalfloat2.0noSeconds between two reads of the approval (default 2).
sleepAnytime.sleepnoFunction 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.

NameTypeDefaultRequiredDescription
approval_idstryesIdentifier of the approval to watch.
timeoutfloat3600.0noMaximum wait in seconds (default 3600); past it approval_timeout is raised.
intervalfloat2.0noSeconds 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.

NameTypeDefaultRequiredDescription
answerAnyyesAnswer of POST /v1/approvals/{id}/cancel to check.

Returns: Any. The same answer, unchanged; otherwise approval_cancel_unconfirmed is raised.

Raises: EaiError.