This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 8871a9ef7b Add test_connection method to PagerdutyEventsHook (#31346)
8871a9ef7b is described below

commit 8871a9ef7b58b8bd84b8d12bc539ab6362a5ba29
Author: Utkarsh Sharma <[email protected]>
AuthorDate: Thu May 18 13:11:13 2023 +0530

    Add test_connection method to PagerdutyEventsHook (#31346)
    
    * Make PagerdutyEvents connections testable
---
 airflow/providers/pagerduty/hooks/pagerduty_events.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/airflow/providers/pagerduty/hooks/pagerduty_events.py 
b/airflow/providers/pagerduty/hooks/pagerduty_events.py
index 917e51a829..47a3094722 100644
--- a/airflow/providers/pagerduty/hooks/pagerduty_events.py
+++ b/airflow/providers/pagerduty/hooks/pagerduty_events.py
@@ -151,3 +151,11 @@ class PagerdutyEventsHook(BaseHook):
         resp = session.post("/v2/enqueue", json=data)
         resp.raise_for_status()
         return resp.json()
+
+    def test_connection(self):
+        try:
+            session = pdpyras.EventsAPISession(self.integration_key)
+            session.resolve("some_dedup_key_that_dont_exist")
+        except Exception:
+            return False, "connection test failed, invalid routing key"
+        return True, "connection tested successfully"

Reply via email to