mik-laj commented on a change in pull request #7725: [AIRFLOW-7064] Add 
CloudFirestoreExportDatabaseOperator
URL: https://github.com/apache/airflow/pull/7725#discussion_r394232169
 
 

 ##########
 File path: airflow/providers/google/firebase/hooks/firestore.py
 ##########
 @@ -0,0 +1,142 @@
+#
+# 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.
+"""Hook for Google Cloud Build service"""
+
+import time
+from typing import Any, Dict, Optional
+
+from googleapiclient.discovery import build, build_from_document
+
+from airflow.exceptions import AirflowException
+from airflow.providers.google.cloud.hooks.base import CloudBaseHook
+
+# Time to sleep between active checks of the operation results
+TIME_TO_SLEEP_IN_SECONDS = 5
+
+
+# noinspection PyAbstractClass
+class CloudFirestoreHook(CloudBaseHook):
+    """
+    Hook for the Google Firestore APIs.
+
+    All the methods in the hook where project_id is used must be called with
+    keyword arguments rather than positional.
+
+    :param api_version: API version used (for example v1 or v1beta1).
+    :type api_version: str
+    :param gcp_conn_id: The connection ID to use when fetching connection info.
+    :type gcp_conn_id: str
+    :param delegate_to: The account to impersonate, if any.
+        For this to work, the service account making the request must have
+        domain-wide delegation enabled.
+    :type delegate_to: str
+    """
+
+    _conn = None  # type: Optional[Any]
+
+    def __init__(
+        self,
+        api_version: str = "v1",
+        gcp_conn_id: str = "google_cloud_default",
+        delegate_to: Optional[str] = None,
+    ) -> None:
+        super().__init__(gcp_conn_id, delegate_to)
+        self.api_version = api_version
+
+    def get_conn(self):
+        """
+        Retrieves the connection to Cloud Build.
+
+        :return: Google Cloud Build services object.
+        """
+        if not self._conn:
+            http_authorized = self._authorize()
+            # We cannot use an Authorized Client to retrieve discovery 
document due to an error in the API.
+            # When the authorized customer will send a request to the address 
below
+            # https://www.googleapis.com/discovery/v1/apis/firestore/v1/rest
+            # then it will get the message below:
+            # > Request contains an invalid argument.
+            # At the same time, the Non-Authorized Client has no problems.
+            non_authorized_conn = build("firestore", self.api_version, 
cache_discovery=False)
 
 Review comment:
   I created a ticket in `google-api-python-client`.
   https://github.com/googleapis/google-api-python-client/issues/845
   I am not sure if this is a good place to report a bug, so I do not add a 
comment in the code. The error is in the service, not in the library, but I 
don't know a better place to report this error.

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


With regards,
Apache Git Services

Reply via email to