EventHook API and schemas #337
Unanswered
mortenoh
asked this question in
Specs & RFCs
Replies: 1 comment 3 replies
-
|
How would this work for SMS events? For example, I want to fire a webhook call when a message is POSTed to |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Event Hooks DHIS2-12194
Event hooks represent a way to have external system react to what's happening inside of DHIS2. We are currently at a very early stage but it does now work for
metadatapaths which is the focus for our 2.40 release. All payloads/schemas download should be considered experimental and be changed before release.EventHookschemaidnameenabledtrue)source.path<main-type>.<sub-type>.<id>for examplemetadata.organisationUnit.bRNvL6NMQXbsource.fieldstargetswebhookTargetHook that does at
POSTwith json payload to an external service.typewebhookurlPOSTwil be made here with the event payload)headersauthAuthorizationheader with supplied auth type (see below forapi-tokenandhttp-basicexamplesconsoleTargetSimple console logger using
log.info(event)with the json payload.typeconsoleEventHookpayload examplesEventHookwith*field filter listening onmetadata.*changes. Target iswebhookwithapi-tokenauth type.{ "id": "bRNvL6NMQXb", "name": "hook1", "enabled": true, "source": { "path": "metadata", "fields": "*" }, "targets": [ { "type": "webhook", "url": "http://localhost:8081/api/gateway", "auth": { "type": "api-token", "token": "EB3F6799-AA5A-47E8-B6B7-97EA54EB3873" } } ] }EventHookwith*field filter listening onmetadata.*changes. Target iswebhookwithhttp-basicauth type.{ "id": "bRNvL6NMQXb", "name": "hook1", "enabled": true, "source": { "path": "metadata", "fields": "*" }, "targets": [ { "type": "webhook", "url": "http://localhost:8081/api/gateway", "auth": { "type": "http-basic", "username": "admin", "password": "admin" } } ] }EventschemaThis represent the current
Eventschema that is sent out for every published event. Focus and examples are on metadata (but the general idea should apply everywhere)Given a event hook that listens on
metadataand has the fieldsid,nameapplied a an example event payload currently looks like this.{ "path": "metadata.organisationUnit.tXjhduKKhY5", "createdAt": "2022-12-21T12:22:46.606308+07:00", "meta": { "op": "create" }, "object": { "name": "Country", "id": "tXjhduKKhY5" } }pathidif applicable to typecreatedAtmetaMap<>). For metadata its currently used to tell what type of operation occuredcreateupdatedeletebut what exactly else should be there, or if there is a better way of doing this is up to debateobjectOrganisationUnitso this is that object with field filtering applied (in the same way you would get this if you did/api/organisationUnits/ID?fields=id,name)Beta Was this translation helpful? Give feedback.
All reactions