Webhooks http extension » Historie » Version 2
[E] Axel S, 31.07.2024 10:40
| 1 | 1 | [X] Philipp Wolak | h1. Webhooks |
|---|---|---|---|
| 2 | |||
| 3 | 2 | [E] Axel S | * Ticket: https://redmine.prodat-sql.de/issues/20712 |
| 4 | |||
| 5 | 1 | [X] Philipp Wolak | *technische Voraussetzung:* |
| 6 | |||
| 7 | # Installation PostgreSQL HTTP Client https://github.com/pramsey/pgsql-http |
||
| 8 | #* Version für Windows x64 und PG13: !pg13http_w64.zip! |
||
| 9 | #* Weitere Versionen: http://www.postgresonline.com/journal/archives/371-http-extension.html |
||
| 10 | # Datenbank-Update ausführen |
||
| 11 | #* liegen auf prodat-demo-20.11 zu Projekt 20417: https://ci.prodat-sql.de/sources/dbupdates/edit/?server=demo2011&q=20417 |
||
| 12 | |||
| 13 | *Konfiguration* |
||
| 14 | |||
| 15 | * Webhooks werden werden über das tabellarische Modul Webhooks konfiguriert |
||
| 16 | {{collapse(Hauptmenü) |
||
| 17 | !clipboard-202312051021-nzwgt.png! |
||
| 18 | }} |
||
| 19 | * Jeder Eintrag führt zur Anlage eines Datenbank-Triggers der bei Ausführung einen HTTP-Request an die konfigurierte URL schickt. |
||
| 20 | * *Beispielkonfigurationen:* |
||
| 21 | |_. wh_name |_. wh_schema |_. wh_table |_. wh_timing |_. wh_event |_. wh_url |_. wh_data |_. wh_data_type | |
||
| 22 | | slack_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://hooks.slack.com/triggers/...... | <notextile>'{"Rechnungsnummer": "' || ($1).beld_dokunr || '"}'</notextile> | application/json | |
||
| 23 | | slack_webhook_bdepab | public | bdepab | AFTER | INSERT | https://hooks.slack.com/triggers/....... | <notextile>'{ |
||
| 24 | "mitarbeiter": "' || (SELECT nameAufloesen(ll_db_usename) FROM llv WHERE ($1).bdab_minr = ll_minr) || '", |
||
| 25 | "bdab_id"": "' || ($1).bdab_id || '", |
||
| 26 | "bdab_anf"": "' || ($1).bdab_anf || '", |
||
| 27 | "bdab_end"": "' || ($1).bdab_end || '", |
||
| 28 | "abw_grund"": "' || (SELECT ab_txt FROM bdeabgruende WHERE ($1).bdab_aus_id = ab_id) || '" |
||
| 29 | }'</notextile> | application/json | |
||
| 30 | | teams_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://.....webhook.office.com/webhookb2/........ | <notextile>'{ |
||
| 31 | "type"":"message", |
||
| 32 | "attachments":[ |
||
| 33 | { |
||
| 34 | "contentType":"application/vnd.microsoft.card.adaptive", |
||
| 35 | "contentUrl":null, |
||
| 36 | "content":{ |
||
| 37 | "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", |
||
| 38 | "type"":"AdaptiveCard", |
||
| 39 | "version":"1.2", |
||
| 40 | "body":[ |
||
| 41 | { |
||
| 42 | "type": "TextBlock", |
||
| 43 | "text": "neue Eingangsrechnung: ' || ($1).beld_dokunr || '" |
||
| 44 | } |
||
| 45 | ] |
||
| 46 | } |
||
| 47 | } |
||
| 48 | ] |
||
| 49 | }'</notextile> | application/json | |