ump_sdk.client
module ump-sdk
Typed httpx clients for ump-core (blueprint “ump-core API”).
CoreClient (sync) and AsyncCoreClient share one endpoint table (_CoreEndpoints): every
method returns self._call(...), which is a value for the sync client and a coroutine for the
async one (await client.list_clients()). Methods return decoded JSON (dicts/lists); validate
with ump_spec.models where you need types. Any status >= 400 raises ProblemError.
The core builder implements these paths exactly; ENDPOINTS lists them (also in CLAUDE.md).
Classes
Section titled “Classes”AsyncCoreClient
Section titled “AsyncCoreClient”class
class AsyncCoreClient(_CoreEndpoints)Async client: same methods, awaitable.
Fields
| Name | Type | Default | Description |
|---|---|---|---|
base_url | (base_url_ or base_url('core')).rstrip('/') | ||
principal | principal |
Methods and properties (4)
init constructor
AsyncCoreClient( self, base_url_: str | None = None, *, principal: str | None = None, timeout: float = 30.0, transport: httpx.AsyncBaseTransport | None = None, on_gate_fail: str | None = None,) -> Nonestream_events method
async def stream_events( self, path: str = '/v1/events/stream', **params: Any,) -> AsyncIterator[dict[str, Any]]Async SSE events {event, id, data}. data is already JSON-decoded to a dict (CloudEvent
or Job JSON), so do not json.loads it again; non-JSON data stays a string.
job_events method
def job_events(self, job_id: str) -> AsyncIterator[dict[str, Any]]aclose method
async def aclose(self) -> NoneSource: packages/ump-sdk/src/ump_sdk/client.py, line 567
CoreClient
Section titled “CoreClient”class
class CoreClient(_CoreEndpoints)Sync client. principal sets X-UMP-Principal (e.g. user:maya.chen).
Fields
| Name | Type | Default | Description |
|---|---|---|---|
base_url | (base_url_ or base_url('core')).rstrip('/') | ||
principal | principal |
Methods and properties (5)
init constructor
CoreClient( self, base_url_: str | None = None, *, principal: str | None = None, timeout: float = 30.0, transport: httpx.BaseTransport | None = None, on_gate_fail: str | None = None,) -> Noneas_principal method
def as_principal(self, principal: str) -> CoreClientA new client acting as another principal (same base URL and transport).
stream_events method
def stream_events( self, path: str = '/v1/events/stream', **params: Any,) -> Iterator[dict[str, Any]]Yield SSE events {event, id, data} until the server closes the stream. data is already
JSON-decoded (a dict for CloudEvents and job.updated), or the raw string if it is not JSON.
job_events method
def job_events(self, job_id: str) -> Iterator[dict[str, Any]]close method
def close(self) -> NoneSource: packages/ump-sdk/src/ump_sdk/client.py, line 511
ProblemError
Section titled “ProblemError”class
class ProblemError(Exception)Raised by the SDK clients for any HTTP status >= 400. problem is the parsed RFC 9457
body (or a synthesised one when the server did not send problem+json).
Fields
| Name | Type | Default | Description |
|---|---|---|---|
problem | problem | ||
status | problem.status | ||
code | problem.code | ||
url | url |
Methods and properties (1)
init constructor
ProblemError(self, problem: Problem, *, url: str | None = None) -> NoneSource: packages/ump-sdk/src/ump_sdk/errors.py, line 14
Constants
Section titled “Constants”| Name | Type | Value | Description |
|---|---|---|---|
ENDPOINTS | list[tuple[str, str, str]] | [('POST', '/v1/clients', 'create_client'), ('GET', '/v1/clients', 'list_clien... | |
PRINCIPAL_HEADER | 'X-UMP-Principal' |