feluelle commented on a change in pull request #10947:
URL: https://github.com/apache/airflow/pull/10947#discussion_r496480810



##########
File path: airflow/providers/amazon/aws/hooks/glacier.py
##########
@@ -0,0 +1,92 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from typing import Any, Dict
+
+from botocore.exceptions import ClientError
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class GlacierHook(AwsBaseHook):
+    """
+    Hook for connection with Amazon Glacier
+    """
+
+    def __init__(self, *, aws_conn_id: str = "aws_default", **kwargs) -> None:
+        super().__init__(client_type="glacier", **kwargs)
+        self.aws_conn_id = aws_conn_id
+
+    def retrieve_inventory(self, vault_name: str) -> Dict[str, Any]:
+        """
+        Initiate an Amazon Glacier inventory-retrieval job
+
+        :param vault_name: the Glacier vault on which job is executed
+        :type vault_name: str
+        """
+        job_parms = {'Type': 'inventory-retrieval'}
+        self.log.info("Retrieving inventory for vault: %s", vault_name)
+        try:
+            response = self.get_conn().initiate_job(vaultName=vault_name, 
jobParameters=job_parms)
+        except ClientError as e:
+            self.log.exception(e)
+            raise
+
+        if response is not None:
+            self.log.info("Initiated inventory-retrieval job for: %s", 
vault_name)
+            self.log.info("Retrieval Job ID: %s", response["jobId"])
+        return response

Review comment:
       Is there something you can handle? **Why did you put it there in the 
first place i.e what specific errors did you get?** Maybe you want to handle 
different errors differently. If you don't know how to handle it, remove the 
except block. If you think a specific exception should not lead to failure of 
the task it was executed by, `except` the error and only log it but do not 
re-raise.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to