GuidoTournois commented on a change in pull request #18784:
URL: https://github.com/apache/airflow/pull/18784#discussion_r725858114



##########
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:
       Thanks for the feedback! Yes indeed, the two different hook required 
different types of api keys. 
   
   I think we have a few options:
   
   - keep it as is (probably causes some confusion to airflow users).
   - a single connection type with two separate fields for the two tokens. The 
password field can be renamed as one token, and we can either rename an 
existing field or use an extra field for the other token. However, in that case 
only one of the tokens would behave as a password (as is automatically hidden 
from logs). Thinking about it, that is the current situation as well with the 
routing_key in the extra field.
   - two separate connection types as you mentioned.
   
   I think I would agree with you. Better to be explicit and have both token be 
hidden from logs.
   
   




-- 
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]


Reply via email to