jedcunningham commented on code in PR #31290:
URL: https://github.com/apache/airflow/pull/31290#discussion_r1197093928
##########
airflow/providers/pagerduty/hooks/pagerduty_events.py:
##########
@@ -114,6 +115,13 @@ def create_event(
link's text.
:return: PagerDuty Events API v2 response.
"""
+ warnings.warn(
+ "This method will be deprecated. Please use the "
Review Comment:
```suggestion
"This method is deprecated. Please use "
```
##########
airflow/providers/pagerduty/hooks/pagerduty_events.py:
##########
@@ -151,3 +159,80 @@ def create_event(
resp = session.post("/v2/enqueue", json=data)
resp.raise_for_status()
return resp.json()
+
+ def send_event(
+ self,
+ summary: str,
+ severity: str,
+ source: str = "airflow",
+ action: str = "trigger",
+ dedup_key: str | None = None,
+ custom_details: Any | None = None,
+ group: str | None = None,
+ component: str | None = None,
+ class_type: str | None = None,
+ images: list[Any] | None = None,
+ links: list[Any] | None = None,
+ ) -> dict:
+ """
+ Create event for service integration.
+
+ :param summary: Summary for the event
+ :param severity: Severity for the event, needs to be one of: info,
warning, error, critical
+ :param source: Specific human-readable unique identifier, such as a
+ hostname, for the system having the problem.
+ :param action: Event action, needs to be one of: trigger, acknowledge,
+ resolve. Default to trigger if not specified.
+ :param dedup_key: A string which identifies the alert triggered for
the given event.
+ Required for the actions acknowledge and resolve.
+ :param custom_details: Free-form details from the event. Can be a
dictionary or a string.
+ If a dictionary is passed it will show up in PagerDuty as a table.
+ :param group: A cluster or grouping of sources. For example, sources
+ "prod-datapipe-02" and "prod-datapipe-03" might both be part of
"prod-datapipe"
+ :param component: The part or component of the affected system that is
broken.
+ :param class_type: The class/type of the event.
+ :param images: List of images to include. Each dictionary in the list
accepts the following keys:
+ `src`: The source (URL) of the image being attached to the
incident. This image must be served via
+ HTTPS.
+ `href`: [Optional] URL to make the image a clickable link.
+ `alt`: [Optional] Alternative text for the image.
+ :param links: List of links to include. Each dictionary in the list
accepts the following keys:
+ `href`: URL of the link to be attached.
+ `text`: [Optional] Plain text that describes the purpose of the
link, and can be used as the
+ link's text.
+ :return: PagerDuty Events API v2 response.
+ """
+ payload = {
Review Comment:
Instead of duplicating the whole construction of the payload, can you
refactor that part out into a common private function?
(Assuming I'm not overlooking some way they actually vary)
--
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]