apache-airflow-providers-google 10.26.0__py3-none-any.whl → 11.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/google/__init__.py +1 -1
- airflow/providers/google/ads/hooks/ads.py +2 -1
- airflow/providers/google/ads/operators/ads.py +2 -1
- airflow/providers/google/ads/transfers/ads_to_gcs.py +2 -1
- airflow/providers/google/assets/gcs.py +17 -1
- airflow/providers/google/cloud/hooks/automl.py +3 -6
- airflow/providers/google/cloud/hooks/bigquery.py +41 -1486
- airflow/providers/google/cloud/hooks/bigquery_dts.py +4 -11
- airflow/providers/google/cloud/hooks/bigtable.py +3 -6
- airflow/providers/google/cloud/hooks/cloud_batch.py +6 -3
- airflow/providers/google/cloud/hooks/cloud_build.py +3 -15
- airflow/providers/google/cloud/hooks/cloud_composer.py +2 -17
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +5 -6
- airflow/providers/google/cloud/hooks/cloud_run.py +10 -5
- airflow/providers/google/cloud/hooks/cloud_sql.py +5 -7
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +3 -7
- airflow/providers/google/cloud/hooks/compute.py +3 -6
- airflow/providers/google/cloud/hooks/compute_ssh.py +0 -5
- airflow/providers/google/cloud/hooks/datacatalog.py +3 -6
- airflow/providers/google/cloud/hooks/dataflow.py +3 -14
- airflow/providers/google/cloud/hooks/dataform.py +2 -9
- airflow/providers/google/cloud/hooks/datafusion.py +4 -15
- airflow/providers/google/cloud/hooks/dataplex.py +4 -7
- airflow/providers/google/cloud/hooks/dataprep.py +2 -2
- airflow/providers/google/cloud/hooks/dataproc.py +77 -22
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +2 -9
- airflow/providers/google/cloud/hooks/datastore.py +3 -6
- airflow/providers/google/cloud/hooks/dlp.py +3 -6
- airflow/providers/google/cloud/hooks/functions.py +2 -6
- airflow/providers/google/cloud/hooks/gcs.py +2 -18
- airflow/providers/google/cloud/hooks/gdm.py +1 -17
- airflow/providers/google/cloud/hooks/kms.py +3 -6
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +7 -97
- airflow/providers/google/cloud/hooks/life_sciences.py +2 -6
- airflow/providers/google/cloud/hooks/looker.py +2 -1
- airflow/providers/google/cloud/hooks/mlengine.py +0 -8
- airflow/providers/google/cloud/hooks/natural_language.py +3 -6
- airflow/providers/google/cloud/hooks/os_login.py +3 -6
- airflow/providers/google/cloud/hooks/pubsub.py +3 -6
- airflow/providers/google/cloud/hooks/secret_manager.py +3 -73
- airflow/providers/google/cloud/hooks/spanner.py +3 -6
- airflow/providers/google/cloud/hooks/speech_to_text.py +3 -6
- airflow/providers/google/cloud/hooks/stackdriver.py +3 -6
- airflow/providers/google/cloud/hooks/tasks.py +3 -6
- airflow/providers/google/cloud/hooks/text_to_speech.py +3 -6
- airflow/providers/google/cloud/hooks/translate.py +455 -9
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +1 -14
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +3 -1
- airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +2 -1
- airflow/providers/google/cloud/hooks/video_intelligence.py +3 -6
- airflow/providers/google/cloud/hooks/vision.py +3 -6
- airflow/providers/google/cloud/hooks/workflows.py +2 -9
- airflow/providers/google/cloud/links/dataproc.py +0 -1
- airflow/providers/google/cloud/links/translate.py +91 -0
- airflow/providers/google/cloud/log/gcs_task_handler.py +2 -1
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +11 -3
- airflow/providers/google/cloud/openlineage/utils.py +54 -21
- airflow/providers/google/cloud/operators/automl.py +5 -4
- airflow/providers/google/cloud/operators/bigquery.py +2 -341
- airflow/providers/google/cloud/operators/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/operators/bigtable.py +2 -1
- airflow/providers/google/cloud/operators/cloud_batch.py +2 -1
- airflow/providers/google/cloud/operators/cloud_build.py +2 -1
- airflow/providers/google/cloud/operators/cloud_composer.py +2 -1
- airflow/providers/google/cloud/operators/cloud_memorystore.py +2 -1
- airflow/providers/google/cloud/operators/cloud_run.py +2 -1
- airflow/providers/google/cloud/operators/cloud_sql.py +2 -1
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/operators/compute.py +2 -1
- airflow/providers/google/cloud/operators/datacatalog.py +2 -1
- airflow/providers/google/cloud/operators/dataflow.py +2 -517
- airflow/providers/google/cloud/operators/dataform.py +2 -1
- airflow/providers/google/cloud/operators/datafusion.py +2 -1
- airflow/providers/google/cloud/operators/dataplex.py +37 -31
- airflow/providers/google/cloud/operators/dataprep.py +2 -1
- airflow/providers/google/cloud/operators/dataproc.py +3 -633
- airflow/providers/google/cloud/operators/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/operators/datastore.py +2 -1
- airflow/providers/google/cloud/operators/dlp.py +2 -1
- airflow/providers/google/cloud/operators/functions.py +2 -1
- airflow/providers/google/cloud/operators/gcs.py +5 -4
- airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -11
- airflow/providers/google/cloud/operators/life_sciences.py +2 -1
- airflow/providers/google/cloud/operators/mlengine.py +2 -1
- airflow/providers/google/cloud/operators/natural_language.py +3 -2
- airflow/providers/google/cloud/operators/pubsub.py +2 -1
- airflow/providers/google/cloud/operators/spanner.py +2 -1
- airflow/providers/google/cloud/operators/speech_to_text.py +2 -1
- airflow/providers/google/cloud/operators/stackdriver.py +2 -1
- airflow/providers/google/cloud/operators/tasks.py +3 -2
- airflow/providers/google/cloud/operators/text_to_speech.py +2 -1
- airflow/providers/google/cloud/operators/translate.py +622 -32
- airflow/providers/google/cloud/operators/translate_speech.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +2 -93
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +2 -17
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +2 -1
- airflow/providers/google/cloud/operators/video_intelligence.py +2 -1
- airflow/providers/google/cloud/operators/vision.py +3 -2
- airflow/providers/google/cloud/operators/workflows.py +3 -2
- airflow/providers/google/cloud/secrets/secret_manager.py +2 -19
- airflow/providers/google/cloud/sensors/bigquery.py +2 -81
- airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/sensors/bigtable.py +2 -1
- airflow/providers/google/cloud/sensors/cloud_composer.py +8 -94
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/sensors/dataflow.py +2 -1
- airflow/providers/google/cloud/sensors/dataform.py +2 -1
- airflow/providers/google/cloud/sensors/datafusion.py +2 -1
- airflow/providers/google/cloud/sensors/dataplex.py +2 -1
- airflow/providers/google/cloud/sensors/dataprep.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/sensors/gcs.py +4 -36
- airflow/providers/google/cloud/sensors/pubsub.py +2 -1
- airflow/providers/google/cloud/sensors/tasks.py +2 -1
- airflow/providers/google/cloud/sensors/workflows.py +2 -1
- airflow/providers/google/cloud/transfers/adls_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +75 -18
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +9 -7
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -1
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +2 -1
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +13 -9
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/local_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/s3_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sheets_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_batch.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_build.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_composer.py +3 -2
- airflow/providers/google/cloud/triggers/cloud_run.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_sql.py +1 -1
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/triggers/dataflow.py +2 -1
- airflow/providers/google/cloud/triggers/datafusion.py +2 -1
- airflow/providers/google/cloud/triggers/dataplex.py +1 -1
- airflow/providers/google/cloud/triggers/dataproc.py +2 -1
- airflow/providers/google/cloud/triggers/gcs.py +3 -2
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -1
- airflow/providers/google/cloud/triggers/mlengine.py +2 -1
- airflow/providers/google/cloud/triggers/pubsub.py +2 -1
- airflow/providers/google/cloud/triggers/vertex_ai.py +2 -1
- airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
- airflow/providers/google/cloud/utils/dataform.py +1 -1
- airflow/providers/google/cloud/utils/field_validator.py +2 -1
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +2 -1
- airflow/providers/google/common/hooks/base_google.py +4 -11
- airflow/providers/google/common/hooks/discovery_api.py +1 -6
- airflow/providers/google/firebase/hooks/firestore.py +1 -1
- airflow/providers/google/firebase/operators/firestore.py +2 -1
- airflow/providers/google/get_provider_info.py +7 -22
- airflow/providers/google/marketing_platform/hooks/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/hooks/campaign_manager.py +2 -3
- airflow/providers/google/marketing_platform/hooks/display_video.py +4 -3
- airflow/providers/google/marketing_platform/hooks/search_ads.py +6 -6
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +2 -42
- airflow/providers/google/marketing_platform/operators/display_video.py +2 -47
- airflow/providers/google/marketing_platform/operators/search_ads.py +2 -1
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +2 -7
- airflow/providers/google/marketing_platform/sensors/display_video.py +2 -13
- airflow/providers/google/suite/hooks/calendar.py +2 -8
- airflow/providers/google/suite/hooks/drive.py +2 -6
- airflow/providers/google/suite/hooks/sheets.py +2 -7
- airflow/providers/google/suite/operators/sheets.py +2 -7
- airflow/providers/google/suite/sensors/drive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +2 -7
- airflow/providers/google/suite/transfers/local_to_drive.py +2 -7
- airflow/providers/google/suite/transfers/sql_to_sheets.py +2 -7
- {apache_airflow_providers_google-10.26.0.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/METADATA +10 -10
- apache_airflow_providers_google-11.0.0.dist-info/RECORD +315 -0
- airflow/providers/google/marketing_platform/hooks/analytics.py +0 -211
- airflow/providers/google/marketing_platform/operators/analytics.py +0 -551
- apache_airflow_providers_google-10.26.0.dist-info/RECORD +0 -317
- {apache_airflow_providers_google-10.26.0.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-10.26.0.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/entry_points.txt +0 -0
@@ -19,10 +19,12 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
+
import shlex
|
23
|
+
import subprocess
|
22
24
|
import time
|
23
25
|
import uuid
|
24
|
-
from collections.abc import MutableSequence
|
25
|
-
from typing import TYPE_CHECKING, Any
|
26
|
+
from collections.abc import MutableSequence, Sequence
|
27
|
+
from typing import TYPE_CHECKING, Any
|
26
28
|
|
27
29
|
from google.api_core.client_options import ClientOptions
|
28
30
|
from google.api_core.exceptions import ServerError
|
@@ -217,19 +219,6 @@ class DataprocHook(GoogleBaseHook):
|
|
217
219
|
keyword arguments rather than positional.
|
218
220
|
"""
|
219
221
|
|
220
|
-
def __init__(
|
221
|
-
self,
|
222
|
-
gcp_conn_id: str = "google_cloud_default",
|
223
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
224
|
-
**kwargs,
|
225
|
-
) -> None:
|
226
|
-
if kwargs.get("delegate_to") is not None:
|
227
|
-
raise RuntimeError(
|
228
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
229
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
230
|
-
)
|
231
|
-
super().__init__(gcp_conn_id=gcp_conn_id, impersonation_chain=impersonation_chain)
|
232
|
-
|
233
222
|
def get_cluster_client(self, region: str | None = None) -> ClusterControllerClient:
|
234
223
|
"""Create a ClusterControllerClient."""
|
235
224
|
client_options = None
|
@@ -274,6 +263,49 @@ class DataprocHook(GoogleBaseHook):
|
|
274
263
|
"""Create a OperationsClient."""
|
275
264
|
return self.get_batch_client(region=region).transport.operations_client
|
276
265
|
|
266
|
+
def dataproc_options_to_args(self, options: dict) -> list[str]:
|
267
|
+
"""
|
268
|
+
Return a formatted cluster parameters from a dictionary of arguments.
|
269
|
+
|
270
|
+
:param options: Dictionary with options
|
271
|
+
:return: List of arguments
|
272
|
+
"""
|
273
|
+
if not options:
|
274
|
+
return []
|
275
|
+
|
276
|
+
args: list[str] = []
|
277
|
+
for attr, value in options.items():
|
278
|
+
if value is None or (isinstance(value, bool) and value):
|
279
|
+
args.append(f"--{attr}")
|
280
|
+
elif isinstance(value, bool) and not value:
|
281
|
+
continue
|
282
|
+
elif isinstance(value, list):
|
283
|
+
args.extend([f"--{attr}={v}" for v in value])
|
284
|
+
else:
|
285
|
+
args.append(f"--{attr}={value}")
|
286
|
+
return args
|
287
|
+
|
288
|
+
def _build_gcloud_command(self, command: list[str], parameters: dict[str, str]) -> list[str]:
|
289
|
+
return [*command, *(self.dataproc_options_to_args(parameters))]
|
290
|
+
|
291
|
+
def _create_dataproc_cluster_with_gcloud(self, cmd: list[str]) -> str:
|
292
|
+
"""Create a Dataproc cluster with a gcloud command and return the job's ID."""
|
293
|
+
self.log.info("Executing command: %s", " ".join(shlex.quote(c) for c in cmd))
|
294
|
+
success_code = 0
|
295
|
+
|
296
|
+
with self.provide_authorized_gcloud():
|
297
|
+
proc = subprocess.run(cmd, capture_output=True)
|
298
|
+
|
299
|
+
if proc.returncode != success_code:
|
300
|
+
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])
|
301
|
+
raise AirflowException(
|
302
|
+
f"Process exit with non-zero exit code. Exit code: {proc.returncode}. Error Details : "
|
303
|
+
f"{stderr_last_20_lines}"
|
304
|
+
)
|
305
|
+
|
306
|
+
response = proc.stdout.decode().strip()
|
307
|
+
return response
|
308
|
+
|
277
309
|
def wait_for_operation(
|
278
310
|
self,
|
279
311
|
operation: Operation,
|
@@ -302,7 +334,7 @@ class DataprocHook(GoogleBaseHook):
|
|
302
334
|
retry: Retry | _MethodDefault = DEFAULT,
|
303
335
|
timeout: float | None = None,
|
304
336
|
metadata: Sequence[tuple[str, str]] = (),
|
305
|
-
) -> Operation:
|
337
|
+
) -> Operation | str:
|
306
338
|
"""
|
307
339
|
Create a cluster in a specified project.
|
308
340
|
|
@@ -339,6 +371,34 @@ class DataprocHook(GoogleBaseHook):
|
|
339
371
|
"project_id": project_id,
|
340
372
|
"cluster_name": cluster_name,
|
341
373
|
}
|
374
|
+
|
375
|
+
if virtual_cluster_config and "kubernetes_cluster_config" in virtual_cluster_config:
|
376
|
+
kube_config = virtual_cluster_config["kubernetes_cluster_config"]["gke_cluster_config"]
|
377
|
+
try:
|
378
|
+
spark_engine_version = virtual_cluster_config["kubernetes_cluster_config"][
|
379
|
+
"kubernetes_software_config"
|
380
|
+
]["component_version"]["SPARK"]
|
381
|
+
except KeyError:
|
382
|
+
spark_engine_version = "latest"
|
383
|
+
gke_cluster_name = kube_config["gke_cluster_target"].rsplit("/", 1)[1]
|
384
|
+
gke_pools = kube_config["node_pool_target"][0]
|
385
|
+
gke_pool_name = gke_pools["node_pool"].rsplit("/", 1)[1]
|
386
|
+
gke_pool_role = gke_pools["roles"][0]
|
387
|
+
gke_pool_machine_type = gke_pools["node_pool_config"]["config"]["machine_type"]
|
388
|
+
gcp_flags = {
|
389
|
+
"region": region,
|
390
|
+
"gke-cluster": gke_cluster_name,
|
391
|
+
"spark-engine-version": spark_engine_version,
|
392
|
+
"pools": f"name={gke_pool_name},roles={gke_pool_role.lower()},machineType={gke_pool_machine_type},min=1,max=10",
|
393
|
+
"setup-workload-identity": None,
|
394
|
+
}
|
395
|
+
cmd = self._build_gcloud_command(
|
396
|
+
command=["gcloud", "dataproc", "clusters", "gke", "create", cluster_name],
|
397
|
+
parameters=gcp_flags,
|
398
|
+
)
|
399
|
+
response = self._create_dataproc_cluster_with_gcloud(cmd=cmd)
|
400
|
+
return response
|
401
|
+
|
342
402
|
if virtual_cluster_config is not None:
|
343
403
|
cluster["virtual_cluster_config"] = virtual_cluster_config # type: ignore
|
344
404
|
if cluster_config is not None:
|
@@ -1219,12 +1279,7 @@ class DataprocAsyncHook(GoogleBaseHook):
|
|
1219
1279
|
impersonation_chain: str | Sequence[str] | None = None,
|
1220
1280
|
**kwargs,
|
1221
1281
|
) -> None:
|
1222
|
-
|
1223
|
-
raise RuntimeError(
|
1224
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
1225
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
1226
|
-
)
|
1227
|
-
super().__init__(gcp_conn_id=gcp_conn_id, impersonation_chain=impersonation_chain)
|
1282
|
+
super().__init__(gcp_conn_id=gcp_conn_id, impersonation_chain=impersonation_chain, **kwargs)
|
1228
1283
|
self._cached_client: JobControllerAsyncClient | None = None
|
1229
1284
|
|
1230
1285
|
def get_cluster_client(self, region: str | None = None) -> ClusterControllerAsyncClient:
|
@@ -19,7 +19,8 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from
|
22
|
+
from collections.abc import Sequence
|
23
|
+
from typing import TYPE_CHECKING, Any
|
23
24
|
|
24
25
|
from google.api_core.client_options import ClientOptions
|
25
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -40,14 +41,6 @@ if TYPE_CHECKING:
|
|
40
41
|
class DataprocMetastoreHook(GoogleBaseHook):
|
41
42
|
"""Hook for Google Cloud Dataproc Metastore APIs."""
|
42
43
|
|
43
|
-
def __init__(self, **kwargs):
|
44
|
-
if kwargs.get("delegate_to") is not None:
|
45
|
-
raise RuntimeError(
|
46
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
47
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
48
|
-
)
|
49
|
-
super().__init__(**kwargs)
|
50
|
-
|
51
44
|
def get_dataproc_metastore_client(self) -> DataprocMetastoreClient:
|
52
45
|
"""Return DataprocMetastoreClient."""
|
53
46
|
client_options = ClientOptions(api_endpoint="metastore.googleapis.com:443")
|
@@ -20,7 +20,8 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import time
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import Any
|
24
25
|
|
25
26
|
from googleapiclient.discovery import Resource, build
|
26
27
|
|
@@ -44,14 +45,10 @@ class DatastoreHook(GoogleBaseHook):
|
|
44
45
|
impersonation_chain: str | Sequence[str] | None = None,
|
45
46
|
**kwargs,
|
46
47
|
) -> None:
|
47
|
-
if kwargs.get("delegate_to") is not None:
|
48
|
-
raise RuntimeError(
|
49
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
50
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
51
|
-
)
|
52
48
|
super().__init__(
|
53
49
|
gcp_conn_id=gcp_conn_id,
|
54
50
|
impersonation_chain=impersonation_chain,
|
51
|
+
**kwargs,
|
55
52
|
)
|
56
53
|
self.connection = None
|
57
54
|
self.api_version = api_version
|
@@ -28,7 +28,8 @@ from __future__ import annotations
|
|
28
28
|
|
29
29
|
import re
|
30
30
|
import time
|
31
|
-
from
|
31
|
+
from collections.abc import Sequence
|
32
|
+
from typing import TYPE_CHECKING
|
32
33
|
|
33
34
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
34
35
|
from google.cloud.dlp import DlpServiceClient
|
@@ -91,14 +92,10 @@ class CloudDLPHook(GoogleBaseHook):
|
|
91
92
|
impersonation_chain: str | Sequence[str] | None = None,
|
92
93
|
**kwargs,
|
93
94
|
) -> None:
|
94
|
-
if kwargs.get("delegate_to") is not None:
|
95
|
-
raise RuntimeError(
|
96
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
97
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
98
|
-
)
|
99
95
|
super().__init__(
|
100
96
|
gcp_conn_id=gcp_conn_id,
|
101
97
|
impersonation_chain=impersonation_chain,
|
98
|
+
**kwargs,
|
102
99
|
)
|
103
100
|
self._client: DlpServiceClient | None = None
|
104
101
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import time
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
24
|
|
25
25
|
import requests
|
26
26
|
from googleapiclient.discovery import build
|
@@ -49,14 +49,10 @@ class CloudFunctionsHook(GoogleBaseHook):
|
|
49
49
|
impersonation_chain: str | Sequence[str] | None = None,
|
50
50
|
**kwargs,
|
51
51
|
) -> None:
|
52
|
-
if kwargs.get("delegate_to") is not None:
|
53
|
-
raise RuntimeError(
|
54
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
55
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
56
|
-
)
|
57
52
|
super().__init__(
|
58
53
|
gcp_conn_id=gcp_conn_id,
|
59
54
|
impersonation_chain=impersonation_chain,
|
55
|
+
**kwargs,
|
60
56
|
)
|
61
57
|
self.api_version = api_version
|
62
58
|
|
@@ -26,11 +26,12 @@ import os
|
|
26
26
|
import shutil
|
27
27
|
import time
|
28
28
|
import warnings
|
29
|
+
from collections.abc import Generator, Sequence
|
29
30
|
from contextlib import contextmanager
|
30
31
|
from functools import partial
|
31
32
|
from io import BytesIO
|
32
33
|
from tempfile import NamedTemporaryFile
|
33
|
-
from typing import IO, TYPE_CHECKING, Any, Callable,
|
34
|
+
from typing import IO, TYPE_CHECKING, Any, Callable, TypeVar, cast, overload
|
34
35
|
from urllib.parse import urlsplit
|
35
36
|
|
36
37
|
from gcloud.aio.storage import Storage
|
@@ -151,23 +152,6 @@ class GCSHook(GoogleBaseHook):
|
|
151
152
|
|
152
153
|
_conn: storage.Client | None = None
|
153
154
|
|
154
|
-
def __init__(
|
155
|
-
self,
|
156
|
-
gcp_conn_id: str = "google_cloud_default",
|
157
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
158
|
-
**kwargs,
|
159
|
-
) -> None:
|
160
|
-
if kwargs.get("delegate_to") is not None:
|
161
|
-
raise RuntimeError(
|
162
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
163
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
164
|
-
)
|
165
|
-
|
166
|
-
super().__init__(
|
167
|
-
gcp_conn_id=gcp_conn_id,
|
168
|
-
impersonation_chain=impersonation_chain,
|
169
|
-
)
|
170
|
-
|
171
155
|
def get_conn(self) -> storage.Client:
|
172
156
|
"""Return a Google Cloud Storage service object."""
|
173
157
|
if not self._conn:
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# under the License.
|
18
18
|
from __future__ import annotations
|
19
19
|
|
20
|
-
from typing import Any
|
20
|
+
from typing import Any
|
21
21
|
|
22
22
|
from googleapiclient.discovery import Resource, build
|
23
23
|
|
@@ -32,22 +32,6 @@ class GoogleDeploymentManagerHook(GoogleBaseHook):
|
|
32
32
|
This allows for scheduled and programmatic inspection and deletion of resources managed by GDM.
|
33
33
|
"""
|
34
34
|
|
35
|
-
def __init__(
|
36
|
-
self,
|
37
|
-
gcp_conn_id: str = "google_cloud_default",
|
38
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
39
|
-
**kwargs,
|
40
|
-
) -> None:
|
41
|
-
if kwargs.get("delegate_to") is not None:
|
42
|
-
raise RuntimeError(
|
43
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
44
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
45
|
-
)
|
46
|
-
super().__init__(
|
47
|
-
gcp_conn_id=gcp_conn_id,
|
48
|
-
impersonation_chain=impersonation_chain,
|
49
|
-
)
|
50
|
-
|
51
35
|
def get_conn(self) -> Resource:
|
52
36
|
"""Return a Google Deployment Manager service object."""
|
53
37
|
http_authorized = self._authorize()
|
@@ -20,7 +20,8 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import base64
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import TYPE_CHECKING
|
24
25
|
|
25
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
26
27
|
from google.cloud.kms_v1 import KeyManagementServiceClient
|
@@ -63,14 +64,10 @@ class CloudKMSHook(GoogleBaseHook):
|
|
63
64
|
impersonation_chain: str | Sequence[str] | None = None,
|
64
65
|
**kwargs,
|
65
66
|
) -> None:
|
66
|
-
if kwargs.get("delegate_to") is not None:
|
67
|
-
raise RuntimeError(
|
68
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
69
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
70
|
-
)
|
71
67
|
super().__init__(
|
72
68
|
gcp_conn_id=gcp_conn_id,
|
73
69
|
impersonation_chain=impersonation_chain,
|
70
|
+
**kwargs,
|
74
71
|
)
|
75
72
|
self._conn: KeyManagementServiceClient | None = None
|
76
73
|
|
@@ -22,14 +22,15 @@ from __future__ import annotations
|
|
22
22
|
import contextlib
|
23
23
|
import json
|
24
24
|
import time
|
25
|
-
from
|
25
|
+
from collections.abc import Sequence
|
26
|
+
from typing import TYPE_CHECKING
|
26
27
|
|
27
28
|
from google.api_core.exceptions import NotFound
|
28
29
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
29
30
|
from google.auth.transport import requests as google_requests
|
30
31
|
|
31
32
|
# not sure why but mypy complains on missing `container_v1` but it is clearly there and is importable
|
32
|
-
from google.cloud import
|
33
|
+
from google.cloud import exceptions # type: ignore[attr-defined]
|
33
34
|
from google.cloud.container_v1 import ClusterManagerAsyncClient, ClusterManagerClient
|
34
35
|
from google.cloud.container_v1.types import Cluster, Operation
|
35
36
|
from kubernetes import client, utils
|
@@ -38,11 +39,10 @@ from kubernetes_asyncio import client as async_client
|
|
38
39
|
from kubernetes_asyncio.config.kube_config import FileOrData
|
39
40
|
|
40
41
|
from airflow import version
|
41
|
-
from airflow.exceptions import AirflowException
|
42
|
+
from airflow.exceptions import AirflowException
|
42
43
|
from airflow.providers.cncf.kubernetes.hooks.kubernetes import AsyncKubernetesHook, KubernetesHook
|
43
44
|
from airflow.providers.cncf.kubernetes.kube_client import _enable_tcp_keepalive
|
44
45
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
45
|
-
from airflow.providers.google.common.deprecated import deprecated
|
46
46
|
from airflow.providers.google.common.hooks.base_google import (
|
47
47
|
PROVIDE_PROJECT_ID,
|
48
48
|
GoogleBaseAsyncHook,
|
@@ -118,14 +118,10 @@ class GKEHook(GoogleBaseHook):
|
|
118
118
|
impersonation_chain: str | Sequence[str] | None = None,
|
119
119
|
**kwargs,
|
120
120
|
) -> None:
|
121
|
-
if kwargs.get("delegate_to") is not None:
|
122
|
-
raise RuntimeError(
|
123
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
124
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
125
|
-
)
|
126
121
|
super().__init__(
|
127
122
|
gcp_conn_id=gcp_conn_id,
|
128
123
|
impersonation_chain=impersonation_chain,
|
124
|
+
**kwargs,
|
129
125
|
)
|
130
126
|
self._client: ClusterManagerClient | None = None
|
131
127
|
self.location = location
|
@@ -136,26 +132,6 @@ class GKEHook(GoogleBaseHook):
|
|
136
132
|
self._client = ClusterManagerClient(credentials=self.get_credentials(), client_info=CLIENT_INFO)
|
137
133
|
return self._client
|
138
134
|
|
139
|
-
# To preserve backward compatibility
|
140
|
-
# TODO: remove one day
|
141
|
-
@deprecated(
|
142
|
-
planned_removal_date="November 01, 2024",
|
143
|
-
use_instead="get_cluster_manager_client",
|
144
|
-
category=AirflowProviderDeprecationWarning,
|
145
|
-
)
|
146
|
-
def get_conn(self) -> container_v1.ClusterManagerClient:
|
147
|
-
return self.get_cluster_manager_client()
|
148
|
-
|
149
|
-
# To preserve backward compatibility
|
150
|
-
# TODO: remove one day
|
151
|
-
@deprecated(
|
152
|
-
planned_removal_date="November 01, 2024",
|
153
|
-
use_instead="get_cluster_manager_client",
|
154
|
-
category=AirflowProviderDeprecationWarning,
|
155
|
-
)
|
156
|
-
def get_client(self) -> ClusterManagerClient:
|
157
|
-
return self.get_conn()
|
158
|
-
|
159
135
|
def wait_for_operation(self, operation: Operation, project_id: str = PROVIDE_PROJECT_ID) -> Operation:
|
160
136
|
"""
|
161
137
|
Continuously fetch the status from Google Cloud.
|
@@ -388,10 +364,12 @@ class GKEAsyncHook(GoogleBaseAsyncHook):
|
|
388
364
|
gcp_conn_id: str = "google_cloud_default",
|
389
365
|
location: str | None = None,
|
390
366
|
impersonation_chain: str | Sequence[str] | None = None,
|
367
|
+
**kwargs,
|
391
368
|
) -> None:
|
392
369
|
super().__init__(
|
393
370
|
gcp_conn_id=gcp_conn_id,
|
394
371
|
impersonation_chain=impersonation_chain,
|
372
|
+
**kwargs,
|
395
373
|
)
|
396
374
|
self._client: ClusterManagerAsyncClient | None = None
|
397
375
|
self.location = location
|
@@ -576,71 +554,3 @@ class GKEKubernetesAsyncHook(GoogleBaseAsyncHook, AsyncKubernetesHook):
|
|
576
554
|
).as_file(),
|
577
555
|
)
|
578
556
|
return configuration
|
579
|
-
|
580
|
-
|
581
|
-
@deprecated(
|
582
|
-
planned_removal_date="October 01, 2024",
|
583
|
-
use_instead="GKEKubernetesHook",
|
584
|
-
category=AirflowProviderDeprecationWarning,
|
585
|
-
)
|
586
|
-
class GKEDeploymentHook(GKEKubernetesHook):
|
587
|
-
"""Google Kubernetes Engine Deployment APIs."""
|
588
|
-
|
589
|
-
|
590
|
-
@deprecated(
|
591
|
-
planned_removal_date="October 01, 2024",
|
592
|
-
use_instead="GKEKubernetesHook",
|
593
|
-
category=AirflowProviderDeprecationWarning,
|
594
|
-
)
|
595
|
-
class GKECustomResourceHook(GKEKubernetesHook):
|
596
|
-
"""Google Kubernetes Engine Custom Resource APIs."""
|
597
|
-
|
598
|
-
|
599
|
-
@deprecated(
|
600
|
-
planned_removal_date="October 01, 2024",
|
601
|
-
use_instead="GKEKubernetesHook",
|
602
|
-
category=AirflowProviderDeprecationWarning,
|
603
|
-
)
|
604
|
-
class GKEPodHook(GKEKubernetesHook):
|
605
|
-
"""Google Kubernetes Engine pod APIs."""
|
606
|
-
|
607
|
-
def __init__(
|
608
|
-
self,
|
609
|
-
cluster_url: str,
|
610
|
-
ssl_ca_cert: str,
|
611
|
-
disable_tcp_keepalive: bool | None = None,
|
612
|
-
gcp_conn_id: str = "google_cloud_default",
|
613
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
614
|
-
**kwargs,
|
615
|
-
):
|
616
|
-
super().__init__(
|
617
|
-
gcp_conn_id=gcp_conn_id,
|
618
|
-
impersonation_chain=impersonation_chain,
|
619
|
-
cluster_url=cluster_url,
|
620
|
-
ssl_ca_cert=ssl_ca_cert,
|
621
|
-
**kwargs,
|
622
|
-
)
|
623
|
-
self.enable_tcp_keepalive = not bool(disable_tcp_keepalive)
|
624
|
-
|
625
|
-
|
626
|
-
@deprecated(
|
627
|
-
planned_removal_date="October 01, 2024",
|
628
|
-
use_instead="GKEKubernetesHook",
|
629
|
-
category=AirflowProviderDeprecationWarning,
|
630
|
-
)
|
631
|
-
class GKEJobHook(GKEKubernetesHook):
|
632
|
-
"""Google Kubernetes Engine Job APIs."""
|
633
|
-
|
634
|
-
|
635
|
-
@deprecated(
|
636
|
-
planned_removal_date="October 01, 2024",
|
637
|
-
use_instead="GKEKubernetesAsyncHook",
|
638
|
-
category=AirflowProviderDeprecationWarning,
|
639
|
-
)
|
640
|
-
class GKEPodAsyncHook(GKEKubernetesAsyncHook):
|
641
|
-
"""
|
642
|
-
Google Kubernetes Engine pods APIs asynchronously.
|
643
|
-
|
644
|
-
:param cluster_url: The URL pointed to the cluster.
|
645
|
-
:param ssl_ca_cert: SSL certificate used for authentication to the pod.
|
646
|
-
"""
|
@@ -20,7 +20,7 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import time
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
24
|
|
25
25
|
import google.api_core.path_template
|
26
26
|
from googleapiclient.discovery import build
|
@@ -73,14 +73,10 @@ class LifeSciencesHook(GoogleBaseHook):
|
|
73
73
|
impersonation_chain: str | Sequence[str] | None = None,
|
74
74
|
**kwargs,
|
75
75
|
) -> None:
|
76
|
-
if kwargs.get("delegate_to") is not None:
|
77
|
-
raise RuntimeError(
|
78
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
79
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
80
|
-
)
|
81
76
|
super().__init__(
|
82
77
|
gcp_conn_id=gcp_conn_id,
|
83
78
|
impersonation_chain=impersonation_chain,
|
79
|
+
**kwargs,
|
84
80
|
)
|
85
81
|
self.api_version = api_version
|
86
82
|
|
@@ -42,8 +42,9 @@ class LookerHook(BaseHook):
|
|
42
42
|
def __init__(
|
43
43
|
self,
|
44
44
|
looker_conn_id: str,
|
45
|
+
**kwargs,
|
45
46
|
) -> None:
|
46
|
-
super().__init__()
|
47
|
+
super().__init__(**kwargs)
|
47
48
|
self.looker_conn_id = looker_conn_id
|
48
49
|
# source is used to track origin of the requests
|
49
50
|
self.source = f"airflow:{version}"
|
@@ -92,14 +92,6 @@ class MLEngineHook(GoogleBaseHook):
|
|
92
92
|
keyword arguments rather than positional.
|
93
93
|
"""
|
94
94
|
|
95
|
-
def __init__(self, **kwargs):
|
96
|
-
if kwargs.get("delegate_to") is not None:
|
97
|
-
raise RuntimeError(
|
98
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
99
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
100
|
-
)
|
101
|
-
super().__init__(**kwargs)
|
102
|
-
|
103
95
|
def get_conn(self) -> Resource:
|
104
96
|
"""
|
105
97
|
Retrieve the connection to MLEngine.
|
@@ -19,7 +19,8 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from
|
22
|
+
from collections.abc import Sequence
|
23
|
+
from typing import TYPE_CHECKING
|
23
24
|
|
24
25
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
25
26
|
from google.cloud.language_v1 import EncodingType, LanguageServiceClient
|
@@ -62,14 +63,10 @@ class CloudNaturalLanguageHook(GoogleBaseHook):
|
|
62
63
|
impersonation_chain: str | Sequence[str] | None = None,
|
63
64
|
**kwargs,
|
64
65
|
) -> None:
|
65
|
-
if kwargs.get("delegate_to") is not None:
|
66
|
-
raise RuntimeError(
|
67
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
68
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
69
|
-
)
|
70
66
|
super().__init__(
|
71
67
|
gcp_conn_id=gcp_conn_id,
|
72
68
|
impersonation_chain=impersonation_chain,
|
69
|
+
**kwargs,
|
73
70
|
)
|
74
71
|
self._conn: LanguageServiceClient | None = None
|
75
72
|
|
@@ -24,7 +24,8 @@ OS Login hooks.
|
|
24
24
|
|
25
25
|
from __future__ import annotations
|
26
26
|
|
27
|
-
from
|
27
|
+
from collections.abc import Sequence
|
28
|
+
from typing import TYPE_CHECKING
|
28
29
|
|
29
30
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
30
31
|
from google.cloud.oslogin_v1 import ImportSshPublicKeyResponse, OsLoginServiceClient
|
@@ -50,14 +51,10 @@ class OSLoginHook(GoogleBaseHook):
|
|
50
51
|
impersonation_chain: str | Sequence[str] | None = None,
|
51
52
|
**kwargs,
|
52
53
|
) -> None:
|
53
|
-
if kwargs.get("delegate_to") is not None:
|
54
|
-
raise RuntimeError(
|
55
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
56
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
57
|
-
)
|
58
54
|
super().__init__(
|
59
55
|
gcp_conn_id=gcp_conn_id,
|
60
56
|
impersonation_chain=impersonation_chain,
|
57
|
+
**kwargs,
|
61
58
|
)
|
62
59
|
self._conn: OsLoginServiceClient | None = None
|
63
60
|
|
@@ -28,8 +28,9 @@ from __future__ import annotations
|
|
28
28
|
|
29
29
|
import warnings
|
30
30
|
from base64 import b64decode
|
31
|
+
from collections.abc import Sequence
|
31
32
|
from functools import cached_property
|
32
|
-
from typing import TYPE_CHECKING, Any
|
33
|
+
from typing import TYPE_CHECKING, Any
|
33
34
|
from uuid import uuid4
|
34
35
|
|
35
36
|
from google.api_core.exceptions import AlreadyExists, GoogleAPICallError
|
@@ -83,14 +84,10 @@ class PubSubHook(GoogleBaseHook):
|
|
83
84
|
enable_message_ordering: bool = False,
|
84
85
|
**kwargs,
|
85
86
|
) -> None:
|
86
|
-
if kwargs.get("delegate_to") is not None:
|
87
|
-
raise RuntimeError(
|
88
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
89
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
90
|
-
)
|
91
87
|
super().__init__(
|
92
88
|
gcp_conn_id=gcp_conn_id,
|
93
89
|
impersonation_chain=impersonation_chain,
|
90
|
+
**kwargs,
|
94
91
|
)
|
95
92
|
self.enable_message_ordering = enable_message_ordering
|
96
93
|
self._client = None
|