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