Projekt

Allgemein

Profil

Webhooks http extension » Historie » Version 3

[E] Axel S, 31.07.2024 11:38

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