Skip to content

Commit

Permalink
DatastoreHook: Remove datastore_conn_id (#23323)
Browse files Browse the repository at this point in the history
* `DatastoreHook`: Remove `datastore_conn_id`
  • Loading branch information
eladkal committed Apr 28, 2022
1 parent 1f32603 commit 9449a10
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
2 changes: 2 additions & 0 deletions airflow/providers/google/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Breaking changes
For more information, see `Deprecation and sunset <https://developers.google.com/google-ads/api/docs/sunset-dates>`_
and `Upgrading to the newest version <https://developers.google.com/google-ads/api/docs/version-migration>`_

* ``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``.
Expand Down
10 changes: 0 additions & 10 deletions airflow/providers/google/cloud/hooks/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@


import time
import warnings
from typing import Any, Dict, Optional, Sequence, Union

from googleapiclient.discovery import Resource, build
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/google/cloud/operators/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/google/cloud/operators/test_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9449a10

Please sign in to comment.