Webhooks http extension » Historie » Version 9
[E] Axel S, 14.08.2024 11:33
1 | 9 | [E] Axel S | {{TOC}} |
---|---|---|---|
2 | |||
3 | 1 | [X] Philipp Wolak | h1. Webhooks |
4 | |||
5 | 8 | [E] Axel S | * Ticket: https://redmine.prodat-sql.de/issues/20417 |
6 | |||
7 | |||
8 | 2 | [E] Axel S | h2. Technische Voraussetzung |
9 | 5 | [E] Axel S | |
10 | * Ticket: https://redmine.prodat-sql.de/issues/20712 |
||
11 | 3 | [E] Axel S | |
12 | 7 | [E] Axel S | # Installation PostgreSQL HTTP Extension https://github.com/pramsey/pgsql-http |
13 | 1 | [X] Philipp Wolak | #* Version für Windows x64 und PG13: !pg13http_w64.zip! |
14 | #* Weitere Versionen: http://www.postgresonline.com/journal/archives/371-http-extension.html |
||
15 | # Datenbank-Update ausführen |
||
16 | #* https://ci.prodat-sql.de/sources/dbupdates/edit/?q=2024-01-17%2016:57:19 |
||
17 | 8 | [E] Axel S | |
18 | 3 | [E] Axel S | |
19 | h2. Verwendung: |
||
20 | |||
21 | * unsere eigenen Wrapperfunktionen verwenden: @TSystem.http_get_request(uri varchar, data json)@, ... TODO: bei Bedarf weitere erstellen |
||
22 | 1 | [X] Philipp Wolak | ** kümmern sich um den Pfad der vertauenswürdigen Root-CAs (Parameter @CURLOPT_CAINFO@) |
23 | 4 | [E] Axel S | ** versuchen den HTTP-Request im Fehlerfall erneut |
24 | 3 | [E] Axel S | |
25 | |||
26 | h2. Konfiguration |
||
27 | 1 | [X] Philipp Wolak | |
28 | * Webhooks werden werden über das tabellarische Modul Webhooks konfiguriert |
||
29 | {{collapse(Hauptmenü) |
||
30 | !clipboard-202312051021-nzwgt.png! |
||
31 | }} |
||
32 | * Jeder Eintrag führt zur Anlage eines Datenbank-Triggers der bei Ausführung einen HTTP-Request an die konfigurierte URL schickt. |
||
33 | * *Beispielkonfigurationen:* |
||
34 | |_. wh_name |_. wh_schema |_. wh_table |_. wh_timing |_. wh_event |_. wh_url |_. wh_data |_. wh_data_type | |
||
35 | | slack_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://hooks.slack.com/triggers/...... | <notextile>'{"Rechnungsnummer": "' || ($1).beld_dokunr || '"}'</notextile> | application/json | |
||
36 | | slack_webhook_bdepab | public | bdepab | AFTER | INSERT | https://hooks.slack.com/triggers/....... | <notextile>'{ |
||
37 | "mitarbeiter": "' || (SELECT nameAufloesen(ll_db_usename) FROM llv WHERE ($1).bdab_minr = ll_minr) || '", |
||
38 | "bdab_id"": "' || ($1).bdab_id || '", |
||
39 | "bdab_anf"": "' || ($1).bdab_anf || '", |
||
40 | "bdab_end"": "' || ($1).bdab_end || '", |
||
41 | "abw_grund"": "' || (SELECT ab_txt FROM bdeabgruende WHERE ($1).bdab_aus_id = ab_id) || '" |
||
42 | }'</notextile> | application/json | |
||
43 | | teams_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://.....webhook.office.com/webhookb2/........ | <notextile>'{ |
||
44 | "type"":"message", |
||
45 | "attachments":[ |
||
46 | { |
||
47 | "contentType":"application/vnd.microsoft.card.adaptive", |
||
48 | "contentUrl":null, |
||
49 | "content":{ |
||
50 | "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", |
||
51 | "type"":"AdaptiveCard", |
||
52 | "version":"1.2", |
||
53 | "body":[ |
||
54 | { |
||
55 | "type": "TextBlock", |
||
56 | "text": "neue Eingangsrechnung: ' || ($1).beld_dokunr || '" |
||
57 | } |
||
58 | ] |
||
59 | } |
||
60 | } |
||
61 | ] |
||
62 | }'</notextile> | application/json | |