apache-airflow-providers-google 14.0.0__py3-none-any.whl → 14.1.0rc1__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.
Files changed (145) hide show
  1. airflow/providers/google/3rd-party-licenses/LICENSES.txt +14 -0
  2. airflow/providers/google/3rd-party-licenses/NOTICE +15 -0
  3. airflow/providers/google/__init__.py +1 -1
  4. airflow/providers/google/_vendor/__init__.py +0 -0
  5. airflow/providers/google/_vendor/json_merge_patch.py +91 -0
  6. airflow/providers/google/ads/hooks/ads.py +12 -11
  7. airflow/providers/google/cloud/_internal_client/secret_manager_client.py +3 -2
  8. airflow/providers/google/cloud/hooks/alloy_db.py +2 -3
  9. airflow/providers/google/cloud/hooks/automl.py +7 -13
  10. airflow/providers/google/cloud/hooks/bigquery.py +21 -22
  11. airflow/providers/google/cloud/hooks/bigquery_dts.py +8 -8
  12. airflow/providers/google/cloud/hooks/bigtable.py +3 -2
  13. airflow/providers/google/cloud/hooks/cloud_batch.py +4 -3
  14. airflow/providers/google/cloud/hooks/cloud_build.py +7 -13
  15. airflow/providers/google/cloud/hooks/cloud_composer.py +7 -12
  16. airflow/providers/google/cloud/hooks/cloud_memorystore.py +4 -3
  17. airflow/providers/google/cloud/hooks/cloud_run.py +4 -3
  18. airflow/providers/google/cloud/hooks/cloud_sql.py +1 -1
  19. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +8 -9
  20. airflow/providers/google/cloud/hooks/compute.py +3 -3
  21. airflow/providers/google/cloud/hooks/datacatalog.py +4 -3
  22. airflow/providers/google/cloud/hooks/dataflow.py +12 -12
  23. airflow/providers/google/cloud/hooks/dataform.py +3 -2
  24. airflow/providers/google/cloud/hooks/datafusion.py +2 -2
  25. airflow/providers/google/cloud/hooks/dataplex.py +11 -10
  26. airflow/providers/google/cloud/hooks/dataproc.py +5 -4
  27. airflow/providers/google/cloud/hooks/dataproc_metastore.py +4 -3
  28. airflow/providers/google/cloud/hooks/dlp.py +4 -3
  29. airflow/providers/google/cloud/hooks/gcs.py +19 -12
  30. airflow/providers/google/cloud/hooks/kms.py +3 -2
  31. airflow/providers/google/cloud/hooks/kubernetes_engine.py +20 -14
  32. airflow/providers/google/cloud/hooks/life_sciences.py +1 -1
  33. airflow/providers/google/cloud/hooks/managed_kafka.py +227 -3
  34. airflow/providers/google/cloud/hooks/natural_language.py +3 -2
  35. airflow/providers/google/cloud/hooks/os_login.py +3 -2
  36. airflow/providers/google/cloud/hooks/pubsub.py +6 -6
  37. airflow/providers/google/cloud/hooks/secret_manager.py +3 -2
  38. airflow/providers/google/cloud/hooks/spanner.py +2 -2
  39. airflow/providers/google/cloud/hooks/speech_to_text.py +3 -2
  40. airflow/providers/google/cloud/hooks/stackdriver.py +4 -4
  41. airflow/providers/google/cloud/hooks/tasks.py +4 -3
  42. airflow/providers/google/cloud/hooks/text_to_speech.py +3 -2
  43. airflow/providers/google/cloud/hooks/translate.py +6 -15
  44. airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +6 -12
  45. airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +6 -12
  46. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +7 -13
  47. airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +5 -12
  48. airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +4 -11
  49. airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +4 -3
  50. airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +6 -12
  51. airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +6 -11
  52. airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +6 -12
  53. airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +3 -2
  54. airflow/providers/google/cloud/hooks/video_intelligence.py +3 -2
  55. airflow/providers/google/cloud/hooks/vision.py +4 -3
  56. airflow/providers/google/cloud/hooks/workflows.py +3 -2
  57. airflow/providers/google/cloud/links/base.py +7 -1
  58. airflow/providers/google/cloud/links/datafusion.py +8 -2
  59. airflow/providers/google/cloud/links/dataproc.py +8 -1
  60. airflow/providers/google/cloud/links/kubernetes_engine.py +2 -1
  61. airflow/providers/google/cloud/links/managed_kafka.py +30 -0
  62. airflow/providers/google/cloud/log/gcs_task_handler.py +15 -7
  63. airflow/providers/google/cloud/log/stackdriver_task_handler.py +8 -6
  64. airflow/providers/google/cloud/openlineage/utils.py +4 -2
  65. airflow/providers/google/cloud/operators/alloy_db.py +6 -5
  66. airflow/providers/google/cloud/operators/automl.py +11 -9
  67. airflow/providers/google/cloud/operators/bigquery.py +8 -6
  68. airflow/providers/google/cloud/operators/bigquery_dts.py +10 -8
  69. airflow/providers/google/cloud/operators/bigtable.py +3 -1
  70. airflow/providers/google/cloud/operators/cloud_base.py +2 -1
  71. airflow/providers/google/cloud/operators/cloud_batch.py +4 -2
  72. airflow/providers/google/cloud/operators/cloud_build.py +5 -3
  73. airflow/providers/google/cloud/operators/cloud_composer.py +7 -5
  74. airflow/providers/google/cloud/operators/cloud_memorystore.py +6 -4
  75. airflow/providers/google/cloud/operators/cloud_run.py +5 -3
  76. airflow/providers/google/cloud/operators/compute.py +5 -4
  77. airflow/providers/google/cloud/operators/datacatalog.py +11 -9
  78. airflow/providers/google/cloud/operators/dataform.py +5 -3
  79. airflow/providers/google/cloud/operators/datafusion.py +1 -1
  80. airflow/providers/google/cloud/operators/dataplex.py +20 -18
  81. airflow/providers/google/cloud/operators/dataproc.py +34 -5
  82. airflow/providers/google/cloud/operators/dataproc_metastore.py +18 -7
  83. airflow/providers/google/cloud/operators/dlp.py +19 -17
  84. airflow/providers/google/cloud/operators/gcs.py +5 -4
  85. airflow/providers/google/cloud/operators/kubernetes_engine.py +54 -5
  86. airflow/providers/google/cloud/operators/managed_kafka.py +271 -4
  87. airflow/providers/google/cloud/operators/natural_language.py +5 -3
  88. airflow/providers/google/cloud/operators/pubsub.py +10 -8
  89. airflow/providers/google/cloud/operators/speech_to_text.py +5 -3
  90. airflow/providers/google/cloud/operators/stackdriver.py +5 -3
  91. airflow/providers/google/cloud/operators/tasks.py +6 -4
  92. airflow/providers/google/cloud/operators/text_to_speech.py +4 -2
  93. airflow/providers/google/cloud/operators/translate.py +5 -3
  94. airflow/providers/google/cloud/operators/translate_speech.py +4 -2
  95. airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +8 -6
  96. airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +6 -4
  97. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +8 -6
  98. airflow/providers/google/cloud/operators/vertex_ai/dataset.py +6 -4
  99. airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +6 -4
  100. airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +6 -4
  101. airflow/providers/google/cloud/operators/vertex_ai/model_service.py +6 -4
  102. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +6 -4
  103. airflow/providers/google/cloud/operators/video_intelligence.py +5 -3
  104. airflow/providers/google/cloud/operators/vision.py +6 -4
  105. airflow/providers/google/cloud/operators/workflows.py +7 -5
  106. airflow/providers/google/cloud/secrets/secret_manager.py +2 -1
  107. airflow/providers/google/cloud/sensors/bigquery_dts.py +5 -3
  108. airflow/providers/google/cloud/sensors/bigtable.py +3 -2
  109. airflow/providers/google/cloud/sensors/cloud_composer.py +1 -1
  110. airflow/providers/google/cloud/sensors/dataplex.py +6 -4
  111. airflow/providers/google/cloud/sensors/dataproc.py +3 -2
  112. airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -1
  113. airflow/providers/google/cloud/sensors/gcs.py +4 -2
  114. airflow/providers/google/cloud/sensors/pubsub.py +3 -2
  115. airflow/providers/google/cloud/sensors/workflows.py +5 -3
  116. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +5 -3
  117. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +12 -10
  118. airflow/providers/google/cloud/triggers/bigquery_dts.py +2 -1
  119. airflow/providers/google/cloud/triggers/cloud_batch.py +2 -1
  120. airflow/providers/google/cloud/triggers/cloud_build.py +2 -1
  121. airflow/providers/google/cloud/triggers/cloud_composer.py +1 -1
  122. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +3 -2
  123. airflow/providers/google/cloud/triggers/dataflow.py +3 -2
  124. airflow/providers/google/cloud/triggers/dataplex.py +2 -1
  125. airflow/providers/google/cloud/triggers/dataproc.py +3 -2
  126. airflow/providers/google/cloud/triggers/kubernetes_engine.py +1 -1
  127. airflow/providers/google/cloud/triggers/pubsub.py +2 -1
  128. airflow/providers/google/cloud/triggers/vertex_ai.py +8 -7
  129. airflow/providers/google/cloud/utils/credentials_provider.py +4 -3
  130. airflow/providers/google/cloud/utils/external_token_supplier.py +0 -1
  131. airflow/providers/google/cloud/{example_dags/__init__.py → utils/validators.py} +27 -0
  132. airflow/providers/google/common/auth_backend/google_openid.py +14 -5
  133. airflow/providers/google/common/consts.py +2 -1
  134. airflow/providers/google/common/hooks/base_google.py +7 -8
  135. airflow/providers/google/common/hooks/operation_helpers.py +79 -0
  136. airflow/providers/google/get_provider_info.py +11 -6
  137. airflow/providers/google/marketing_platform/hooks/analytics_admin.py +3 -2
  138. airflow/providers/google/marketing_platform/hooks/search_ads.py +1 -1
  139. airflow/providers/google/marketing_platform/links/analytics_admin.py +10 -2
  140. airflow/providers/google/marketing_platform/operators/analytics_admin.py +7 -5
  141. {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-14.1.0rc1.dist-info}/METADATA +35 -38
  142. {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-14.1.0rc1.dist-info}/RECORD +144 -140
  143. {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-14.1.0rc1.dist-info}/WHEEL +1 -1
  144. airflow/providers/google/cloud/example_dags/example_cloud_task.py +0 -54
  145. {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-14.1.0rc1.dist-info}/entry_points.txt +0 -0
@@ -19,12 +19,18 @@ from __future__ import annotations
19
19
 
20
20
  from typing import TYPE_CHECKING, ClassVar
21
21
 
22
- from airflow.models import BaseOperatorLink, XCom
22
+ from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
23
23
 
24
24
  if TYPE_CHECKING:
25
25
  from airflow.models import BaseOperator
26
26
  from airflow.models.taskinstancekey import TaskInstanceKey
27
27
 
28
+ if AIRFLOW_V_3_0_PLUS:
29
+ from airflow.sdk import BaseOperatorLink
30
+ from airflow.sdk.execution_time.xcom import XCom
31
+ else:
32
+ from airflow.models.baseoperatorlink import BaseOperatorLink # type: ignore[no-redef]
33
+ from airflow.models.xcom import XCom # type: ignore[no-redef]
28
34
 
29
35
  BASE_LINK = "https://console.cloud.google.com"
30
36
 
@@ -21,14 +21,20 @@ from __future__ import annotations
21
21
 
22
22
  from typing import TYPE_CHECKING, ClassVar
23
23
 
24
- from airflow.models import BaseOperatorLink, XCom
24
+ from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
25
+
26
+ if AIRFLOW_V_3_0_PLUS:
27
+ from airflow.sdk import BaseOperatorLink
28
+ from airflow.sdk.execution_time.xcom import XCom
29
+ else:
30
+ from airflow.models import XCom # type: ignore[no-redef]
31
+ from airflow.models.baseoperatorlink import BaseOperatorLink # type: ignore[no-redef]
25
32
 
26
33
  if TYPE_CHECKING:
27
34
  from airflow.models import BaseOperator
28
35
  from airflow.models.taskinstancekey import TaskInstanceKey
29
36
  from airflow.utils.context import Context
30
37
 
31
-
32
38
  BASE_LINK = "https://console.cloud.google.com/data-fusion"
33
39
  DATAFUSION_INSTANCE_LINK = BASE_LINK + "/locations/{region}/instances/{instance_name}?project={project_id}"
34
40
  DATAFUSION_PIPELINES_LINK = "{uri}/cdap/ns/{namespace}/pipelines"
@@ -25,14 +25,21 @@ from typing import TYPE_CHECKING, Any
25
25
  import attr
26
26
 
27
27
  from airflow.exceptions import AirflowProviderDeprecationWarning
28
- from airflow.models import BaseOperatorLink, XCom
29
28
  from airflow.providers.google.cloud.links.base import BASE_LINK, BaseGoogleLink
29
+ from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
30
30
 
31
31
  if TYPE_CHECKING:
32
32
  from airflow.models import BaseOperator
33
33
  from airflow.models.taskinstancekey import TaskInstanceKey
34
34
  from airflow.utils.context import Context
35
35
 
36
+ if AIRFLOW_V_3_0_PLUS:
37
+ from airflow.sdk import BaseOperatorLink
38
+ from airflow.sdk.execution_time.xcom import XCom
39
+ else:
40
+ from airflow.models import XCom # type: ignore[no-redef]
41
+ from airflow.models.baseoperatorlink import BaseOperatorLink # type: ignore[no-redef]
42
+
36
43
 
37
44
  def __getattr__(name: str) -> Any:
38
45
  # PEP-562: deprecate module-level variable
@@ -19,9 +19,10 @@ from __future__ import annotations
19
19
  import json
20
20
  from typing import TYPE_CHECKING
21
21
 
22
- from airflow.providers.google.cloud.links.base import BaseGoogleLink
23
22
  from google.cloud.container_v1.types import Cluster
24
23
 
24
+ from airflow.providers.google.cloud.links.base import BaseGoogleLink
25
+
25
26
  if TYPE_CHECKING:
26
27
  from airflow.utils.context import Context
27
28
 
@@ -31,6 +31,10 @@ MANAGED_KAFKA_CLUSTER_LIST_LINK = MANAGED_KAFKA_BASE_LINK + "/clusters?project={
31
31
  MANAGED_KAFKA_TOPIC_LINK = (
32
32
  MANAGED_KAFKA_BASE_LINK + "/{location}/clusters/{cluster_id}/topics/{topic_id}?project={project_id}"
33
33
  )
34
+ MANAGED_KAFKA_CONSUMER_GROUP_LINK = (
35
+ MANAGED_KAFKA_BASE_LINK
36
+ + "/{location}/clusters/{cluster_id}/consumer_groups/{consumer_group_id}?project={project_id}"
37
+ )
34
38
 
35
39
 
36
40
  class ApacheKafkaClusterLink(BaseGoogleLink):
@@ -102,3 +106,29 @@ class ApacheKafkaTopicLink(BaseGoogleLink):
102
106
  "project_id": task_instance.project_id,
103
107
  },
104
108
  )
109
+
110
+
111
+ class ApacheKafkaConsumerGroupLink(BaseGoogleLink):
112
+ """Helper class for constructing Apache Kafka Consumer Group link."""
113
+
114
+ name = "Apache Kafka Consumer Group"
115
+ key = "consumer_group_conf"
116
+ format_str = MANAGED_KAFKA_CONSUMER_GROUP_LINK
117
+
118
+ @staticmethod
119
+ def persist(
120
+ context: Context,
121
+ task_instance,
122
+ cluster_id: str,
123
+ consumer_group_id: str,
124
+ ):
125
+ task_instance.xcom_push(
126
+ context=context,
127
+ key=ApacheKafkaConsumerGroupLink.key,
128
+ value={
129
+ "location": task_instance.location,
130
+ "cluster_id": cluster_id,
131
+ "consumer_group_id": consumer_group_id,
132
+ "project_id": task_instance.project_id,
133
+ },
134
+ )
@@ -25,18 +25,21 @@ from functools import cached_property
25
25
  from pathlib import Path
26
26
  from typing import TYPE_CHECKING
27
27
 
28
+ # not sure why but mypy complains on missing `storage` but it is clearly there and is importable
29
+ from google.cloud import storage # type: ignore[attr-defined]
30
+
28
31
  from airflow.configuration import conf
29
32
  from airflow.exceptions import AirflowNotFoundException
30
33
  from airflow.providers.google.cloud.hooks.gcs import GCSHook, _parse_gcs_url
31
- from airflow.providers.google.cloud.utils.credentials_provider import get_credentials_and_project_id
34
+ from airflow.providers.google.cloud.utils.credentials_provider import (
35
+ get_credentials_and_project_id,
36
+ )
32
37
  from airflow.providers.google.common.consts import CLIENT_INFO
33
38
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
39
+ from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
34
40
  from airflow.utils.log.file_task_handler import FileTaskHandler
35
41
  from airflow.utils.log.logging_mixin import LoggingMixin
36
42
 
37
- # not sure why but mypy complains on missing `storage` but it is clearly there and is importable
38
- from google.cloud import storage # type: ignore[attr-defined]
39
-
40
43
  if TYPE_CHECKING:
41
44
  from airflow.models.taskinstance import TaskInstance
42
45
 
@@ -188,9 +191,13 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin):
188
191
 
189
192
  if blobs:
190
193
  uris = [f"gs://{bucket}/{b.name}" for b in blobs]
191
- messages.extend(["Found remote logs:", *[f" * {x}" for x in sorted(uris)]])
194
+ if AIRFLOW_V_3_0_PLUS:
195
+ messages = uris
196
+ else:
197
+ messages.extend(["Found remote logs:", *[f" * {x}" for x in sorted(uris)]])
192
198
  else:
193
- messages.append(f"No logs found in GCS; ti=%s {ti}")
199
+ if not AIRFLOW_V_3_0_PLUS:
200
+ messages.append(f"No logs found in GCS; ti={ti}")
194
201
  try:
195
202
  for key in sorted(uris):
196
203
  blob = storage.Blob.from_string(key, self.client)
@@ -198,7 +205,8 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin):
198
205
  if remote_log:
199
206
  logs.append(remote_log)
200
207
  except Exception as e:
201
- messages.append(f"Unable to read remote log {e}")
208
+ if not AIRFLOW_V_3_0_PLUS:
209
+ messages.append(f"Unable to read remote log {e}")
202
210
  return messages, logs
203
211
 
204
212
  def gcs_write(self, log, remote_log_location) -> bool:
@@ -25,21 +25,23 @@ from functools import cached_property
25
25
  from typing import TYPE_CHECKING
26
26
  from urllib.parse import urlencode
27
27
 
28
- from airflow.exceptions import AirflowProviderDeprecationWarning
29
- from airflow.providers.google.cloud.utils.credentials_provider import get_credentials_and_project_id
30
- from airflow.providers.google.common.consts import CLIENT_INFO
31
- from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
32
- from airflow.utils.types import NOTSET, ArgNotSet
33
28
  from google.cloud import logging as gcp_logging
34
29
  from google.cloud.logging import Resource
35
30
  from google.cloud.logging.handlers.transports import BackgroundThreadTransport, Transport
36
31
  from google.cloud.logging_v2.services.logging_service_v2 import LoggingServiceV2Client
37
32
  from google.cloud.logging_v2.types import ListLogEntriesRequest, ListLogEntriesResponse
38
33
 
34
+ from airflow.exceptions import AirflowProviderDeprecationWarning
35
+ from airflow.providers.google.cloud.utils.credentials_provider import get_credentials_and_project_id
36
+ from airflow.providers.google.common.consts import CLIENT_INFO
37
+ from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
38
+ from airflow.utils.types import NOTSET, ArgNotSet
39
+
39
40
  if TYPE_CHECKING:
40
- from airflow.models import TaskInstance
41
41
  from google.auth.credentials import Credentials
42
42
 
43
+ from airflow.models import TaskInstance
44
+
43
45
 
44
46
  if not AIRFLOW_V_3_0_PLUS:
45
47
  from airflow.utils.log.trigger_handler import ctx_indiv_trigger
@@ -26,6 +26,8 @@ from collections import defaultdict
26
26
  from collections.abc import Iterable
27
27
  from typing import TYPE_CHECKING, Any
28
28
 
29
+ from google.cloud.dataproc_v1 import Batch, RuntimeConfig
30
+
29
31
  from airflow.providers.common.compat.openlineage.facet import (
30
32
  ColumnLineageDatasetFacet,
31
33
  DatasetFacet,
@@ -42,12 +44,12 @@ from airflow.providers.common.compat.openlineage.utils.spark import (
42
44
  inject_transport_information_into_spark_properties,
43
45
  )
44
46
  from airflow.providers.google.cloud.hooks.gcs import _parse_gcs_url
45
- from google.cloud.dataproc_v1 import Batch, RuntimeConfig
46
47
 
47
48
  if TYPE_CHECKING:
49
+ from google.cloud.bigquery.table import Table
50
+
48
51
  from airflow.providers.common.compat.openlineage.facet import Dataset
49
52
  from airflow.utils.context import Context
50
- from google.cloud.bigquery.table import Table
51
53
 
52
54
 
53
55
  log = logging.getLogger(__name__)
@@ -23,6 +23,10 @@ from collections.abc import Sequence
23
23
  from functools import cached_property
24
24
  from typing import TYPE_CHECKING
25
25
 
26
+ from google.api_core.exceptions import NotFound
27
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
+ from google.cloud import alloydb_v1
29
+
26
30
  from airflow.exceptions import AirflowException
27
31
  from airflow.providers.google.cloud.hooks.alloy_db import AlloyDbHook
28
32
  from airflow.providers.google.cloud.links.alloy_db import (
@@ -31,18 +35,15 @@ from airflow.providers.google.cloud.links.alloy_db import (
31
35
  AlloyDBUsersLink,
32
36
  )
33
37
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
34
- from google.api_core.exceptions import NotFound
35
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
36
- from google.cloud import alloydb_v1
37
38
 
38
39
  if TYPE_CHECKING:
39
40
  import proto
40
-
41
- from airflow.utils.context import Context
42
41
  from google.api_core.operation import Operation
43
42
  from google.api_core.retry import Retry
44
43
  from google.protobuf.field_mask_pb2 import FieldMask
45
44
 
45
+ from airflow.utils.context import Context
46
+
46
47
 
47
48
  class AlloyDBBaseOperator(GoogleCloudBaseOperator):
48
49
  """
@@ -24,6 +24,15 @@ from collections.abc import Sequence
24
24
  from functools import cached_property
25
25
  from typing import TYPE_CHECKING, cast
26
26
 
27
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
+ from google.cloud.automl_v1beta1 import (
29
+ ColumnSpec,
30
+ Dataset,
31
+ Model,
32
+ PredictResponse,
33
+ TableSpec,
34
+ )
35
+
27
36
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
28
37
  from airflow.providers.google.cloud.hooks.automl import CloudAutoMLHook
29
38
  from airflow.providers.google.cloud.hooks.vertex_ai.prediction_service import PredictionServiceHook
@@ -37,19 +46,12 @@ from airflow.providers.google.cloud.links.translate import (
37
46
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
38
47
  from airflow.providers.google.common.deprecated import deprecated
39
48
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
40
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
41
- from google.cloud.automl_v1beta1 import (
42
- ColumnSpec,
43
- Dataset,
44
- Model,
45
- PredictResponse,
46
- TableSpec,
47
- )
48
49
 
49
50
  if TYPE_CHECKING:
50
- from airflow.utils.context import Context
51
51
  from google.api_core.retry import Retry
52
52
 
53
+ from airflow.utils.context import Context
54
+
53
55
  MetaData = Sequence[tuple[str, str]]
54
56
 
55
57
 
@@ -27,6 +27,11 @@ from collections.abc import Sequence
27
27
  from functools import cached_property
28
28
  from typing import TYPE_CHECKING, Any, SupportsAbs
29
29
 
30
+ from google.api_core.exceptions import Conflict
31
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
32
+ from google.cloud.bigquery import DEFAULT_RETRY, CopyJob, ExtractJob, LoadJob, QueryJob, Row
33
+ from google.cloud.bigquery.table import RowIterator, Table, TableListItem, TableReference
34
+
30
35
  from airflow.configuration import conf
31
36
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning, AirflowSkipException
32
37
  from airflow.providers.common.sql.operators.sql import ( # type: ignore[attr-defined] # for _parse_boolean
@@ -57,16 +62,13 @@ from airflow.providers.google.cloud.utils.bigquery import convert_job_id
57
62
  from airflow.providers.google.common.deprecated import deprecated
58
63
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
59
64
  from airflow.utils.helpers import exactly_one
60
- from google.api_core.exceptions import Conflict
61
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
62
- from google.cloud.bigquery import DEFAULT_RETRY, CopyJob, ExtractJob, LoadJob, QueryJob, Row
63
- from google.cloud.bigquery.table import RowIterator, Table, TableListItem, TableReference
64
65
 
65
66
  if TYPE_CHECKING:
66
- from airflow.utils.context import Context
67
67
  from google.api_core.retry import Retry
68
68
  from google.cloud.bigquery import UnknownJob
69
69
 
70
+ from airflow.utils.context import Context
71
+
70
72
 
71
73
  BIGQUERY_JOB_DETAILS_LINK_FMT = "https://console.cloud.google.com/bigquery?j={job_id}"
72
74
 
@@ -2895,7 +2897,7 @@ class BigQueryInsertJobOperator(GoogleCloudBaseOperator, _BigQueryInsertJobOpera
2895
2897
 
2896
2898
  def _add_job_labels(self) -> None:
2897
2899
  dag_label = self.dag_id.lower()
2898
- task_label = self.task_id.lower()
2900
+ task_label = self.task_id.lower().replace(".", "-")
2899
2901
 
2900
2902
  if LABEL_REGEX.match(dag_label) and LABEL_REGEX.match(task_label):
2901
2903
  automatic_labels = {"airflow-dag": dag_label, "airflow-task": task_label}
@@ -24,13 +24,6 @@ from collections.abc import Sequence
24
24
  from functools import cached_property
25
25
  from typing import TYPE_CHECKING
26
26
 
27
- from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException
29
- from airflow.providers.google.cloud.hooks.bigquery_dts import BiqQueryDataTransferServiceHook, get_object_id
30
- from airflow.providers.google.cloud.links.bigquery_dts import BigQueryDataTransferConfigLink
31
- from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
32
- from airflow.providers.google.cloud.triggers.bigquery_dts import BigQueryDataTransferRunTrigger
33
- from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
34
27
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
35
28
  from google.cloud.bigquery_datatransfer_v1 import (
36
29
  StartManualTransferRunsResponse,
@@ -39,10 +32,19 @@ from google.cloud.bigquery_datatransfer_v1 import (
39
32
  TransferState,
40
33
  )
41
34
 
35
+ from airflow.configuration import conf
36
+ from airflow.exceptions import AirflowException
37
+ from airflow.providers.google.cloud.hooks.bigquery_dts import BiqQueryDataTransferServiceHook, get_object_id
38
+ from airflow.providers.google.cloud.links.bigquery_dts import BigQueryDataTransferConfigLink
39
+ from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
40
+ from airflow.providers.google.cloud.triggers.bigquery_dts import BigQueryDataTransferRunTrigger
41
+ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
42
+
42
43
  if TYPE_CHECKING:
43
- from airflow.utils.context import Context
44
44
  from google.api_core.retry import Retry
45
45
 
46
+ from airflow.utils.context import Context
47
+
46
48
 
47
49
  def _get_transfer_config_details(config_transfer_name: str):
48
50
  config_details = config_transfer_name.split("/")
@@ -23,6 +23,7 @@ from collections.abc import Iterable, Sequence
23
23
  from typing import TYPE_CHECKING
24
24
 
25
25
  import google.api_core.exceptions
26
+
26
27
  from airflow.exceptions import AirflowException
27
28
  from airflow.providers.google.cloud.hooks.bigtable import BigtableHook
28
29
  from airflow.providers.google.cloud.links.bigtable import (
@@ -36,10 +37,11 @@ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
36
37
  if TYPE_CHECKING:
37
38
  import enum
38
39
 
39
- from airflow.utils.context import Context
40
40
  from google.cloud.bigtable import enums
41
41
  from google.cloud.bigtable.column_family import GarbageCollectionRule
42
42
 
43
+ from airflow.utils.context import Context
44
+
43
45
 
44
46
  class BigtableValidationMixin:
45
47
  """Common class for Cloud Bigtable operators for validating required fields."""
@@ -19,9 +19,10 @@
19
19
 
20
20
  from __future__ import annotations
21
21
 
22
- from airflow.models import BaseOperator
23
22
  from google.api_core.gapic_v1.method import DEFAULT
24
23
 
24
+ from airflow.models import BaseOperator
25
+
25
26
 
26
27
  class GoogleCloudBaseOperator(BaseOperator):
27
28
  """Abstract base class for operators using Google API client libraries."""
@@ -20,17 +20,19 @@ from __future__ import annotations
20
20
  from collections.abc import Sequence
21
21
  from typing import TYPE_CHECKING
22
22
 
23
+ from google.cloud.batch_v1 import Job, Task
24
+
23
25
  from airflow.configuration import conf
24
26
  from airflow.exceptions import AirflowException
25
27
  from airflow.providers.google.cloud.hooks.cloud_batch import CloudBatchHook
26
28
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
27
29
  from airflow.providers.google.cloud.triggers.cloud_batch import CloudBatchJobFinishedTrigger
28
- from google.cloud.batch_v1 import Job, Task
29
30
 
30
31
  if TYPE_CHECKING:
31
- from airflow.utils.context import Context
32
32
  from google.api_core import operation
33
33
 
34
+ from airflow.utils.context import Context
35
+
34
36
 
35
37
  class CloudBatchSubmitJobOperator(GoogleCloudBaseOperator):
36
38
  """
@@ -26,6 +26,9 @@ from copy import deepcopy
26
26
  from typing import TYPE_CHECKING, Any
27
27
  from urllib.parse import unquote, urlsplit
28
28
 
29
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
30
+ from google.cloud.devtools.cloudbuild_v1.types import Build, BuildTrigger, RepoSource
31
+
29
32
  from airflow.configuration import conf
30
33
  from airflow.exceptions import AirflowException
31
34
  from airflow.providers.google.cloud.hooks.cloud_build import CloudBuildHook
@@ -41,13 +44,12 @@ from airflow.providers.google.common.consts import GOOGLE_DEFAULT_DEFERRABLE_MET
41
44
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
42
45
  from airflow.utils import yaml
43
46
  from airflow.utils.helpers import exactly_one
44
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
45
- from google.cloud.devtools.cloudbuild_v1.types import Build, BuildTrigger, RepoSource
46
47
 
47
48
  if TYPE_CHECKING:
48
- from airflow.utils.context import Context
49
49
  from google.api_core.retry import Retry
50
50
 
51
+ from airflow.utils.context import Context
52
+
51
53
 
52
54
  REGEX_REPO_PATH = re.compile(r"^/(?P<project_id>[^/]+)/(?P<repo_name>[^/]+)[\+/]*(?P<branch_name>[^:]+)?")
53
55
 
@@ -21,6 +21,11 @@ import shlex
21
21
  from collections.abc import Sequence
22
22
  from typing import TYPE_CHECKING
23
23
 
24
+ from google.api_core.exceptions import AlreadyExists
25
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
26
+ from google.cloud.orchestration.airflow.service_v1 import ImageVersion
27
+ from google.cloud.orchestration.airflow.service_v1.types import Environment, ExecuteAirflowCommandResponse
28
+
24
29
  from airflow.configuration import conf
25
30
  from airflow.exceptions import AirflowException
26
31
  from airflow.providers.google.cloud.hooks.cloud_composer import CloudComposerHook
@@ -31,16 +36,13 @@ from airflow.providers.google.cloud.triggers.cloud_composer import (
31
36
  CloudComposerExecutionTrigger,
32
37
  )
33
38
  from airflow.providers.google.common.consts import GOOGLE_DEFAULT_DEFERRABLE_METHOD_NAME
34
- from google.api_core.exceptions import AlreadyExists
35
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
36
- from google.cloud.orchestration.airflow.service_v1 import ImageVersion
37
- from google.cloud.orchestration.airflow.service_v1.types import Environment, ExecuteAirflowCommandResponse
38
39
 
39
40
  if TYPE_CHECKING:
40
- from airflow.utils.context import Context
41
41
  from google.api_core.retry import Retry
42
42
  from google.protobuf.field_mask_pb2 import FieldMask
43
43
 
44
+ from airflow.utils.context import Context
45
+
44
46
  CLOUD_COMPOSER_BASE_LINK = "https://console.cloud.google.com/composer/environments"
45
47
  CLOUD_COMPOSER_DETAILS_LINK = (
46
48
  CLOUD_COMPOSER_BASE_LINK + "/detail/{region}/{environment_id}/monitoring?project={project_id}"
@@ -29,6 +29,10 @@ from __future__ import annotations
29
29
  from collections.abc import Sequence
30
30
  from typing import TYPE_CHECKING
31
31
 
32
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
33
+ from google.cloud.memcache_v1beta2.types import cloud_memcache
34
+ from google.cloud.redis_v1 import FailoverInstanceRequest, InputConfig, Instance, OutputConfig
35
+
32
36
  from airflow.providers.google.cloud.hooks.cloud_memorystore import (
33
37
  CloudMemorystoreHook,
34
38
  CloudMemorystoreMemcachedHook,
@@ -41,15 +45,13 @@ from airflow.providers.google.cloud.links.cloud_memorystore import (
41
45
  )
42
46
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
43
47
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
44
- from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
45
- from google.cloud.memcache_v1beta2.types import cloud_memcache
46
- from google.cloud.redis_v1 import FailoverInstanceRequest, InputConfig, Instance, OutputConfig
47
48
 
48
49
  if TYPE_CHECKING:
49
- from airflow.utils.context import Context
50
50
  from google.api_core.retry import Retry
51
51
  from google.protobuf.field_mask_pb2 import FieldMask
52
52
 
53
+ from airflow.utils.context import Context
54
+
53
55
 
54
56
  class CloudMemorystoreCreateInstanceOperator(GoogleCloudBaseOperator):
55
57
  """
@@ -21,19 +21,21 @@ from collections.abc import Sequence
21
21
  from typing import TYPE_CHECKING, Any
22
22
 
23
23
  import google.cloud.exceptions
24
+ from google.api_core.exceptions import AlreadyExists
25
+ from google.cloud.run_v2 import Job, Service
26
+
24
27
  from airflow.configuration import conf
25
28
  from airflow.exceptions import AirflowException
26
29
  from airflow.providers.google.cloud.hooks.cloud_run import CloudRunHook, CloudRunServiceHook
27
30
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
28
31
  from airflow.providers.google.cloud.triggers.cloud_run import CloudRunJobFinishedTrigger, RunJobStatus
29
- from google.api_core.exceptions import AlreadyExists
30
- from google.cloud.run_v2 import Job, Service
31
32
 
32
33
  if TYPE_CHECKING:
33
- from airflow.utils.context import Context
34
34
  from google.api_core import operation
35
35
  from google.cloud.run_v2.types import Execution
36
36
 
37
+ from airflow.utils.context import Context
38
+
37
39
 
38
40
  class CloudRunCreateJobOperator(GoogleCloudBaseOperator):
39
41
  """
@@ -23,9 +23,11 @@ from collections.abc import Sequence
23
23
  from copy import deepcopy
24
24
  from typing import TYPE_CHECKING, Any
25
25
 
26
- from json_merge_patch import merge
26
+ from google.api_core import exceptions
27
+ from google.cloud.compute_v1.types import Instance, InstanceGroupManager, InstanceTemplate
27
28
 
28
29
  from airflow.exceptions import AirflowException
30
+ from airflow.providers.google._vendor.json_merge_patch import merge
29
31
  from airflow.providers.google.cloud.hooks.compute import ComputeEngineHook
30
32
  from airflow.providers.google.cloud.links.compute import (
31
33
  ComputeInstanceDetailsLink,
@@ -36,13 +38,12 @@ from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseO
36
38
  from airflow.providers.google.cloud.utils.field_sanitizer import GcpBodyFieldSanitizer
37
39
  from airflow.providers.google.cloud.utils.field_validator import GcpBodyFieldValidator
38
40
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
39
- from google.api_core import exceptions
40
- from google.cloud.compute_v1.types import Instance, InstanceGroupManager, InstanceTemplate
41
41
 
42
42
  if TYPE_CHECKING:
43
- from airflow.utils.context import Context
44
43
  from google.api_core.retry import Retry
45
44
 
45
+ from airflow.utils.context import Context
46
+
46
47
 
47
48
  class ComputeEngineBaseOperator(GoogleCloudBaseOperator):
48
49
  """Abstract base operator for Google Compute Engine operators to inherit from."""
@@ -19,14 +19,6 @@ from __future__ import annotations
19
19
  from collections.abc import Sequence
20
20
  from typing import TYPE_CHECKING
21
21
 
22
- from airflow.providers.google.cloud.hooks.datacatalog import CloudDataCatalogHook
23
- from airflow.providers.google.cloud.links.datacatalog import (
24
- DataCatalogEntryGroupLink,
25
- DataCatalogEntryLink,
26
- DataCatalogTagTemplateLink,
27
- )
28
- from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
29
- from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
30
22
  from google.api_core.exceptions import AlreadyExists, NotFound
31
23
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
32
24
  from google.cloud.datacatalog import (
@@ -40,11 +32,21 @@ from google.cloud.datacatalog import (
40
32
  TagTemplateField,
41
33
  )
42
34
 
35
+ from airflow.providers.google.cloud.hooks.datacatalog import CloudDataCatalogHook
36
+ from airflow.providers.google.cloud.links.datacatalog import (
37
+ DataCatalogEntryGroupLink,
38
+ DataCatalogEntryLink,
39
+ DataCatalogTagTemplateLink,
40
+ )
41
+ from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
42
+ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
43
+
43
44
  if TYPE_CHECKING:
44
- from airflow.utils.context import Context
45
45
  from google.api_core.retry import Retry
46
46
  from google.protobuf.field_mask_pb2 import FieldMask
47
47
 
48
+ from airflow.utils.context import Context
49
+
48
50
 
49
51
  class CloudDataCatalogCreateEntryOperator(GoogleCloudBaseOperator):
50
52
  """
@@ -26,11 +26,10 @@ from airflow.providers.google.cloud.links.dataform import (
26
26
  )
27
27
 
28
28
  if TYPE_CHECKING:
29
- from airflow.utils.context import Context
30
29
  from google.api_core.retry import Retry
31
30
 
32
- from airflow.providers.google.cloud.hooks.dataform import DataformHook
33
- from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
31
+ from airflow.utils.context import Context
32
+
34
33
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
35
34
  from google.cloud.dataform_v1beta1.types import (
36
35
  CompilationResult,
@@ -43,6 +42,9 @@ from google.cloud.dataform_v1beta1.types import (
43
42
  WriteFileResponse,
44
43
  )
45
44
 
45
+ from airflow.providers.google.cloud.hooks.dataform import DataformHook
46
+ from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
47
+
46
48
 
47
49
  class DataformCreateCompilationResultOperator(GoogleCloudBaseOperator):
48
50
  """
@@ -22,6 +22,7 @@ import time
22
22
  from collections.abc import Sequence
23
23
  from typing import TYPE_CHECKING, Any
24
24
 
25
+ from google.api_core.retry import exponential_sleep_generator
25
26
  from googleapiclient.errors import HttpError
26
27
 
27
28
  from airflow.configuration import conf
@@ -38,7 +39,6 @@ from airflow.providers.google.cloud.utils.datafusion import DataFusionPipelineTy
38
39
  from airflow.providers.google.cloud.utils.helpers import resource_path_to_dict
39
40
  from airflow.providers.google.common.deprecated import deprecated
40
41
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
41
- from google.api_core.retry import exponential_sleep_generator
42
42
 
43
43
  if TYPE_CHECKING:
44
44
  from airflow.utils.context import Context