apache-airflow-providers-google 10.17.0rc1__py3-none-any.whl → 10.18.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 (91) hide show
  1. airflow/providers/google/__init__.py +5 -8
  2. airflow/providers/google/cloud/hooks/automl.py +35 -1
  3. airflow/providers/google/cloud/hooks/bigquery.py +126 -41
  4. airflow/providers/google/cloud/hooks/cloud_composer.py +250 -2
  5. airflow/providers/google/cloud/hooks/cloud_sql.py +154 -7
  6. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +7 -2
  7. airflow/providers/google/cloud/hooks/compute_ssh.py +2 -1
  8. airflow/providers/google/cloud/hooks/dataflow.py +246 -32
  9. airflow/providers/google/cloud/hooks/dataplex.py +6 -2
  10. airflow/providers/google/cloud/hooks/dlp.py +14 -14
  11. airflow/providers/google/cloud/hooks/gcs.py +6 -2
  12. airflow/providers/google/cloud/hooks/gdm.py +2 -2
  13. airflow/providers/google/cloud/hooks/kubernetes_engine.py +2 -2
  14. airflow/providers/google/cloud/hooks/mlengine.py +8 -4
  15. airflow/providers/google/cloud/hooks/pubsub.py +1 -1
  16. airflow/providers/google/cloud/hooks/secret_manager.py +252 -4
  17. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +1431 -74
  18. airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +91 -0
  19. airflow/providers/google/cloud/links/vertex_ai.py +2 -1
  20. airflow/providers/google/cloud/log/gcs_task_handler.py +2 -1
  21. airflow/providers/google/cloud/operators/automl.py +243 -37
  22. airflow/providers/google/cloud/operators/bigquery.py +164 -62
  23. airflow/providers/google/cloud/operators/bigquery_dts.py +4 -3
  24. airflow/providers/google/cloud/operators/bigtable.py +7 -6
  25. airflow/providers/google/cloud/operators/cloud_build.py +12 -11
  26. airflow/providers/google/cloud/operators/cloud_composer.py +147 -2
  27. airflow/providers/google/cloud/operators/cloud_memorystore.py +17 -16
  28. airflow/providers/google/cloud/operators/cloud_sql.py +60 -17
  29. airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +35 -16
  30. airflow/providers/google/cloud/operators/compute.py +12 -11
  31. airflow/providers/google/cloud/operators/datacatalog.py +21 -20
  32. airflow/providers/google/cloud/operators/dataflow.py +59 -42
  33. airflow/providers/google/cloud/operators/datafusion.py +11 -10
  34. airflow/providers/google/cloud/operators/datapipeline.py +3 -2
  35. airflow/providers/google/cloud/operators/dataprep.py +5 -4
  36. airflow/providers/google/cloud/operators/dataproc.py +20 -17
  37. airflow/providers/google/cloud/operators/datastore.py +8 -7
  38. airflow/providers/google/cloud/operators/dlp.py +31 -30
  39. airflow/providers/google/cloud/operators/functions.py +4 -3
  40. airflow/providers/google/cloud/operators/gcs.py +66 -41
  41. airflow/providers/google/cloud/operators/kubernetes_engine.py +256 -49
  42. airflow/providers/google/cloud/operators/life_sciences.py +2 -1
  43. airflow/providers/google/cloud/operators/mlengine.py +11 -10
  44. airflow/providers/google/cloud/operators/pubsub.py +6 -5
  45. airflow/providers/google/cloud/operators/spanner.py +7 -6
  46. airflow/providers/google/cloud/operators/speech_to_text.py +2 -1
  47. airflow/providers/google/cloud/operators/stackdriver.py +11 -10
  48. airflow/providers/google/cloud/operators/tasks.py +14 -13
  49. airflow/providers/google/cloud/operators/text_to_speech.py +2 -1
  50. airflow/providers/google/cloud/operators/translate_speech.py +2 -1
  51. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +333 -26
  52. airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +20 -12
  53. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +0 -1
  54. airflow/providers/google/cloud/operators/vision.py +13 -12
  55. airflow/providers/google/cloud/operators/workflows.py +12 -14
  56. airflow/providers/google/cloud/secrets/secret_manager.py +2 -1
  57. airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
  58. airflow/providers/google/cloud/sensors/bigtable.py +2 -1
  59. airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -1
  60. airflow/providers/google/cloud/sensors/dataflow.py +239 -52
  61. airflow/providers/google/cloud/sensors/datafusion.py +2 -1
  62. airflow/providers/google/cloud/sensors/dataproc.py +3 -2
  63. airflow/providers/google/cloud/sensors/gcs.py +14 -12
  64. airflow/providers/google/cloud/sensors/tasks.py +2 -1
  65. airflow/providers/google/cloud/sensors/workflows.py +2 -1
  66. airflow/providers/google/cloud/transfers/adls_to_gcs.py +8 -2
  67. airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +7 -1
  68. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +7 -1
  69. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +2 -1
  70. airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +1 -1
  71. airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -0
  72. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +5 -6
  73. airflow/providers/google/cloud/transfers/gcs_to_gcs.py +22 -12
  74. airflow/providers/google/cloud/triggers/bigquery.py +75 -6
  75. airflow/providers/google/cloud/triggers/cloud_composer.py +68 -0
  76. airflow/providers/google/cloud/triggers/cloud_sql.py +2 -1
  77. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +2 -1
  78. airflow/providers/google/cloud/triggers/dataflow.py +504 -4
  79. airflow/providers/google/cloud/triggers/dataproc.py +190 -27
  80. airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -3
  81. airflow/providers/google/cloud/triggers/mlengine.py +2 -1
  82. airflow/providers/google/cloud/triggers/vertex_ai.py +94 -0
  83. airflow/providers/google/common/hooks/base_google.py +45 -7
  84. airflow/providers/google/firebase/hooks/firestore.py +2 -2
  85. airflow/providers/google/firebase/operators/firestore.py +2 -1
  86. airflow/providers/google/get_provider_info.py +5 -3
  87. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/METADATA +18 -18
  88. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/RECORD +90 -90
  89. airflow/providers/google/cloud/example_dags/example_cloud_sql_query.py +0 -289
  90. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/WHEEL +0 -0
  91. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/entry_points.txt +0 -0
@@ -1,289 +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
- """
19
- Example Airflow DAG that performs query in a Cloud SQL instance.
20
-
21
- This DAG relies on the following OS environment variables
22
-
23
- * GCP_PROJECT_ID - Google Cloud project for the Cloud SQL instance
24
- * GCP_REGION - Google Cloud region where the database is created
25
- *
26
- * GCSQL_POSTGRES_INSTANCE_NAME - Name of the postgres Cloud SQL instance
27
- * GCSQL_POSTGRES_USER - Name of the postgres database user
28
- * GCSQL_POSTGRES_PASSWORD - Password of the postgres database user
29
- * GCSQL_POSTGRES_PUBLIC_IP - Public IP of the Postgres database
30
- * GCSQL_POSTGRES_PUBLIC_PORT - Port of the postgres database
31
- *
32
- * GCSQL_MYSQL_INSTANCE_NAME - Name of the postgres Cloud SQL instance
33
- * GCSQL_MYSQL_USER - Name of the mysql database user
34
- * GCSQL_MYSQL_PASSWORD - Password of the mysql database user
35
- * GCSQL_MYSQL_PUBLIC_IP - Public IP of the mysql database
36
- * GCSQL_MYSQL_PUBLIC_PORT - Port of the mysql database
37
- """
38
-
39
- from __future__ import annotations
40
-
41
- import os
42
- import subprocess
43
- from datetime import datetime
44
- from pathlib import Path
45
- from urllib.parse import quote_plus
46
-
47
- from airflow.models.dag import DAG
48
- from airflow.providers.google.cloud.operators.cloud_sql import CloudSQLExecuteQueryOperator
49
-
50
- GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project")
51
- GCP_REGION = os.environ.get("GCP_REGION", "europe-west1")
52
-
53
- GCSQL_POSTGRES_INSTANCE_NAME_QUERY = os.environ.get(
54
- "GCSQL_POSTGRES_INSTANCE_NAME_QUERY", "test-postgres-query"
55
- )
56
- GCSQL_POSTGRES_DATABASE_NAME = os.environ.get("GCSQL_POSTGRES_DATABASE_NAME", "postgresdb")
57
- GCSQL_POSTGRES_USER = os.environ.get("GCSQL_POSTGRES_USER", "postgres_user")
58
- GCSQL_POSTGRES_PASSWORD = os.environ.get("GCSQL_POSTGRES_PASSWORD", "JoxHlwrPzwch0gz9")
59
- GCSQL_POSTGRES_PUBLIC_IP = os.environ.get("GCSQL_POSTGRES_PUBLIC_IP", "0.0.0.0")
60
- GCSQL_POSTGRES_PUBLIC_PORT = os.environ.get("GCSQL_POSTGRES_PUBLIC_PORT", 5432)
61
- GCSQL_POSTGRES_CLIENT_CERT_FILE = os.environ.get(
62
- "GCSQL_POSTGRES_CLIENT_CERT_FILE", ".key/postgres-client-cert.pem"
63
- )
64
- GCSQL_POSTGRES_CLIENT_KEY_FILE = os.environ.get(
65
- "GCSQL_POSTGRES_CLIENT_KEY_FILE", ".key/postgres-client-key.pem"
66
- )
67
- GCSQL_POSTGRES_SERVER_CA_FILE = os.environ.get("GCSQL_POSTGRES_SERVER_CA_FILE", ".key/postgres-server-ca.pem")
68
-
69
- GCSQL_MYSQL_INSTANCE_NAME_QUERY = os.environ.get("GCSQL_MYSQL_INSTANCE_NAME_QUERY", "test-mysql-query")
70
- GCSQL_MYSQL_DATABASE_NAME = os.environ.get("GCSQL_MYSQL_DATABASE_NAME", "mysqldb")
71
- GCSQL_MYSQL_USER = os.environ.get("GCSQL_MYSQL_USER", "mysql_user")
72
- GCSQL_MYSQL_PASSWORD = os.environ.get("GCSQL_MYSQL_PASSWORD", "JoxHlwrPzwch0gz9")
73
- GCSQL_MYSQL_PUBLIC_IP = os.environ.get("GCSQL_MYSQL_PUBLIC_IP", "0.0.0.0")
74
- GCSQL_MYSQL_PUBLIC_PORT = os.environ.get("GCSQL_MYSQL_PUBLIC_PORT", 3306)
75
- GCSQL_MYSQL_CLIENT_CERT_FILE = os.environ.get("GCSQL_MYSQL_CLIENT_CERT_FILE", ".key/mysql-client-cert.pem")
76
- GCSQL_MYSQL_CLIENT_KEY_FILE = os.environ.get("GCSQL_MYSQL_CLIENT_KEY_FILE", ".key/mysql-client-key.pem")
77
- GCSQL_MYSQL_SERVER_CA_FILE = os.environ.get("GCSQL_MYSQL_SERVER_CA_FILE", ".key/mysql-server-ca.pem")
78
-
79
- SQL = [
80
- "CREATE TABLE IF NOT EXISTS TABLE_TEST (I INTEGER)",
81
- "CREATE TABLE IF NOT EXISTS TABLE_TEST (I INTEGER)", # shows warnings logged
82
- "INSERT INTO TABLE_TEST VALUES (0)",
83
- "CREATE TABLE IF NOT EXISTS TABLE_TEST2 (I INTEGER)",
84
- "DROP TABLE TABLE_TEST",
85
- "DROP TABLE TABLE_TEST2",
86
- ]
87
-
88
-
89
- # [START howto_operator_cloudsql_query_connections]
90
-
91
- HOME_DIR = Path.home()
92
-
93
-
94
- def get_absolute_path(path):
95
- """
96
- Returns absolute path.
97
- """
98
- return os.fspath(HOME_DIR / path)
99
-
100
-
101
- postgres_kwargs = {
102
- "user": quote_plus(GCSQL_POSTGRES_USER),
103
- "password": quote_plus(GCSQL_POSTGRES_PASSWORD),
104
- "public_port": GCSQL_POSTGRES_PUBLIC_PORT,
105
- "public_ip": quote_plus(GCSQL_POSTGRES_PUBLIC_IP),
106
- "project_id": quote_plus(GCP_PROJECT_ID),
107
- "location": quote_plus(GCP_REGION),
108
- "instance": quote_plus(GCSQL_POSTGRES_INSTANCE_NAME_QUERY),
109
- "database": quote_plus(GCSQL_POSTGRES_DATABASE_NAME),
110
- "client_cert_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_CLIENT_CERT_FILE)),
111
- "client_key_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_CLIENT_KEY_FILE)),
112
- "server_ca_file": quote_plus(get_absolute_path(GCSQL_POSTGRES_SERVER_CA_FILE)),
113
- }
114
-
115
- # The connections below are created using one of the standard approaches - via environment
116
- # variables named AIRFLOW_CONN_* . The connections can also be created in the database
117
- # of AIRFLOW (using command line or UI).
118
-
119
- # Postgres: connect via proxy over TCP
120
- os.environ["AIRFLOW_CONN_PROXY_POSTGRES_TCP"] = (
121
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
122
- "database_type=postgres&"
123
- "project_id={project_id}&"
124
- "location={location}&"
125
- "instance={instance}&"
126
- "use_proxy=True&"
127
- "sql_proxy_use_tcp=True".format(**postgres_kwargs)
128
- )
129
-
130
- # Postgres: connect via proxy over UNIX socket (specific proxy version)
131
- os.environ["AIRFLOW_CONN_PROXY_POSTGRES_SOCKET"] = (
132
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
133
- "database_type=postgres&"
134
- "project_id={project_id}&"
135
- "location={location}&"
136
- "instance={instance}&"
137
- "use_proxy=True&"
138
- "sql_proxy_version=v1.13&"
139
- "sql_proxy_use_tcp=False".format(**postgres_kwargs)
140
- )
141
-
142
- # Postgres: connect directly via TCP (non-SSL)
143
- os.environ["AIRFLOW_CONN_PUBLIC_POSTGRES_TCP"] = (
144
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
145
- "database_type=postgres&"
146
- "project_id={project_id}&"
147
- "location={location}&"
148
- "instance={instance}&"
149
- "use_proxy=False&"
150
- "use_ssl=False".format(**postgres_kwargs)
151
- )
152
-
153
- # Postgres: connect directly via TCP (SSL)
154
- os.environ["AIRFLOW_CONN_PUBLIC_POSTGRES_TCP_SSL"] = (
155
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
156
- "database_type=postgres&"
157
- "project_id={project_id}&"
158
- "location={location}&"
159
- "instance={instance}&"
160
- "use_proxy=False&"
161
- "use_ssl=True&"
162
- "sslcert={client_cert_file}&"
163
- "sslkey={client_key_file}&"
164
- "sslrootcert={server_ca_file}".format(**postgres_kwargs)
165
- )
166
-
167
- mysql_kwargs = {
168
- "user": quote_plus(GCSQL_MYSQL_USER),
169
- "password": quote_plus(GCSQL_MYSQL_PASSWORD),
170
- "public_port": GCSQL_MYSQL_PUBLIC_PORT,
171
- "public_ip": quote_plus(GCSQL_MYSQL_PUBLIC_IP),
172
- "project_id": quote_plus(GCP_PROJECT_ID),
173
- "location": quote_plus(GCP_REGION),
174
- "instance": quote_plus(GCSQL_MYSQL_INSTANCE_NAME_QUERY),
175
- "database": quote_plus(GCSQL_MYSQL_DATABASE_NAME),
176
- "client_cert_file": quote_plus(get_absolute_path(GCSQL_MYSQL_CLIENT_CERT_FILE)),
177
- "client_key_file": quote_plus(get_absolute_path(GCSQL_MYSQL_CLIENT_KEY_FILE)),
178
- "server_ca_file": quote_plus(get_absolute_path(GCSQL_MYSQL_SERVER_CA_FILE)),
179
- }
180
-
181
- # MySQL: connect via proxy over TCP (specific proxy version)
182
- os.environ["AIRFLOW_CONN_PROXY_MYSQL_TCP"] = (
183
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
184
- "database_type=mysql&"
185
- "project_id={project_id}&"
186
- "location={location}&"
187
- "instance={instance}&"
188
- "use_proxy=True&"
189
- "sql_proxy_version=v1.13&"
190
- "sql_proxy_use_tcp=True".format(**mysql_kwargs)
191
- )
192
-
193
- # MySQL: connect via proxy over UNIX socket using pre-downloaded Cloud Sql Proxy binary
194
- try:
195
- sql_proxy_binary_path = subprocess.check_output(["which", "cloud_sql_proxy"]).decode("utf-8").rstrip()
196
- except subprocess.CalledProcessError:
197
- sql_proxy_binary_path = "/tmp/anyhow_download_cloud_sql_proxy"
198
-
199
- os.environ["AIRFLOW_CONN_PROXY_MYSQL_SOCKET"] = (
200
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
201
- "database_type=mysql&"
202
- "project_id={project_id}&"
203
- "location={location}&"
204
- "instance={instance}&"
205
- "use_proxy=True&"
206
- "sql_proxy_use_tcp=False".format(**mysql_kwargs)
207
- )
208
-
209
- # MySQL: connect directly via TCP (non-SSL)
210
- os.environ["AIRFLOW_CONN_PUBLIC_MYSQL_TCP"] = (
211
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
212
- "database_type=mysql&"
213
- "project_id={project_id}&"
214
- "location={location}&"
215
- "instance={instance}&"
216
- "use_proxy=False&"
217
- "use_ssl=False".format(**mysql_kwargs)
218
- )
219
-
220
- # MySQL: connect directly via TCP (SSL) and with fixed Cloud Sql Proxy binary path
221
- os.environ["AIRFLOW_CONN_PUBLIC_MYSQL_TCP_SSL"] = (
222
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
223
- "database_type=mysql&"
224
- "project_id={project_id}&"
225
- "location={location}&"
226
- "instance={instance}&"
227
- "use_proxy=False&"
228
- "use_ssl=True&"
229
- "sslcert={client_cert_file}&"
230
- "sslkey={client_key_file}&"
231
- "sslrootcert={server_ca_file}".format(**mysql_kwargs)
232
- )
233
-
234
- # Special case: MySQL: connect directly via TCP (SSL) and with fixed Cloud Sql
235
- # Proxy binary path AND with missing project_id
236
-
237
- os.environ["AIRFLOW_CONN_PUBLIC_MYSQL_TCP_SSL_NO_PROJECT_ID"] = (
238
- "gcpcloudsql://{user}:{password}@{public_ip}:{public_port}/{database}?"
239
- "database_type=mysql&"
240
- "location={location}&"
241
- "instance={instance}&"
242
- "use_proxy=False&"
243
- "use_ssl=True&"
244
- "sslcert={client_cert_file}&"
245
- "sslkey={client_key_file}&"
246
- "sslrootcert={server_ca_file}".format(**mysql_kwargs)
247
- )
248
-
249
-
250
- # [END howto_operator_cloudsql_query_connections]
251
-
252
- # [START howto_operator_cloudsql_query_operators]
253
-
254
- connection_names = [
255
- "proxy_postgres_tcp",
256
- "proxy_postgres_socket",
257
- "public_postgres_tcp",
258
- "public_postgres_tcp_ssl",
259
- "proxy_mysql_tcp",
260
- "proxy_mysql_socket",
261
- "public_mysql_tcp",
262
- "public_mysql_tcp_ssl",
263
- "public_mysql_tcp_ssl_no_project_id",
264
- ]
265
-
266
- tasks = []
267
-
268
-
269
- with DAG(
270
- dag_id="example_gcp_sql_query",
271
- start_date=datetime(2021, 1, 1),
272
- catchup=False,
273
- tags=["example"],
274
- ) as dag:
275
- prev_task = None
276
-
277
- for connection_name in connection_names:
278
- task = CloudSQLExecuteQueryOperator(
279
- gcp_cloudsql_conn_id=connection_name,
280
- task_id="example_gcp_sql_task_" + connection_name,
281
- sql=SQL,
282
- sql_proxy_binary_path=sql_proxy_binary_path,
283
- )
284
- tasks.append(task)
285
- if prev_task:
286
- prev_task >> task
287
- prev_task = task
288
-
289
- # [END howto_operator_cloudsql_query_operators]