apache-airflow-providers-google 16.0.0rc1__py3-none-any.whl → 16.1.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.
Files changed (166) hide show
  1. airflow/providers/google/__init__.py +1 -1
  2. airflow/providers/google/ads/hooks/ads.py +9 -5
  3. airflow/providers/google/ads/operators/ads.py +1 -1
  4. airflow/providers/google/ads/transfers/ads_to_gcs.py +1 -1
  5. airflow/providers/google/cloud/hooks/bigquery.py +2 -3
  6. airflow/providers/google/cloud/hooks/cloud_sql.py +8 -4
  7. airflow/providers/google/cloud/hooks/datacatalog.py +9 -1
  8. airflow/providers/google/cloud/hooks/dataflow.py +2 -2
  9. airflow/providers/google/cloud/hooks/dataplex.py +1 -1
  10. airflow/providers/google/cloud/hooks/dataprep.py +4 -1
  11. airflow/providers/google/cloud/hooks/gcs.py +2 -2
  12. airflow/providers/google/cloud/hooks/looker.py +5 -1
  13. airflow/providers/google/cloud/hooks/mlengine.py +2 -1
  14. airflow/providers/google/cloud/hooks/secret_manager.py +102 -10
  15. airflow/providers/google/cloud/hooks/spanner.py +2 -2
  16. airflow/providers/google/cloud/hooks/translate.py +1 -1
  17. airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +307 -7
  18. airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +43 -14
  19. airflow/providers/google/cloud/hooks/vertex_ai/ray.py +11 -2
  20. airflow/providers/google/cloud/hooks/vision.py +2 -2
  21. airflow/providers/google/cloud/links/alloy_db.py +0 -46
  22. airflow/providers/google/cloud/links/base.py +75 -11
  23. airflow/providers/google/cloud/links/bigquery.py +0 -47
  24. airflow/providers/google/cloud/links/bigquery_dts.py +0 -20
  25. airflow/providers/google/cloud/links/bigtable.py +0 -48
  26. airflow/providers/google/cloud/links/cloud_build.py +0 -73
  27. airflow/providers/google/cloud/links/cloud_functions.py +0 -33
  28. airflow/providers/google/cloud/links/cloud_memorystore.py +0 -58
  29. airflow/providers/google/cloud/links/cloud_run.py +1 -33
  30. airflow/providers/google/cloud/links/cloud_sql.py +0 -33
  31. airflow/providers/google/cloud/links/cloud_storage_transfer.py +16 -43
  32. airflow/providers/google/cloud/links/cloud_tasks.py +6 -25
  33. airflow/providers/google/cloud/links/compute.py +0 -58
  34. airflow/providers/google/cloud/links/data_loss_prevention.py +0 -169
  35. airflow/providers/google/cloud/links/datacatalog.py +23 -54
  36. airflow/providers/google/cloud/links/dataflow.py +0 -34
  37. airflow/providers/google/cloud/links/dataform.py +0 -64
  38. airflow/providers/google/cloud/links/datafusion.py +1 -96
  39. airflow/providers/google/cloud/links/dataplex.py +0 -154
  40. airflow/providers/google/cloud/links/dataprep.py +0 -24
  41. airflow/providers/google/cloud/links/dataproc.py +14 -90
  42. airflow/providers/google/cloud/links/datastore.py +0 -31
  43. airflow/providers/google/cloud/links/kubernetes_engine.py +5 -59
  44. airflow/providers/google/cloud/links/life_sciences.py +0 -19
  45. airflow/providers/google/cloud/links/managed_kafka.py +0 -70
  46. airflow/providers/google/cloud/links/mlengine.py +0 -70
  47. airflow/providers/google/cloud/links/pubsub.py +0 -32
  48. airflow/providers/google/cloud/links/spanner.py +0 -33
  49. airflow/providers/google/cloud/links/stackdriver.py +0 -30
  50. airflow/providers/google/cloud/links/translate.py +16 -186
  51. airflow/providers/google/cloud/links/vertex_ai.py +8 -224
  52. airflow/providers/google/cloud/links/workflows.py +0 -52
  53. airflow/providers/google/cloud/operators/alloy_db.py +69 -54
  54. airflow/providers/google/cloud/operators/automl.py +16 -14
  55. airflow/providers/google/cloud/operators/bigquery.py +0 -15
  56. airflow/providers/google/cloud/operators/bigquery_dts.py +2 -4
  57. airflow/providers/google/cloud/operators/bigtable.py +35 -6
  58. airflow/providers/google/cloud/operators/cloud_base.py +21 -1
  59. airflow/providers/google/cloud/operators/cloud_build.py +74 -31
  60. airflow/providers/google/cloud/operators/cloud_composer.py +34 -35
  61. airflow/providers/google/cloud/operators/cloud_memorystore.py +68 -42
  62. airflow/providers/google/cloud/operators/cloud_run.py +0 -1
  63. airflow/providers/google/cloud/operators/cloud_sql.py +11 -15
  64. airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +0 -2
  65. airflow/providers/google/cloud/operators/compute.py +7 -39
  66. airflow/providers/google/cloud/operators/datacatalog.py +156 -20
  67. airflow/providers/google/cloud/operators/dataflow.py +37 -14
  68. airflow/providers/google/cloud/operators/dataform.py +14 -4
  69. airflow/providers/google/cloud/operators/datafusion.py +4 -12
  70. airflow/providers/google/cloud/operators/dataplex.py +180 -96
  71. airflow/providers/google/cloud/operators/dataprep.py +0 -4
  72. airflow/providers/google/cloud/operators/dataproc.py +10 -16
  73. airflow/providers/google/cloud/operators/dataproc_metastore.py +95 -87
  74. airflow/providers/google/cloud/operators/datastore.py +21 -5
  75. airflow/providers/google/cloud/operators/dlp.py +3 -26
  76. airflow/providers/google/cloud/operators/functions.py +15 -6
  77. airflow/providers/google/cloud/operators/gcs.py +0 -7
  78. airflow/providers/google/cloud/operators/kubernetes_engine.py +50 -7
  79. airflow/providers/google/cloud/operators/life_sciences.py +0 -1
  80. airflow/providers/google/cloud/operators/managed_kafka.py +106 -51
  81. airflow/providers/google/cloud/operators/mlengine.py +0 -1
  82. airflow/providers/google/cloud/operators/pubsub.py +2 -4
  83. airflow/providers/google/cloud/operators/spanner.py +0 -4
  84. airflow/providers/google/cloud/operators/speech_to_text.py +0 -1
  85. airflow/providers/google/cloud/operators/stackdriver.py +0 -8
  86. airflow/providers/google/cloud/operators/tasks.py +0 -11
  87. airflow/providers/google/cloud/operators/text_to_speech.py +0 -1
  88. airflow/providers/google/cloud/operators/translate.py +37 -13
  89. airflow/providers/google/cloud/operators/translate_speech.py +0 -1
  90. airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +31 -18
  91. airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +28 -8
  92. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +38 -25
  93. airflow/providers/google/cloud/operators/vertex_ai/dataset.py +69 -7
  94. airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +42 -8
  95. airflow/providers/google/cloud/operators/vertex_ai/feature_store.py +531 -0
  96. airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +93 -25
  97. airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +10 -8
  98. airflow/providers/google/cloud/operators/vertex_ai/model_service.py +56 -10
  99. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +25 -6
  100. airflow/providers/google/cloud/operators/vertex_ai/ray.py +9 -6
  101. airflow/providers/google/cloud/operators/workflows.py +1 -9
  102. airflow/providers/google/cloud/sensors/bigquery.py +1 -1
  103. airflow/providers/google/cloud/sensors/bigquery_dts.py +6 -1
  104. airflow/providers/google/cloud/sensors/bigtable.py +15 -3
  105. airflow/providers/google/cloud/sensors/cloud_composer.py +6 -1
  106. airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +6 -1
  107. airflow/providers/google/cloud/sensors/dataflow.py +3 -3
  108. airflow/providers/google/cloud/sensors/dataform.py +6 -1
  109. airflow/providers/google/cloud/sensors/datafusion.py +6 -1
  110. airflow/providers/google/cloud/sensors/dataplex.py +6 -1
  111. airflow/providers/google/cloud/sensors/dataprep.py +6 -1
  112. airflow/providers/google/cloud/sensors/dataproc.py +6 -1
  113. airflow/providers/google/cloud/sensors/dataproc_metastore.py +6 -1
  114. airflow/providers/google/cloud/sensors/gcs.py +9 -3
  115. airflow/providers/google/cloud/sensors/looker.py +6 -1
  116. airflow/providers/google/cloud/sensors/pubsub.py +8 -3
  117. airflow/providers/google/cloud/sensors/tasks.py +6 -1
  118. airflow/providers/google/cloud/sensors/vertex_ai/feature_store.py +6 -1
  119. airflow/providers/google/cloud/sensors/workflows.py +6 -1
  120. airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +1 -1
  121. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +1 -1
  122. airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +1 -2
  123. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +1 -2
  124. airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +0 -1
  125. airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -1
  126. airflow/providers/google/cloud/transfers/calendar_to_gcs.py +1 -1
  127. airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +1 -1
  128. airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +1 -1
  129. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +1 -2
  130. airflow/providers/google/cloud/transfers/gcs_to_gcs.py +1 -1
  131. airflow/providers/google/cloud/transfers/gcs_to_local.py +1 -1
  132. airflow/providers/google/cloud/transfers/gcs_to_sftp.py +1 -1
  133. airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +5 -1
  134. airflow/providers/google/cloud/transfers/gdrive_to_local.py +1 -1
  135. airflow/providers/google/cloud/transfers/http_to_gcs.py +1 -1
  136. airflow/providers/google/cloud/transfers/local_to_gcs.py +1 -1
  137. airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +1 -1
  138. airflow/providers/google/cloud/transfers/sftp_to_gcs.py +1 -1
  139. airflow/providers/google/cloud/transfers/sheets_to_gcs.py +2 -2
  140. airflow/providers/google/cloud/transfers/sql_to_gcs.py +1 -1
  141. airflow/providers/google/cloud/utils/field_validator.py +1 -2
  142. airflow/providers/google/common/auth_backend/google_openid.py +2 -1
  143. airflow/providers/google/common/deprecated.py +2 -1
  144. airflow/providers/google/common/hooks/base_google.py +7 -3
  145. airflow/providers/google/common/links/storage.py +0 -22
  146. airflow/providers/google/firebase/operators/firestore.py +1 -1
  147. airflow/providers/google/get_provider_info.py +0 -11
  148. airflow/providers/google/leveldb/hooks/leveldb.py +5 -1
  149. airflow/providers/google/leveldb/operators/leveldb.py +1 -1
  150. airflow/providers/google/marketing_platform/links/analytics_admin.py +3 -6
  151. airflow/providers/google/marketing_platform/operators/analytics_admin.py +0 -1
  152. airflow/providers/google/marketing_platform/operators/campaign_manager.py +4 -4
  153. airflow/providers/google/marketing_platform/operators/display_video.py +6 -6
  154. airflow/providers/google/marketing_platform/operators/search_ads.py +1 -1
  155. airflow/providers/google/marketing_platform/sensors/campaign_manager.py +6 -1
  156. airflow/providers/google/marketing_platform/sensors/display_video.py +6 -1
  157. airflow/providers/google/suite/operators/sheets.py +3 -3
  158. airflow/providers/google/suite/sensors/drive.py +6 -1
  159. airflow/providers/google/suite/transfers/gcs_to_gdrive.py +1 -1
  160. airflow/providers/google/suite/transfers/gcs_to_sheets.py +1 -1
  161. airflow/providers/google/suite/transfers/local_to_drive.py +1 -1
  162. airflow/providers/google/version_compat.py +28 -0
  163. {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/METADATA +27 -28
  164. {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/RECORD +166 -166
  165. {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/WHEEL +0 -0
  166. {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/entry_points.txt +0 -0
@@ -807,7 +807,6 @@ class DataprocCreateClusterOperator(GoogleCloudBaseOperator):
807
807
  if project_id:
808
808
  DataprocClusterLink.persist(
809
809
  context=context,
810
- operator=self,
811
810
  cluster_id=self.cluster_name,
812
811
  project_id=project_id,
813
812
  region=self.region,
@@ -1174,7 +1173,6 @@ class DataprocStartClusterOperator(_DataprocStartStopClusterBaseOperator):
1174
1173
  cluster = super().execute(context)
1175
1174
  DataprocClusterLink.persist(
1176
1175
  context=context,
1177
- operator=self,
1178
1176
  cluster_id=self.cluster_name,
1179
1177
  project_id=self._get_project_id(),
1180
1178
  region=self.region,
@@ -1355,7 +1353,11 @@ class DataprocJobBaseOperator(GoogleCloudBaseOperator):
1355
1353
  self.log.info("Job %s submitted successfully.", job_id)
1356
1354
  # Save data required for extra links no matter what the job status will be
1357
1355
  DataprocLink.persist(
1358
- context=context, task_instance=self, url=DATAPROC_JOB_LINK_DEPRECATED, resource=job_id
1356
+ context=context,
1357
+ url=DATAPROC_JOB_LINK_DEPRECATED,
1358
+ resource=job_id,
1359
+ region=self.region,
1360
+ project_id=self.project_id,
1359
1361
  )
1360
1362
 
1361
1363
  if self.deferrable:
@@ -1459,7 +1461,6 @@ class DataprocCreateWorkflowTemplateOperator(GoogleCloudBaseOperator):
1459
1461
  if project_id:
1460
1462
  DataprocWorkflowTemplateLink.persist(
1461
1463
  context=context,
1462
- operator=self,
1463
1464
  workflow_template_id=self.template["id"],
1464
1465
  region=self.region,
1465
1466
  project_id=project_id,
@@ -1571,7 +1572,6 @@ class DataprocInstantiateWorkflowTemplateOperator(GoogleCloudBaseOperator):
1571
1572
  if project_id:
1572
1573
  DataprocWorkflowLink.persist(
1573
1574
  context=context,
1574
- operator=self,
1575
1575
  workflow_id=workflow_id,
1576
1576
  region=self.region,
1577
1577
  project_id=project_id,
@@ -1727,7 +1727,6 @@ class DataprocInstantiateInlineWorkflowTemplateOperator(GoogleCloudBaseOperator)
1727
1727
  if project_id:
1728
1728
  DataprocWorkflowLink.persist(
1729
1729
  context=context,
1730
- operator=self,
1731
1730
  workflow_id=workflow_id,
1732
1731
  region=self.region,
1733
1732
  project_id=project_id,
@@ -1901,7 +1900,6 @@ class DataprocSubmitJobOperator(GoogleCloudBaseOperator):
1901
1900
  if project_id:
1902
1901
  DataprocJobLink.persist(
1903
1902
  context=context,
1904
- operator=self,
1905
1903
  job_id=new_job_id,
1906
1904
  region=self.region,
1907
1905
  project_id=project_id,
@@ -2074,7 +2072,6 @@ class DataprocUpdateClusterOperator(GoogleCloudBaseOperator):
2074
2072
  if project_id:
2075
2073
  DataprocClusterLink.persist(
2076
2074
  context=context,
2077
- operator=self,
2078
2075
  cluster_id=self.cluster_name,
2079
2076
  project_id=project_id,
2080
2077
  region=self.region,
@@ -2373,7 +2370,6 @@ class DataprocCreateBatchOperator(GoogleCloudBaseOperator):
2373
2370
  # Persist the link earlier so users can observe the progress
2374
2371
  DataprocBatchLink.persist(
2375
2372
  context=context,
2376
- operator=self,
2377
2373
  project_id=self.project_id,
2378
2374
  region=self.region,
2379
2375
  batch_id=self.batch_id,
@@ -2410,7 +2406,6 @@ class DataprocCreateBatchOperator(GoogleCloudBaseOperator):
2410
2406
 
2411
2407
  DataprocBatchLink.persist(
2412
2408
  context=context,
2413
- operator=self,
2414
2409
  project_id=self.project_id,
2415
2410
  region=self.region,
2416
2411
  batch_id=batch_id,
@@ -2493,13 +2488,13 @@ class DataprocCreateBatchOperator(GoogleCloudBaseOperator):
2493
2488
  link = DATAPROC_BATCH_LINK.format(region=self.region, project_id=self.project_id, batch_id=batch_id)
2494
2489
  if state == Batch.State.FAILED:
2495
2490
  raise AirflowException(
2496
- f"Batch job {batch_id} failed with error: {state_message}\nDriver Logs: {link}"
2491
+ f"Batch job {batch_id} failed with error: {state_message}.\nDriver logs: {link}"
2497
2492
  )
2498
2493
  if state in (Batch.State.CANCELLED, Batch.State.CANCELLING):
2499
- raise AirflowException(f"Batch job {batch_id} was cancelled. Driver logs: {link}")
2494
+ raise AirflowException(f"Batch job {batch_id} was cancelled.\nDriver logs: {link}")
2500
2495
  if state == Batch.State.STATE_UNSPECIFIED:
2501
- raise AirflowException(f"Batch job {batch_id} unspecified. Driver logs: {link}")
2502
- self.log.info("Batch job %s completed. Driver logs: %s", batch_id, link)
2496
+ raise AirflowException(f"Batch job {batch_id} unspecified.\nDriver logs: {link}")
2497
+ self.log.info("Batch job %s completed.\nDriver logs: %s", batch_id, link)
2503
2498
 
2504
2499
  def retry_batch_creation(
2505
2500
  self,
@@ -2723,7 +2718,6 @@ class DataprocGetBatchOperator(GoogleCloudBaseOperator):
2723
2718
  if project_id:
2724
2719
  DataprocBatchLink.persist(
2725
2720
  context=context,
2726
- operator=self,
2727
2721
  project_id=project_id,
2728
2722
  region=self.region,
2729
2723
  batch_id=self.batch_id,
@@ -2806,7 +2800,7 @@ class DataprocListBatchesOperator(GoogleCloudBaseOperator):
2806
2800
  )
2807
2801
  project_id = self.project_id or hook.project_id
2808
2802
  if project_id:
2809
- DataprocBatchesListLink.persist(context=context, operator=self, project_id=project_id)
2803
+ DataprocBatchesListLink.persist(context=context, project_id=project_id)
2810
2804
  return [Batch.to_dict(result) for result in results]
2811
2805
 
2812
2806
 
@@ -21,7 +21,7 @@ from __future__ import annotations
21
21
 
22
22
  import time
23
23
  from collections.abc import Sequence
24
- from typing import TYPE_CHECKING
24
+ from typing import TYPE_CHECKING, Any
25
25
 
26
26
  from google.api_core.exceptions import AlreadyExists
27
27
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
@@ -32,26 +32,17 @@ from google.cloud.metastore_v1.types.metastore import DatabaseDumpSpec, Restore
32
32
 
33
33
  from airflow.exceptions import AirflowException
34
34
  from airflow.providers.google.cloud.hooks.dataproc_metastore import DataprocMetastoreHook
35
+ from airflow.providers.google.cloud.links.base import BaseGoogleLink
35
36
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
36
37
  from airflow.providers.google.common.links.storage import StorageLink
37
38
 
38
39
  if TYPE_CHECKING:
39
40
  from google.protobuf.field_mask_pb2 import FieldMask
40
41
 
41
- from airflow.models import BaseOperator
42
42
  from airflow.models.taskinstancekey import TaskInstanceKey
43
+ from airflow.providers.google.version_compat import BaseOperator
43
44
  from airflow.utils.context import Context
44
45
 
45
- from airflow.providers.google.version_compat import AIRFLOW_V_3_0_PLUS
46
-
47
- if AIRFLOW_V_3_0_PLUS:
48
- from airflow.sdk import BaseOperatorLink
49
- from airflow.sdk.execution_time.xcom import XCom
50
- else:
51
- from airflow.models import XCom # type: ignore[no-redef]
52
- from airflow.models.baseoperatorlink import BaseOperatorLink # type: ignore[no-redef]
53
-
54
-
55
46
  BASE_LINK = "https://console.cloud.google.com"
56
47
  METASTORE_BASE_LINK = BASE_LINK + "/dataproc/metastore/services/{region}/{service_id}"
57
48
  METASTORE_BACKUP_LINK = METASTORE_BASE_LINK + "/backups/{resource}?project={project_id}"
@@ -61,97 +52,50 @@ METASTORE_IMPORT_LINK = METASTORE_BASE_LINK + "/imports/{resource}?project={proj
61
52
  METASTORE_SERVICE_LINK = METASTORE_BASE_LINK + "/config?project={project_id}"
62
53
 
63
54
 
64
- class DataprocMetastoreLink(BaseOperatorLink):
55
+ class DataprocMetastoreLink(BaseGoogleLink):
65
56
  """Helper class for constructing Dataproc Metastore resource link."""
66
57
 
67
58
  name = "Dataproc Metastore"
68
59
  key = "conf"
69
60
 
70
- @staticmethod
71
- def persist(
72
- context: Context,
73
- task_instance: (
74
- DataprocMetastoreCreateServiceOperator
75
- | DataprocMetastoreGetServiceOperator
76
- | DataprocMetastoreRestoreServiceOperator
77
- | DataprocMetastoreUpdateServiceOperator
78
- | DataprocMetastoreListBackupsOperator
79
- | DataprocMetastoreExportMetadataOperator
80
- ),
81
- url: str,
82
- ):
83
- task_instance.xcom_push(
84
- context=context,
85
- key=DataprocMetastoreLink.key,
86
- value={
87
- "region": task_instance.region,
88
- "service_id": task_instance.service_id,
89
- "project_id": task_instance.project_id,
90
- "url": url,
91
- },
92
- )
93
-
94
61
  def get_link(
95
62
  self,
96
63
  operator: BaseOperator,
97
64
  *,
98
65
  ti_key: TaskInstanceKey,
99
66
  ) -> str:
100
- conf = XCom.get_value(key=self.key, ti_key=ti_key)
101
- return (
102
- conf["url"].format(
103
- region=conf["region"],
104
- service_id=conf["service_id"],
105
- project_id=conf["project_id"],
106
- )
107
- if conf
108
- else ""
67
+ conf = self.get_config(operator, ti_key)
68
+ if not conf:
69
+ return ""
70
+
71
+ return conf["url"].format(
72
+ region=conf["region"],
73
+ service_id=conf["service_id"],
74
+ project_id=conf["project_id"],
109
75
  )
110
76
 
111
77
 
112
- class DataprocMetastoreDetailedLink(BaseOperatorLink):
78
+ class DataprocMetastoreDetailedLink(BaseGoogleLink):
113
79
  """Helper class for constructing Dataproc Metastore detailed resource link."""
114
80
 
115
81
  name = "Dataproc Metastore resource"
116
82
  key = "config"
117
83
 
118
- @staticmethod
119
- def persist(
120
- context: Context,
121
- task_instance: (
122
- DataprocMetastoreCreateBackupOperator | DataprocMetastoreCreateMetadataImportOperator
123
- ),
124
- url: str,
125
- resource: str,
126
- ):
127
- task_instance.xcom_push(
128
- context=context,
129
- key=DataprocMetastoreDetailedLink.key,
130
- value={
131
- "region": task_instance.region,
132
- "service_id": task_instance.service_id,
133
- "project_id": task_instance.project_id,
134
- "url": url,
135
- "resource": resource,
136
- },
137
- )
138
-
139
84
  def get_link(
140
85
  self,
141
86
  operator: BaseOperator,
142
87
  *,
143
88
  ti_key: TaskInstanceKey,
144
89
  ) -> str:
145
- conf = XCom.get_value(key=self.key, ti_key=ti_key)
146
- return (
147
- conf["url"].format(
148
- region=conf["region"],
149
- service_id=conf["service_id"],
150
- project_id=conf["project_id"],
151
- resource=conf["resource"],
152
- )
153
- if conf
154
- else ""
90
+ conf = self.get_config(operator, ti_key)
91
+ if not conf:
92
+ return ""
93
+
94
+ return conf["url"].format(
95
+ region=conf["region"],
96
+ service_id=conf["service_id"],
97
+ project_id=conf["project_id"],
98
+ resource=conf["resource"],
155
99
  )
156
100
 
157
101
 
@@ -231,6 +175,14 @@ class DataprocMetastoreCreateBackupOperator(GoogleCloudBaseOperator):
231
175
  self.gcp_conn_id = gcp_conn_id
232
176
  self.impersonation_chain = impersonation_chain
233
177
 
178
+ @property
179
+ def extra_links_params(self) -> dict[str, Any]:
180
+ return {
181
+ "region": self.region,
182
+ "service_id": self.service_id,
183
+ "project_id": self.project_id,
184
+ }
185
+
234
186
  def execute(self, context: Context) -> dict:
235
187
  hook = DataprocMetastoreHook(
236
188
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -263,7 +215,7 @@ class DataprocMetastoreCreateBackupOperator(GoogleCloudBaseOperator):
263
215
  metadata=self.metadata,
264
216
  )
265
217
  DataprocMetastoreDetailedLink.persist(
266
- context=context, task_instance=self, url=METASTORE_BACKUP_LINK, resource=self.backup_id
218
+ context=context, url=METASTORE_BACKUP_LINK, resource=self.backup_id
267
219
  )
268
220
  return Backup.to_dict(backup)
269
221
 
@@ -344,6 +296,14 @@ class DataprocMetastoreCreateMetadataImportOperator(GoogleCloudBaseOperator):
344
296
  self.gcp_conn_id = gcp_conn_id
345
297
  self.impersonation_chain = impersonation_chain
346
298
 
299
+ @property
300
+ def extra_links_params(self) -> dict[str, Any]:
301
+ return {
302
+ "region": self.region,
303
+ "service_id": self.service_id,
304
+ "project_id": self.project_id,
305
+ }
306
+
347
307
  def execute(self, context: Context):
348
308
  hook = DataprocMetastoreHook(
349
309
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -364,7 +324,7 @@ class DataprocMetastoreCreateMetadataImportOperator(GoogleCloudBaseOperator):
364
324
  self.log.info("Metadata import %s created successfully", self.metadata_import_id)
365
325
 
366
326
  DataprocMetastoreDetailedLink.persist(
367
- context=context, task_instance=self, url=METASTORE_IMPORT_LINK, resource=self.metadata_import_id
327
+ context=context, url=METASTORE_IMPORT_LINK, resource=self.metadata_import_id
368
328
  )
369
329
  return MetadataImport.to_dict(metadata_import)
370
330
 
@@ -437,6 +397,14 @@ class DataprocMetastoreCreateServiceOperator(GoogleCloudBaseOperator):
437
397
  self.gcp_conn_id = gcp_conn_id
438
398
  self.impersonation_chain = impersonation_chain
439
399
 
400
+ @property
401
+ def extra_links_params(self) -> dict[str, Any]:
402
+ return {
403
+ "region": self.region,
404
+ "service_id": self.service_id,
405
+ "project_id": self.project_id,
406
+ }
407
+
440
408
  def execute(self, context: Context) -> dict:
441
409
  hook = DataprocMetastoreHook(
442
410
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -465,7 +433,7 @@ class DataprocMetastoreCreateServiceOperator(GoogleCloudBaseOperator):
465
433
  timeout=self.timeout,
466
434
  metadata=self.metadata,
467
435
  )
468
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_SERVICE_LINK)
436
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_SERVICE_LINK)
469
437
  return Service.to_dict(service)
470
438
 
471
439
 
@@ -689,6 +657,14 @@ class DataprocMetastoreExportMetadataOperator(GoogleCloudBaseOperator):
689
657
  self.gcp_conn_id = gcp_conn_id
690
658
  self.impersonation_chain = impersonation_chain
691
659
 
660
+ @property
661
+ def extra_links_params(self) -> dict[str, Any]:
662
+ return {
663
+ "region": self.region,
664
+ "service_id": self.service_id,
665
+ "project_id": self.project_id,
666
+ }
667
+
692
668
  def execute(self, context: Context):
693
669
  hook = DataprocMetastoreHook(
694
670
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -708,9 +684,9 @@ class DataprocMetastoreExportMetadataOperator(GoogleCloudBaseOperator):
708
684
  metadata_export = self._wait_for_export_metadata(hook)
709
685
  self.log.info("Metadata from service %s exported successfully", self.service_id)
710
686
 
711
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_EXPORT_LINK)
687
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_EXPORT_LINK)
712
688
  uri = self._get_uri_from_destination(MetadataExport.to_dict(metadata_export)["destination_gcs_uri"])
713
- StorageLink.persist(context=context, task_instance=self, uri=uri, project_id=self.project_id)
689
+ StorageLink.persist(context=context, uri=uri, project_id=self.project_id)
714
690
  return MetadataExport.to_dict(metadata_export)
715
691
 
716
692
  def _get_uri_from_destination(self, destination_uri: str):
@@ -799,6 +775,14 @@ class DataprocMetastoreGetServiceOperator(GoogleCloudBaseOperator):
799
775
  self.gcp_conn_id = gcp_conn_id
800
776
  self.impersonation_chain = impersonation_chain
801
777
 
778
+ @property
779
+ def extra_links_params(self) -> dict[str, Any]:
780
+ return {
781
+ "region": self.region,
782
+ "service_id": self.service_id,
783
+ "project_id": self.project_id,
784
+ }
785
+
802
786
  def execute(self, context: Context) -> dict:
803
787
  hook = DataprocMetastoreHook(
804
788
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -812,7 +796,7 @@ class DataprocMetastoreGetServiceOperator(GoogleCloudBaseOperator):
812
796
  timeout=self.timeout,
813
797
  metadata=self.metadata,
814
798
  )
815
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_SERVICE_LINK)
799
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_SERVICE_LINK)
816
800
  return Service.to_dict(result)
817
801
 
818
802
 
@@ -880,6 +864,14 @@ class DataprocMetastoreListBackupsOperator(GoogleCloudBaseOperator):
880
864
  self.gcp_conn_id = gcp_conn_id
881
865
  self.impersonation_chain = impersonation_chain
882
866
 
867
+ @property
868
+ def extra_links_params(self) -> dict[str, Any]:
869
+ return {
870
+ "region": self.region,
871
+ "service_id": self.service_id,
872
+ "project_id": self.project_id,
873
+ }
874
+
883
875
  def execute(self, context: Context) -> list[dict]:
884
876
  hook = DataprocMetastoreHook(
885
877
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -897,7 +889,7 @@ class DataprocMetastoreListBackupsOperator(GoogleCloudBaseOperator):
897
889
  timeout=self.timeout,
898
890
  metadata=self.metadata,
899
891
  )
900
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_BACKUPS_LINK)
892
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_BACKUPS_LINK)
901
893
  return [Backup.to_dict(backup) for backup in backups]
902
894
 
903
895
 
@@ -981,6 +973,14 @@ class DataprocMetastoreRestoreServiceOperator(GoogleCloudBaseOperator):
981
973
  self.gcp_conn_id = gcp_conn_id
982
974
  self.impersonation_chain = impersonation_chain
983
975
 
976
+ @property
977
+ def extra_links_params(self) -> dict[str, Any]:
978
+ return {
979
+ "region": self.region,
980
+ "service_id": self.service_id,
981
+ "project_id": self.project_id,
982
+ }
983
+
984
984
  def execute(self, context: Context):
985
985
  hook = DataprocMetastoreHook(
986
986
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -1004,7 +1004,7 @@ class DataprocMetastoreRestoreServiceOperator(GoogleCloudBaseOperator):
1004
1004
  )
1005
1005
  self._wait_for_restore_service(hook)
1006
1006
  self.log.info("Service %s restored from backup %s", self.service_id, self.backup_id)
1007
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_SERVICE_LINK)
1007
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_SERVICE_LINK)
1008
1008
 
1009
1009
  def _wait_for_restore_service(self, hook: DataprocMetastoreHook):
1010
1010
  """
@@ -1107,6 +1107,14 @@ class DataprocMetastoreUpdateServiceOperator(GoogleCloudBaseOperator):
1107
1107
  self.gcp_conn_id = gcp_conn_id
1108
1108
  self.impersonation_chain = impersonation_chain
1109
1109
 
1110
+ @property
1111
+ def extra_links_params(self) -> dict[str, Any]:
1112
+ return {
1113
+ "region": self.region,
1114
+ "service_id": self.service_id,
1115
+ "project_id": self.project_id,
1116
+ }
1117
+
1110
1118
  def execute(self, context: Context):
1111
1119
  hook = DataprocMetastoreHook(
1112
1120
  gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain
@@ -1126,4 +1134,4 @@ class DataprocMetastoreUpdateServiceOperator(GoogleCloudBaseOperator):
1126
1134
  )
1127
1135
  hook.wait_for_operation(self.timeout, operation)
1128
1136
  self.log.info("Service %s updated successfully", self.service.get("name"))
1129
- DataprocMetastoreLink.persist(context=context, task_instance=self, url=METASTORE_SERVICE_LINK)
1137
+ DataprocMetastoreLink.persist(context=context, url=METASTORE_SERVICE_LINK)
@@ -136,7 +136,6 @@ class CloudDatastoreExportEntitiesOperator(GoogleCloudBaseOperator):
136
136
  raise AirflowException(f"Operation failed: result={result}")
137
137
  StorageLink.persist(
138
138
  context=context,
139
- task_instance=self,
140
139
  uri=f"{self.bucket}/{result['response']['outputUrl'].split('/')[3]}",
141
140
  project_id=self.project_id or ds_hook.project_id,
142
141
  )
@@ -211,6 +210,12 @@ class CloudDatastoreImportEntitiesOperator(GoogleCloudBaseOperator):
211
210
  self.project_id = project_id
212
211
  self.impersonation_chain = impersonation_chain
213
212
 
213
+ @property
214
+ def extra_links_params(self) -> dict[str, Any]:
215
+ return {
216
+ "project_id": self.project_id,
217
+ }
218
+
214
219
  def execute(self, context: Context):
215
220
  self.log.info("Importing data from Cloud Storage bucket %s", self.bucket)
216
221
  ds_hook = DatastoreHook(
@@ -231,8 +236,7 @@ class CloudDatastoreImportEntitiesOperator(GoogleCloudBaseOperator):
231
236
  state = result["metadata"]["common"]["state"]
232
237
  if state != "SUCCESSFUL":
233
238
  raise AirflowException(f"Operation failed: result={result}")
234
-
235
- CloudDatastoreImportExportLink.persist(context=context, task_instance=self)
239
+ CloudDatastoreImportExportLink.persist(context=context)
236
240
  return result
237
241
 
238
242
 
@@ -282,6 +286,12 @@ class CloudDatastoreAllocateIdsOperator(GoogleCloudBaseOperator):
282
286
  self.project_id = project_id
283
287
  self.impersonation_chain = impersonation_chain
284
288
 
289
+ @property
290
+ def extra_links_params(self) -> dict[str, Any]:
291
+ return {
292
+ "project_id": self.project_id,
293
+ }
294
+
285
295
  def execute(self, context: Context) -> list:
286
296
  hook = DatastoreHook(
287
297
  gcp_conn_id=self.gcp_conn_id,
@@ -291,7 +301,7 @@ class CloudDatastoreAllocateIdsOperator(GoogleCloudBaseOperator):
291
301
  partial_keys=self.partial_keys,
292
302
  project_id=self.project_id,
293
303
  )
294
- CloudDatastoreEntitiesLink.persist(context=context, task_instance=self)
304
+ CloudDatastoreEntitiesLink.persist(context=context)
295
305
  return keys
296
306
 
297
307
 
@@ -398,6 +408,12 @@ class CloudDatastoreCommitOperator(GoogleCloudBaseOperator):
398
408
  self.project_id = project_id
399
409
  self.impersonation_chain = impersonation_chain
400
410
 
411
+ @property
412
+ def extra_links_params(self) -> dict[str, Any]:
413
+ return {
414
+ "project_id": self.project_id,
415
+ }
416
+
401
417
  def execute(self, context: Context) -> dict:
402
418
  hook = DatastoreHook(
403
419
  gcp_conn_id=self.gcp_conn_id,
@@ -407,7 +423,7 @@ class CloudDatastoreCommitOperator(GoogleCloudBaseOperator):
407
423
  body=self.body,
408
424
  project_id=self.project_id,
409
425
  )
410
- CloudDatastoreEntitiesLink.persist(context=context, task_instance=self)
426
+ CloudDatastoreEntitiesLink.persist(context=context)
411
427
  return response
412
428
 
413
429