Skip to content

Commit

Permalink
Remove deprecated parameters from PubSub operators: (#23261)
Browse files Browse the repository at this point in the history
* `PubSubCreateTopicOperator`: Remove `project`. Please use `project_id`

* `PubSubCreateSubscriptionOperator`: Remove `topic_project`. Please use `project_id`

* `PubSubCreateSubscriptionOperator`: Remove `subscription_project`. Please use `subscription_project_id`

* `PubSubDeleteTopicOperator`: Remove `project`. Please use `project_id`

* `PubSubDeleteSubscriptionOperator`: Remove `project`. Please use `project_id`

* `PubSubPublishMessageOperator`: Remove `project`. Please use `project_id`
  • Loading branch information
eladkal committed Apr 27, 2022
1 parent 0d6e29a commit 6cf0176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 73 deletions.
12 changes: 12 additions & 0 deletions airflow/providers/google/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ Breaking changes

* ``GCSObjectsWtihPrefixExistenceSensor`` removed. Please use ``GCSObjectsWithPrefixExistenceSensor``.

* ``PubSubCreateTopicOperator``: Remove ``project``. Please use ``project_id``

* ``PubSubCreateSubscriptionOperator``: Remove ``topic_project``. Please use ``project_id``

* ``PubSubCreateSubscriptionOperator``: Remove ``subscription_project``. Please use ``subscription_project_id``

* ``PubSubDeleteTopicOperator``: Remove ``project``. Please use ``project_id``

* ``PubSubDeleteSubscriptionOperator``: Remove ``project``. Please use ``project_id``

* ``PubSubPublishMessageOperator``: Remove ``project``. Please use ``project_id``

* ``PubSubPullSensor``: Remove ``project``. Please use ``project_id``

* ``PubSubPullSensor``: Remove ``return_immediately``
Expand Down
73 changes: 0 additions & 73 deletions airflow/providers/google/cloud/operators/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
MessageStoragePolicy
"""
import warnings
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
Expand Down Expand Up @@ -102,7 +101,6 @@ class PubSubCreateTopicOperator(BaseOperator):
to complete. Note that if retry is specified, the timeout applies to each
individual attempt.
:param metadata: (Optional) Additional metadata that is provided to the method.
:param project: (Deprecated) the Google Cloud project ID where the topic will be created
:param impersonation_chain: Optional service account to impersonate using short-term
credentials, or chained list of accounts required to get the access_token
of the last account in the list, which will be impersonated in the request.
Expand Down Expand Up @@ -134,19 +132,9 @@ def __init__(
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
project: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:
# To preserve backward compatibility
# TODO: remove one day
if project:
warnings.warn(
"The project parameter has been deprecated. You should pass the project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
project_id = project

super().__init__(**kwargs)
self.project_id = project_id
Expand Down Expand Up @@ -299,9 +287,6 @@ class PubSubCreateSubscriptionOperator(BaseOperator):
to complete. Note that if retry is specified, the timeout applies to each
individual attempt.
:param metadata: (Optional) Additional metadata that is provided to the method.
:param topic_project: (Deprecated) the Google Cloud project ID where the topic exists
:param subscription_project: (Deprecated) the Google Cloud project ID where the subscription
will be created. If empty, ``topic_project`` will be used.
:param impersonation_chain: Optional service account to impersonate using short-term
credentials, or chained list of accounts required to get the access_token
of the last account in the list, which will be impersonated in the request.
Expand Down Expand Up @@ -344,31 +329,9 @@ def __init__(
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
topic_project: Optional[str] = None,
subscription_project: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:

# To preserve backward compatibility
# TODO: remove one day
if topic_project:
warnings.warn(
"The topic_project parameter has been deprecated. You should pass "
"the project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
project_id = topic_project
if subscription_project:
warnings.warn(
"The subscription_project parameter has been deprecated. You should pass "
"the subscription_project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
subscription_project_id = subscription_project

super().__init__(**kwargs)
self.project_id = project_id
self.topic = topic
Expand Down Expand Up @@ -466,7 +429,6 @@ class PubSubDeleteTopicOperator(BaseOperator):
to complete. Note that if retry is specified, the timeout applies to each
individual attempt.
:param metadata: (Optional) Additional metadata that is provided to the method.
:param project: (Deprecated) the Google Cloud project ID where the topic will be created
:param impersonation_chain: Optional service account to impersonate using short-term
credentials, or chained list of accounts required to get the access_token
of the last account in the list, which will be impersonated in the request.
Expand Down Expand Up @@ -495,20 +457,9 @@ def __init__(
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
project: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:
# To preserve backward compatibility
# TODO: remove one day
if project:
warnings.warn(
"The project parameter has been deprecated. You should pass the project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
project_id = project

super().__init__(**kwargs)
self.project_id = project_id
self.topic = topic
Expand Down Expand Up @@ -582,7 +533,6 @@ class PubSubDeleteSubscriptionOperator(BaseOperator):
to complete. Note that if retry is specified, the timeout applies to each
individual attempt.
:param metadata: (Optional) Additional metadata that is provided to the method.
:param project: (Deprecated) the Google Cloud project ID where the topic will be created
:param impersonation_chain: Optional service account to impersonate using short-term
credentials, or chained list of accounts required to get the access_token
of the last account in the list, which will be impersonated in the request.
Expand Down Expand Up @@ -611,20 +561,9 @@ def __init__(
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
project: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:
# To preserve backward compatibility
# TODO: remove one day
if project:
warnings.warn(
"The project parameter has been deprecated. You should pass the project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
project_id = project

super().__init__(**kwargs)
self.project_id = project_id
self.subscription = subscription
Expand Down Expand Up @@ -702,7 +641,6 @@ class PubSubPublishMessageOperator(BaseOperator):
:param delegate_to: The account to impersonate using domain-wide delegation of authority,
if any. For this to work, the service account making the request must have
domain-wide delegation enabled.
:param project: (Deprecated) the Google Cloud project ID where the topic will be created
:param impersonation_chain: Optional service account to impersonate using short-term
credentials, or chained list of accounts required to get the access_token
of the last account in the list, which will be impersonated in the request.
Expand All @@ -729,20 +667,9 @@ def __init__(
project_id: Optional[str] = None,
gcp_conn_id: str = 'google_cloud_default',
delegate_to: Optional[str] = None,
project: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:
# To preserve backward compatibility
# TODO: remove one day
if project:
warnings.warn(
"The project parameter has been deprecated. You should pass the project_id parameter.",
DeprecationWarning,
stacklevel=2,
)
project_id = project

super().__init__(**kwargs)
self.project_id = project_id
self.topic = topic
Expand Down

0 comments on commit 6cf0176

Please sign in to comment.