Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion providers/pagerduty/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ requires-python = "~=3.9"
dependencies = [
"apache-airflow>=2.10.0",
"apache-airflow-providers-common-compat>=1.6.1",
"pagerduty>=1.0.0",
"pagerduty>=2.3.0",
]

[dependency-groups]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,26 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
),
}

def __init__(self, token: str | None = None, pagerduty_conn_id: str | None = None) -> None:
def __init__(self, token: str = "", pagerduty_conn_id: str | None = None) -> None:
super().__init__()
self.routing_key = None
self._client = None
self.token = ""
self._client: pagerduty.RestApiV2Client | None = None

if pagerduty_conn_id is not None:
conn = self.get_connection(pagerduty_conn_id)
self.token = conn.get_password()
password = conn.get_password()
if password is not None:
self.token = password

routing_key = conn.extra_dejson.get("routing_key")
if routing_key:
self.routing_key = routing_key

if token is not None: # token takes higher priority
if token != "": # token takes higher priority
self.token = token

if self.token is None:
if self.token == "":
raise AirflowException("Cannot get token: No valid api token nor pagerduty_conn_id supplied.")

def client(self) -> pagerduty.RestApiV2Client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ def __init__(
self, integration_key: str | None = None, pagerduty_events_conn_id: str | None = None
) -> None:
super().__init__()
self.integration_key = None
self.integration_key = ""
self._client = None

if pagerduty_events_conn_id is not None:
conn = self.get_connection(pagerduty_events_conn_id)
self.integration_key = conn.get_password()
password = conn.get_password()
if password is not None:
self.integration_key = password

if integration_key is not None: # token takes higher priority
self.integration_key = integration_key

if self.integration_key is None:
if self.integration_key == "":
raise AirflowException(
"Cannot get token: No valid integration key nor pagerduty_events_conn_id supplied."
)
Expand All @@ -89,7 +91,7 @@ def send_event(
class_type: str | None = None,
images: list[Any] | None = None,
links: list[Any] | None = None,
) -> dict:
) -> str:
"""
Create event for service integration.

Expand Down Expand Up @@ -193,7 +195,7 @@ def create_change_event(
custom_details: Any | None = None,
timestamp: datetime | None = None,
links: list[Any] | None = None,
) -> dict:
) -> str:
"""
Create change event for service integration.

Expand Down