You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/05/04 03:18:23 UTC
[GitHub] [airflow] josh-fell commented on a diff in pull request #23405: Add `OpsgenieDeleteAlertOperator`
josh-fell commented on code in PR #23405:
URL: https://github.com/apache/airflow/pull/23405#discussion_r864430454
##########
airflow/providers/opsgenie/operators/opsgenie.py:
##########
@@ -208,3 +208,55 @@ def execute(self, context: 'Context') -> None:
payload=self._build_opsgenie_close_alert_payload(),
kwargs=self.close_alert_kwargs,
)
+
+
+class OpsgenieDeleteAlertOperator(BaseOperator):
+ """
+ This operator allows you to Delete alerts to Opsgenie.
Review Comment:
```suggestion
This operator allows you to delete alerts in Opsgenie.
```
##########
airflow/providers/opsgenie/operators/opsgenie.py:
##########
@@ -208,3 +208,55 @@ def execute(self, context: 'Context') -> None:
payload=self._build_opsgenie_close_alert_payload(),
kwargs=self.close_alert_kwargs,
)
+
+
+class OpsgenieDeleteAlertOperator(BaseOperator):
+ """
+ This operator allows you to Delete alerts to Opsgenie.
+ Accepts a connection that has an Opsgenie API key as the connection's password.
+ This operator sets the domain to conn_id.host, and if not set will default
+ to ``https://api.opsgenie.com``.
+
+ Each Opsgenie API key can be pre-configured to a team integration.
+ You can override these defaults in this operator.
+
+ .. seealso::
+ For more information on how to use this operator, take a look at the guide:
+ :ref:`howto/operator:OpsgenieDeleteAlertOperator`
+
+ :param opsgenie_conn_id: The name of the Opsgenie connection to use
+ :param identifier: Identifier of alert which could be alert id, tiny id or alert alias
+ :param identifier_type: Type of the identifier that is provided as an in-line parameter.
+ Possible values are 'id', 'alias' or 'tiny'
+ :param user: Display name of the request owner
+ :param source: Display name of the request source
+ """
+
+ def __init__(
Review Comment:
Anything to add to `template_fields`? Maybe `identifier`?
##########
docs/apache-airflow-providers-opsgenie/operators/opsgenie_alert.rst:
##########
@@ -48,3 +48,20 @@ Close alert in Opsgenie.
:language: python
:start-after: [START howto_opsgenie_close_alert_operator]
:end-before: [END howto_opsgenie_close_alert_operator]
+
+.. _howto/operator:OpsgenieDeleteAlertOperator:
+
+OpsgenieDeleteAlertOperator
+===========================
+
+Use the :class:`~airflow.providers.opsgenie.operators.opsgenie.OpsgenieDeleteAlertOperator` to delete alert in opsgenie.
+
+
+Using the Operator
+^^^^^^^^^^^^^^^^^^
+Delete alert in Opsgenie.
+
+.. exampleinclude:: /../../airflow/providers/opsgenie/example_dags/example_opsgenie_alert.py
+ :language: python
+ :start-after: [START howto_opsgenie_delete_alert_operator]
+ :end-before: [END howto_opsgenie_delete_alert_operator]
Review Comment:
```suggestion
:language: python
:dedent: 4
:start-after: [START howto_opsgenie_delete_alert_operator]
:end-before: [END howto_opsgenie_delete_alert_operator]
```
I believe this is needed to make sure the code snippet renders correctly in the docs?
##########
airflow/providers/opsgenie/operators/opsgenie.py:
##########
@@ -208,3 +208,55 @@ def execute(self, context: 'Context') -> None:
payload=self._build_opsgenie_close_alert_payload(),
kwargs=self.close_alert_kwargs,
)
+
+
+class OpsgenieDeleteAlertOperator(BaseOperator):
+ """
+ This operator allows you to Delete alerts to Opsgenie.
+ Accepts a connection that has an Opsgenie API key as the connection's password.
+ This operator sets the domain to conn_id.host, and if not set will default
+ to ``https://api.opsgenie.com``.
+
+ Each Opsgenie API key can be pre-configured to a team integration.
+ You can override these defaults in this operator.
+
+ .. seealso::
+ For more information on how to use this operator, take a look at the guide:
+ :ref:`howto/operator:OpsgenieDeleteAlertOperator`
+
+ :param opsgenie_conn_id: The name of the Opsgenie connection to use
+ :param identifier: Identifier of alert which could be alert id, tiny id or alert alias
+ :param identifier_type: Type of the identifier that is provided as an in-line parameter.
+ Possible values are 'id', 'alias' or 'tiny'
Review Comment:
Is this something that should be enforced in the operator itself or does the underlying API throw an error for an expected `indentifier_type` value?
##########
airflow/providers/opsgenie/operators/opsgenie.py:
##########
@@ -208,3 +208,55 @@ def execute(self, context: 'Context') -> None:
payload=self._build_opsgenie_close_alert_payload(),
kwargs=self.close_alert_kwargs,
)
+
+
+class OpsgenieDeleteAlertOperator(BaseOperator):
+ """
+ This operator allows you to Delete alerts to Opsgenie.
+ Accepts a connection that has an Opsgenie API key as the connection's password.
+ This operator sets the domain to conn_id.host, and if not set will default
+ to ``https://api.opsgenie.com``.
+
+ Each Opsgenie API key can be pre-configured to a team integration.
+ You can override these defaults in this operator.
+
+ .. seealso::
+ For more information on how to use this operator, take a look at the guide:
+ :ref:`howto/operator:OpsgenieDeleteAlertOperator`
+
+ :param opsgenie_conn_id: The name of the Opsgenie connection to use
+ :param identifier: Identifier of alert which could be alert id, tiny id or alert alias
+ :param identifier_type: Type of the identifier that is provided as an in-line parameter.
+ Possible values are 'id', 'alias' or 'tiny'
+ :param user: Display name of the request owner
+ :param source: Display name of the request source
+ """
+
+ def __init__(
+ self,
+ *,
+ identifier: str,
+ opsgenie_conn_id: str = 'opsgenie_default',
+ identifier_type: Optional[str] = None,
+ user: Optional[str] = None,
+ source: Optional[str] = None,
+ **kwargs,
+ ) -> None:
+ super().__init__(**kwargs)
+
+ self.opsgenie_conn_id = opsgenie_conn_id
+ self.identifier = identifier
+ self.identifier_type = identifier_type
+ self.user = user
+ self.source = source
+ self.hook: Optional[OpsgenieAlertHook] = None
Review Comment:
Does this need to be an instance attr since it's only used in `execute()`?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org