Skip to content

Commit

Permalink
Add test_connection method to PagerdutyHook (#31344)
Browse files Browse the repository at this point in the history
* Add test_connection method to PagerdutyHook

* update the error message
  • Loading branch information
utkarsharma2 committed May 18, 2023
1 parent 8871a9e commit 8bce0ce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions airflow/providers/pagerduty/hooks/pagerduty.py
Expand Up @@ -159,3 +159,11 @@ def create_event(
images=images,
links=links,
)

def test_connection(self):
try:
session = pdpyras.APISession(self.token)
session.list_all("services", params={"query": "some_non_existing_service"})
except Exception:
return False, "connection test failed, invalid token"
return True, "connection tested successfully"

0 comments on commit 8bce0ce

Please sign in to comment.