Apps¶
Apps¶
The /api/apps endpoint can be used for installing, deleting and listing apps. The app key is based on the app name, but with all non-alphanumerical characters removed, and spaces replaced with a dash. My app! will return the key My-app.
Note
Previous to 2.28, the app key was derived from the name of the ZIP archive, excluding the file extension. URLs using the old format should still return the correct app in the api.
/api/33/apps
Obtenha aplicativos¶
Note
Previous to 2.28 the app property folderName referred to the actual path of the installed app. With the ability to store apps on cloud services, folderName's purpose changed, and will now refer to the app key.
You can read the keys for apps by listing all apps from the apps resource and look for the key property. To list all installed apps in JSON:
curl -u user:pass -H "Accept: application/json" "http://server.com/api/33/apps"
Também pode simplesmente apontar seu navegador para o URL do recurso:
http://server.com/api/33/apps
The apps list can also be filtered by app type and by name, by appending one or more filter parameters to the URL:
http://server.com/api/33/apps?filter=appType:eq:DASHBOARD_APP&filter=name:ilike:youtube
App names support the eq and ilike filter operators, while appType supports eq only.
Instale um aplicativo¶
Para instalar um aplicativo, o seguinte comando pode ser emitido:
curl -X POST -u user:pass -F file=@app.zip "http://server.com/api/33/apps"
Excluir um aplicativo¶
Para excluir um aplicativo, pode emitir o seguinte comando:
curl -X DELETE -u user:pass "http://server.com/api/33/apps/<app-key>"
Recarregar aplicativos¶
To force a reload of currently installed apps, you can issue the following command. This is useful if you added a file manually directly to the file system, instead of uploading through the DHIS2 user interface.
curl -X PUT -u user:pass "http://server.com/api/33/apps"
Compartilhar aplicativos entre instâncias¶
If the DHIS2 instance has been configured to use cloud storage, apps will now be installed and stored on the cloud service. This will enable multiple instances share the same versions on installed apps, instead of installing the same apps on each individual instance.
Note
Previous to 2.28, installed apps would only be stored on the instance's local filesystem. Apps installed before 2.28 will still be available on the instance it was installed, but it will not be shared with other instances, as it's still located on the instances local filesystem.
Loja de aplicativos¶
The Web API exposes the content of the DHIS2 App Store as a JSON representation which can found at the /api/appHub resource.
/api/33/appHub
Obtenha aplicativos¶
Se pode recuperar aplicativos com uma solicitação GET:
GET /api/33/appHub
Um exemplo de resposta JSON é descrito abaixo.
{
[
{
"name": "Tabular Tracker Capture",
"description": "Tabular Tracker Capture is an app that makes you more effective.",
"sourceUrl": "https://github.com/dhis2/App-repository",
"appType": "DASHBOARD_WIDGET",
"status": "PENDING",
"id": "NSD06BVoV21",
"developer": {
"name": "DHIS",
"organisation": "Uio",
"address": "Oslo",
"email": "dhis@abc.com",
},
"versions": [
{
"id": "upAPqrVgwK6",
"version": "1.2",
"minDhisVersion": "2.17",
"maxDhisVersion": "2.20",
"downloadUrl": "https://dhis2.org/download/appstore/tabular-capture-12.zip",
"demoUrl": "http://play.dhis2.org/demo"
}
],
"images": [
{
"id": "upAPqrVgwK6",
"logo": "true",
"imageUrl": "https://dhis2.org/download/appstore/tabular-capture-12.png",
"description": "added feature snapshot",
"caption": "dialog",
}
]
}
]
}
Instale aplicativos¶
You can install apps on your instance of DHIS2 assuming you have the appropriate permissions. An app is referred to using the id property of the relevant version of the app. An app is installed with a POST request with the version id to the following resource:
POST/api/33/appHub/{app-version-id}