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