Data store — key/value accessor¶
Typed helper over DHIS2's namespaced key/value stores. Accessed via Dhis2Client.datastore.
DHIS2 has two stores with the same shape:
/api/dataStore— the instance/app store (shared, sharing-controlled). The default./api/userDataStore— the per-user store. Reach it by passinguser=Trueto any method.
(There is no /api/systemDataStore; instance-wide system config is systemSettings, exposed by
d2w system settings.)
Stored values are arbitrary user JSON — object, array, or scalar — so get returns Any and
set accepts Any. set is create-or-update: DHIS2 splits create (POST) from update (PUT), so
the accessor checks existence first and dispatches accordingly.
See also:
- CLI + MCP surface: d2w datastore (namespaces / keys / get / set / delete) and the
datastore_* tools.
datastore
¶
DHIS2 key-value store helpers — Dhis2Client.datastore.
Wraps DHIS2's two namespaced key/value stores:
/api/dataStore— the instance/app store (shared, sharing-controlled). The default./api/userDataStore— the per-user store. Reach it by passinguser=Trueto any method.
(There is no /api/systemDataStore; instance-wide system config is systemSettings, exposed by
d2w system settings.) Stored values are arbitrary user JSON — object, array, or scalar — so
reads return Any. set is create-or-update: DHIS2 splits create (POST) from update (PUT), so
this checks existence first and dispatches accordingly.
Classes¶
DatastoreAccessor
¶
Dhis2Client.datastore — namespaced key/value access over /api/dataStore + /api/userDataStore.
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
Functions¶
__init__(client)
¶
Bind to the sharing client — reuses its auth + HTTP pool for every request.
list_namespaces(*, user=False)
async
¶
List every namespace in the store.
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
list_keys(namespace, *, user=False)
async
¶
List every key in a namespace.
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
get(namespace, key, *, user=False)
async
¶
Return the value at namespace/key (opaque user JSON). Raises if the key is absent.
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
exists(namespace, key, *, user=False)
async
¶
Whether namespace/key exists (status check, no body parse).
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
set(namespace, key, value, *, user=False)
async
¶
Create or update namespace/key — POST when new, PUT when it already exists.
Source code in packages/dhis2w-client/src/dhis2w_client/v42/datastore.py
delete(namespace, key, *, user=False)
async
¶
Delete namespace/key. Raises if it doesn't exist.
delete_namespace(namespace, *, user=False)
async
¶
Delete an entire namespace and all its keys.