exlab_wizard.lims.client#
Read-only LIMS client (Mapping B). Backend Spec §7.2.
The client wraps an httpx.AsyncClient to talk to the LIMS REST
API. Authentication is cookie-session per §7.2.5: login() POSTs the
operator’s email + password to /api/v1/login, the underlying
httpx client retains the session cookie, and subsequent reads
(list_projects, get_project, get_me) reuse it. On a 401
response from any of those reads, the client transparently re-runs
login() once before failing – the LIMS may have invalidated the
cookie out-of-band (server restart, session timeout) and a fresh login
recovers without surfacing a transient error to the caller.
The client is intentionally read-only. Per §7.2.8 the v1 LIMS write
surface is the empty set; the only mutating call is login and that
is auth bookkeeping, not project mutation.
Classes
|
Read-only LIMS client. |
- class exlab_wizard.lims.client.LIMSClient(*, endpoint, email, keyring_password_provider)[source]#
Bases:
objectRead-only LIMS client. Backend Spec §7.2 Mapping B.
Cookie-session auth:
login()establishes the session; subsequent list/get methods reuse the cookie. On 401, the client refreshes the cookie vialogin()once before failing.The
keyring_password_providercallable is invoked fromlogin()when no explicit password is passed. Callers wire this toexlab_wizard.lims.keyring_store.KeyringStore.get_passwordin production; tests can pass a lambda that returns a static value.- async get_project(uid_or_short_id)[source]#
GET /api/v1/projects/<id>; returns None on 404.uid_or_short_idmay be either a UUID (uidcolumn) or aPROJ-NNNNstring (short_idcolumn). The LIMS resolves both at the same endpoint.- Parameters:
uid_or_short_id (
str)- Return type:
- async health_check()[source]#
Return a
HealthStatussnapshot. Backend Spec §7.2.3.Calls
GET /api/v1/meand times the response. On any error (network, 4xx, 5xx) returnsok=Falsewith a short reason rather than raising – the Settings “Test connection” UX needs a value to render.- Return type:
- async list_projects(*, status_filter=None)[source]#
GET /api/v1/projects; returns one LIMSProject per row.status_filteris an optional list of allowed status values; rows whosestatusis not in the set are dropped on the client side. Filtering happens after deserialization so the wire format stays uniform.Wire envelope: upstream returns
{"data": [...], "count": N}; a missingdatakey is treated as an empty list rather than propagating aKeyErrorto the caller.- Parameters:
- Return type:
- async login(*, password=None)[source]#
POST
/api/v1/loginwith email + password.On success the underlying
httpx.AsyncClientretains the session cookie automatically; subsequent reads reuse it.Raises
exlab_wizard.errors.ConfigErrorwhen the keyring provider returns no password and none was supplied – that is a configuration condition, not a transient network failure.