Skip to content

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

class

class AsyncCoreClient(_CoreEndpoints)

Async client: same methods, awaitable.

Fields

NameTypeDefaultDescription
base_url(base_url_ or base_url('core')).rstrip('/')
principalprincipal
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,
) -> None

stream_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) -> None

Source: packages/ump-sdk/src/ump_sdk/client.py, line 567

class

class CoreClient(_CoreEndpoints)

Sync client. principal sets X-UMP-Principal (e.g. user:maya.chen).

Fields

NameTypeDefaultDescription
base_url(base_url_ or base_url('core')).rstrip('/')
principalprincipal
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,
) -> None

as_principal method

def as_principal(self, principal: str) -> CoreClient

A 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) -> None

Source: packages/ump-sdk/src/ump_sdk/client.py, line 511

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

NameTypeDefaultDescription
problemproblem
statusproblem.status
codeproblem.code
urlurl
Methods and properties (1)

init constructor

ProblemError(self, problem: Problem, *, url: str | None = None) -> None

Source: packages/ump-sdk/src/ump_sdk/errors.py, line 14

NameTypeValueDescription
ENDPOINTSlist[tuple[str, str, str]][('POST', '/v1/clients', 'create_client'), ('GET', '/v1/clients', 'list_clien...
PRINCIPAL_HEADER'X-UMP-Principal'