Apps¶
AppsAccessor on Dhis2Client.apps — install / uninstall / update DHIS2 apps via /api/apps and the configured App Hub (/api/appHub). The App model is generated from the OpenAPI schema; AppHubApp + AppHubVersion are thin wrappers with extra="allow" over the hub's proxied JSON, so new hub fields ride through without a codegen bump.
Typical flow:
client.apps.list_apps()— enumerate installed apps.client.apps.hub_list()— enumerate App Hub catalog.client.apps.install_from_hub(version_id)orinstall_from_file(path)to install.client.apps.uninstall(key)to remove.
For update orchestration (compare installed version to hub latest, install newer), see dhis2w_core.plugins.apps.service.update_all — also exposed as the dhis2 apps update --all CLI verb with a --dry-run preview mode.
apps
¶
DHIS2 apps + App Hub — /api/apps and /api/appHub.
Covers the installed-apps surface (list / install from zip / install from App
Hub / uninstall / reload-from-disk) plus read-only App Hub queries used by
the update verbs in the apps plugin.
Terminology:
- An installed app is a row DHIS2 returns from
GET /api/apps. Its identifier is the folder name (key); that's what the DELETE endpoint takes.app_hub_idon the installed record matches the App Hub's ownidso anupdateverb can locate the latest version. - An App Hub app is a catalog entry under
GET /api/appHub. Each has a list ofversions, each with a uniqueid(theversionIdthe install endpoint takes).
Classes¶
App
¶
Bases: BaseModel
OpenAPI schema App.
Source code in packages/dhis2w-client/src/dhis2w_client/generated/v42/oas/app.py
AppStatus
¶
Bases: StrEnum
AppStatus.
Source code in packages/dhis2w-client/src/dhis2w_client/generated/v42/oas/_enums.py
AppType
¶
AppHubVersion
¶
Bases: BaseModel
One version of an App Hub app — the install target for POST /api/appHub/{versionId}.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
AppSnapshotEntry
¶
Bases: BaseModel
One row of an AppsSnapshot — a single installed app captured for later restore.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
RestoreOutcome
¶
Bases: BaseModel
Per-app result of an apps.restore(snapshot) call.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
RestoreSummary
¶
Bases: BaseModel
Aggregate of apps.restore(...) — rows plus totals for the table footer.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
Attributes¶
restored
property
¶
Count of apps successfully installed from their snapshot version.
available
property
¶
Count of apps that would restore under dry_run=True.
up_to_date
property
¶
Count of apps already at the snapshot's version (no-op).
skipped
property
¶
Count of side-loaded entries with no hub version to restore from.
failed
property
¶
Count of install calls that raised.
AppsSnapshot
¶
Bases: BaseModel
Typed inventory of every installed app — portable across instances.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
AppHubApp
¶
Bases: BaseModel
One catalog entry from GET /api/appHub — the App Hub's view of an app.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
AppsAccessor
¶
Dhis2Client.apps — list / install / uninstall / reload + App Hub queries.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
Functions¶
__init__(client)
¶
list_apps()
async
¶
Return every installed app — GET /api/apps.
The response body is a bare JSON array (no envelope key), so
get_raw wraps it under "data" — unwrapping is a one-liner.
Every row becomes a typed App; extra fields DHIS2 tacks on in
minor versions ride through via model_config = extra="allow".
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
get(key)
async
¶
Find one installed app by key (folder name). Returns None if not installed.
install_from_file(path, *, filename=None)
async
¶
Upload an .zip to POST /api/apps — installs or updates in place.
DHIS2 accepts multipart/form-data with a single file field. On
success the endpoint returns 204 No Content (or a thin JSON body);
the caller then calls list() again to see the new row.
filename overrides the on-the-wire filename (defaults to the
local path's basename).
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
install_from_hub(version_id)
async
¶
Install a specific App Hub version — POST /api/appHub/{versionId}.
DHIS2 streams the app zip from the App Hub server-side, so the
local caller only supplies the versionId (usually a UUID the
App Hub hands out). On success the installed row is returned
from the next list() call.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
uninstall(key)
async
¶
Remove an installed app by key — DELETE /api/apps/{key}.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
reload()
async
¶
Re-read every app from disk — PUT /api/apps. No new versions are fetched.
hub_list(*, query=None)
async
¶
List every app in the configured App Hub — GET /api/appHub.
DHIS2 proxies this call to the App Hub server the instance is
pointed at (typically apps.dhis2.org, configurable via the
keyAppHubUrl system setting). The response is a JSON array of
hub-app records; each has a versions list whose id fields
are install targets for install_from_hub(version_id).
query applies a case-insensitive substring filter on name +
description after the full catalog lands — the App Hub proxy
doesn't expose a server-side query parameter in v42, so the
filter is client-side.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
snapshot()
async
¶
Capture an inventory of every installed app into a typed snapshot.
Each entry records the app's key, human name, installed
version, and — when the app was installed from the App Hub —
its app_hub_id plus the matching hub version_id +
download_url so the snapshot is sufficient to rehydrate the
same catalog on another instance via install_from_hub.
Apps without an app_hub_id (side-loaded zips uploaded via the
legacy UI or install_from_file) are captured too, but with
source="side-loaded" + no reinstall target. A restore step
would have to source those zips externally.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
restore(snapshot, *, dry_run=False)
async
¶
Reinstall every hub-backed entry in snapshot via install_from_hub.
For each entry:
- Side-loaded apps (no
hub_version_id) →SKIPPEDwith a reason. - App already installed at the same version →
UP_TO_DATE, no POST. dry_run=True+ install would happen →AVAILABLE, no POST.- Otherwise →
POST /api/appHub/{hub_version_id}, outcomeRESTOREDon 2xx orFAILEDwith the exception string.
The flip side of snapshot() — same data model, opposite
direction. Use to rehydrate a pinned app catalog on another
instance or recover a known-good state after an upgrade.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
get_hub_url()
async
¶
Return the configured App Hub URL (keyAppHubUrl system setting) or None if unset.
When None, DHIS2 falls back to its hard-coded default
(https://apps.dhis2.org/api on v42). The App Hub is open
source (https://github.com/dhis2/app-hub); self-hosters can
point their instance at a private catalog by setting this.
Source code in packages/dhis2w-client/src/dhis2w_client/apps.py
set_hub_url(url)
async
¶
Set the keyAppHubUrl system setting — points DHIS2 at a different App Hub.
Passing None clears the setting (server reverts to its
hard-coded default). Any HTTP call that hits /api/appHub on
this instance after this write uses the new URL.