From 9449a107f092f2f6cfa9c8bbcf5fd62fadfa01be Mon Sep 17 00:00:00 2001 From: eladkal <45845474+eladkal@users.noreply.github.com> Date: Thu, 28 Apr 2022 17:11:24 +0300 Subject: [PATCH] `DatastoreHook`: Remove `datastore_conn_id` (#23323) * `DatastoreHook`: Remove `datastore_conn_id` --- airflow/providers/google/CHANGELOG.rst | 2 ++ airflow/providers/google/cloud/hooks/datastore.py | 10 ---------- airflow/providers/google/cloud/operators/datastore.py | 4 ++-- .../providers/google/cloud/operators/test_datastore.py | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/airflow/providers/google/CHANGELOG.rst b/airflow/providers/google/CHANGELOG.rst index 66833f43da38d..cd0f09bf836f9 100644 --- a/airflow/providers/google/CHANGELOG.rst +++ b/airflow/providers/google/CHANGELOG.rst @@ -34,6 +34,8 @@ Breaking changes For more information, see `Deprecation and sunset `_ and `Upgrading to the newest version `_ +* ``DatastoreHook``: Remove ``datastore_conn_id``. Please use ``gcp_conn_id`` + * ``CloudBuildCreateBuildOperator``: Remove ``body``. Please use ``build`` * ``BigtableCreateInstanceOperator`` Remove ``replica_cluster_id``, ``replica_cluster_zone``. Please use ``replica_clusters``. diff --git a/airflow/providers/google/cloud/hooks/datastore.py b/airflow/providers/google/cloud/hooks/datastore.py index 53d42002aa496..f62b3ccfd5b64 100644 --- a/airflow/providers/google/cloud/hooks/datastore.py +++ b/airflow/providers/google/cloud/hooks/datastore.py @@ -20,7 +20,6 @@ import time -import warnings from typing import Any, Dict, Optional, Sequence, Union from googleapiclient.discovery import Resource, build @@ -43,17 +42,8 @@ def __init__( gcp_conn_id: str = "google_cloud_default", delegate_to: Optional[str] = None, api_version: str = 'v1', - datastore_conn_id: Optional[str] = None, impersonation_chain: Optional[Union[str, Sequence[str]]] = None, ) -> None: - if datastore_conn_id: - warnings.warn( - "The datastore_conn_id parameter has been deprecated. You should pass " - "the gcp_conn_id parameter.", - DeprecationWarning, - stacklevel=2, - ) - gcp_conn_id = datastore_conn_id super().__init__( gcp_conn_id=gcp_conn_id, delegate_to=delegate_to, diff --git a/airflow/providers/google/cloud/operators/datastore.py b/airflow/providers/google/cloud/operators/datastore.py index d36c6d6617284..8a92665e3694e 100644 --- a/airflow/providers/google/cloud/operators/datastore.py +++ b/airflow/providers/google/cloud/operators/datastore.py @@ -119,8 +119,8 @@ def execute(self, context: 'Context') -> dict: gcs_hook.delete(self.bucket, obj) ds_hook = DatastoreHook( - self.datastore_conn_id, - self.delegate_to, + gcp_conn_id=self.datastore_conn_id, + delegate_to=self.delegate_to, impersonation_chain=self.impersonation_chain, ) result = ds_hook.export_to_storage_bucket( diff --git a/tests/providers/google/cloud/operators/test_datastore.py b/tests/providers/google/cloud/operators/test_datastore.py index 75f3d2ac94f47..61bd47cee475e 100644 --- a/tests/providers/google/cloud/operators/test_datastore.py +++ b/tests/providers/google/cloud/operators/test_datastore.py @@ -59,7 +59,7 @@ def test_execute(self, mock_hook): ) op.execute(context={'ti': mock.MagicMock()}) - mock_hook.assert_called_once_with(CONN_ID, None, impersonation_chain=None) + mock_hook.assert_called_once_with(gcp_conn_id=CONN_ID, delegate_to=None, impersonation_chain=None) mock_hook.return_value.export_to_storage_bucket.assert_called_once_with( project_id=PROJECT_ID, bucket=BUCKET,