Skip to content

Commit

Permalink
chore: black format
Browse files Browse the repository at this point in the history
Signed-off-by: 35C4n0r <[email protected]>
  • Loading branch information
35C4n0r committed Nov 18, 2024
1 parent ceab51b commit e60b3f2
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions keep/providers/pagerduty_provider/pagerduty_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class PagerdutyProvider(BaseTopologyProvider, BaseIncidentProvider):
FINGERPRINT_FIELDS = ["alert_key"]

def __init__(
self, context_manager: ContextManager, provider_id: str, config: ProviderConfig
self, context_manager: ContextManager, provider_id: str, config: ProviderConfig
):
super().__init__(context_manager, provider_id, config)

Expand All @@ -164,7 +164,7 @@ def __init__(
self.logger.info("Refreshing access token")
self.__refresh_token()
elif (
self.authentication_config.api_key or self.authentication_config.routing_key
self.authentication_config.api_key or self.authentication_config.routing_key
):
# No need to do anything
return
Expand Down Expand Up @@ -206,9 +206,9 @@ def validate_config(self):
**self.config.authentication
)
if (
not self.authentication_config.routing_key
and not self.authentication_config.api_key
and not self.authentication_config.oauth_data
not self.authentication_config.routing_key
and not self.authentication_config.api_key
and not self.authentication_config.oauth_data
):
raise ProviderConfigException(
"PagerdutyProvider requires either routing_key or api_key or OAuth configuration",
Expand Down Expand Up @@ -334,13 +334,13 @@ def validate_scopes(self):
return scopes

def _build_alert(
self,
title: str,
alert_body: str,
dedup: str | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
source: str = "custom_event",
self,
title: str,
alert_body: str,
dedup: str | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
source: str = "custom_event",
) -> typing.Dict[str, typing.Any]:
"""
Builds the payload for an event alert.
Expand Down Expand Up @@ -392,13 +392,13 @@ def _build_alert(
}

def _send_alert(
self,
title: str,
body: str,
dedup: str | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
source: str = "custom_event",
self,
title: str,
body: str,
dedup: str | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
source: str = "custom_event",
):
"""
Sends PagerDuty Alert
Expand Down Expand Up @@ -426,12 +426,12 @@ def _send_alert(
return result.json()

def _trigger_incident(
self,
service_id: str,
title: str,
body: dict,
requester: str,
incident_key: str | None = None,
self,
service_id: str,
title: str,
body: dict,
requester: str,
incident_key: str | None = None,
):
"""Triggers an incident via the V2 REST API using sample data."""

Expand Down Expand Up @@ -464,11 +464,11 @@ def dispose(self):
pass

def setup_incident_webhook(
self,
tenant_id: str,
keep_api_url: str,
api_key: str,
setup_alerts: bool = True,
self,
tenant_id: str,
keep_api_url: str,
api_key: str,
setup_alerts: bool = True,
):
self.logger.info("Setting up Pagerduty webhook")

Expand Down Expand Up @@ -546,17 +546,17 @@ def setup_incident_webhook(
self.logger.info("Webhook created")

def _notify(
self,
title: str = "",
alert_body: str = "",
dedup: str = "",
service_id: str = "",
requester: str = "",
incident_id: str = "",
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
source: str = "custom_event",
**kwargs: dict,
self,
title: str = "",
alert_body: str = "",
dedup: str = "",
service_id: str = "",
requester: str = "",
incident_id: str = "",
event_type: typing.Literal["trigger", "acknowledge", "resolve"] | None = None,
severity: typing.Literal["critical", "error", "warning", "info"] | None = None,
source: str = "custom_event",
**kwargs: dict,
):
"""
Create a PagerDuty alert.
Expand Down Expand Up @@ -592,7 +592,7 @@ def _query(self, incident_id: str = None):
)

def _format_alert(
event: dict, provider_instance: "BaseProvider" = None
event: dict, provider_instance: "BaseProvider" = None
) -> AlertDto:
# If somebody connected the provider before we refactored it
old_format_event = event.get("event", {})
Expand Down Expand Up @@ -836,7 +836,7 @@ def _get_incident_id(incident_id: str) -> str:

@staticmethod
def _format_incident(
event: dict, provider_instance: "BaseProvider" = None
event: dict, provider_instance: "BaseProvider" = None
) -> IncidentDto | list[IncidentDto]:

event = event["event"]["data"]
Expand Down

0 comments on commit e60b3f2

Please sign in to comment.