apache-airflow-providers-google 10.7.0rc1__py3-none-any.whl → 10.8.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 (174) hide show
  1. airflow/providers/google/__init__.py +1 -1
  2. airflow/providers/google/ads/hooks/ads.py +10 -6
  3. airflow/providers/google/cloud/_internal_client/secret_manager_client.py +4 -1
  4. airflow/providers/google/cloud/example_dags/example_cloud_sql_query.py +31 -34
  5. airflow/providers/google/cloud/hooks/automl.py +11 -9
  6. airflow/providers/google/cloud/hooks/bigquery.py +30 -36
  7. airflow/providers/google/cloud/hooks/bigquery_dts.py +5 -3
  8. airflow/providers/google/cloud/hooks/bigtable.py +11 -8
  9. airflow/providers/google/cloud/hooks/cloud_batch.py +5 -3
  10. airflow/providers/google/cloud/hooks/cloud_build.py +6 -4
  11. airflow/providers/google/cloud/hooks/cloud_composer.py +14 -10
  12. airflow/providers/google/cloud/hooks/cloud_memorystore.py +5 -3
  13. airflow/providers/google/cloud/hooks/cloud_run.py +5 -3
  14. airflow/providers/google/cloud/hooks/cloud_sql.py +11 -14
  15. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +8 -6
  16. airflow/providers/google/cloud/hooks/compute.py +5 -3
  17. airflow/providers/google/cloud/hooks/compute_ssh.py +1 -1
  18. airflow/providers/google/cloud/hooks/datacatalog.py +5 -3
  19. airflow/providers/google/cloud/hooks/dataflow.py +8 -11
  20. airflow/providers/google/cloud/hooks/dataform.py +4 -2
  21. airflow/providers/google/cloud/hooks/datafusion.py +24 -6
  22. airflow/providers/google/cloud/hooks/dataplex.py +75 -6
  23. airflow/providers/google/cloud/hooks/dataproc.py +9 -7
  24. airflow/providers/google/cloud/hooks/dataproc_metastore.py +8 -6
  25. airflow/providers/google/cloud/hooks/dlp.py +139 -137
  26. airflow/providers/google/cloud/hooks/gcs.py +15 -20
  27. airflow/providers/google/cloud/hooks/kms.py +4 -2
  28. airflow/providers/google/cloud/hooks/kubernetes_engine.py +34 -34
  29. airflow/providers/google/cloud/hooks/looker.py +4 -1
  30. airflow/providers/google/cloud/hooks/mlengine.py +8 -6
  31. airflow/providers/google/cloud/hooks/natural_language.py +4 -2
  32. airflow/providers/google/cloud/hooks/os_login.py +9 -7
  33. airflow/providers/google/cloud/hooks/pubsub.py +13 -11
  34. airflow/providers/google/cloud/hooks/spanner.py +7 -5
  35. airflow/providers/google/cloud/hooks/speech_to_text.py +4 -2
  36. airflow/providers/google/cloud/hooks/stackdriver.py +6 -5
  37. airflow/providers/google/cloud/hooks/tasks.py +5 -3
  38. airflow/providers/google/cloud/hooks/text_to_speech.py +4 -2
  39. airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +7 -5
  40. airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +6 -4
  41. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +11 -9
  42. airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +12 -10
  43. airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +8 -6
  44. airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +6 -4
  45. airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +7 -5
  46. airflow/providers/google/cloud/hooks/video_intelligence.py +5 -3
  47. airflow/providers/google/cloud/hooks/vision.py +5 -3
  48. airflow/providers/google/cloud/hooks/workflows.py +8 -6
  49. airflow/providers/google/cloud/links/bigquery.py +1 -1
  50. airflow/providers/google/cloud/links/bigquery_dts.py +1 -1
  51. airflow/providers/google/cloud/links/cloud_functions.py +1 -1
  52. airflow/providers/google/cloud/links/cloud_memorystore.py +1 -1
  53. airflow/providers/google/cloud/links/cloud_sql.py +1 -1
  54. airflow/providers/google/cloud/links/cloud_tasks.py +1 -1
  55. airflow/providers/google/cloud/links/compute.py +1 -1
  56. airflow/providers/google/cloud/links/datacatalog.py +1 -1
  57. airflow/providers/google/cloud/links/dataflow.py +1 -1
  58. airflow/providers/google/cloud/links/dataform.py +1 -1
  59. airflow/providers/google/cloud/links/pubsub.py +1 -1
  60. airflow/providers/google/cloud/links/spanner.py +1 -1
  61. airflow/providers/google/cloud/links/stackdriver.py +1 -1
  62. airflow/providers/google/cloud/links/workflows.py +2 -2
  63. airflow/providers/google/cloud/log/gcs_task_handler.py +5 -7
  64. airflow/providers/google/cloud/log/stackdriver_task_handler.py +8 -4
  65. airflow/providers/google/cloud/operators/automl.py +2 -1
  66. airflow/providers/google/cloud/operators/bigquery.py +6 -2
  67. airflow/providers/google/cloud/operators/bigquery_dts.py +2 -1
  68. airflow/providers/google/cloud/operators/bigtable.py +5 -3
  69. airflow/providers/google/cloud/operators/cloud_batch.py +6 -3
  70. airflow/providers/google/cloud/operators/cloud_build.py +2 -1
  71. airflow/providers/google/cloud/operators/cloud_composer.py +3 -2
  72. airflow/providers/google/cloud/operators/cloud_memorystore.py +3 -2
  73. airflow/providers/google/cloud/operators/cloud_run.py +3 -2
  74. airflow/providers/google/cloud/operators/cloud_sql.py +157 -152
  75. airflow/providers/google/cloud/operators/compute.py +59 -61
  76. airflow/providers/google/cloud/operators/datacatalog.py +3 -2
  77. airflow/providers/google/cloud/operators/dataflow.py +3 -1
  78. airflow/providers/google/cloud/operators/dataform.py +2 -1
  79. airflow/providers/google/cloud/operators/datafusion.py +1 -1
  80. airflow/providers/google/cloud/operators/dataplex.py +110 -8
  81. airflow/providers/google/cloud/operators/dataproc.py +39 -18
  82. airflow/providers/google/cloud/operators/dataproc_metastore.py +2 -1
  83. airflow/providers/google/cloud/operators/dlp.py +3 -2
  84. airflow/providers/google/cloud/operators/functions.py +46 -46
  85. airflow/providers/google/cloud/operators/gcs.py +4 -6
  86. airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -1
  87. airflow/providers/google/cloud/operators/natural_language.py +3 -2
  88. airflow/providers/google/cloud/operators/pubsub.py +2 -1
  89. airflow/providers/google/cloud/operators/speech_to_text.py +3 -2
  90. airflow/providers/google/cloud/operators/stackdriver.py +2 -1
  91. airflow/providers/google/cloud/operators/tasks.py +3 -2
  92. airflow/providers/google/cloud/operators/text_to_speech.py +3 -2
  93. airflow/providers/google/cloud/operators/translate_speech.py +2 -1
  94. airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +2 -1
  95. airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +3 -2
  96. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +2 -1
  97. airflow/providers/google/cloud/operators/vertex_ai/dataset.py +3 -2
  98. airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +4 -4
  99. airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +3 -2
  100. airflow/providers/google/cloud/operators/vertex_ai/model_service.py +2 -1
  101. airflow/providers/google/cloud/operators/video_intelligence.py +2 -1
  102. airflow/providers/google/cloud/operators/vision.py +3 -2
  103. airflow/providers/google/cloud/operators/workflows.py +7 -5
  104. airflow/providers/google/cloud/secrets/secret_manager.py +2 -2
  105. airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
  106. airflow/providers/google/cloud/sensors/dataplex.py +2 -1
  107. airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -2
  108. airflow/providers/google/cloud/sensors/gcs.py +2 -1
  109. airflow/providers/google/cloud/sensors/workflows.py +2 -1
  110. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +24 -10
  111. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +2 -1
  112. airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +2 -1
  113. airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -4
  114. airflow/providers/google/cloud/transfers/bigquery_to_postgres.py +1 -4
  115. airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -1
  116. airflow/providers/google/cloud/transfers/calendar_to_gcs.py +4 -2
  117. airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +1 -3
  118. airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +2 -2
  119. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +2 -1
  120. airflow/providers/google/cloud/transfers/presto_to_gcs.py +5 -4
  121. airflow/providers/google/cloud/transfers/sql_to_gcs.py +1 -1
  122. airflow/providers/google/cloud/transfers/trino_to_gcs.py +5 -4
  123. airflow/providers/google/cloud/triggers/bigquery.py +30 -36
  124. airflow/providers/google/cloud/triggers/bigquery_dts.py +9 -10
  125. airflow/providers/google/cloud/triggers/cloud_batch.py +6 -8
  126. airflow/providers/google/cloud/triggers/cloud_build.py +5 -6
  127. airflow/providers/google/cloud/triggers/cloud_run.py +4 -3
  128. airflow/providers/google/cloud/triggers/cloud_sql.py +10 -10
  129. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +1 -1
  130. airflow/providers/google/cloud/triggers/dataflow.py +5 -6
  131. airflow/providers/google/cloud/triggers/datafusion.py +5 -6
  132. airflow/providers/google/cloud/triggers/dataplex.py +110 -0
  133. airflow/providers/google/cloud/triggers/dataproc.py +18 -20
  134. airflow/providers/google/cloud/triggers/kubernetes_engine.py +14 -13
  135. airflow/providers/google/cloud/triggers/mlengine.py +5 -5
  136. airflow/providers/google/cloud/triggers/pubsub.py +2 -2
  137. airflow/providers/google/cloud/utils/bigquery_get_data.py +6 -3
  138. airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
  139. airflow/providers/google/cloud/utils/field_validator.py +13 -13
  140. airflow/providers/google/cloud/utils/mlengine_operator_utils.py +5 -3
  141. airflow/providers/google/cloud/utils/mlengine_prediction_summary.py +1 -1
  142. airflow/providers/google/common/hooks/base_google.py +10 -2
  143. airflow/providers/google/common/links/storage.py +1 -1
  144. airflow/providers/google/common/utils/id_token_credentials.py +4 -1
  145. airflow/providers/google/get_provider_info.py +5 -0
  146. airflow/providers/google/marketing_platform/hooks/campaign_manager.py +4 -2
  147. airflow/providers/google/marketing_platform/sensors/display_video.py +6 -3
  148. airflow/providers/google/suite/hooks/calendar.py +4 -2
  149. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/METADATA +8 -8
  150. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/RECORD +155 -173
  151. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/WHEEL +1 -1
  152. airflow/providers/google/ads/_vendor/__init__.py +0 -16
  153. airflow/providers/google/ads/_vendor/googleads/__init__.py +0 -16
  154. airflow/providers/google/ads/_vendor/googleads/interceptors/__init__.py +0 -16
  155. airflow/providers/google/ads/_vendor/googleads/v12/__init__.py +0 -16
  156. airflow/providers/google/ads/_vendor/googleads/v12/common/__init__.py +0 -16
  157. airflow/providers/google/ads/_vendor/googleads/v12/common/types/__init__.py +0 -16
  158. airflow/providers/google/ads/_vendor/googleads/v12/enums/__init__.py +0 -16
  159. airflow/providers/google/ads/_vendor/googleads/v12/enums/types/__init__.py +0 -16
  160. airflow/providers/google/ads/_vendor/googleads/v12/errors/__init__.py +0 -16
  161. airflow/providers/google/ads/_vendor/googleads/v12/errors/types/__init__.py +0 -16
  162. airflow/providers/google/ads/_vendor/googleads/v12/resources/__init__.py +0 -16
  163. airflow/providers/google/ads/_vendor/googleads/v12/resources/types/__init__.py +0 -16
  164. airflow/providers/google/ads/_vendor/googleads/v12/services/__init__.py +0 -16
  165. airflow/providers/google/ads/_vendor/googleads/v12/services/services/__init__.py +0 -16
  166. airflow/providers/google/ads/_vendor/googleads/v12/services/services/customer_service/__init__.py +0 -16
  167. airflow/providers/google/ads/_vendor/googleads/v12/services/services/customer_service/transports/__init__.py +0 -16
  168. airflow/providers/google/ads/_vendor/googleads/v12/services/services/google_ads_service/__init__.py +0 -16
  169. airflow/providers/google/ads/_vendor/googleads/v12/services/services/google_ads_service/transports/__init__.py +0 -16
  170. airflow/providers/google/ads/_vendor/googleads/v12/services/types/__init__.py +0 -16
  171. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/LICENSE +0 -0
  172. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/NOTICE +0 -0
  173. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/entry_points.txt +0 -0
  174. {apache_airflow_providers_google-10.7.0rc1.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/top_level.txt +0 -0
@@ -27,10 +27,9 @@ from __future__ import annotations
27
27
 
28
28
  import re
29
29
  import time
30
- from typing import Sequence
30
+ from typing import TYPE_CHECKING, Sequence
31
31
 
32
32
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
33
- from google.api_core.retry import Retry
34
33
  from google.cloud.dlp import DlpServiceClient
35
34
  from google.cloud.dlp_v2.types import (
36
35
  ByteContentItem,
@@ -58,6 +57,9 @@ from airflow.exceptions import AirflowException
58
57
  from airflow.providers.google.common.consts import CLIENT_INFO
59
58
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
60
59
 
60
+ if TYPE_CHECKING:
61
+ from google.api_core.retry import Retry
62
+
61
63
  DLP_JOB_PATH_PATTERN = "^projects/[^/]+/dlpJobs/(?P<job>.*?)$"
62
64
 
63
65
 
@@ -148,9 +150,9 @@ class CloudDLPHook(GoogleBaseHook):
148
150
 
149
151
  name = DlpServiceClient.dlp_job_path(project_id, dlp_job_id)
150
152
  client.cancel_dlp_job(
151
- request=dict(
152
- name=name,
153
- ),
153
+ request={
154
+ "name": name,
155
+ },
154
156
  retry=retry,
155
157
  timeout=timeout,
156
158
  metadata=metadata,
@@ -195,11 +197,11 @@ class CloudDLPHook(GoogleBaseHook):
195
197
  raise AirflowException("Please provide either organization_id or project_id.")
196
198
 
197
199
  return client.create_deidentify_template(
198
- request=dict(
199
- parent=parent,
200
- deidentify_template=deidentify_template,
201
- template_id=template_id,
202
- ),
200
+ request={
201
+ "parent": parent,
202
+ "deidentify_template": deidentify_template,
203
+ "template_id": template_id,
204
+ },
203
205
  retry=retry,
204
206
  timeout=timeout,
205
207
  metadata=metadata,
@@ -242,12 +244,12 @@ class CloudDLPHook(GoogleBaseHook):
242
244
 
243
245
  parent = DlpServiceClient.common_project_path(project_id)
244
246
  job = client.create_dlp_job(
245
- request=dict(
246
- parent=parent,
247
- inspect_job=inspect_job,
248
- risk_job=risk_job,
249
- job_id=job_id,
250
- ),
247
+ request={
248
+ "parent": parent,
249
+ "inspect_job": inspect_job,
250
+ "risk_job": risk_job,
251
+ "job_id": job_id,
252
+ },
251
253
  retry=retry,
252
254
  timeout=timeout,
253
255
  metadata=metadata,
@@ -321,11 +323,11 @@ class CloudDLPHook(GoogleBaseHook):
321
323
  raise AirflowException("Please provide either organization_id or project_id.")
322
324
 
323
325
  return client.create_inspect_template(
324
- request=dict(
325
- parent=parent,
326
- inspect_template=inspect_template,
327
- template_id=template_id,
328
- ),
326
+ request={
327
+ "parent": parent,
328
+ "inspect_template": inspect_template,
329
+ "template_id": template_id,
330
+ },
329
331
  retry=retry,
330
332
  timeout=timeout,
331
333
  metadata=metadata,
@@ -360,11 +362,11 @@ class CloudDLPHook(GoogleBaseHook):
360
362
 
361
363
  parent = DlpServiceClient.common_project_path(project_id)
362
364
  return client.create_job_trigger(
363
- request=dict(
364
- parent=parent,
365
- job_trigger=job_trigger,
366
- trigger_id=trigger_id,
367
- ),
365
+ request={
366
+ "parent": parent,
367
+ "job_trigger": job_trigger,
368
+ "trigger_id": trigger_id,
369
+ },
368
370
  retry=retry,
369
371
  timeout=timeout,
370
372
  metadata=metadata,
@@ -410,11 +412,11 @@ class CloudDLPHook(GoogleBaseHook):
410
412
  raise AirflowException("Please provide either organization_id or project_id.")
411
413
 
412
414
  return client.create_stored_info_type(
413
- request=dict(
414
- parent=parent,
415
- config=config,
416
- stored_info_type_id=stored_info_type_id,
417
- ),
415
+ request={
416
+ "parent": parent,
417
+ "config": config,
418
+ "stored_info_type_id": stored_info_type_id,
419
+ },
418
420
  retry=retry,
419
421
  timeout=timeout,
420
422
  metadata=metadata,
@@ -461,14 +463,14 @@ class CloudDLPHook(GoogleBaseHook):
461
463
 
462
464
  parent = DlpServiceClient.common_project_path(project_id)
463
465
  return client.deidentify_content(
464
- request=dict(
465
- parent=parent,
466
- deidentify_config=deidentify_config,
467
- inspect_config=inspect_config,
468
- item=item,
469
- inspect_template_name=inspect_template_name,
470
- deidentify_template_name=deidentify_template_name,
471
- ),
466
+ request={
467
+ "parent": parent,
468
+ "deidentify_config": deidentify_config,
469
+ "inspect_config": inspect_config,
470
+ "item": item,
471
+ "inspect_template_name": inspect_template_name,
472
+ "deidentify_template_name": deidentify_template_name,
473
+ },
472
474
  retry=retry,
473
475
  timeout=timeout,
474
476
  metadata=metadata,
@@ -509,9 +511,9 @@ class CloudDLPHook(GoogleBaseHook):
509
511
  raise AirflowException("Please provide either organization_id or project_id.")
510
512
 
511
513
  client.delete_deidentify_template(
512
- request=dict(
513
- name=name,
514
- ),
514
+ request={
515
+ "name": name,
516
+ },
515
517
  retry=retry,
516
518
  timeout=timeout,
517
519
  metadata=metadata,
@@ -550,9 +552,9 @@ class CloudDLPHook(GoogleBaseHook):
550
552
 
551
553
  name = DlpServiceClient.dlp_job_path(project_id, dlp_job_id)
552
554
  client.delete_dlp_job(
553
- request=dict(
554
- name=name,
555
- ),
555
+ request={
556
+ "name": name,
557
+ },
556
558
  retry=retry,
557
559
  timeout=timeout,
558
560
  metadata=metadata,
@@ -599,9 +601,9 @@ class CloudDLPHook(GoogleBaseHook):
599
601
  raise AirflowException("Please provide either organization_id or project_id.")
600
602
 
601
603
  client.delete_inspect_template(
602
- request=dict(
603
- name=name,
604
- ),
604
+ request={
605
+ "name": name,
606
+ },
605
607
  retry=retry,
606
608
  timeout=timeout,
607
609
  metadata=metadata,
@@ -637,9 +639,9 @@ class CloudDLPHook(GoogleBaseHook):
637
639
 
638
640
  name = DlpServiceClient.job_trigger_path(project_id, job_trigger_id)
639
641
  client.delete_job_trigger(
640
- request=dict(
641
- name=name,
642
- ),
642
+ request={
643
+ "name": name,
644
+ },
643
645
  retry=retry,
644
646
  timeout=timeout,
645
647
  metadata=metadata,
@@ -686,9 +688,9 @@ class CloudDLPHook(GoogleBaseHook):
686
688
  raise AirflowException("Please provide either organization_id or project_id.")
687
689
 
688
690
  client.delete_stored_info_type(
689
- request=dict(
690
- name=name,
691
- ),
691
+ request={
692
+ "name": name,
693
+ },
692
694
  retry=retry,
693
695
  timeout=timeout,
694
696
  metadata=metadata,
@@ -735,9 +737,9 @@ class CloudDLPHook(GoogleBaseHook):
735
737
  raise AirflowException("Please provide either organization_id or project_id.")
736
738
 
737
739
  return client.get_deidentify_template(
738
- request=dict(
739
- name=name,
740
- ),
740
+ request={
741
+ "name": name,
742
+ },
741
743
  retry=retry,
742
744
  timeout=timeout,
743
745
  metadata=metadata,
@@ -773,9 +775,9 @@ class CloudDLPHook(GoogleBaseHook):
773
775
 
774
776
  name = DlpServiceClient.dlp_job_path(project_id, dlp_job_id)
775
777
  return client.get_dlp_job(
776
- request=dict(
777
- name=name,
778
- ),
778
+ request={
779
+ "name": name,
780
+ },
779
781
  retry=retry,
780
782
  timeout=timeout,
781
783
  metadata=metadata,
@@ -822,9 +824,9 @@ class CloudDLPHook(GoogleBaseHook):
822
824
  raise AirflowException("Please provide either organization_id or project_id.")
823
825
 
824
826
  return client.get_inspect_template(
825
- request=dict(
826
- name=name,
827
- ),
827
+ request={
828
+ "name": name,
829
+ },
828
830
  retry=retry,
829
831
  timeout=timeout,
830
832
  metadata=metadata,
@@ -860,9 +862,9 @@ class CloudDLPHook(GoogleBaseHook):
860
862
 
861
863
  name = DlpServiceClient.job_trigger_path(project_id, job_trigger_id)
862
864
  return client.get_job_trigger(
863
- request=dict(
864
- name=name,
865
- ),
865
+ request={
866
+ "name": name,
867
+ },
866
868
  retry=retry,
867
869
  timeout=timeout,
868
870
  metadata=metadata,
@@ -909,9 +911,9 @@ class CloudDLPHook(GoogleBaseHook):
909
911
  raise AirflowException("Please provide either organization_id or project_id.")
910
912
 
911
913
  return client.get_stored_info_type(
912
- request=dict(
913
- name=name,
914
- ),
914
+ request={
915
+ "name": name,
916
+ },
915
917
  retry=retry,
916
918
  timeout=timeout,
917
919
  metadata=metadata,
@@ -950,12 +952,12 @@ class CloudDLPHook(GoogleBaseHook):
950
952
 
951
953
  parent = DlpServiceClient.common_project_path(project_id)
952
954
  return client.inspect_content(
953
- request=dict(
954
- parent=parent,
955
- inspect_config=inspect_config,
956
- item=item,
957
- inspect_template_name=inspect_template_name,
958
- ),
955
+ request={
956
+ "parent": parent,
957
+ "inspect_config": inspect_config,
958
+ "item": item,
959
+ "inspect_template_name": inspect_template_name,
960
+ },
959
961
  retry=retry,
960
962
  timeout=timeout,
961
963
  metadata=metadata,
@@ -1003,11 +1005,11 @@ class CloudDLPHook(GoogleBaseHook):
1003
1005
  raise AirflowException("Please provide either organization_id or project_id.")
1004
1006
 
1005
1007
  results = client.list_deidentify_templates(
1006
- request=dict(
1007
- parent=parent,
1008
- page_size=page_size,
1009
- order_by=order_by,
1010
- ),
1008
+ request={
1009
+ "parent": parent,
1010
+ "page_size": page_size,
1011
+ "order_by": order_by,
1012
+ },
1011
1013
  retry=retry,
1012
1014
  timeout=timeout,
1013
1015
  metadata=metadata,
@@ -1050,13 +1052,13 @@ class CloudDLPHook(GoogleBaseHook):
1050
1052
 
1051
1053
  parent = DlpServiceClient.common_project_path(project_id)
1052
1054
  results = client.list_dlp_jobs(
1053
- request=dict(
1054
- parent=parent,
1055
- filter=results_filter,
1056
- page_size=page_size,
1057
- type_=job_type,
1058
- order_by=order_by,
1059
- ),
1055
+ request={
1056
+ "parent": parent,
1057
+ "filter": results_filter,
1058
+ "page_size": page_size,
1059
+ "type_": job_type,
1060
+ "order_by": order_by,
1061
+ },
1060
1062
  retry=retry,
1061
1063
  timeout=timeout,
1062
1064
  metadata=metadata,
@@ -1088,10 +1090,10 @@ class CloudDLPHook(GoogleBaseHook):
1088
1090
  client = self.get_conn()
1089
1091
 
1090
1092
  return client.list_info_types(
1091
- request=dict(
1092
- language_code=language_code,
1093
- filter=results_filter,
1094
- ),
1093
+ request={
1094
+ "language_code": language_code,
1095
+ "filter": results_filter,
1096
+ },
1095
1097
  retry=retry,
1096
1098
  timeout=timeout,
1097
1099
  metadata=metadata,
@@ -1139,11 +1141,11 @@ class CloudDLPHook(GoogleBaseHook):
1139
1141
  raise AirflowException("Please provide either organization_id or project_id.")
1140
1142
 
1141
1143
  results = client.list_inspect_templates(
1142
- request=dict(
1143
- parent=parent,
1144
- page_size=page_size,
1145
- order_by=order_by,
1146
- ),
1144
+ request={
1145
+ "parent": parent,
1146
+ "page_size": page_size,
1147
+ "order_by": order_by,
1148
+ },
1147
1149
  retry=retry,
1148
1150
  timeout=timeout,
1149
1151
  metadata=metadata,
@@ -1183,12 +1185,12 @@ class CloudDLPHook(GoogleBaseHook):
1183
1185
 
1184
1186
  parent = DlpServiceClient.common_project_path(project_id)
1185
1187
  results = client.list_job_triggers(
1186
- request=dict(
1187
- parent=parent,
1188
- page_size=page_size,
1189
- order_by=order_by,
1190
- filter=results_filter,
1191
- ),
1188
+ request={
1189
+ "parent": parent,
1190
+ "page_size": page_size,
1191
+ "order_by": order_by,
1192
+ "filter": results_filter,
1193
+ },
1192
1194
  retry=retry,
1193
1195
  timeout=timeout,
1194
1196
  metadata=metadata,
@@ -1237,11 +1239,11 @@ class CloudDLPHook(GoogleBaseHook):
1237
1239
  raise AirflowException("Please provide either organization_id or project_id.")
1238
1240
 
1239
1241
  results = client.list_stored_info_types(
1240
- request=dict(
1241
- parent=parent,
1242
- page_size=page_size,
1243
- order_by=order_by,
1244
- ),
1242
+ request={
1243
+ "parent": parent,
1244
+ "page_size": page_size,
1245
+ "order_by": order_by,
1246
+ },
1245
1247
  retry=retry,
1246
1248
  timeout=timeout,
1247
1249
  metadata=metadata,
@@ -1285,13 +1287,13 @@ class CloudDLPHook(GoogleBaseHook):
1285
1287
 
1286
1288
  parent = DlpServiceClient.common_project_path(project_id)
1287
1289
  return client.redact_image(
1288
- request=dict(
1289
- parent=parent,
1290
- inspect_config=inspect_config,
1291
- image_redaction_configs=image_redaction_configs,
1292
- include_findings=include_findings,
1293
- byte_item=byte_item,
1294
- ),
1290
+ request={
1291
+ "parent": parent,
1292
+ "inspect_config": inspect_config,
1293
+ "image_redaction_configs": image_redaction_configs,
1294
+ "include_findings": include_findings,
1295
+ "byte_item": byte_item,
1296
+ },
1295
1297
  retry=retry,
1296
1298
  timeout=timeout,
1297
1299
  metadata=metadata,
@@ -1336,14 +1338,14 @@ class CloudDLPHook(GoogleBaseHook):
1336
1338
 
1337
1339
  parent = DlpServiceClient.common_project_path(project_id)
1338
1340
  return client.reidentify_content(
1339
- request=dict(
1340
- parent=parent,
1341
- reidentify_config=reidentify_config,
1342
- inspect_config=inspect_config,
1343
- item=item,
1344
- inspect_template_name=inspect_template_name,
1345
- reidentify_template_name=reidentify_template_name,
1346
- ),
1341
+ request={
1342
+ "parent": parent,
1343
+ "reidentify_config": reidentify_config,
1344
+ "inspect_config": inspect_config,
1345
+ "item": item,
1346
+ "inspect_template_name": inspect_template_name,
1347
+ "reidentify_template_name": reidentify_template_name,
1348
+ },
1347
1349
  retry=retry,
1348
1350
  timeout=timeout,
1349
1351
  metadata=metadata,
@@ -1394,11 +1396,11 @@ class CloudDLPHook(GoogleBaseHook):
1394
1396
  raise AirflowException("Please provide either organization_id or project_id.")
1395
1397
 
1396
1398
  return client.update_deidentify_template(
1397
- request=dict(
1398
- name=name,
1399
- deidentify_template=deidentify_template,
1400
- update_mask=update_mask,
1401
- ),
1399
+ request={
1400
+ "name": name,
1401
+ "deidentify_template": deidentify_template,
1402
+ "update_mask": update_mask,
1403
+ },
1402
1404
  retry=retry,
1403
1405
  timeout=timeout,
1404
1406
  metadata=metadata,
@@ -1448,11 +1450,11 @@ class CloudDLPHook(GoogleBaseHook):
1448
1450
  raise AirflowException("Please provide either organization_id or project_id.")
1449
1451
 
1450
1452
  return client.update_inspect_template(
1451
- request=dict(
1452
- name=name,
1453
- inspect_template=inspect_template,
1454
- update_mask=update_mask,
1455
- ),
1453
+ request={
1454
+ "name": name,
1455
+ "inspect_template": inspect_template,
1456
+ "update_mask": update_mask,
1457
+ },
1456
1458
  retry=retry,
1457
1459
  timeout=timeout,
1458
1460
  metadata=metadata,
@@ -1552,11 +1554,11 @@ class CloudDLPHook(GoogleBaseHook):
1552
1554
  raise AirflowException("Please provide either organization_id or project_id.")
1553
1555
 
1554
1556
  return client.update_stored_info_type(
1555
- request=dict(
1556
- name=name,
1557
- config=config,
1558
- update_mask=update_mask,
1559
- ),
1557
+ request={
1558
+ "name": name,
1559
+ "config": config,
1560
+ "update_mask": update_mask,
1561
+ },
1560
1562
  retry=retry,
1561
1563
  timeout=timeout,
1562
1564
  metadata=metadata,
@@ -26,18 +26,14 @@ import shutil
26
26
  import time
27
27
  import warnings
28
28
  from contextlib import contextmanager
29
- from datetime import datetime
30
29
  from functools import partial
31
30
  from io import BytesIO
32
- from os import path
33
31
  from tempfile import NamedTemporaryFile
34
- from typing import IO, Any, Callable, Generator, Sequence, TypeVar, cast, overload
32
+ from typing import IO, TYPE_CHECKING, Any, Callable, Generator, Sequence, TypeVar, cast, overload
35
33
  from urllib.parse import urlsplit
36
34
 
37
- from aiohttp import ClientSession
38
35
  from gcloud.aio.storage import Storage
39
36
  from google.api_core.exceptions import GoogleAPICallError, NotFound
40
- from google.api_core.retry import Retry
41
37
 
42
38
  # not sure why but mypy complains on missing `storage` but it is clearly there and is importable
43
39
  from google.cloud import storage # type: ignore[attr-defined]
@@ -52,6 +48,12 @@ from airflow.providers.google.common.hooks.base_google import GoogleBaseAsyncHoo
52
48
  from airflow.utils import timezone
53
49
  from airflow.version import version
54
50
 
51
+ if TYPE_CHECKING:
52
+ from datetime import datetime
53
+
54
+ from aiohttp import ClientSession
55
+ from google.api_core.retry import Retry
56
+
55
57
  try:
56
58
  # Airflow 2.3 doesn't have this yet
57
59
  from airflow.typing_compat import ParamSpec
@@ -358,7 +360,6 @@ class GCSHook(GoogleBaseHook):
358
360
  # Wait with exponential backoff scheme before retrying.
359
361
  timeout_seconds = 2 ** (num_file_attempts - 1)
360
362
  time.sleep(timeout_seconds)
361
- continue
362
363
 
363
364
  def download_as_byte_array(
364
365
  self,
@@ -505,28 +506,23 @@ class GCSHook(GoogleBaseHook):
505
506
 
506
507
  :param f: Callable that should be retried.
507
508
  """
508
- num_file_attempts = 0
509
-
510
- while num_file_attempts < num_max_attempts:
509
+ for attempt in range(1, 1 + num_max_attempts):
511
510
  try:
512
- num_file_attempts += 1
513
511
  f()
514
-
515
512
  except GoogleCloudError as e:
516
- if num_file_attempts == num_max_attempts:
513
+ if attempt == num_max_attempts:
517
514
  self.log.error(
518
515
  "Upload attempt of object: %s from %s has failed. Attempt: %s, max %s.",
519
516
  object_name,
520
517
  object_name,
521
- num_file_attempts,
518
+ attempt,
522
519
  num_max_attempts,
523
520
  )
524
521
  raise e
525
522
 
526
523
  # Wait with exponential backoff scheme before retrying.
527
- timeout_seconds = 2 ** (num_file_attempts - 1)
524
+ timeout_seconds = 2 ** (attempt - 1)
528
525
  time.sleep(timeout_seconds)
529
- continue
530
526
 
531
527
  client = self.get_conn()
532
528
  bucket = client.bucket(bucket_name, user_project=user_project)
@@ -550,10 +546,9 @@ class GCSHook(GoogleBaseHook):
550
546
  if gzip:
551
547
  filename_gz = filename + ".gz"
552
548
 
553
- with open(filename, "rb") as f_in:
554
- with gz.open(filename_gz, "wb") as f_out:
555
- shutil.copyfileobj(f_in, f_out)
556
- filename = filename_gz
549
+ with open(filename, "rb") as f_in, gz.open(filename_gz, "wb") as f_out:
550
+ shutil.copyfileobj(f_in, f_out)
551
+ filename = filename_gz
557
552
 
558
553
  _call_with_retry(
559
554
  partial(blob.upload_from_filename, filename=filename, content_type=mime_type, timeout=timeout)
@@ -1294,7 +1289,7 @@ class GCSHook(GoogleBaseHook):
1294
1289
  self, blob: storage.Blob, destination_object: str | None, source_object_prefix_len: int
1295
1290
  ) -> str:
1296
1291
  return (
1297
- path.join(destination_object, blob.name[source_object_prefix_len:])
1292
+ os.path.join(destination_object, blob.name[source_object_prefix_len:])
1298
1293
  if destination_object
1299
1294
  else blob.name[source_object_prefix_len:]
1300
1295
  )
@@ -19,15 +19,17 @@
19
19
  from __future__ import annotations
20
20
 
21
21
  import base64
22
- from typing import Sequence
22
+ from typing import TYPE_CHECKING, Sequence
23
23
 
24
24
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
25
- from google.api_core.retry import Retry
26
25
  from google.cloud.kms_v1 import KeyManagementServiceClient
27
26
 
28
27
  from airflow.providers.google.common.consts import CLIENT_INFO
29
28
  from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
30
29
 
30
+ if TYPE_CHECKING:
31
+ from google.api_core.retry import Retry
32
+
31
33
 
32
34
  def _b64encode(s: bytes) -> str:
33
35
  """Base 64 encodes a bytes object to a string."""