wojsamjan commented on a change in pull request #20377: URL: https://github.com/apache/airflow/pull/20377#discussion_r778823070
########## File path: airflow/providers/google/cloud/hooks/dataplex.py ########## @@ -0,0 +1,228 @@ +# 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. + +"""This module contains Google Dataplex hook.""" +import os +from time import sleep +from typing import Any, Dict, Optional, Sequence, Union + +from google.api_core.retry import exponential_sleep_generator +from googleapiclient.discovery import Resource, build + +from airflow.exceptions import AirflowException +from airflow.providers.google.common.hooks.base_google import GoogleBaseHook + +API_KEY = os.environ.get("GCP_API_KEY", "INVALID API KEY") + + +class DataplexHook(GoogleBaseHook): + """Hook for Google Dataplex.""" + + _conn = None # type: Optional[Resource] + + def __init__( + self, + api_version: str = "v1", + gcp_conn_id: str = "google_cloud_default", + delegate_to: Optional[str] = None, + impersonation_chain: Optional[Union[str, Sequence[str]]] = None, + ) -> None: + super().__init__( + gcp_conn_id=gcp_conn_id, + delegate_to=delegate_to, + impersonation_chain=impersonation_chain, + ) + self.api_key = API_KEY Review comment: In Airflow Connection I set standard Keyfile Path - pointing to: /files/airflow-breeze-config/keys/<KEY_FILE_NAME>.json On the other hand we have to set an API Key in Credentials on GCP side to connect with discovery API - otherwise we can not perform operations. I have not seen an option to set this value inside the Airflow Connection - so I used an environment variable. I am open to any suggestions about where it should be stored and any other improvements. -- 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]
