potiuk commented on a change in pull request #18784:
URL: https://github.com/apache/airflow/pull/18784#discussion_r725610984
##########
File path: airflow/providers/pagerduty/hooks/pagerduty.py
##########
@@ -129,10 +147,114 @@ def create_event(
:return: PagerDuty Events API v2 response.
:rtype: dict
"""
- if routing_key is None:
- routing_key = self.routing_key
- if routing_key is None:
- raise AirflowException('No routing/integration key specified.')
+ warnings.warn(
+ "This method will be deprecated. Please use the "
+ "`airflow.providers.pagerduty.hooks.PagerdutyEventsHook` to
interact with the Events API",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+
+ routing_key = routing_key or self.routing_key
+
+ return PagerdutyEventsHook(integration_key=routing_key).create_event(
+ summary=summary,
+ severity=severity,
+ source=source,
+ action=action,
+ dedup_key=dedup_key,
+ custom_details=custom_details,
+ group=group,
+ component=component,
+ class_type=class_type,
+ images=images,
+ links=links,
+ )
+
+
+class PagerdutyEventsHook(BaseHook):
+ """
+ This class can be used to interact with the Pagerduty Events API.
+
+ It takes both an Events API token and a PagerDuty connection with the
Events API token
+ (i.e. Integration key) as the password/Pagerduty API token. If both
supplied, the token will be used.
+
+ :param integration_key: PagerDuty Events API token
+ :param pagerduty_conn_id: connection that has PagerDuty integration key in
the Pagerduty API token field
+ """
+
Review comment:
Should we create a separate "pagerduty_events" type of connection ?
Seems that those two different connection types have two different keys ? This
is perfectly fine to define second type of connection for the the new hook.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]