apache-airflow-providers-google 10.7.0__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.
- airflow/providers/google/__init__.py +1 -1
- airflow/providers/google/ads/hooks/ads.py +10 -6
- airflow/providers/google/cloud/_internal_client/secret_manager_client.py +4 -1
- airflow/providers/google/cloud/example_dags/example_cloud_sql_query.py +31 -34
- airflow/providers/google/cloud/hooks/automl.py +11 -9
- airflow/providers/google/cloud/hooks/bigquery.py +30 -36
- airflow/providers/google/cloud/hooks/bigquery_dts.py +5 -3
- airflow/providers/google/cloud/hooks/bigtable.py +11 -8
- airflow/providers/google/cloud/hooks/cloud_batch.py +5 -3
- airflow/providers/google/cloud/hooks/cloud_build.py +6 -4
- airflow/providers/google/cloud/hooks/cloud_composer.py +14 -10
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +5 -3
- airflow/providers/google/cloud/hooks/cloud_run.py +5 -3
- airflow/providers/google/cloud/hooks/cloud_sql.py +11 -14
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +8 -6
- airflow/providers/google/cloud/hooks/compute.py +5 -3
- airflow/providers/google/cloud/hooks/compute_ssh.py +1 -1
- airflow/providers/google/cloud/hooks/datacatalog.py +5 -3
- airflow/providers/google/cloud/hooks/dataflow.py +8 -11
- airflow/providers/google/cloud/hooks/dataform.py +4 -2
- airflow/providers/google/cloud/hooks/datafusion.py +24 -6
- airflow/providers/google/cloud/hooks/dataplex.py +75 -6
- airflow/providers/google/cloud/hooks/dataproc.py +9 -7
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +8 -6
- airflow/providers/google/cloud/hooks/dlp.py +139 -137
- airflow/providers/google/cloud/hooks/gcs.py +15 -20
- airflow/providers/google/cloud/hooks/kms.py +4 -2
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +34 -34
- airflow/providers/google/cloud/hooks/looker.py +4 -1
- airflow/providers/google/cloud/hooks/mlengine.py +8 -6
- airflow/providers/google/cloud/hooks/natural_language.py +4 -2
- airflow/providers/google/cloud/hooks/os_login.py +9 -7
- airflow/providers/google/cloud/hooks/pubsub.py +13 -11
- airflow/providers/google/cloud/hooks/spanner.py +7 -5
- airflow/providers/google/cloud/hooks/speech_to_text.py +4 -2
- airflow/providers/google/cloud/hooks/stackdriver.py +6 -5
- airflow/providers/google/cloud/hooks/tasks.py +5 -3
- airflow/providers/google/cloud/hooks/text_to_speech.py +4 -2
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +7 -5
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +6 -4
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +11 -9
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +12 -10
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +8 -6
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +6 -4
- airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +7 -5
- airflow/providers/google/cloud/hooks/video_intelligence.py +5 -3
- airflow/providers/google/cloud/hooks/vision.py +5 -3
- airflow/providers/google/cloud/hooks/workflows.py +8 -6
- airflow/providers/google/cloud/links/bigquery.py +1 -1
- airflow/providers/google/cloud/links/bigquery_dts.py +1 -1
- airflow/providers/google/cloud/links/cloud_functions.py +1 -1
- airflow/providers/google/cloud/links/cloud_memorystore.py +1 -1
- airflow/providers/google/cloud/links/cloud_sql.py +1 -1
- airflow/providers/google/cloud/links/cloud_tasks.py +1 -1
- airflow/providers/google/cloud/links/compute.py +1 -1
- airflow/providers/google/cloud/links/datacatalog.py +1 -1
- airflow/providers/google/cloud/links/dataflow.py +1 -1
- airflow/providers/google/cloud/links/dataform.py +1 -1
- airflow/providers/google/cloud/links/pubsub.py +1 -1
- airflow/providers/google/cloud/links/spanner.py +1 -1
- airflow/providers/google/cloud/links/stackdriver.py +1 -1
- airflow/providers/google/cloud/links/workflows.py +2 -2
- airflow/providers/google/cloud/log/gcs_task_handler.py +5 -7
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +8 -4
- airflow/providers/google/cloud/operators/automl.py +2 -1
- airflow/providers/google/cloud/operators/bigquery.py +6 -2
- airflow/providers/google/cloud/operators/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/operators/bigtable.py +5 -3
- airflow/providers/google/cloud/operators/cloud_batch.py +6 -3
- airflow/providers/google/cloud/operators/cloud_build.py +2 -1
- airflow/providers/google/cloud/operators/cloud_composer.py +3 -2
- airflow/providers/google/cloud/operators/cloud_memorystore.py +3 -2
- airflow/providers/google/cloud/operators/cloud_run.py +3 -2
- airflow/providers/google/cloud/operators/cloud_sql.py +157 -152
- airflow/providers/google/cloud/operators/compute.py +59 -61
- airflow/providers/google/cloud/operators/datacatalog.py +3 -2
- airflow/providers/google/cloud/operators/dataflow.py +3 -1
- airflow/providers/google/cloud/operators/dataform.py +2 -1
- airflow/providers/google/cloud/operators/datafusion.py +1 -1
- airflow/providers/google/cloud/operators/dataplex.py +110 -8
- airflow/providers/google/cloud/operators/dataproc.py +39 -18
- airflow/providers/google/cloud/operators/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/operators/dlp.py +3 -2
- airflow/providers/google/cloud/operators/functions.py +46 -46
- airflow/providers/google/cloud/operators/gcs.py +4 -6
- airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -1
- airflow/providers/google/cloud/operators/natural_language.py +3 -2
- airflow/providers/google/cloud/operators/pubsub.py +2 -1
- airflow/providers/google/cloud/operators/speech_to_text.py +3 -2
- airflow/providers/google/cloud/operators/stackdriver.py +2 -1
- airflow/providers/google/cloud/operators/tasks.py +3 -2
- airflow/providers/google/cloud/operators/text_to_speech.py +3 -2
- airflow/providers/google/cloud/operators/translate_speech.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +3 -2
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +3 -2
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +4 -4
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +3 -2
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +2 -1
- airflow/providers/google/cloud/operators/video_intelligence.py +2 -1
- airflow/providers/google/cloud/operators/vision.py +3 -2
- airflow/providers/google/cloud/operators/workflows.py +7 -5
- airflow/providers/google/cloud/secrets/secret_manager.py +2 -2
- airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/sensors/dataplex.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -2
- airflow/providers/google/cloud/sensors/gcs.py +2 -1
- airflow/providers/google/cloud/sensors/workflows.py +2 -1
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +24 -10
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -4
- airflow/providers/google/cloud/transfers/bigquery_to_postgres.py +1 -4
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -1
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +4 -2
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +1 -3
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +2 -1
- airflow/providers/google/cloud/transfers/presto_to_gcs.py +5 -4
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/trino_to_gcs.py +5 -4
- airflow/providers/google/cloud/triggers/bigquery.py +30 -36
- airflow/providers/google/cloud/triggers/bigquery_dts.py +9 -10
- airflow/providers/google/cloud/triggers/cloud_batch.py +6 -8
- airflow/providers/google/cloud/triggers/cloud_build.py +5 -6
- airflow/providers/google/cloud/triggers/cloud_run.py +4 -3
- airflow/providers/google/cloud/triggers/cloud_sql.py +10 -10
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +1 -1
- airflow/providers/google/cloud/triggers/dataflow.py +5 -6
- airflow/providers/google/cloud/triggers/datafusion.py +5 -6
- airflow/providers/google/cloud/triggers/dataplex.py +110 -0
- airflow/providers/google/cloud/triggers/dataproc.py +18 -20
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +14 -13
- airflow/providers/google/cloud/triggers/mlengine.py +5 -5
- airflow/providers/google/cloud/triggers/pubsub.py +2 -2
- airflow/providers/google/cloud/utils/bigquery_get_data.py +6 -3
- airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
- airflow/providers/google/cloud/utils/field_validator.py +13 -13
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +5 -3
- airflow/providers/google/cloud/utils/mlengine_prediction_summary.py +1 -1
- airflow/providers/google/common/hooks/base_google.py +10 -2
- airflow/providers/google/common/links/storage.py +1 -1
- airflow/providers/google/common/utils/id_token_credentials.py +4 -1
- airflow/providers/google/get_provider_info.py +5 -0
- airflow/providers/google/marketing_platform/hooks/campaign_manager.py +4 -2
- airflow/providers/google/marketing_platform/sensors/display_video.py +6 -3
- airflow/providers/google/suite/hooks/calendar.py +4 -2
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/METADATA +6 -6
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/RECORD +155 -173
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/WHEEL +1 -1
- airflow/providers/google/ads/_vendor/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/interceptors/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/common/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/common/types/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/enums/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/enums/types/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/errors/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/errors/types/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/resources/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/resources/types/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/services/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/services/customer_service/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/services/customer_service/transports/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/services/google_ads_service/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/services/google_ads_service/transports/__init__.py +0 -16
- airflow/providers/google/ads/_vendor/googleads/v12/services/types/__init__.py +0 -16
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/LICENSE +0 -0
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/NOTICE +0 -0
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/entry_points.txt +0 -0
- {apache_airflow_providers_google-10.7.0.dist-info → apache_airflow_providers_google-10.8.0.dist-info}/top_level.txt +0 -0
@@ -20,20 +20,22 @@ from __future__ import annotations
|
|
20
20
|
|
21
21
|
from functools import cached_property
|
22
22
|
from tempfile import NamedTemporaryFile
|
23
|
-
from typing import IO, Any
|
23
|
+
from typing import IO, TYPE_CHECKING, Any
|
24
24
|
|
25
25
|
from google.ads.googleads.client import GoogleAdsClient
|
26
26
|
from google.ads.googleads.errors import GoogleAdsException
|
27
|
-
from google.ads.googleads.v14.services.services.customer_service import CustomerServiceClient
|
28
|
-
from google.ads.googleads.v14.services.services.google_ads_service import GoogleAdsServiceClient
|
29
|
-
from google.ads.googleads.v14.services.types.google_ads_service import GoogleAdsRow
|
30
|
-
from google.api_core.page_iterator import GRPCIterator
|
31
27
|
from google.auth.exceptions import GoogleAuthError
|
32
28
|
|
33
29
|
from airflow import AirflowException
|
34
30
|
from airflow.hooks.base import BaseHook
|
35
31
|
from airflow.providers.google.common.hooks.base_google import get_field
|
36
32
|
|
33
|
+
if TYPE_CHECKING:
|
34
|
+
from google.ads.googleads.v14.services.services.customer_service import CustomerServiceClient
|
35
|
+
from google.ads.googleads.v14.services.services.google_ads_service import GoogleAdsServiceClient
|
36
|
+
from google.ads.googleads.v14.services.types.google_ads_service import GoogleAdsRow
|
37
|
+
from google.api_core.page_iterator import GRPCIterator
|
38
|
+
|
37
39
|
|
38
40
|
class GoogleAdsHook(BaseHook):
|
39
41
|
"""Interact with Google Ads API.
|
@@ -224,7 +226,9 @@ class GoogleAdsHook(BaseHook):
|
|
224
226
|
|
225
227
|
iterators = []
|
226
228
|
for client_id in client_ids:
|
227
|
-
iterator = service.search(
|
229
|
+
iterator = service.search(
|
230
|
+
request={"customer_id": client_id, "query": query, "page_size": page_size}
|
231
|
+
)
|
228
232
|
iterators.append(iterator)
|
229
233
|
|
230
234
|
self.log.info("Fetched Google Ads Iterators")
|
@@ -18,14 +18,17 @@ from __future__ import annotations
|
|
18
18
|
|
19
19
|
import re
|
20
20
|
from functools import cached_property
|
21
|
+
from typing import TYPE_CHECKING
|
21
22
|
|
22
|
-
import google
|
23
23
|
from google.api_core.exceptions import InvalidArgument, NotFound, PermissionDenied
|
24
24
|
from google.cloud.secretmanager_v1 import SecretManagerServiceClient
|
25
25
|
|
26
26
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
27
27
|
from airflow.utils.log.logging_mixin import LoggingMixin
|
28
28
|
|
29
|
+
if TYPE_CHECKING:
|
30
|
+
import google
|
31
|
+
|
29
32
|
SECRET_ID_PATTERN = r"^[a-zA-Z0-9-_]*$"
|
30
33
|
|
31
34
|
|
@@ -40,7 +40,7 @@ from __future__ import annotations
|
|
40
40
|
import os
|
41
41
|
import subprocess
|
42
42
|
from datetime import datetime
|
43
|
-
from
|
43
|
+
from pathlib import Path
|
44
44
|
from urllib.parse import quote_plus
|
45
45
|
|
46
46
|
from airflow import models
|
@@ -87,32 +87,29 @@ SQL = [
|
|
87
87
|
|
88
88
|
# [START howto_operator_cloudsql_query_connections]
|
89
89
|
|
90
|
-
HOME_DIR =
|
90
|
+
HOME_DIR = Path.home()
|
91
91
|
|
92
92
|
|
93
93
|
def get_absolute_path(path):
|
94
94
|
"""
|
95
95
|
Returns absolute path.
|
96
96
|
"""
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
client_key_file=quote_plus(get_absolute_path(GCSQL_POSTGRES_CLIENT_KEY_FILE)),
|
114
|
-
server_ca_file=quote_plus(get_absolute_path(GCSQL_POSTGRES_SERVER_CA_FILE)),
|
115
|
-
)
|
97
|
+
return os.fspath(HOME_DIR / path)
|
98
|
+
|
99
|
+
|
100
|
+
postgres_kwargs = {
|
101
|
+
"user": quote_plus(GCSQL_POSTGRES_USER),
|
102
|
+
"password": quote_plus(GCSQL_POSTGRES_PASSWORD),
|
103
|
+
"public_port": GCSQL_POSTGRES_PUBLIC_PORT,
|
104
|
+
"public_ip": quote_plus(GCSQL_POSTGRES_PUBLIC_IP),
|
105
|
+
"project_id": quote_plus(GCP_PROJECT_ID),
|
106
|
+
"location": quote_plus(GCP_REGION),
|
107
|
+
"instance": quote_plus(GCSQL_POSTGRES_INSTANCE_NAME_QUERY),
|
108
|
+
"database": quote_plus(GCSQL_POSTGRES_DATABASE_NAME),
|
109
|
+
"client_cert_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_CLIENT_CERT_FILE)),
|
110
|
+
"client_key_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_CLIENT_KEY_FILE)),
|
111
|
+
"server_ca_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_SERVER_CA_FILE)),
|
112
|
+
}
|
116
113
|
|
117
114
|
# The connections below are created using one of the standard approaches - via environment
|
118
115
|
# variables named AIRFLOW_CONN_* . The connections can also be created in the database
|
@@ -166,19 +163,19 @@ os.environ["AIRFLOW_CONN_PUBLIC_POSTGRES_TCP_SSL"] = (
|
|
166
163
|
"sslrootcert={server_ca_file}".format(**postgres_kwargs)
|
167
164
|
)
|
168
165
|
|
169
|
-
mysql_kwargs =
|
170
|
-
user
|
171
|
-
password
|
172
|
-
public_port
|
173
|
-
public_ip
|
174
|
-
project_id
|
175
|
-
location
|
176
|
-
instance
|
177
|
-
database
|
178
|
-
client_cert_file
|
179
|
-
client_key_file
|
180
|
-
server_ca_file
|
181
|
-
|
166
|
+
mysql_kwargs = {
|
167
|
+
"user": quote_plus(GCSQL_MYSQL_USER),
|
168
|
+
"password": quote_plus(GCSQL_MYSQL_PASSWORD),
|
169
|
+
"public_port": GCSQL_MYSQL_PUBLIC_PORT,
|
170
|
+
"public_ip": quote_plus(GCSQL_MYSQL_PUBLIC_IP),
|
171
|
+
"project_id": quote_plus(GCP_PROJECT_ID),
|
172
|
+
"location": quote_plus(GCP_REGION),
|
173
|
+
"instance": quote_plus(GCSQL_MYSQL_INSTANCE_NAME_QUERY),
|
174
|
+
"database": quote_plus(GCSQL_MYSQL_DATABASE_NAME),
|
175
|
+
"client_cert_file": quote_plus(get_absolute_path(GCSQL_MYSQL_CLIENT_CERT_FILE)),
|
176
|
+
"client_key_file": quote_plus(get_absolute_path(GCSQL_MYSQL_CLIENT_KEY_FILE)),
|
177
|
+
"server_ca_file": quote_plus(get_absolute_path(GCSQL_MYSQL_SERVER_CA_FILE)),
|
178
|
+
}
|
182
179
|
|
183
180
|
# MySQL: connect via proxy over TCP (specific proxy version)
|
184
181
|
os.environ["AIRFLOW_CONN_PROXY_MYSQL_TCP"] = (
|
@@ -25,11 +25,9 @@ This module contains a Google AutoML hook.
|
|
25
25
|
from __future__ import annotations
|
26
26
|
|
27
27
|
from functools import cached_property
|
28
|
-
from typing import Sequence
|
28
|
+
from typing import TYPE_CHECKING, Sequence
|
29
29
|
|
30
30
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
31
|
-
from google.api_core.operation import Operation
|
32
|
-
from google.api_core.retry import Retry
|
33
31
|
from google.cloud.automl_v1beta1 import (
|
34
32
|
AutoMlClient,
|
35
33
|
BatchPredictInputConfig,
|
@@ -42,17 +40,21 @@ from google.cloud.automl_v1beta1 import (
|
|
42
40
|
PredictionServiceClient,
|
43
41
|
PredictResponse,
|
44
42
|
)
|
45
|
-
from google.cloud.automl_v1beta1.services.auto_ml.pagers import (
|
46
|
-
ListColumnSpecsPager,
|
47
|
-
ListDatasetsPager,
|
48
|
-
ListTableSpecsPager,
|
49
|
-
)
|
50
|
-
from google.protobuf.field_mask_pb2 import FieldMask
|
51
43
|
|
52
44
|
from airflow import AirflowException
|
53
45
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
54
46
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
55
47
|
|
48
|
+
if TYPE_CHECKING:
|
49
|
+
from google.api_core.operation import Operation
|
50
|
+
from google.api_core.retry import Retry
|
51
|
+
from google.cloud.automl_v1beta1.services.auto_ml.pagers import (
|
52
|
+
ListColumnSpecsPager,
|
53
|
+
ListDatasetsPager,
|
54
|
+
ListTableSpecsPager,
|
55
|
+
)
|
56
|
+
from google.protobuf.field_mask_pb2 import FieldMask
|
57
|
+
|
56
58
|
|
57
59
|
class CloudAutoMLHook(GoogleBaseHook):
|
58
60
|
"""
|
@@ -32,8 +32,6 @@ from typing import TYPE_CHECKING, Any, Iterable, Mapping, NoReturn, Sequence, Un
|
|
32
32
|
|
33
33
|
from aiohttp import ClientSession as ClientSession
|
34
34
|
from gcloud.aio.bigquery import Job, Table as Table_async
|
35
|
-
from google.api_core.page_iterator import HTTPIterator
|
36
|
-
from google.api_core.retry import Retry
|
37
35
|
from google.cloud.bigquery import (
|
38
36
|
DEFAULT_RETRY,
|
39
37
|
Client,
|
@@ -70,6 +68,8 @@ from airflow.utils.log.logging_mixin import LoggingMixin
|
|
70
68
|
|
71
69
|
if TYPE_CHECKING:
|
72
70
|
import pandas as pd
|
71
|
+
from google.api_core.page_iterator import HTTPIterator
|
72
|
+
from google.api_core.retry import Retry
|
73
73
|
|
74
74
|
log = logging.getLogger(__name__)
|
75
75
|
|
@@ -268,9 +268,7 @@ class BigQueryHook(GoogleBaseHook, DbApiHook):
|
|
268
268
|
|
269
269
|
credentials, project_id = self.get_credentials_and_project_id()
|
270
270
|
|
271
|
-
return read_gbq(
|
272
|
-
sql, project_id=project_id, dialect=dialect, verbose=False, credentials=credentials, **kwargs
|
273
|
-
)
|
271
|
+
return read_gbq(sql, project_id=project_id, dialect=dialect, credentials=credentials, **kwargs)
|
274
272
|
|
275
273
|
@GoogleBaseHook.fallback_to_default_project_id
|
276
274
|
def table_exists(self, dataset_id: str, table_id: str, project_id: str) -> bool:
|
@@ -2208,27 +2206,25 @@ class BigQueryHook(GoogleBaseHook, DbApiHook):
|
|
2208
2206
|
if param_name == "schemaUpdateOptions" and param:
|
2209
2207
|
self.log.info("Adding experimental 'schemaUpdateOptions': %s", schema_update_options)
|
2210
2208
|
|
2211
|
-
if param_name
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2209
|
+
if param_name == "destinationTable":
|
2210
|
+
for key in ["projectId", "datasetId", "tableId"]:
|
2211
|
+
if key not in configuration["query"]["destinationTable"]:
|
2212
|
+
raise ValueError(
|
2213
|
+
"Not correct 'destinationTable' in "
|
2214
|
+
"api_resource_configs. 'destinationTable' "
|
2215
|
+
"must be a dict with {'projectId':'', "
|
2216
|
+
"'datasetId':'', 'tableId':''}"
|
2217
|
+
)
|
2218
|
+
else:
|
2219
|
+
configuration["query"].update(
|
2220
|
+
{
|
2221
|
+
"allowLargeResults": allow_large_results,
|
2222
|
+
"flattenResults": flatten_results,
|
2223
|
+
"writeDisposition": write_disposition,
|
2224
|
+
"createDisposition": create_disposition,
|
2225
|
+
}
|
2221
2226
|
)
|
2222
2227
|
|
2223
|
-
configuration["query"].update(
|
2224
|
-
{
|
2225
|
-
"allowLargeResults": allow_large_results,
|
2226
|
-
"flattenResults": flatten_results,
|
2227
|
-
"writeDisposition": write_disposition,
|
2228
|
-
"createDisposition": create_disposition,
|
2229
|
-
}
|
2230
|
-
)
|
2231
|
-
|
2232
2228
|
if (
|
2233
2229
|
"useLegacySql" in configuration["query"]
|
2234
2230
|
and configuration["query"]["useLegacySql"]
|
@@ -3033,12 +3029,10 @@ def _api_resource_configs_duplication_check(
|
|
3033
3029
|
) -> None:
|
3034
3030
|
if key in config_dict and value != config_dict[key]:
|
3035
3031
|
raise ValueError(
|
3036
|
-
"Values of {
|
3037
|
-
"{
|
3038
|
-
"in `query` config and {
|
3039
|
-
"with arg to run_query() method. Please remove duplicates."
|
3040
|
-
param_name=key, dict_name=config_dict_name
|
3041
|
-
)
|
3032
|
+
f"Values of {key} param are duplicated. "
|
3033
|
+
f"{config_dict_name} contained {key} param "
|
3034
|
+
f"in `query` config and {key} was also provided "
|
3035
|
+
"with arg to run_query() method. Please remove duplicates."
|
3042
3036
|
)
|
3043
3037
|
|
3044
3038
|
|
@@ -3156,15 +3150,15 @@ class BigQueryAsyncHook(GoogleBaseAsyncHook):
|
|
3156
3150
|
if "rows" in query_results and query_results["rows"]:
|
3157
3151
|
rows = query_results["rows"]
|
3158
3152
|
fields = query_results["schema"]["fields"]
|
3153
|
+
fields_names = [field["name"] for field in fields]
|
3159
3154
|
col_types = [field["type"] for field in fields]
|
3160
3155
|
for dict_row in rows:
|
3161
|
-
typed_row = [bq_cast(vs["v"],
|
3162
|
-
if
|
3163
|
-
|
3164
|
-
else:
|
3165
|
-
fields_names = [field["name"] for field in fields]
|
3166
|
-
typed_row_dict = {k: v for k, v in zip(fields_names, typed_row)}
|
3156
|
+
typed_row = [bq_cast(vs["v"], col_type) for vs, col_type in zip(dict_row["f"], col_types)]
|
3157
|
+
if as_dict:
|
3158
|
+
typed_row_dict = dict(zip(fields_names, typed_row))
|
3167
3159
|
buffer.append(typed_row_dict)
|
3160
|
+
else:
|
3161
|
+
buffer.append(typed_row)
|
3168
3162
|
return buffer
|
3169
3163
|
|
3170
3164
|
def value_check(
|
@@ -19,17 +19,15 @@
|
|
19
19
|
from __future__ import annotations
|
20
20
|
|
21
21
|
from copy import copy
|
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.bigquery_datatransfer_v1 import DataTransferServiceAsyncClient, DataTransferServiceClient
|
27
26
|
from google.cloud.bigquery_datatransfer_v1.types import (
|
28
27
|
StartManualTransferRunsResponse,
|
29
28
|
TransferConfig,
|
30
29
|
TransferRun,
|
31
30
|
)
|
32
|
-
from googleapiclient.discovery import Resource
|
33
31
|
|
34
32
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
35
33
|
from airflow.providers.google.common.hooks.base_google import (
|
@@ -38,6 +36,10 @@ from airflow.providers.google.common.hooks.base_google import (
|
|
38
36
|
GoogleBaseHook,
|
39
37
|
)
|
40
38
|
|
39
|
+
if TYPE_CHECKING:
|
40
|
+
from google.api_core.retry import Retry
|
41
|
+
from googleapiclient.discovery import Resource
|
42
|
+
|
41
43
|
|
42
44
|
def get_object_id(obj: dict) -> str:
|
43
45
|
"""Returns unique id of the object."""
|
@@ -18,18 +18,21 @@
|
|
18
18
|
"""This module contains a Google Cloud Bigtable Hook."""
|
19
19
|
from __future__ import annotations
|
20
20
|
|
21
|
-
import
|
22
|
-
from typing import Sequence
|
21
|
+
from typing import TYPE_CHECKING, Sequence
|
23
22
|
|
24
23
|
from google.cloud.bigtable import Client, enums
|
25
24
|
from google.cloud.bigtable.cluster import Cluster
|
26
|
-
from google.cloud.bigtable.column_family import ColumnFamily, GarbageCollectionRule
|
27
25
|
from google.cloud.bigtable.instance import Instance
|
28
26
|
from google.cloud.bigtable.table import ClusterState, Table
|
29
27
|
|
30
28
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
31
29
|
from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
|
32
30
|
|
31
|
+
if TYPE_CHECKING:
|
32
|
+
import enum
|
33
|
+
|
34
|
+
from google.cloud.bigtable.column_family import ColumnFamily, GarbageCollectionRule
|
35
|
+
|
33
36
|
|
34
37
|
class BigtableHook(GoogleBaseHook):
|
35
38
|
"""
|
@@ -148,11 +151,11 @@ class BigtableHook(GoogleBaseHook):
|
|
148
151
|
instance_labels,
|
149
152
|
)
|
150
153
|
|
151
|
-
cluster_kwargs =
|
152
|
-
cluster_id
|
153
|
-
location_id
|
154
|
-
default_storage_type
|
155
|
-
|
154
|
+
cluster_kwargs = {
|
155
|
+
"cluster_id": main_cluster_id,
|
156
|
+
"location_id": main_cluster_zone,
|
157
|
+
"default_storage_type": cluster_storage_type,
|
158
|
+
}
|
156
159
|
if instance_type != enums.Instance.Type.DEVELOPMENT and cluster_nodes:
|
157
160
|
cluster_kwargs["serve_nodes"] = cluster_nodes
|
158
161
|
clusters = [instance.cluster(**cluster_kwargs)]
|
@@ -20,9 +20,8 @@ from __future__ import annotations
|
|
20
20
|
import itertools
|
21
21
|
import json
|
22
22
|
from time import sleep
|
23
|
-
from typing import Iterable, Sequence
|
23
|
+
from typing import TYPE_CHECKING, Iterable, Sequence
|
24
24
|
|
25
|
-
from google.api_core import operation # type: ignore
|
26
25
|
from google.cloud.batch import ListJobsRequest, ListTasksRequest
|
27
26
|
from google.cloud.batch_v1 import (
|
28
27
|
BatchServiceAsyncClient,
|
@@ -32,12 +31,15 @@ from google.cloud.batch_v1 import (
|
|
32
31
|
JobStatus,
|
33
32
|
Task,
|
34
33
|
)
|
35
|
-
from google.cloud.batch_v1.services.batch_service import pagers
|
36
34
|
|
37
35
|
from airflow.exceptions import AirflowException
|
38
36
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
39
37
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
40
38
|
|
39
|
+
if TYPE_CHECKING:
|
40
|
+
from google.api_core import operation
|
41
|
+
from google.cloud.batch_v1.services.batch_service import pagers
|
42
|
+
|
41
43
|
|
42
44
|
class CloudBatchHook(GoogleBaseHook):
|
43
45
|
"""
|
@@ -19,20 +19,22 @@
|
|
19
19
|
from __future__ import annotations
|
20
20
|
|
21
21
|
import warnings
|
22
|
-
from typing import Sequence
|
22
|
+
from typing import TYPE_CHECKING, Sequence
|
23
23
|
|
24
24
|
from google.api_core.client_options import ClientOptions
|
25
25
|
from google.api_core.exceptions import AlreadyExists
|
26
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
27
|
-
from google.api_core.operation import Operation
|
28
|
-
from google.api_core.retry import Retry
|
29
27
|
from google.cloud.devtools.cloudbuild_v1 import CloudBuildAsyncClient, CloudBuildClient, GetBuildRequest
|
30
|
-
from google.cloud.devtools.cloudbuild_v1.types import Build, BuildTrigger, RepoSource
|
31
28
|
|
32
29
|
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
|
33
30
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
34
31
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
35
32
|
|
33
|
+
if TYPE_CHECKING:
|
34
|
+
from google.api_core.operation import Operation
|
35
|
+
from google.api_core.retry import Retry
|
36
|
+
from google.cloud.devtools.cloudbuild_v1.types import Build, BuildTrigger, RepoSource
|
37
|
+
|
36
38
|
# Time to sleep between active checks of the operation results
|
37
39
|
TIME_TO_SLEEP_IN_SECONDS = 5
|
38
40
|
|
@@ -17,29 +17,33 @@
|
|
17
17
|
# under the License.
|
18
18
|
from __future__ import annotations
|
19
19
|
|
20
|
-
from typing import Sequence
|
20
|
+
from typing import TYPE_CHECKING, Sequence
|
21
21
|
|
22
22
|
from google.api_core.client_options import ClientOptions
|
23
23
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
24
|
-
from google.api_core.operation import Operation
|
25
|
-
from google.api_core.operation_async import AsyncOperation
|
26
|
-
from google.api_core.retry import Retry
|
27
24
|
from google.cloud.orchestration.airflow.service_v1 import (
|
28
25
|
EnvironmentsAsyncClient,
|
29
26
|
EnvironmentsClient,
|
30
27
|
ImageVersionsClient,
|
31
28
|
)
|
32
|
-
from google.cloud.orchestration.airflow.service_v1.services.environments.pagers import ListEnvironmentsPager
|
33
|
-
from google.cloud.orchestration.airflow.service_v1.services.image_versions.pagers import (
|
34
|
-
ListImageVersionsPager,
|
35
|
-
)
|
36
|
-
from google.cloud.orchestration.airflow.service_v1.types import Environment
|
37
|
-
from google.protobuf.field_mask_pb2 import FieldMask
|
38
29
|
|
39
30
|
from airflow import AirflowException
|
40
31
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
41
32
|
from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
|
42
33
|
|
34
|
+
if TYPE_CHECKING:
|
35
|
+
from google.api_core.operation import Operation
|
36
|
+
from google.api_core.operation_async import AsyncOperation
|
37
|
+
from google.api_core.retry import Retry
|
38
|
+
from google.cloud.orchestration.airflow.service_v1.services.environments.pagers import (
|
39
|
+
ListEnvironmentsPager,
|
40
|
+
)
|
41
|
+
from google.cloud.orchestration.airflow.service_v1.services.image_versions.pagers import (
|
42
|
+
ListImageVersionsPager,
|
43
|
+
)
|
44
|
+
from google.cloud.orchestration.airflow.service_v1.types import Environment
|
45
|
+
from google.protobuf.field_mask_pb2 import FieldMask
|
46
|
+
|
43
47
|
|
44
48
|
class CloudComposerHook(GoogleBaseHook):
|
45
49
|
"""Hook for Google Cloud Composer APIs."""
|
@@ -27,12 +27,11 @@ Hooks for Cloud Memorystore service.
|
|
27
27
|
"""
|
28
28
|
from __future__ import annotations
|
29
29
|
|
30
|
-
from typing import Sequence
|
30
|
+
from typing import TYPE_CHECKING, Sequence
|
31
31
|
|
32
32
|
from google.api_core import path_template
|
33
33
|
from google.api_core.exceptions import NotFound
|
34
34
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
35
|
-
from google.api_core.retry import Retry
|
36
35
|
from google.cloud.memcache_v1beta2 import CloudMemcacheClient
|
37
36
|
from google.cloud.memcache_v1beta2.types import cloud_memcache
|
38
37
|
from google.cloud.redis_v1 import (
|
@@ -42,12 +41,15 @@ from google.cloud.redis_v1 import (
|
|
42
41
|
Instance,
|
43
42
|
OutputConfig,
|
44
43
|
)
|
45
|
-
from google.protobuf.field_mask_pb2 import FieldMask
|
46
44
|
|
47
45
|
from airflow import version
|
48
46
|
from airflow.exceptions import AirflowException
|
49
47
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
50
48
|
|
49
|
+
if TYPE_CHECKING:
|
50
|
+
from google.api_core.retry import Retry
|
51
|
+
from google.protobuf.field_mask_pb2 import FieldMask
|
52
|
+
|
51
53
|
|
52
54
|
class CloudMemorystoreHook(GoogleBaseHook):
|
53
55
|
"""
|
@@ -18,9 +18,8 @@
|
|
18
18
|
from __future__ import annotations
|
19
19
|
|
20
20
|
import itertools
|
21
|
-
from typing import Iterable, Sequence
|
21
|
+
from typing import TYPE_CHECKING, Iterable, Sequence
|
22
22
|
|
23
|
-
from google.api_core import operation
|
24
23
|
from google.cloud.run_v2 import (
|
25
24
|
CreateJobRequest,
|
26
25
|
DeleteJobRequest,
|
@@ -32,13 +31,16 @@ from google.cloud.run_v2 import (
|
|
32
31
|
RunJobRequest,
|
33
32
|
UpdateJobRequest,
|
34
33
|
)
|
35
|
-
from google.cloud.run_v2.services.jobs import pagers
|
36
34
|
from google.longrunning import operations_pb2
|
37
35
|
|
38
36
|
from airflow.exceptions import AirflowException
|
39
37
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
40
38
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
41
39
|
|
40
|
+
if TYPE_CHECKING:
|
41
|
+
from google.api_core import operation
|
42
|
+
from google.cloud.run_v2.services.jobs import pagers
|
43
|
+
|
42
44
|
|
43
45
|
class CloudRunHook(GoogleBaseHook):
|
44
46
|
"""
|
@@ -21,7 +21,6 @@ from __future__ import annotations
|
|
21
21
|
import errno
|
22
22
|
import json
|
23
23
|
import os
|
24
|
-
import os.path
|
25
24
|
import platform
|
26
25
|
import random
|
27
26
|
import re
|
@@ -35,7 +34,7 @@ from inspect import signature
|
|
35
34
|
from pathlib import Path
|
36
35
|
from subprocess import PIPE, Popen
|
37
36
|
from tempfile import gettempdir
|
38
|
-
from typing import Any, Sequence
|
37
|
+
from typing import TYPE_CHECKING, Any, Sequence
|
39
38
|
from urllib.parse import quote_plus
|
40
39
|
|
41
40
|
import httpx
|
@@ -43,7 +42,6 @@ from aiohttp import ClientSession
|
|
43
42
|
from gcloud.aio.auth import AioSession, Token
|
44
43
|
from googleapiclient.discovery import Resource, build
|
45
44
|
from googleapiclient.errors import HttpError
|
46
|
-
from requests import Session
|
47
45
|
|
48
46
|
# Number of retries - used by googleapiclient method calls to perform retries
|
49
47
|
# For requests that are "retriable"
|
@@ -55,6 +53,9 @@ from airflow.providers.mysql.hooks.mysql import MySqlHook
|
|
55
53
|
from airflow.providers.postgres.hooks.postgres import PostgresHook
|
56
54
|
from airflow.utils.log.logging_mixin import LoggingMixin
|
57
55
|
|
56
|
+
if TYPE_CHECKING:
|
57
|
+
from requests import Session
|
58
|
+
|
58
59
|
UNIX_PATH_MAX = 108
|
59
60
|
|
60
61
|
# Time to sleep between active checks of the operation results
|
@@ -435,15 +436,12 @@ class CloudSQLAsyncHook(GoogleBaseAsyncHook):
|
|
435
436
|
|
436
437
|
async def get_operation(self, project_id: str, operation_name: str):
|
437
438
|
async with ClientSession() as session:
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
operation = await operation.json(content_type=None)
|
445
|
-
except HttpError as e:
|
446
|
-
raise e
|
439
|
+
operation = await self.get_operation_name(
|
440
|
+
project_id=project_id,
|
441
|
+
operation_name=operation_name,
|
442
|
+
session=session,
|
443
|
+
)
|
444
|
+
operation = await operation.json(content_type=None)
|
447
445
|
return operation
|
448
446
|
|
449
447
|
|
@@ -671,8 +669,7 @@ class CloudSqlProxyRunner(LoggingMixin):
|
|
671
669
|
command_to_run.extend(["--version"])
|
672
670
|
command_to_run.extend(self._get_credential_parameters())
|
673
671
|
result = subprocess.check_output(command_to_run).decode("utf-8")
|
674
|
-
|
675
|
-
matched = pattern.match(result)
|
672
|
+
matched = re.search("[Vv]ersion (.*?);", result)
|
676
673
|
if matched:
|
677
674
|
return matched.group(1)
|
678
675
|
else:
|
@@ -33,7 +33,7 @@ import time
|
|
33
33
|
import warnings
|
34
34
|
from copy import deepcopy
|
35
35
|
from datetime import timedelta
|
36
|
-
from typing import Any, Sequence
|
36
|
+
from typing import TYPE_CHECKING, Any, Sequence
|
37
37
|
|
38
38
|
from google.cloud.storage_transfer_v1 import (
|
39
39
|
ListTransferJobsRequest,
|
@@ -41,16 +41,18 @@ from google.cloud.storage_transfer_v1 import (
|
|
41
41
|
TransferJob,
|
42
42
|
TransferOperation,
|
43
43
|
)
|
44
|
-
from google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers import (
|
45
|
-
ListTransferJobsAsyncPager,
|
46
|
-
)
|
47
44
|
from googleapiclient.discovery import Resource, build
|
48
45
|
from googleapiclient.errors import HttpError
|
49
|
-
from proto import Message
|
50
46
|
|
51
47
|
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
|
52
48
|
from airflow.providers.google.common.hooks.base_google import GoogleBaseAsyncHook, GoogleBaseHook
|
53
49
|
|
50
|
+
if TYPE_CHECKING:
|
51
|
+
from google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers import (
|
52
|
+
ListTransferJobsAsyncPager,
|
53
|
+
)
|
54
|
+
from proto import Message
|
55
|
+
|
54
56
|
log = logging.getLogger(__name__)
|
55
57
|
|
56
58
|
# Time to sleep between active checks of the operation results
|
@@ -517,7 +519,7 @@ class CloudDataTransferServiceAsyncHook(GoogleBaseAsyncHook):
|
|
517
519
|
"""
|
518
520
|
client = self.get_conn()
|
519
521
|
jobs_list_request = ListTransferJobsRequest(
|
520
|
-
filter=json.dumps(
|
522
|
+
filter=json.dumps({"project_id": self.project_id, "job_names": job_names})
|
521
523
|
)
|
522
524
|
return await client.list_transfer_jobs(request=jobs_list_request)
|
523
525
|
|