vincbeck commented on code in PR #28850:
URL: https://github.com/apache/airflow/pull/28850#discussion_r1068349671
##########
airflow/providers/amazon/aws/triggers/redshift_cluster.py:
##########
@@ -0,0 +1,51 @@
+from typing import AsyncIterator, Any, Tuple, Dict
+
+from airflow.providers.amazon.aws.hooks.redshift_cluster import
RedshiftHookAsync
+from airflow.triggers.base import BaseTrigger, TriggerEvent
+
+
+class RedshiftClusterTrigger(BaseTrigger):
+ def __init__(
+ self,
+ task_id: str,
+ aws_conn_id: str,
+ cluster_identifier: str,
+ operation_type: str,
+ poll_interval: float = 5.0,
+ ):
+ super().__init__()
+ self.task_id = task_id
+ self.poll_interval = poll_interval
+ self.aws_conn_id = aws_conn_id
+ self.cluster_identifier = cluster_identifier
+ self.operation_type = operation_type
+
+ def serialize(self) -> Tuple[str, Dict[str, Any]]:
+ return (
+
"airflow.providers.amazon.aws.triggers.redshift_cluster.RedshiftClusterTrigger",
+ {
+ "task_id": self.task_id,
+ "poll_interval": self.poll_interval,
+ "aws_conn_id": self.aws_conn_id,
+ "cluster_identifier": self.cluster_identifier,
+ "operation_type": self.operation_type,
+ },
+ )
+
+ async def run(self) -> AsyncIterator["TriggerEvent"]:
+ hook = RedshiftHookAsync(aws_conn_id=self.aws_conn_id)
+ try:
+ if self.operation_type == "pause_cluster":
Review Comment:
Should we throw an exception if `operation_type` is not "pause_cluster"
--
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]