apache-airflow-providers-google 10.26.0rc1__py3-none-any.whl → 11.0.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/google/__init__.py +1 -1
- airflow/providers/google/ads/hooks/ads.py +2 -1
- airflow/providers/google/ads/operators/ads.py +2 -1
- airflow/providers/google/ads/transfers/ads_to_gcs.py +2 -1
- airflow/providers/google/assets/gcs.py +17 -1
- airflow/providers/google/cloud/hooks/automl.py +3 -6
- airflow/providers/google/cloud/hooks/bigquery.py +41 -1486
- airflow/providers/google/cloud/hooks/bigquery_dts.py +4 -11
- airflow/providers/google/cloud/hooks/bigtable.py +3 -6
- airflow/providers/google/cloud/hooks/cloud_batch.py +6 -3
- airflow/providers/google/cloud/hooks/cloud_build.py +3 -15
- airflow/providers/google/cloud/hooks/cloud_composer.py +2 -17
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +5 -6
- airflow/providers/google/cloud/hooks/cloud_run.py +10 -5
- airflow/providers/google/cloud/hooks/cloud_sql.py +5 -7
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +3 -7
- airflow/providers/google/cloud/hooks/compute.py +3 -6
- airflow/providers/google/cloud/hooks/compute_ssh.py +0 -5
- airflow/providers/google/cloud/hooks/datacatalog.py +3 -6
- airflow/providers/google/cloud/hooks/dataflow.py +3 -14
- airflow/providers/google/cloud/hooks/dataform.py +2 -9
- airflow/providers/google/cloud/hooks/datafusion.py +4 -15
- airflow/providers/google/cloud/hooks/dataplex.py +4 -7
- airflow/providers/google/cloud/hooks/dataprep.py +2 -2
- airflow/providers/google/cloud/hooks/dataproc.py +77 -22
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +2 -9
- airflow/providers/google/cloud/hooks/datastore.py +3 -6
- airflow/providers/google/cloud/hooks/dlp.py +3 -6
- airflow/providers/google/cloud/hooks/functions.py +2 -6
- airflow/providers/google/cloud/hooks/gcs.py +2 -18
- airflow/providers/google/cloud/hooks/gdm.py +1 -17
- airflow/providers/google/cloud/hooks/kms.py +3 -6
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +7 -97
- airflow/providers/google/cloud/hooks/life_sciences.py +2 -6
- airflow/providers/google/cloud/hooks/looker.py +2 -1
- airflow/providers/google/cloud/hooks/mlengine.py +0 -8
- airflow/providers/google/cloud/hooks/natural_language.py +3 -6
- airflow/providers/google/cloud/hooks/os_login.py +3 -6
- airflow/providers/google/cloud/hooks/pubsub.py +3 -6
- airflow/providers/google/cloud/hooks/secret_manager.py +3 -73
- airflow/providers/google/cloud/hooks/spanner.py +3 -6
- airflow/providers/google/cloud/hooks/speech_to_text.py +3 -6
- airflow/providers/google/cloud/hooks/stackdriver.py +3 -6
- airflow/providers/google/cloud/hooks/tasks.py +3 -6
- airflow/providers/google/cloud/hooks/text_to_speech.py +3 -6
- airflow/providers/google/cloud/hooks/translate.py +455 -9
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +1 -14
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +3 -1
- airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +2 -1
- airflow/providers/google/cloud/hooks/video_intelligence.py +3 -6
- airflow/providers/google/cloud/hooks/vision.py +3 -6
- airflow/providers/google/cloud/hooks/workflows.py +2 -9
- airflow/providers/google/cloud/links/dataproc.py +0 -1
- airflow/providers/google/cloud/links/translate.py +91 -0
- airflow/providers/google/cloud/log/gcs_task_handler.py +2 -1
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +11 -3
- airflow/providers/google/cloud/openlineage/utils.py +54 -21
- airflow/providers/google/cloud/operators/automl.py +5 -4
- airflow/providers/google/cloud/operators/bigquery.py +2 -341
- airflow/providers/google/cloud/operators/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/operators/bigtable.py +2 -1
- airflow/providers/google/cloud/operators/cloud_batch.py +2 -1
- airflow/providers/google/cloud/operators/cloud_build.py +2 -1
- airflow/providers/google/cloud/operators/cloud_composer.py +2 -1
- airflow/providers/google/cloud/operators/cloud_memorystore.py +2 -1
- airflow/providers/google/cloud/operators/cloud_run.py +2 -1
- airflow/providers/google/cloud/operators/cloud_sql.py +2 -1
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/operators/compute.py +2 -1
- airflow/providers/google/cloud/operators/datacatalog.py +2 -1
- airflow/providers/google/cloud/operators/dataflow.py +2 -517
- airflow/providers/google/cloud/operators/dataform.py +2 -1
- airflow/providers/google/cloud/operators/datafusion.py +2 -1
- airflow/providers/google/cloud/operators/dataplex.py +37 -31
- airflow/providers/google/cloud/operators/dataprep.py +2 -1
- airflow/providers/google/cloud/operators/dataproc.py +3 -633
- airflow/providers/google/cloud/operators/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/operators/datastore.py +2 -1
- airflow/providers/google/cloud/operators/dlp.py +2 -1
- airflow/providers/google/cloud/operators/functions.py +2 -1
- airflow/providers/google/cloud/operators/gcs.py +5 -4
- airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -11
- airflow/providers/google/cloud/operators/life_sciences.py +2 -1
- airflow/providers/google/cloud/operators/mlengine.py +2 -1
- airflow/providers/google/cloud/operators/natural_language.py +3 -2
- airflow/providers/google/cloud/operators/pubsub.py +2 -1
- airflow/providers/google/cloud/operators/spanner.py +2 -1
- airflow/providers/google/cloud/operators/speech_to_text.py +2 -1
- airflow/providers/google/cloud/operators/stackdriver.py +2 -1
- airflow/providers/google/cloud/operators/tasks.py +3 -2
- airflow/providers/google/cloud/operators/text_to_speech.py +2 -1
- airflow/providers/google/cloud/operators/translate.py +622 -32
- airflow/providers/google/cloud/operators/translate_speech.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +2 -93
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +2 -17
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +2 -1
- airflow/providers/google/cloud/operators/video_intelligence.py +2 -1
- airflow/providers/google/cloud/operators/vision.py +3 -2
- airflow/providers/google/cloud/operators/workflows.py +3 -2
- airflow/providers/google/cloud/secrets/secret_manager.py +2 -19
- airflow/providers/google/cloud/sensors/bigquery.py +2 -81
- airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/sensors/bigtable.py +2 -1
- airflow/providers/google/cloud/sensors/cloud_composer.py +8 -94
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/sensors/dataflow.py +2 -1
- airflow/providers/google/cloud/sensors/dataform.py +2 -1
- airflow/providers/google/cloud/sensors/datafusion.py +2 -1
- airflow/providers/google/cloud/sensors/dataplex.py +2 -1
- airflow/providers/google/cloud/sensors/dataprep.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/sensors/gcs.py +4 -36
- airflow/providers/google/cloud/sensors/pubsub.py +2 -1
- airflow/providers/google/cloud/sensors/tasks.py +2 -1
- airflow/providers/google/cloud/sensors/workflows.py +2 -1
- airflow/providers/google/cloud/transfers/adls_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +75 -18
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +9 -7
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -1
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +2 -1
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +13 -9
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/local_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/s3_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sheets_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_batch.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_build.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_composer.py +3 -2
- airflow/providers/google/cloud/triggers/cloud_run.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_sql.py +1 -1
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/triggers/dataflow.py +2 -1
- airflow/providers/google/cloud/triggers/datafusion.py +2 -1
- airflow/providers/google/cloud/triggers/dataplex.py +1 -1
- airflow/providers/google/cloud/triggers/dataproc.py +2 -1
- airflow/providers/google/cloud/triggers/gcs.py +3 -2
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -1
- airflow/providers/google/cloud/triggers/mlengine.py +2 -1
- airflow/providers/google/cloud/triggers/pubsub.py +2 -1
- airflow/providers/google/cloud/triggers/vertex_ai.py +2 -1
- airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
- airflow/providers/google/cloud/utils/dataform.py +1 -1
- airflow/providers/google/cloud/utils/field_validator.py +2 -1
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +2 -1
- airflow/providers/google/common/hooks/base_google.py +4 -11
- airflow/providers/google/common/hooks/discovery_api.py +1 -6
- airflow/providers/google/firebase/hooks/firestore.py +1 -1
- airflow/providers/google/firebase/operators/firestore.py +2 -1
- airflow/providers/google/get_provider_info.py +7 -22
- airflow/providers/google/marketing_platform/hooks/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/hooks/campaign_manager.py +2 -3
- airflow/providers/google/marketing_platform/hooks/display_video.py +4 -3
- airflow/providers/google/marketing_platform/hooks/search_ads.py +6 -6
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +2 -42
- airflow/providers/google/marketing_platform/operators/display_video.py +2 -47
- airflow/providers/google/marketing_platform/operators/search_ads.py +2 -1
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +2 -7
- airflow/providers/google/marketing_platform/sensors/display_video.py +2 -13
- airflow/providers/google/suite/hooks/calendar.py +2 -8
- airflow/providers/google/suite/hooks/drive.py +2 -6
- airflow/providers/google/suite/hooks/sheets.py +2 -7
- airflow/providers/google/suite/operators/sheets.py +2 -7
- airflow/providers/google/suite/sensors/drive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +2 -7
- airflow/providers/google/suite/transfers/local_to_drive.py +2 -7
- airflow/providers/google/suite/transfers/sql_to_sheets.py +2 -7
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0rc1.dist-info}/METADATA +10 -10
- apache_airflow_providers_google-11.0.0rc1.dist-info/RECORD +315 -0
- airflow/providers/google/marketing_platform/hooks/analytics.py +0 -211
- airflow/providers/google/marketing_platform/operators/analytics.py +0 -551
- apache_airflow_providers_google-10.26.0rc1.dist-info/RECORD +0 -317
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0rc1.dist-info}/entry_points.txt +0 -0
@@ -1,551 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
"""This module contains Google Analytics 360 operators."""
|
19
|
-
|
20
|
-
from __future__ import annotations
|
21
|
-
|
22
|
-
import csv
|
23
|
-
from tempfile import NamedTemporaryFile
|
24
|
-
from typing import TYPE_CHECKING, Any, Sequence
|
25
|
-
|
26
|
-
from airflow.exceptions import AirflowProviderDeprecationWarning
|
27
|
-
from airflow.models import BaseOperator
|
28
|
-
from airflow.providers.google.cloud.hooks.gcs import GCSHook
|
29
|
-
from airflow.providers.google.common.deprecated import deprecated
|
30
|
-
from airflow.providers.google.marketing_platform.hooks.analytics import GoogleAnalyticsHook
|
31
|
-
|
32
|
-
if TYPE_CHECKING:
|
33
|
-
from airflow.utils.context import Context
|
34
|
-
|
35
|
-
|
36
|
-
@deprecated(
|
37
|
-
planned_removal_date="November 01, 2024",
|
38
|
-
use_instead="GoogleAnalyticsAdminListAccountsOperator",
|
39
|
-
reason="The Google Analytics API v3 has sunset and is no longer available as of July 1, 2024.",
|
40
|
-
category=AirflowProviderDeprecationWarning,
|
41
|
-
)
|
42
|
-
class GoogleAnalyticsListAccountsOperator(BaseOperator):
|
43
|
-
"""
|
44
|
-
Lists all accounts to which the user has access.
|
45
|
-
|
46
|
-
.. seealso::
|
47
|
-
This operator is deprecated, please use
|
48
|
-
:class:`~airflow.providers.google.marketing_platform.operators.analytics_admin.GoogleAnalyticsAdminListAccountsOperator`:
|
49
|
-
|
50
|
-
.. seealso::
|
51
|
-
Check official API docs:
|
52
|
-
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accounts/list
|
53
|
-
and for python client
|
54
|
-
http://googleapis.github.io/google-api-python-client/docs/dyn/analytics_v3.management.accounts.html#list
|
55
|
-
|
56
|
-
:param api_version: The version of the api that will be requested for example 'v3'.
|
57
|
-
:param gcp_conn_id: The connection ID to use when fetching connection info.
|
58
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
59
|
-
credentials, or chained list of accounts required to get the access_token
|
60
|
-
of the last account in the list, which will be impersonated in the request.
|
61
|
-
If set as a string, the account must grant the originating account
|
62
|
-
the Service Account Token Creator IAM role.
|
63
|
-
If set as a sequence, the identities from the list must grant
|
64
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
65
|
-
account from the list granting this role to the originating account (templated).
|
66
|
-
"""
|
67
|
-
|
68
|
-
template_fields: Sequence[str] = (
|
69
|
-
"api_version",
|
70
|
-
"gcp_conn_id",
|
71
|
-
"impersonation_chain",
|
72
|
-
)
|
73
|
-
|
74
|
-
def __init__(
|
75
|
-
self,
|
76
|
-
*,
|
77
|
-
api_version: str = "v3",
|
78
|
-
gcp_conn_id: str = "google_cloud_default",
|
79
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
80
|
-
**kwargs,
|
81
|
-
) -> None:
|
82
|
-
super().__init__(**kwargs)
|
83
|
-
|
84
|
-
self.api_version = api_version
|
85
|
-
self.gcp_conn_id = gcp_conn_id
|
86
|
-
self.impersonation_chain = impersonation_chain
|
87
|
-
|
88
|
-
def execute(self, context: Context) -> list[dict[str, Any]]:
|
89
|
-
hook = GoogleAnalyticsHook(
|
90
|
-
api_version=self.api_version,
|
91
|
-
gcp_conn_id=self.gcp_conn_id,
|
92
|
-
impersonation_chain=self.impersonation_chain,
|
93
|
-
)
|
94
|
-
result = hook.list_accounts()
|
95
|
-
return result
|
96
|
-
|
97
|
-
|
98
|
-
@deprecated(
|
99
|
-
planned_removal_date="November 01, 2024",
|
100
|
-
use_instead="GoogleAnalyticsAdminGetGoogleAdsLinkOperator",
|
101
|
-
reason="The Google Analytics API v3 has sunset and is no longer available as of July 1, 2024.",
|
102
|
-
category=AirflowProviderDeprecationWarning,
|
103
|
-
)
|
104
|
-
class GoogleAnalyticsGetAdsLinkOperator(BaseOperator):
|
105
|
-
"""
|
106
|
-
Returns a web property-Google Ads link to which the user has access.
|
107
|
-
|
108
|
-
.. seealso::
|
109
|
-
This operator is deprecated, please use
|
110
|
-
:class:`~airflow.providers.google.marketing_platform.operators.analytics_admin.GoogleAnalyticsAdminGetGoogleAdsLinkOperator`:
|
111
|
-
|
112
|
-
.. seealso::
|
113
|
-
Check official API docs:
|
114
|
-
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/webPropertyAdWordsLinks/get
|
115
|
-
|
116
|
-
|
117
|
-
:param account_id: ID of the account which the given web property belongs to.
|
118
|
-
:param web_property_ad_words_link_id: Web property-Google Ads link ID.
|
119
|
-
:param web_property_id: Web property ID to retrieve the Google Ads link for.
|
120
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
121
|
-
credentials, or chained list of accounts required to get the access_token
|
122
|
-
of the last account in the list, which will be impersonated in the request.
|
123
|
-
If set as a string, the account must grant the originating account
|
124
|
-
the Service Account Token Creator IAM role.
|
125
|
-
If set as a sequence, the identities from the list must grant
|
126
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
127
|
-
account from the list granting this role to the originating account (templated).
|
128
|
-
"""
|
129
|
-
|
130
|
-
template_fields: Sequence[str] = (
|
131
|
-
"api_version",
|
132
|
-
"gcp_conn_id",
|
133
|
-
"account_id",
|
134
|
-
"web_property_ad_words_link_id",
|
135
|
-
"web_property_id",
|
136
|
-
"impersonation_chain",
|
137
|
-
)
|
138
|
-
|
139
|
-
def __init__(
|
140
|
-
self,
|
141
|
-
*,
|
142
|
-
account_id: str,
|
143
|
-
web_property_ad_words_link_id: str,
|
144
|
-
web_property_id: str,
|
145
|
-
api_version: str = "v3",
|
146
|
-
gcp_conn_id: str = "google_cloud_default",
|
147
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
148
|
-
**kwargs,
|
149
|
-
):
|
150
|
-
super().__init__(**kwargs)
|
151
|
-
|
152
|
-
self.account_id = account_id
|
153
|
-
self.web_property_ad_words_link_id = web_property_ad_words_link_id
|
154
|
-
self.web_property_id = web_property_id
|
155
|
-
self.api_version = api_version
|
156
|
-
self.gcp_conn_id = gcp_conn_id
|
157
|
-
self.impersonation_chain = impersonation_chain
|
158
|
-
|
159
|
-
def execute(self, context: Context) -> dict[str, Any]:
|
160
|
-
hook = GoogleAnalyticsHook(
|
161
|
-
api_version=self.api_version,
|
162
|
-
gcp_conn_id=self.gcp_conn_id,
|
163
|
-
impersonation_chain=self.impersonation_chain,
|
164
|
-
)
|
165
|
-
result = hook.get_ad_words_link(
|
166
|
-
account_id=self.account_id,
|
167
|
-
web_property_id=self.web_property_id,
|
168
|
-
web_property_ad_words_link_id=self.web_property_ad_words_link_id,
|
169
|
-
)
|
170
|
-
return result
|
171
|
-
|
172
|
-
|
173
|
-
@deprecated(
|
174
|
-
planned_removal_date="November 01, 2024",
|
175
|
-
use_instead="GoogleAnalyticsAdminListGoogleAdsLinksOperator",
|
176
|
-
reason="The Google Analytics API v3 has sunset and is no longer available as of July 1, 2024.",
|
177
|
-
category=AirflowProviderDeprecationWarning,
|
178
|
-
)
|
179
|
-
class GoogleAnalyticsRetrieveAdsLinksListOperator(BaseOperator):
|
180
|
-
"""
|
181
|
-
Lists webProperty-Google Ads links for a given web property.
|
182
|
-
|
183
|
-
.. seealso::
|
184
|
-
This operator is deprecated, please use
|
185
|
-
:class:`~airflow.providers.google.marketing_platform.operators.analytics_admin.GoogleAnalyticsAdminListGoogleAdsLinksOperator`:
|
186
|
-
|
187
|
-
.. seealso::
|
188
|
-
Check official API docs:
|
189
|
-
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/webPropertyAdWordsLinks/list#http-request
|
190
|
-
|
191
|
-
:param account_id: ID of the account which the given web property belongs to.
|
192
|
-
:param web_property_id: Web property UA-string to retrieve the Google Ads links for.
|
193
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
194
|
-
credentials, or chained list of accounts required to get the access_token
|
195
|
-
of the last account in the list, which will be impersonated in the request.
|
196
|
-
If set as a string, the account must grant the originating account
|
197
|
-
the Service Account Token Creator IAM role.
|
198
|
-
If set as a sequence, the identities from the list must grant
|
199
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
200
|
-
account from the list granting this role to the originating account (templated).
|
201
|
-
"""
|
202
|
-
|
203
|
-
template_fields: Sequence[str] = (
|
204
|
-
"api_version",
|
205
|
-
"gcp_conn_id",
|
206
|
-
"account_id",
|
207
|
-
"web_property_id",
|
208
|
-
"impersonation_chain",
|
209
|
-
)
|
210
|
-
|
211
|
-
def __init__(
|
212
|
-
self,
|
213
|
-
*,
|
214
|
-
account_id: str,
|
215
|
-
web_property_id: str,
|
216
|
-
api_version: str = "v3",
|
217
|
-
gcp_conn_id: str = "google_cloud_default",
|
218
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
219
|
-
**kwargs,
|
220
|
-
) -> None:
|
221
|
-
super().__init__(**kwargs)
|
222
|
-
|
223
|
-
self.account_id = account_id
|
224
|
-
self.web_property_id = web_property_id
|
225
|
-
self.api_version = api_version
|
226
|
-
self.gcp_conn_id = gcp_conn_id
|
227
|
-
self.impersonation_chain = impersonation_chain
|
228
|
-
|
229
|
-
def execute(self, context: Context) -> list[dict[str, Any]]:
|
230
|
-
hook = GoogleAnalyticsHook(
|
231
|
-
api_version=self.api_version,
|
232
|
-
gcp_conn_id=self.gcp_conn_id,
|
233
|
-
impersonation_chain=self.impersonation_chain,
|
234
|
-
)
|
235
|
-
result = hook.list_ad_words_links(
|
236
|
-
account_id=self.account_id,
|
237
|
-
web_property_id=self.web_property_id,
|
238
|
-
)
|
239
|
-
return result
|
240
|
-
|
241
|
-
|
242
|
-
@deprecated(
|
243
|
-
planned_removal_date="November 01, 2024",
|
244
|
-
use_instead="GoogleAnalyticsAdminCreateDataStreamOperator",
|
245
|
-
reason="The Google Analytics API v3 has sunset and is no longer available as of July 1, 2024.",
|
246
|
-
category=AirflowProviderDeprecationWarning,
|
247
|
-
)
|
248
|
-
class GoogleAnalyticsDataImportUploadOperator(BaseOperator):
|
249
|
-
"""
|
250
|
-
Take a file from Cloud Storage and uploads it to GA via data import API.
|
251
|
-
|
252
|
-
.. seealso::
|
253
|
-
This operator is deprecated, please use
|
254
|
-
:class:`~airflow.providers.google.marketing_platform.operators.analytics_admin.GoogleAnalyticsAdminCreateDataStreamOperator`:
|
255
|
-
|
256
|
-
:param storage_bucket: The Google cloud storage bucket where the file is stored.
|
257
|
-
:param storage_name_object: The name of the object in the desired Google cloud
|
258
|
-
storage bucket. (templated) If the destination points to an existing
|
259
|
-
folder, the file will be taken from the specified folder.
|
260
|
-
:param account_id: The GA account Id (long) to which the data upload belongs.
|
261
|
-
:param web_property_id: The web property UA-string associated with the upload.
|
262
|
-
:param custom_data_source_id: The id to which the data import belongs
|
263
|
-
:param resumable_upload: flag to upload the file in a resumable fashion, using a
|
264
|
-
series of at least two requests.
|
265
|
-
:param gcp_conn_id: The connection ID to use when fetching connection info.
|
266
|
-
:param delegate_to: The account to impersonate using domain-wide delegation of authority,
|
267
|
-
if any. For this to work, the service account making the request must have
|
268
|
-
domain-wide delegation enabled.
|
269
|
-
:param api_version: The version of the api that will be requested for example 'v3'.
|
270
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
271
|
-
credentials, or chained list of accounts required to get the access_token
|
272
|
-
of the last account in the list, which will be impersonated in the request.
|
273
|
-
If set as a string, the account must grant the originating account
|
274
|
-
the Service Account Token Creator IAM role.
|
275
|
-
If set as a sequence, the identities from the list must grant
|
276
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
277
|
-
account from the list granting this role to the originating account (templated).
|
278
|
-
"""
|
279
|
-
|
280
|
-
template_fields: Sequence[str] = (
|
281
|
-
"storage_bucket",
|
282
|
-
"storage_name_object",
|
283
|
-
"impersonation_chain",
|
284
|
-
)
|
285
|
-
|
286
|
-
def __init__(
|
287
|
-
self,
|
288
|
-
*,
|
289
|
-
storage_bucket: str,
|
290
|
-
storage_name_object: str,
|
291
|
-
account_id: str,
|
292
|
-
web_property_id: str,
|
293
|
-
custom_data_source_id: str,
|
294
|
-
resumable_upload: bool = False,
|
295
|
-
gcp_conn_id: str = "google_cloud_default",
|
296
|
-
delegate_to: str | None = None,
|
297
|
-
api_version: str = "v3",
|
298
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
299
|
-
**kwargs,
|
300
|
-
) -> None:
|
301
|
-
super().__init__(**kwargs)
|
302
|
-
self.storage_bucket = storage_bucket
|
303
|
-
self.storage_name_object = storage_name_object
|
304
|
-
self.account_id = account_id
|
305
|
-
self.web_property_id = web_property_id
|
306
|
-
self.custom_data_source_id = custom_data_source_id
|
307
|
-
self.resumable_upload = resumable_upload
|
308
|
-
self.gcp_conn_id = gcp_conn_id
|
309
|
-
self.delegate_to = delegate_to
|
310
|
-
self.api_version = api_version
|
311
|
-
self.impersonation_chain = impersonation_chain
|
312
|
-
|
313
|
-
def execute(self, context: Context) -> None:
|
314
|
-
gcs_hook = GCSHook(
|
315
|
-
gcp_conn_id=self.gcp_conn_id,
|
316
|
-
delegate_to=self.delegate_to,
|
317
|
-
impersonation_chain=self.impersonation_chain,
|
318
|
-
)
|
319
|
-
|
320
|
-
ga_hook = GoogleAnalyticsHook(
|
321
|
-
gcp_conn_id=self.gcp_conn_id,
|
322
|
-
delegate_to=self.delegate_to,
|
323
|
-
api_version=self.api_version,
|
324
|
-
impersonation_chain=self.impersonation_chain,
|
325
|
-
)
|
326
|
-
|
327
|
-
with NamedTemporaryFile("w+") as tmp_file:
|
328
|
-
self.log.info(
|
329
|
-
"Downloading file from GCS: %s/%s ",
|
330
|
-
self.storage_bucket,
|
331
|
-
self.storage_name_object,
|
332
|
-
)
|
333
|
-
gcs_hook.download(
|
334
|
-
bucket_name=self.storage_bucket,
|
335
|
-
object_name=self.storage_name_object,
|
336
|
-
filename=tmp_file.name,
|
337
|
-
)
|
338
|
-
|
339
|
-
ga_hook.upload_data(
|
340
|
-
tmp_file.name,
|
341
|
-
self.account_id,
|
342
|
-
self.web_property_id,
|
343
|
-
self.custom_data_source_id,
|
344
|
-
self.resumable_upload,
|
345
|
-
)
|
346
|
-
|
347
|
-
|
348
|
-
@deprecated(
|
349
|
-
planned_removal_date="November 01, 2024",
|
350
|
-
use_instead="GoogleAnalyticsAdminDeleteDataStreamOperator",
|
351
|
-
reason="The Google Analytics API v3 has sunset and is no longer available as of July 1, 2024.",
|
352
|
-
category=AirflowProviderDeprecationWarning,
|
353
|
-
)
|
354
|
-
class GoogleAnalyticsDeletePreviousDataUploadsOperator(BaseOperator):
|
355
|
-
"""
|
356
|
-
Deletes previous GA uploads to leave the latest file to control the size of the Data Set Quota.
|
357
|
-
|
358
|
-
.. seealso::
|
359
|
-
This operator is deprecated, please use
|
360
|
-
:class:`~airflow.providers.google.marketing_platform.operators.analytics_admin.GoogleAnalyticsAdminDeleteDataStreamOperator`:
|
361
|
-
|
362
|
-
:param account_id: The GA account Id (long) to which the data upload belongs.
|
363
|
-
:param web_property_id: The web property UA-string associated with the upload.
|
364
|
-
:param custom_data_source_id: The id to which the data import belongs.
|
365
|
-
:param gcp_conn_id: The connection ID to use when fetching connection info.
|
366
|
-
:param delegate_to: The account to impersonate using domain-wide delegation of authority,
|
367
|
-
if any. For this to work, the service account making the request must have
|
368
|
-
domain-wide delegation enabled.
|
369
|
-
:param api_version: The version of the api that will be requested for example 'v3'.
|
370
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
371
|
-
credentials, or chained list of accounts required to get the access_token
|
372
|
-
of the last account in the list, which will be impersonated in the request.
|
373
|
-
If set as a string, the account must grant the originating account
|
374
|
-
the Service Account Token Creator IAM role.
|
375
|
-
If set as a sequence, the identities from the list must grant
|
376
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
377
|
-
account from the list granting this role to the originating account (templated).
|
378
|
-
"""
|
379
|
-
|
380
|
-
template_fields: Sequence[str] = ("impersonation_chain",)
|
381
|
-
|
382
|
-
def __init__(
|
383
|
-
self,
|
384
|
-
account_id: str,
|
385
|
-
web_property_id: str,
|
386
|
-
custom_data_source_id: str,
|
387
|
-
gcp_conn_id: str = "google_cloud_default",
|
388
|
-
delegate_to: str | None = None,
|
389
|
-
api_version: str = "v3",
|
390
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
391
|
-
**kwargs,
|
392
|
-
) -> None:
|
393
|
-
super().__init__(**kwargs)
|
394
|
-
|
395
|
-
self.account_id = account_id
|
396
|
-
self.web_property_id = web_property_id
|
397
|
-
self.custom_data_source_id = custom_data_source_id
|
398
|
-
self.gcp_conn_id = gcp_conn_id
|
399
|
-
self.delegate_to = delegate_to
|
400
|
-
self.api_version = api_version
|
401
|
-
self.impersonation_chain = impersonation_chain
|
402
|
-
|
403
|
-
def execute(self, context: Context) -> None:
|
404
|
-
ga_hook = GoogleAnalyticsHook(
|
405
|
-
gcp_conn_id=self.gcp_conn_id,
|
406
|
-
delegate_to=self.delegate_to,
|
407
|
-
api_version=self.api_version,
|
408
|
-
impersonation_chain=self.impersonation_chain,
|
409
|
-
)
|
410
|
-
|
411
|
-
uploads = ga_hook.list_uploads(
|
412
|
-
account_id=self.account_id,
|
413
|
-
web_property_id=self.web_property_id,
|
414
|
-
custom_data_source_id=self.custom_data_source_id,
|
415
|
-
)
|
416
|
-
|
417
|
-
cids = [upload["id"] for upload in uploads]
|
418
|
-
delete_request_body = {"customDataImportUids": cids}
|
419
|
-
|
420
|
-
ga_hook.delete_upload_data(
|
421
|
-
self.account_id,
|
422
|
-
self.web_property_id,
|
423
|
-
self.custom_data_source_id,
|
424
|
-
delete_request_body,
|
425
|
-
)
|
426
|
-
|
427
|
-
|
428
|
-
class GoogleAnalyticsModifyFileHeadersDataImportOperator(BaseOperator):
|
429
|
-
"""
|
430
|
-
GA has a very particular naming convention for Data Import.
|
431
|
-
|
432
|
-
Ability to prefix "ga:" to all column headers and also a dict to rename columns to
|
433
|
-
match the custom dimension ID in GA i.e clientId : dimensionX.
|
434
|
-
|
435
|
-
:param storage_bucket: The Google cloud storage bucket where the file is stored.
|
436
|
-
:param storage_name_object: The name of the object in the desired Google cloud
|
437
|
-
storage bucket. (templated) If the destination points to an existing
|
438
|
-
folder, the file will be taken from the specified folder.
|
439
|
-
:param gcp_conn_id: The connection ID to use when fetching connection info.
|
440
|
-
:param custom_dimension_header_mapping: Dictionary to handle when uploading
|
441
|
-
custom dimensions which have generic IDs ie. 'dimensionX' which are
|
442
|
-
set by GA. Dictionary maps the current CSV header to GA ID which will
|
443
|
-
be the new header for the CSV to upload to GA eg clientId : dimension1.
|
444
|
-
:param delegate_to: The account to impersonate using domain-wide delegation of authority,
|
445
|
-
if any. For this to work, the service account making the request must have
|
446
|
-
domain-wide delegation enabled.
|
447
|
-
:param impersonation_chain: Optional service account to impersonate using short-term
|
448
|
-
credentials, or chained list of accounts required to get the access_token
|
449
|
-
of the last account in the list, which will be impersonated in the request.
|
450
|
-
If set as a string, the account must grant the originating account
|
451
|
-
the Service Account Token Creator IAM role.
|
452
|
-
If set as a sequence, the identities from the list must grant
|
453
|
-
Service Account Token Creator IAM role to the directly preceding identity, with first
|
454
|
-
account from the list granting this role to the originating account (templated).
|
455
|
-
"""
|
456
|
-
|
457
|
-
template_fields: Sequence[str] = (
|
458
|
-
"storage_bucket",
|
459
|
-
"storage_name_object",
|
460
|
-
"impersonation_chain",
|
461
|
-
)
|
462
|
-
|
463
|
-
def __init__(
|
464
|
-
self,
|
465
|
-
storage_bucket: str,
|
466
|
-
storage_name_object: str,
|
467
|
-
gcp_conn_id: str = "google_cloud_default",
|
468
|
-
delegate_to: str | None = None,
|
469
|
-
custom_dimension_header_mapping: dict[str, str] | None = None,
|
470
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
471
|
-
**kwargs,
|
472
|
-
) -> None:
|
473
|
-
super().__init__(**kwargs)
|
474
|
-
self.storage_bucket = storage_bucket
|
475
|
-
self.storage_name_object = storage_name_object
|
476
|
-
self.gcp_conn_id = gcp_conn_id
|
477
|
-
self.delegate_to = delegate_to
|
478
|
-
self.custom_dimension_header_mapping = custom_dimension_header_mapping or {}
|
479
|
-
self.impersonation_chain = impersonation_chain
|
480
|
-
|
481
|
-
def _modify_column_headers(
|
482
|
-
self, tmp_file_location: str, custom_dimension_header_mapping: dict[str, str]
|
483
|
-
) -> None:
|
484
|
-
# Check headers
|
485
|
-
self.log.info("Checking if file contains headers")
|
486
|
-
with open(tmp_file_location) as check_header_file:
|
487
|
-
has_header = csv.Sniffer().has_header(check_header_file.read(1024))
|
488
|
-
if not has_header:
|
489
|
-
raise NameError(
|
490
|
-
"CSV does not contain headers, please add them "
|
491
|
-
"to use the modify column headers functionality"
|
492
|
-
)
|
493
|
-
|
494
|
-
# Transform
|
495
|
-
self.log.info("Modifying column headers to be compatible for data upload")
|
496
|
-
with open(tmp_file_location) as read_file:
|
497
|
-
reader = csv.reader(read_file)
|
498
|
-
headers = next(reader)
|
499
|
-
new_headers = []
|
500
|
-
for header in headers:
|
501
|
-
if header in custom_dimension_header_mapping:
|
502
|
-
header = custom_dimension_header_mapping.get(header) # type: ignore
|
503
|
-
new_header = f"ga:{header}"
|
504
|
-
new_headers.append(new_header)
|
505
|
-
all_data = read_file.readlines()
|
506
|
-
final_headers = ",".join(new_headers) + "\n"
|
507
|
-
all_data.insert(0, final_headers)
|
508
|
-
|
509
|
-
# Save result
|
510
|
-
self.log.info("Saving transformed file")
|
511
|
-
with open(tmp_file_location, "w") as write_file:
|
512
|
-
write_file.writelines(all_data)
|
513
|
-
|
514
|
-
def execute(self, context: Context) -> None:
|
515
|
-
gcs_hook = GCSHook(
|
516
|
-
gcp_conn_id=self.gcp_conn_id,
|
517
|
-
delegate_to=self.delegate_to,
|
518
|
-
impersonation_chain=self.impersonation_chain,
|
519
|
-
)
|
520
|
-
with NamedTemporaryFile("w+") as tmp_file:
|
521
|
-
# Download file from GCS
|
522
|
-
self.log.info(
|
523
|
-
"Downloading file from GCS: %s/%s ",
|
524
|
-
self.storage_bucket,
|
525
|
-
self.storage_name_object,
|
526
|
-
)
|
527
|
-
|
528
|
-
gcs_hook.download(
|
529
|
-
bucket_name=self.storage_bucket,
|
530
|
-
object_name=self.storage_name_object,
|
531
|
-
filename=tmp_file.name,
|
532
|
-
)
|
533
|
-
|
534
|
-
# Modify file
|
535
|
-
self.log.info("Modifying temporary file %s", tmp_file.name)
|
536
|
-
self._modify_column_headers(
|
537
|
-
tmp_file_location=tmp_file.name,
|
538
|
-
custom_dimension_header_mapping=self.custom_dimension_header_mapping,
|
539
|
-
)
|
540
|
-
|
541
|
-
# Upload newly formatted file to cloud storage
|
542
|
-
self.log.info(
|
543
|
-
"Uploading file to GCS: %s/%s ",
|
544
|
-
self.storage_bucket,
|
545
|
-
self.storage_name_object,
|
546
|
-
)
|
547
|
-
gcs_hook.upload(
|
548
|
-
bucket_name=self.storage_bucket,
|
549
|
-
object_name=self.storage_name_object,
|
550
|
-
filename=tmp_file.name,
|
551
|
-
)
|