Skip to content

AsyncWarmHubClient

Class: warmhub.AsyncWarmHubClient

AsyncWarmHubClient(*, api_url: str | Unset = UNSET, http_client: httpx.AsyncClient | Unset = UNSET, access_token: AccessTokenProvider | Unset = UNSET, auth: AuthProvider | Unset = UNSET, function_logs: str | Unset = UNSET, client: Mapping[str, str] | ClientIdentity | Unset = UNSET, client_flags: Sequence[str] | Unset = UNSET, **unknown_options: NoReturn)

Asynchronous WarmHub client.

The client owns an httpx connection pool, so it is closable:

async with AsyncWarmHubClient(access_token=token) as client:
...
client = AsyncWarmHubClient(access_token=token) # also valid
await client.aclose()

An httpx.AsyncClient passed as http_client= belongs to the caller and is never closed by the SDK.

from_env(*, api_url: str | Unset = UNSET, http_client: httpx.AsyncClient | Unset = UNSET, access_token: AccessTokenProvider | Unset = UNSET, auth: AuthProvider | Unset = UNSET, function_logs: str | Unset = UNSET, client: Mapping[str, str] | ClientIdentity | Unset = UNSET, client_flags: Sequence[str] | Unset = UNSET, **unknown_options: NoReturn)

Construct from WH_TOKEN and WARMHUB_API_URL.

Explicit keyword arguments win over the environment. The default constructor reads neither variable — see the module docstring for why that distinction is load-bearing rather than stylistic.

with_access_token(access_token: AccessTokenProvider)

A second client authenticating as access_token, on THIS pool.

Ports withAccessToken (packages/sdk-ts/src/index.ts:6569), which copies exactly five things onto the clone: the backend URL, the fetch implementation, the new token, the client identity, and the client flags — so a token-scoped clone of a CLI client keeps reporting warmhub-cli/… rather than reverting to the SDK default, and stays opted into whatever the parent declared. function_logs is NOT among them, in either language: a clone reverts to the default mode.

Pool ownership. The derived client SHARES this client’s httpx connection pool, through the same http_client= injection a caller would use. That sharing is the point of the method — the alternative, constructing a second client, opens a second pool. Three consequences follow, and they are the contract:

  • derived.owns_transport is False. The pool is borrowed.
  • await derived.aclose() does not close the pool. This client remains usable, and remains the owner.
  • Once THIS client closes a pool it owns, the derived client’s calls fail the way any client on a closed injected transport fails — a RuntimeError naming a closed client, per the registered deviation client.closed_is_runtime_error. Close the derived clones first, or keep the parent alive for as long as they are.

repository(locator: str)

Bind a repository handle to locator.

Accepts the slug the UI shows and the wref a previous read returned:

sensors = client.repository("acme/sensors")
sensors = client.repository("wh:acme/sensors/Reading/probe-1")

Anything else raises ValueError naming the input and both accepted forms. Deliberately not a WarmHubError: no request was made, so a caller’s except WarmHubError around a network call must not swallow what is a typo in a literal.

aclose()

Close the connection pool, if this client opened it.

subscription = AsyncSubscriptionNamespace(self._transport)

Documentation is not yet available.

api_url

Documentation is not yet available.

transport

Documentation is not yet available.

client_identity

Documentation is not yet available.

client_flags

Normalized client_flags, stamped on every request.

function_log_mode

Documentation is not yet available.

owns_transport

False when the caller injected an httpx.AsyncClient.

is_closed

Documentation is not yet available.

access

Documentation is not yet available.

action

Documentation is not yet available.

auth

Documentation is not yet available.

collection

Documentation is not yet available.

commit

Documentation is not yet available.

component

Documentation is not yet available.

credential

Documentation is not yet available.

diagnostics

Documentation is not yet available.

homepage

Documentation is not yet available.

org

Documentation is not yet available.

repo

Documentation is not yet available.

shape

Documentation is not yet available.

stream

Documentation is not yet available.

thing

Documentation is not yet available.

token

Documentation is not yet available.

view

Documentation is not yet available.