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/08/26 16:02:51 UTC
[GitHub] [airflow] vincbeck commented on a diff in pull request #25975: Add RedshiftDeleteClusterSnapshotOperator
vincbeck commented on code in PR #25975:
URL: https://github.com/apache/airflow/pull/25975#discussion_r956191667
##########
airflow/providers/amazon/aws/hooks/redshift_cluster.py:
##########
@@ -153,3 +153,18 @@ def create_cluster_snapshot(
ManualSnapshotRetentionPeriod=retention_period,
)
return response['Snapshot'] if response['Snapshot'] else None
+
+ def get_cluster_snapshot_status(self, snapshot_identifier: str, cluster_identifier: str):
+ try:
+ response = self.get_conn().describe_cluster_snapshots(
+ ClusterIdentifier=cluster_identifier,
+ SnapshotIdentifier=snapshot_identifier,
+ )
+ snapshot = response.get("Snapshots")[0]
+ snapshot_status: str = snapshot.get("Status")
+ return snapshot_status
+ except ClientError as exception:
+ if exception.response.get("Error", {}).get("Code", "") == "ClusterSnapshotNotFound":
+ return "cluster_snapshot_not_found"
Review Comment:
I dont really like this magic string. I would return `None` instead. Could you also add docstring to make it clear for users
--
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