Projekt

Allgemein

Profil

Webhooks http extension » Historie » Revision 4

Revision 3 ([E] Axel S, 31.07.2024 11:38) → Revision 4/10 ([E] Axel S, 31.07.2024 11:38)

h1. Webhooks 

 * Ticket: https://redmine.prodat-sql.de/issues/20712 


 h2. Technische Voraussetzung 

 # Installation PostgreSQL HTTP Client https://github.com/pramsey/pgsql-http 
 #* Version für Windows x64 und PG13: !pg13http_w64.zip! 
 #* Weitere Versionen: http://www.postgresonline.com/journal/archives/371-http-extension.html 
 # Datenbank-Update ausführen 
 #* liegen auf prodat-demo-20.11 zu Projekt 20417: https://ci.prodat-sql.de/sources/dbupdates/edit/?server=demo2011&q=20417 


 h2. Verwendung: 

 * unsere eigenen Wrapperfunktionen verwenden: @TSystem.http_get_request(uri varchar, data json)@, ... TODO: bei Bedarf weitere erstellen 
 ** versuchen den HTTP-Request im Fehlerfall erneut 
 ** kümmern sich um den Pfad der vertauenswürdigen Root-CAs (Parameter @CURLOPT_CAINFO@) 
 ** versuchen den HTTP-Request im Fehlerfall erneut 


 h2. Konfiguration 

 * Webhooks werden werden über das tabellarische Modul Webhooks konfiguriert 
 {{collapse(Hauptmenü) 
 !clipboard-202312051021-nzwgt.png! 
 }} 
 * Jeder Eintrag führt zur Anlage eines Datenbank-Triggers der bei Ausführung einen HTTP-Request an die konfigurierte URL schickt. 
 * *Beispielkonfigurationen:* 
 |_. wh_name |_. wh_schema |_. wh_table |_. wh_timing |_. wh_event |_. wh_url |_. wh_data |_. wh_data_type | 
 | slack_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://hooks.slack.com/triggers/...... | <notextile>'{"Rechnungsnummer": "' || ($1).beld_dokunr || '"}'</notextile> | application/json | 
 | slack_webhook_bdepab | public | bdepab | AFTER | INSERT | https://hooks.slack.com/triggers/....... | <notextile>'{ 
   "mitarbeiter": "' || (SELECT nameAufloesen(ll_db_usename) FROM llv WHERE ($1).bdab_minr = ll_minr) || '", 
   "bdab_id"": "' || ($1).bdab_id || '", 
   "bdab_anf"": "' || ($1).bdab_anf || '", 
   "bdab_end"": "' || ($1).bdab_end || '", 
   "abw_grund"": "' || (SELECT ab_txt FROM bdeabgruende WHERE ($1).bdab_aus_id = ab_id) || '" 
 }'</notextile> | application/json | 
 | teams_webhook_eingrech | public | eingrechdokument | AFTER | INSERT | https://.....webhook.office.com/webhookb2/........ | <notextile>'{ 
    "type"":"message", 
    "attachments":[ 
       { 
          "contentType":"application/vnd.microsoft.card.adaptive", 
          "contentUrl":null, 
          "content":{ 
             "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", 
             "type"":"AdaptiveCard", 
             "version":"1.2", 
             "body":[ 
                 { 
                 "type": "TextBlock", 
                 "text": "neue Eingangsrechnung: ' || ($1).beld_dokunr || '" 
                 } 
             ] 
          } 
       } 
    ] 
 }'</notextile> | application/json |