Skip to main content

aip_sdk.APIClient

aip_sdk.APIClient(base_url: str | None = None, api_key: str | None = None, impersonate_user_id: str | None = None, token: str | None = None, workspace_id: str | None = None, *, user_id: str | None = None, _auto_login: bool = True)

Synchronous HTTP client for AIP v2 API.

Auth precedence: JWT Bearer token > x-api-key > unauthenticated. impersonate_user_id is not a credential — it is an admin-only override layered on top of whichever credential authenticates the call.

Parameters

  • base_url str | None: Base URL of the aip-api service.
  • api_key str | None: Long-lived API key, sent as x-api-key.
  • impersonate_user_id str | None: Admin-only override scoping calls to another user's data, sent as x-user-id. Ignored for non-admin credentials.
  • token str | None: Pre-obtained JWT. Short-lived, and never refreshed by this client.
  • workspace_id str | None: Default workspace for calls that take one.
  • user_id str | None: Deprecated alias for impersonate_user_id.

aip_sdk.APIClient.close​

aip_sdk.APIClient.close() -> None

Close the underlying HTTP connection pool.

aip_sdk.APIClient.delete​

aip_sdk.APIClient.delete(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

DELETE via request(); see it for scope/workspace and the other kwargs.

aip_sdk.APIClient.get​

aip_sdk.APIClient.get(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

GET via request(); see it for scope/workspace and the other kwargs.

aip_sdk.APIClient.get_bytes​

aip_sdk.APIClient.get_bytes(path: str, **kwargs: Any) -> bytes

Return a non-JSON GET response body as bytes.

aip_sdk.APIClient.is_closed​

aip_sdk.APIClient.is_closed: bool

Whether the underlying HTTP connection pool has been closed.

aip_sdk.APIClient.iter_bytes​

aip_sdk.APIClient.iter_bytes(method: str, path: str, *, json: dict[str, Any] | None = None, params: dict[str, Any] | None = None, files: dict[str, Any] | None = None, data: dict[str, Any] | None = None, headers: dict[str, str] | None = None, chunk_size: int | None = None) -> Iterator[bytes]

Stream an authenticated response body as bytes.

aip_sdk.APIClient.patch​

aip_sdk.APIClient.patch(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

PATCH via request(); see it for scope/workspace and the other kwargs.

aip_sdk.APIClient.post​

aip_sdk.APIClient.post(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

POST via request(); see it for scope/workspace and the other kwargs.

aip_sdk.APIClient.put​

aip_sdk.APIClient.put(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

PUT via request(); see it for scope/workspace and the other kwargs.

aip_sdk.APIClient.reopen​

aip_sdk.APIClient.reopen() -> None

Re-open the HTTP connection pool if it was previously closed.

A no-op when the client is already open. Auth is recomputed per request from self.config, so the revived client keeps the same credentials. Lets a module-level default client survive being closed by an owning with aip.run(...) block.

aip_sdk.APIClient.request​

aip_sdk.APIClient.request(method: str, path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, json: dict[str, Any] | None = None, params: dict[str, Any] | None = None, files: dict[str, Any] | None = None, data: dict[str, Any] | None = None, headers: dict[str, str] | None = None) -> Any

Make an authenticated request with automatic retry on transient failures.

Parameters

  • method str: The HTTP method, e.g. "GET".
  • path str: The request path, relative to the client's configured base_url.
  • scope WorkspaceScope | None: Which workspace-resolution mode this call declares, without saying where the resolved value goes — see WorkspaceScope. Resolved into a query parameter. Omitting it warns and resolves nothing; it will become required in a future release. get/post/patch/put/ delete default it to WorkspaceScope.NONE; that default goes away with this deprecation.
  • workspace WorkspaceRequest | ResolvedWorkspace | None: The full declaration — how to resolve the workspace and where to send it (see WorkspaceRequest). Pass this or scope, not both. Pass a ResolvedWorkspace to place an already-resolved value.
  • json dict[str, Any] | None: JSON request body.
  • params dict[str, Any] | None: Query string parameters.
  • files dict[str, Any] | None: Multipart file uploads.
  • data dict[str, Any] | None: Form-encoded request body.
  • headers dict[str, str] | None: Extra headers, merged over the client's own auth headers.

Returns

  • Any: The parsed JSON response body, or None for a 204 or empty body.

Raises

Inherited members​

Inherited from libs/aip-sdk/src/aip_sdk/client.py

aip_sdk.APIClient.config​

aip_sdk.APIClient.config = get_config(base_url=base_url, api_key=api_key, impersonate_user_id=impersonate_user_id, token=token, workspace_id=workspace_id)

No docstring is defined in the source.

Inherited from libs/aip-sdk/src/aip_sdk/client.py

aip_sdk.APIClient.resolve_workspace​

aip_sdk.APIClient.resolve_workspace(spec: WorkspaceRequest) -> ResolvedWorkspace

Resolve a workspace declaration now, before the request is made.

For a call that needs the resolved workspace in its own code — to name it in an error message, build a path from it, choose between two routes, or filter a response. Pass the result straight back as request(workspace=...): it is already resolved, so nothing resolves twice and the value sent cannot drift from the value used.

Parameters

Returns

Raises