From 72f150fe39313173ac6c02616b6ca4466f5855fe Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:08:11 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#187) - [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): require google-api-core >= 1.28.0 fix(deps): drop packaging dependency committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: https://github.com/googleapis/googleapis/commit/83d81b0c8fc22291a13398d6d77f02dc97a5b6f4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9 --- .../services/cloud_tasks/async_client.py | 100 +++++++------- .../tasks_v2/services/cloud_tasks/client.py | 34 ++--- .../services/cloud_tasks/transports/base.py | 35 +---- .../cloud_tasks/transports/grpc_asyncio.py | 1 - google/cloud/tasks_v2/types/target.py | 9 ++ google/cloud/tasks_v2/types/task.py | 9 ++ .../services/cloud_tasks/async_client.py | 124 +++++++++--------- .../services/cloud_tasks/client.py | 42 +++--- .../services/cloud_tasks/transports/base.py | 35 +---- .../cloud_tasks/transports/grpc_asyncio.py | 1 - google/cloud/tasks_v2beta2/types/queue.py | 18 +++ google/cloud/tasks_v2beta2/types/task.py | 9 ++ .../services/cloud_tasks/async_client.py | 100 +++++++------- .../services/cloud_tasks/client.py | 34 ++--- .../services/cloud_tasks/transports/base.py | 35 +---- .../cloud_tasks/transports/grpc_asyncio.py | 1 - google/cloud/tasks_v2beta3/types/queue.py | 4 + google/cloud/tasks_v2beta3/types/target.py | 9 ++ google/cloud/tasks_v2beta3/types/task.py | 10 ++ setup.py | 3 +- testing/constraints-3.6.txt | 4 +- tests/unit/gapic/tasks_v2/test_cloud_tasks.py | 88 ++----------- .../gapic/tasks_v2beta2/test_cloud_tasks.py | 88 ++----------- .../gapic/tasks_v2beta3/test_cloud_tasks.py | 88 ++----------- 24 files changed, 323 insertions(+), 558 deletions(-) diff --git a/google/cloud/tasks_v2/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2/services/cloud_tasks/async_client.py index 9af0c5bc..30368be8 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2.services.cloud_tasks import pagers from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -171,10 +173,10 @@ def __init__( async def list_queues( self, - request: cloudtasks.ListQueuesRequest = None, + request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesAsyncPager: @@ -182,7 +184,7 @@ async def list_queues( Queues are returned in lexicographical order. Args: - request (:class:`google.cloud.tasks_v2.types.ListQueuesRequest`): + request (Union[google.cloud.tasks_v2.types.ListQueuesRequest, dict]): The request object. Request message for [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. parent (:class:`str`): @@ -262,17 +264,17 @@ async def list_queues( async def get_queue( self, - request: cloudtasks.GetQueueRequest = None, + request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: r"""Gets a queue. Args: - request (:class:`google.cloud.tasks_v2.types.GetQueueRequest`): + request (Union[google.cloud.tasks_v2.types.GetQueueRequest, dict]): The request object. Request message for [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue]. name (:class:`str`): @@ -347,11 +349,11 @@ async def get_queue( async def create_queue( self, - request: cloudtasks.CreateQueueRequest = None, + request: Union[cloudtasks.CreateQueueRequest, dict] = None, *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -368,7 +370,7 @@ async def create_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2.types.CreateQueueRequest`): + request (Union[google.cloud.tasks_v2.types.CreateQueueRequest, dict]): The request object. Request message for [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue]. parent (:class:`str`): @@ -449,11 +451,11 @@ async def create_queue( async def update_queue( self, - request: cloudtasks.UpdateQueueRequest = None, + request: Union[cloudtasks.UpdateQueueRequest, dict] = None, *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -473,7 +475,7 @@ async def update_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2.types.UpdateQueueRequest`): + request (Union[google.cloud.tasks_v2.types.UpdateQueueRequest, dict]): The request object. Request message for [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue]. queue (:class:`google.cloud.tasks_v2.types.Queue`): @@ -559,10 +561,10 @@ async def update_queue( async def delete_queue( self, - request: cloudtasks.DeleteQueueRequest = None, + request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -580,7 +582,7 @@ async def delete_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2.types.DeleteQueueRequest`): + request (Union[google.cloud.tasks_v2.types.DeleteQueueRequest, dict]): The request object. Request message for [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue]. name (:class:`str`): @@ -644,10 +646,10 @@ async def delete_queue( async def purge_queue( self, - request: cloudtasks.PurgeQueueRequest = None, + request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -659,7 +661,7 @@ async def purge_queue( effect. A purge is irreversible. Args: - request (:class:`google.cloud.tasks_v2.types.PurgeQueueRequest`): + request (Union[google.cloud.tasks_v2.types.PurgeQueueRequest, dict]): The request object. Request message for [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue]. name (:class:`str`): @@ -724,10 +726,10 @@ async def purge_queue( async def pause_queue( self, - request: cloudtasks.PauseQueueRequest = None, + request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -741,7 +743,7 @@ async def pause_queue( [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. Args: - request (:class:`google.cloud.tasks_v2.types.PauseQueueRequest`): + request (Union[google.cloud.tasks_v2.types.PauseQueueRequest, dict]): The request object. Request message for [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue]. name (:class:`str`): @@ -806,10 +808,10 @@ async def pause_queue( async def resume_queue( self, - request: cloudtasks.ResumeQueueRequest = None, + request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -830,7 +832,7 @@ async def resume_queue( Risks `__. Args: - request (:class:`google.cloud.tasks_v2.types.ResumeQueueRequest`): + request (Union[google.cloud.tasks_v2.types.ResumeQueueRequest, dict]): The request object. Request message for [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. name (:class:`str`): @@ -895,10 +897,10 @@ async def resume_queue( async def get_iam_policy( self, - request: iam_policy_pb2.GetIamPolicyRequest = None, + request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -913,7 +915,7 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.GetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` method. resource (:class:`str`): @@ -1039,10 +1041,10 @@ async def get_iam_policy( async def set_iam_policy( self, - request: iam_policy_pb2.SetIamPolicyRequest = None, + request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1061,7 +1063,7 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.SetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` method. resource (:class:`str`): @@ -1177,11 +1179,11 @@ async def set_iam_policy( async def test_iam_permissions( self, - request: iam_policy_pb2.TestIamPermissionsRequest = None, + request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None, *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1196,7 +1198,7 @@ async def test_iam_permissions( warning. Args: - request (:class:`google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest`): + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for `TestIamPermissions` method. resource (:class:`str`): @@ -1278,10 +1280,10 @@ async def test_iam_permissions( async def list_tasks( self, - request: cloudtasks.ListTasksRequest = None, + request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksAsyncPager: @@ -1297,7 +1299,7 @@ async def list_tasks( at any time. Args: - request (:class:`google.cloud.tasks_v2.types.ListTasksRequest`): + request (Union[google.cloud.tasks_v2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks using [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. @@ -1378,17 +1380,17 @@ async def list_tasks( async def get_task( self, - request: cloudtasks.GetTaskRequest = None, + request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: r"""Gets a task. Args: - request (:class:`google.cloud.tasks_v2.types.GetTaskRequest`): + request (Union[google.cloud.tasks_v2.types.GetTaskRequest, dict]): The request object. Request message for getting a task using [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask]. @@ -1458,11 +1460,11 @@ async def get_task( async def create_task( self, - request: cloudtasks.CreateTaskRequest = None, + request: Union[cloudtasks.CreateTaskRequest, dict] = None, *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1474,7 +1476,7 @@ async def create_task( - The maximum task size is 100KB. Args: - request (:class:`google.cloud.tasks_v2.types.CreateTaskRequest`): + request (Union[google.cloud.tasks_v2.types.CreateTaskRequest, dict]): The request object. Request message for [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. parent (:class:`str`): @@ -1583,10 +1585,10 @@ async def create_task( async def delete_task( self, - request: cloudtasks.DeleteTaskRequest = None, + request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1596,7 +1598,7 @@ async def delete_task( or permanently failed. Args: - request (:class:`google.cloud.tasks_v2.types.DeleteTaskRequest`): + request (Union[google.cloud.tasks_v2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task using [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask]. @@ -1661,10 +1663,10 @@ async def delete_task( async def run_task( self, - request: cloudtasks.RunTaskRequest = None, + request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1697,7 +1699,7 @@ async def run_task( task that has already succeeded or permanently failed. Args: - request (:class:`google.cloud.tasks_v2.types.RunTaskRequest`): + request (Union[google.cloud.tasks_v2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task to run now using [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask]. diff --git a/google/cloud/tasks_v2/services/cloud_tasks/client.py b/google/cloud/tasks_v2/services/cloud_tasks/client.py index 3dc823be..d78f1cca 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2.services.cloud_tasks import pagers from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -378,7 +380,7 @@ def list_queues( request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesPager: @@ -459,7 +461,7 @@ def get_queue( request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -535,7 +537,7 @@ def create_queue( *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -637,7 +639,7 @@ def update_queue( *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -746,7 +748,7 @@ def delete_queue( request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -821,7 +823,7 @@ def purge_queue( request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -901,7 +903,7 @@ def pause_queue( request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -983,7 +985,7 @@ def resume_queue( request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -1072,7 +1074,7 @@ def get_iam_policy( request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1205,7 +1207,7 @@ def set_iam_policy( request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1343,7 +1345,7 @@ def test_iam_permissions( *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1432,7 +1434,7 @@ def list_tasks( request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksPager: @@ -1522,7 +1524,7 @@ def get_task( request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1593,7 +1595,7 @@ def create_task( *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1717,7 +1719,7 @@ def delete_task( request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1785,7 +1787,7 @@ def run_task( request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py index ae967353..7f09c669 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -42,15 +41,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class CloudTasksTransport(abc.ABC): """Abstract transport class for CloudTasks.""" @@ -100,7 +90,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -133,29 +123,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py index 9502958b..bbcd2d04 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/tasks_v2/types/target.py b/google/cloud/tasks_v2/types/target.py index 4556cee2..3920caec 100644 --- a/google/cloud/tasks_v2/types/target.py +++ b/google/cloud/tasks_v2/types/target.py @@ -77,6 +77,13 @@ class HttpRequest(proto.Message): queue being unpaused, or many tasks that are scheduled at the same time). + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: url (str): Required. The full url path that the request will be sent @@ -143,6 +150,7 @@ class HttpRequest(proto.Message): This type of authorization should generally only be used when calling Google APIs hosted on \*.googleapis.com. + This field is a member of `oneof`_ ``authorization_header``. oidc_token (google.cloud.tasks_v2.types.OidcToken): If specified, an `OIDC `__ @@ -152,6 +160,7 @@ class HttpRequest(proto.Message): This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself. + This field is a member of `oneof`_ ``authorization_header``. """ url = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/tasks_v2/types/task.py b/google/cloud/tasks_v2/types/task.py index 10794708..cb0bf0f3 100644 --- a/google/cloud/tasks_v2/types/task.py +++ b/google/cloud/tasks_v2/types/task.py @@ -29,6 +29,13 @@ class Task(proto.Message): r"""A unit of scheduled work. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Optionally caller-specified in @@ -61,11 +68,13 @@ class Task(proto.Message): An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] set. + This field is a member of `oneof`_ ``message_type``. http_request (google.cloud.tasks_v2.types.HttpRequest): HTTP request that is sent to the worker. An HTTP task is a task that has [HttpRequest][google.cloud.tasks.v2.HttpRequest] set. + This field is a member of `oneof`_ ``message_type``. schedule_time (google.protobuf.timestamp_pb2.Timestamp): The time when the task is scheduled to be attempted or retried. diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py index 880683a4..327e499e 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -171,10 +173,10 @@ def __init__( async def list_queues( self, - request: cloudtasks.ListQueuesRequest = None, + request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesAsyncPager: @@ -182,7 +184,7 @@ async def list_queues( Queues are returned in lexicographical order. Args: - request (:class:`google.cloud.tasks_v2beta2.types.ListQueuesRequest`): + request (Union[google.cloud.tasks_v2beta2.types.ListQueuesRequest, dict]): The request object. Request message for [ListQueues][google.cloud.tasks.v2beta2.CloudTasks.ListQueues]. parent (:class:`str`): @@ -262,17 +264,17 @@ async def list_queues( async def get_queue( self, - request: cloudtasks.GetQueueRequest = None, + request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: r"""Gets a queue. Args: - request (:class:`google.cloud.tasks_v2beta2.types.GetQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.GetQueueRequest, dict]): The request object. Request message for [GetQueue][google.cloud.tasks.v2beta2.CloudTasks.GetQueue]. name (:class:`str`): @@ -347,11 +349,11 @@ async def get_queue( async def create_queue( self, - request: cloudtasks.CreateQueueRequest = None, + request: Union[cloudtasks.CreateQueueRequest, dict] = None, *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -368,7 +370,7 @@ async def create_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta2.types.CreateQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.CreateQueueRequest, dict]): The request object. Request message for [CreateQueue][google.cloud.tasks.v2beta2.CloudTasks.CreateQueue]. parent (:class:`str`): @@ -449,11 +451,11 @@ async def create_queue( async def update_queue( self, - request: cloudtasks.UpdateQueueRequest = None, + request: Union[cloudtasks.UpdateQueueRequest, dict] = None, *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -473,7 +475,7 @@ async def update_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta2.types.UpdateQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.UpdateQueueRequest, dict]): The request object. Request message for [UpdateQueue][google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue]. queue (:class:`google.cloud.tasks_v2beta2.types.Queue`): @@ -560,10 +562,10 @@ async def update_queue( async def delete_queue( self, - request: cloudtasks.DeleteQueueRequest = None, + request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -581,7 +583,7 @@ async def delete_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta2.types.DeleteQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]): The request object. Request message for [DeleteQueue][google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue]. name (:class:`str`): @@ -645,10 +647,10 @@ async def delete_queue( async def purge_queue( self, - request: cloudtasks.PurgeQueueRequest = None, + request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -660,7 +662,7 @@ async def purge_queue( effect. A purge is irreversible. Args: - request (:class:`google.cloud.tasks_v2beta2.types.PurgeQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.PurgeQueueRequest, dict]): The request object. Request message for [PurgeQueue][google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue]. name (:class:`str`): @@ -725,10 +727,10 @@ async def purge_queue( async def pause_queue( self, - request: cloudtasks.PauseQueueRequest = None, + request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -742,7 +744,7 @@ async def pause_queue( [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. Args: - request (:class:`google.cloud.tasks_v2beta2.types.PauseQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.PauseQueueRequest, dict]): The request object. Request message for [PauseQueue][google.cloud.tasks.v2beta2.CloudTasks.PauseQueue]. name (:class:`str`): @@ -807,10 +809,10 @@ async def pause_queue( async def resume_queue( self, - request: cloudtasks.ResumeQueueRequest = None, + request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -831,7 +833,7 @@ async def resume_queue( Risks `__. Args: - request (:class:`google.cloud.tasks_v2beta2.types.ResumeQueueRequest`): + request (Union[google.cloud.tasks_v2beta2.types.ResumeQueueRequest, dict]): The request object. Request message for [ResumeQueue][google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue]. name (:class:`str`): @@ -896,10 +898,10 @@ async def resume_queue( async def get_iam_policy( self, - request: iam_policy_pb2.GetIamPolicyRequest = None, + request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -914,7 +916,7 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.GetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` method. resource (:class:`str`): @@ -1040,10 +1042,10 @@ async def get_iam_policy( async def set_iam_policy( self, - request: iam_policy_pb2.SetIamPolicyRequest = None, + request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1062,7 +1064,7 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.SetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` method. resource (:class:`str`): @@ -1178,11 +1180,11 @@ async def set_iam_policy( async def test_iam_permissions( self, - request: iam_policy_pb2.TestIamPermissionsRequest = None, + request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None, *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1197,7 +1199,7 @@ async def test_iam_permissions( warning. Args: - request (:class:`google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest`): + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for `TestIamPermissions` method. resource (:class:`str`): @@ -1279,10 +1281,10 @@ async def test_iam_permissions( async def list_tasks( self, - request: cloudtasks.ListTasksRequest = None, + request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksAsyncPager: @@ -1298,7 +1300,7 @@ async def list_tasks( at any time. Args: - request (:class:`google.cloud.tasks_v2beta2.types.ListTasksRequest`): + request (Union[google.cloud.tasks_v2beta2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks using [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. @@ -1379,17 +1381,17 @@ async def list_tasks( async def get_task( self, - request: cloudtasks.GetTaskRequest = None, + request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: r"""Gets a task. Args: - request (:class:`google.cloud.tasks_v2beta2.types.GetTaskRequest`): + request (Union[google.cloud.tasks_v2beta2.types.GetTaskRequest, dict]): The request object. Request message for getting a task using [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask]. @@ -1459,11 +1461,11 @@ async def get_task( async def create_task( self, - request: cloudtasks.CreateTaskRequest = None, + request: Union[cloudtasks.CreateTaskRequest, dict] = None, *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1479,7 +1481,7 @@ async def create_task( maximum task size is 1MB. Args: - request (:class:`google.cloud.tasks_v2beta2.types.CreateTaskRequest`): + request (Union[google.cloud.tasks_v2beta2.types.CreateTaskRequest, dict]): The request object. Request message for [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask]. parent (:class:`str`): @@ -1588,10 +1590,10 @@ async def create_task( async def delete_task( self, - request: cloudtasks.DeleteTaskRequest = None, + request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1601,7 +1603,7 @@ async def delete_task( successfully or permanently failed. Args: - request (:class:`google.cloud.tasks_v2beta2.types.DeleteTaskRequest`): + request (Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task using [DeleteTask][google.cloud.tasks.v2beta2.CloudTasks.DeleteTask]. @@ -1666,11 +1668,11 @@ async def delete_task( async def lease_tasks( self, - request: cloudtasks.LeaseTasksRequest = None, + request: Union[cloudtasks.LeaseTasksRequest, dict] = None, *, parent: str = None, lease_duration: duration_pb2.Duration = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloudtasks.LeaseTasksResponse: @@ -1700,7 +1702,7 @@ async def lease_tasks( is exceeded. Args: - request (:class:`google.cloud.tasks_v2beta2.types.LeaseTasksRequest`): + request (Union[google.cloud.tasks_v2beta2.types.LeaseTasksRequest, dict]): The request object. Request message for leasing tasks using [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. @@ -1794,11 +1796,11 @@ async def lease_tasks( async def acknowledge_task( self, - request: cloudtasks.AcknowledgeTaskRequest = None, + request: Union[cloudtasks.AcknowledgeTaskRequest, dict] = None, *, name: str = None, schedule_time: timestamp_pb2.Timestamp = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1819,7 +1821,7 @@ async def acknowledge_task( [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. Args: - request (:class:`google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest`): + request (Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]): The request object. Request message for acknowledging a task using [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask]. @@ -1890,12 +1892,12 @@ async def acknowledge_task( async def renew_lease( self, - request: cloudtasks.RenewLeaseRequest = None, + request: Union[cloudtasks.RenewLeaseRequest, dict] = None, *, name: str = None, schedule_time: timestamp_pb2.Timestamp = None, lease_duration: duration_pb2.Duration = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1907,7 +1909,7 @@ async def renew_lease( [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. Args: - request (:class:`google.cloud.tasks_v2beta2.types.RenewLeaseRequest`): + request (Union[google.cloud.tasks_v2beta2.types.RenewLeaseRequest, dict]): The request object. Request message for renewing a lease using [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease]. @@ -1995,11 +1997,11 @@ async def renew_lease( async def cancel_lease( self, - request: cloudtasks.CancelLeaseRequest = None, + request: Union[cloudtasks.CancelLeaseRequest, dict] = None, *, name: str = None, schedule_time: timestamp_pb2.Timestamp = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -2013,7 +2015,7 @@ async def cancel_lease( [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. Args: - request (:class:`google.cloud.tasks_v2beta2.types.CancelLeaseRequest`): + request (Union[google.cloud.tasks_v2beta2.types.CancelLeaseRequest, dict]): The request object. Request message for canceling a lease using [CancelLease][google.cloud.tasks.v2beta2.CloudTasks.CancelLease]. @@ -2089,10 +2091,10 @@ async def cancel_lease( async def run_task( self, - request: cloudtasks.RunTaskRequest = None, + request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -2131,7 +2133,7 @@ async def run_task( task][google.cloud.tasks.v2beta2.PullMessage]. Args: - request (:class:`google.cloud.tasks_v2beta2.types.RunTaskRequest`): + request (Union[google.cloud.tasks_v2beta2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task to run now using [RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask]. diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py index d212f93f..07d6cb1e 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -378,7 +380,7 @@ def list_queues( request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesPager: @@ -459,7 +461,7 @@ def get_queue( request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -535,7 +537,7 @@ def create_queue( *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -637,7 +639,7 @@ def update_queue( *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -747,7 +749,7 @@ def delete_queue( request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -822,7 +824,7 @@ def purge_queue( request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -902,7 +904,7 @@ def pause_queue( request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -984,7 +986,7 @@ def resume_queue( request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -1073,7 +1075,7 @@ def get_iam_policy( request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1206,7 +1208,7 @@ def set_iam_policy( request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1344,7 +1346,7 @@ def test_iam_permissions( *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1433,7 +1435,7 @@ def list_tasks( request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksPager: @@ -1523,7 +1525,7 @@ def get_task( request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1594,7 +1596,7 @@ def create_task( *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1722,7 +1724,7 @@ def delete_task( request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1791,7 +1793,7 @@ def lease_tasks( *, parent: str = None, lease_duration: duration_pb2.Duration = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloudtasks.LeaseTasksResponse: @@ -1919,7 +1921,7 @@ def acknowledge_task( *, name: str = None, schedule_time: timestamp_pb2.Timestamp = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -2016,7 +2018,7 @@ def renew_lease( name: str = None, schedule_time: timestamp_pb2.Timestamp = None, lease_duration: duration_pb2.Duration = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -2120,7 +2122,7 @@ def cancel_lease( *, name: str = None, schedule_time: timestamp_pb2.Timestamp = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -2213,7 +2215,7 @@ def run_task( request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py index f3303865..39995981 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -42,15 +41,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class CloudTasksTransport(abc.ABC): """Abstract transport class for CloudTasks.""" @@ -100,7 +90,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -133,29 +123,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py index f29e3aa1..989147ff 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/tasks_v2beta2/types/queue.py b/google/cloud/tasks_v2beta2/types/queue.py index 085bd4be..e8eaccda 100644 --- a/google/cloud/tasks_v2beta2/types/queue.py +++ b/google/cloud/tasks_v2beta2/types/queue.py @@ -32,6 +32,13 @@ class Queue(proto.Message): Configurable properties include rate limits, retry options, target types, and others. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Caller-specified and required in @@ -61,11 +68,13 @@ class Queue(proto.Message): An App Engine queue is a queue that has an [AppEngineHttpTarget][google.cloud.tasks.v2beta2.AppEngineHttpTarget]. + This field is a member of `oneof`_ ``target_type``. pull_target (google.cloud.tasks_v2beta2.types.PullTarget): Pull target. A pull queue is a queue that has a [PullTarget][google.cloud.tasks.v2beta2.PullTarget]. + This field is a member of `oneof`_ ``target_type``. rate_limits (google.cloud.tasks_v2beta2.types.RateLimits): Rate limits for task dispatches. @@ -285,6 +294,13 @@ class RetryConfig(proto.Message): r"""Retry config. These settings determine how a failed task attempt is retried. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: max_attempts (int): The maximum number of attempts for a task. @@ -292,9 +308,11 @@ class RetryConfig(proto.Message): Cloud Tasks will attempt the task ``max_attempts`` times (that is, if the first attempt fails, then there will be ``max_attempts - 1`` retries). Must be > 0. + This field is a member of `oneof`_ ``num_attempts``. unlimited_attempts (bool): If true, then the number of attempts is unlimited. + This field is a member of `oneof`_ ``num_attempts``. max_retry_duration (google.protobuf.duration_pb2.Duration): If positive, ``max_retry_duration`` specifies the time limit for retrying a failed task, measured from when the task was diff --git a/google/cloud/tasks_v2beta2/types/task.py b/google/cloud/tasks_v2beta2/types/task.py index 86463e38..c5f65760 100644 --- a/google/cloud/tasks_v2beta2/types/task.py +++ b/google/cloud/tasks_v2beta2/types/task.py @@ -29,6 +29,13 @@ class Task(proto.Message): r"""A unit of scheduled work. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Optionally caller-specified in @@ -64,6 +71,7 @@ class Task(proto.Message): An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest] set. + This field is a member of `oneof`_ ``payload_type``. pull_message (google.cloud.tasks_v2beta2.types.PullMessage): [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] to process the task. Can be set only if @@ -72,6 +80,7 @@ class Task(proto.Message): A pull task is a task that has [PullMessage][google.cloud.tasks.v2beta2.PullMessage] set. + This field is a member of `oneof`_ ``payload_type``. schedule_time (google.protobuf.timestamp_pb2.Timestamp): The time when the task is scheduled to be attempted. diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py index a7cd3ba0..cd05f11e 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -171,10 +173,10 @@ def __init__( async def list_queues( self, - request: cloudtasks.ListQueuesRequest = None, + request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesAsyncPager: @@ -182,7 +184,7 @@ async def list_queues( Queues are returned in lexicographical order. Args: - request (:class:`google.cloud.tasks_v2beta3.types.ListQueuesRequest`): + request (Union[google.cloud.tasks_v2beta3.types.ListQueuesRequest, dict]): The request object. Request message for [ListQueues][google.cloud.tasks.v2beta3.CloudTasks.ListQueues]. parent (:class:`str`): @@ -262,17 +264,17 @@ async def list_queues( async def get_queue( self, - request: cloudtasks.GetQueueRequest = None, + request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: r"""Gets a queue. Args: - request (:class:`google.cloud.tasks_v2beta3.types.GetQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.GetQueueRequest, dict]): The request object. Request message for [GetQueue][google.cloud.tasks.v2beta3.CloudTasks.GetQueue]. name (:class:`str`): @@ -347,11 +349,11 @@ async def get_queue( async def create_queue( self, - request: cloudtasks.CreateQueueRequest = None, + request: Union[cloudtasks.CreateQueueRequest, dict] = None, *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -368,7 +370,7 @@ async def create_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta3.types.CreateQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.CreateQueueRequest, dict]): The request object. Request message for [CreateQueue][google.cloud.tasks.v2beta3.CloudTasks.CreateQueue]. parent (:class:`str`): @@ -449,11 +451,11 @@ async def create_queue( async def update_queue( self, - request: cloudtasks.UpdateQueueRequest = None, + request: Union[cloudtasks.UpdateQueueRequest, dict] = None, *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -473,7 +475,7 @@ async def update_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta3.types.UpdateQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.UpdateQueueRequest, dict]): The request object. Request message for [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue]. queue (:class:`google.cloud.tasks_v2beta3.types.Queue`): @@ -560,10 +562,10 @@ async def update_queue( async def delete_queue( self, - request: cloudtasks.DeleteQueueRequest = None, + request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -581,7 +583,7 @@ async def delete_queue( before using this method. Args: - request (:class:`google.cloud.tasks_v2beta3.types.DeleteQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.DeleteQueueRequest, dict]): The request object. Request message for [DeleteQueue][google.cloud.tasks.v2beta3.CloudTasks.DeleteQueue]. name (:class:`str`): @@ -645,10 +647,10 @@ async def delete_queue( async def purge_queue( self, - request: cloudtasks.PurgeQueueRequest = None, + request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -660,7 +662,7 @@ async def purge_queue( effect. A purge is irreversible. Args: - request (:class:`google.cloud.tasks_v2beta3.types.PurgeQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.PurgeQueueRequest, dict]): The request object. Request message for [PurgeQueue][google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue]. name (:class:`str`): @@ -725,10 +727,10 @@ async def purge_queue( async def pause_queue( self, - request: cloudtasks.PauseQueueRequest = None, + request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -742,7 +744,7 @@ async def pause_queue( [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. Args: - request (:class:`google.cloud.tasks_v2beta3.types.PauseQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.PauseQueueRequest, dict]): The request object. Request message for [PauseQueue][google.cloud.tasks.v2beta3.CloudTasks.PauseQueue]. name (:class:`str`): @@ -807,10 +809,10 @@ async def pause_queue( async def resume_queue( self, - request: cloudtasks.ResumeQueueRequest = None, + request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -831,7 +833,7 @@ async def resume_queue( Risks `__. Args: - request (:class:`google.cloud.tasks_v2beta3.types.ResumeQueueRequest`): + request (Union[google.cloud.tasks_v2beta3.types.ResumeQueueRequest, dict]): The request object. Request message for [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue]. name (:class:`str`): @@ -896,10 +898,10 @@ async def resume_queue( async def get_iam_policy( self, - request: iam_policy_pb2.GetIamPolicyRequest = None, + request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -914,7 +916,7 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.GetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` method. resource (:class:`str`): @@ -1040,10 +1042,10 @@ async def get_iam_policy( async def set_iam_policy( self, - request: iam_policy_pb2.SetIamPolicyRequest = None, + request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1062,7 +1064,7 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` Args: - request (:class:`google.iam.v1.iam_policy_pb2.SetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` method. resource (:class:`str`): @@ -1178,11 +1180,11 @@ async def set_iam_policy( async def test_iam_permissions( self, - request: iam_policy_pb2.TestIamPermissionsRequest = None, + request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None, *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1197,7 +1199,7 @@ async def test_iam_permissions( warning. Args: - request (:class:`google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest`): + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for `TestIamPermissions` method. resource (:class:`str`): @@ -1279,10 +1281,10 @@ async def test_iam_permissions( async def list_tasks( self, - request: cloudtasks.ListTasksRequest = None, + request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksAsyncPager: @@ -1298,7 +1300,7 @@ async def list_tasks( at any time. Args: - request (:class:`google.cloud.tasks_v2beta3.types.ListTasksRequest`): + request (Union[google.cloud.tasks_v2beta3.types.ListTasksRequest, dict]): The request object. Request message for listing tasks using [ListTasks][google.cloud.tasks.v2beta3.CloudTasks.ListTasks]. @@ -1379,17 +1381,17 @@ async def list_tasks( async def get_task( self, - request: cloudtasks.GetTaskRequest = None, + request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: r"""Gets a task. Args: - request (:class:`google.cloud.tasks_v2beta3.types.GetTaskRequest`): + request (Union[google.cloud.tasks_v2beta3.types.GetTaskRequest, dict]): The request object. Request message for getting a task using [GetTask][google.cloud.tasks.v2beta3.CloudTasks.GetTask]. @@ -1459,11 +1461,11 @@ async def get_task( async def create_task( self, - request: cloudtasks.CreateTaskRequest = None, + request: Union[cloudtasks.CreateTaskRequest, dict] = None, *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1475,7 +1477,7 @@ async def create_task( - The maximum task size is 100KB. Args: - request (:class:`google.cloud.tasks_v2beta3.types.CreateTaskRequest`): + request (Union[google.cloud.tasks_v2beta3.types.CreateTaskRequest, dict]): The request object. Request message for [CreateTask][google.cloud.tasks.v2beta3.CloudTasks.CreateTask]. parent (:class:`str`): @@ -1584,10 +1586,10 @@ async def create_task( async def delete_task( self, - request: cloudtasks.DeleteTaskRequest = None, + request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1597,7 +1599,7 @@ async def delete_task( or permanently failed. Args: - request (:class:`google.cloud.tasks_v2beta3.types.DeleteTaskRequest`): + request (Union[google.cloud.tasks_v2beta3.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task using [DeleteTask][google.cloud.tasks.v2beta3.CloudTasks.DeleteTask]. @@ -1662,10 +1664,10 @@ async def delete_task( async def run_task( self, - request: cloudtasks.RunTaskRequest = None, + request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1699,7 +1701,7 @@ async def run_task( task that has already succeeded or permanently failed. Args: - request (:class:`google.cloud.tasks_v2beta3.types.RunTaskRequest`): + request (Union[google.cloud.tasks_v2beta3.types.RunTaskRequest, dict]): The request object. Request message for forcing a task to run now using [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask]. diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py index 4379426f..66d0ea5f 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -378,7 +380,7 @@ def list_queues( request: Union[cloudtasks.ListQueuesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListQueuesPager: @@ -459,7 +461,7 @@ def get_queue( request: Union[cloudtasks.GetQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -535,7 +537,7 @@ def create_queue( *, parent: str = None, queue: gct_queue.Queue = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -637,7 +639,7 @@ def update_queue( *, queue: gct_queue.Queue = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_queue.Queue: @@ -747,7 +749,7 @@ def delete_queue( request: Union[cloudtasks.DeleteQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -822,7 +824,7 @@ def purge_queue( request: Union[cloudtasks.PurgeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -902,7 +904,7 @@ def pause_queue( request: Union[cloudtasks.PauseQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -984,7 +986,7 @@ def resume_queue( request: Union[cloudtasks.ResumeQueueRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> queue.Queue: @@ -1073,7 +1075,7 @@ def get_iam_policy( request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1206,7 +1208,7 @@ def set_iam_policy( request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1344,7 +1346,7 @@ def test_iam_permissions( *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1433,7 +1435,7 @@ def list_tasks( request: Union[cloudtasks.ListTasksRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTasksPager: @@ -1523,7 +1525,7 @@ def get_task( request: Union[cloudtasks.GetTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: @@ -1594,7 +1596,7 @@ def create_task( *, parent: str = None, task: gct_task.Task = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gct_task.Task: @@ -1718,7 +1720,7 @@ def delete_task( request: Union[cloudtasks.DeleteTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1786,7 +1788,7 @@ def run_task( request: Union[cloudtasks.RunTaskRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> task.Task: diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py index e8e9dbd4..050ec955 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -42,15 +41,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class CloudTasksTransport(abc.ABC): """Abstract transport class for CloudTasks.""" @@ -100,7 +90,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -133,29 +123,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py index 30d565b7..542d9ade 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/tasks_v2beta3/types/queue.py b/google/cloud/tasks_v2beta3/types/queue.py index b8cdcfc4..ef4455a6 100644 --- a/google/cloud/tasks_v2beta3/types/queue.py +++ b/google/cloud/tasks_v2beta3/types/queue.py @@ -38,6 +38,9 @@ class Queue(proto.Message): Configurable properties include rate limits, retry options, queue types, and others. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Caller-specified and required in @@ -69,6 +72,7 @@ class Queue(proto.Message): this queue. [Http tasks][google.cloud.tasks.v2beta3.HttpRequest] are not affected by this proto. + This field is a member of `oneof`_ ``queue_type``. rate_limits (google.cloud.tasks_v2beta3.types.RateLimits): Rate limits for task dispatches. diff --git a/google/cloud/tasks_v2beta3/types/target.py b/google/cloud/tasks_v2beta3/types/target.py index e75ef387..d1899617 100644 --- a/google/cloud/tasks_v2beta3/types/target.py +++ b/google/cloud/tasks_v2beta3/types/target.py @@ -111,6 +111,13 @@ class HttpRequest(proto.Message): queue being unpaused, or many tasks that are scheduled at the same time). + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: url (str): Required. The full url path that the request will be sent @@ -177,6 +184,7 @@ class HttpRequest(proto.Message): This type of authorization should generally only be used when calling Google APIs hosted on \*.googleapis.com. + This field is a member of `oneof`_ ``authorization_header``. oidc_token (google.cloud.tasks_v2beta3.types.OidcToken): If specified, an `OIDC `__ @@ -186,6 +194,7 @@ class HttpRequest(proto.Message): This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself. + This field is a member of `oneof`_ ``authorization_header``. """ url = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/tasks_v2beta3/types/task.py b/google/cloud/tasks_v2beta3/types/task.py index 38c83a4b..a567cd8f 100644 --- a/google/cloud/tasks_v2beta3/types/task.py +++ b/google/cloud/tasks_v2beta3/types/task.py @@ -29,6 +29,13 @@ class Task(proto.Message): r"""A unit of scheduled work. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Optionally caller-specified in @@ -61,11 +68,13 @@ class Task(proto.Message): An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta3.AppEngineHttpRequest] set. + This field is a member of `oneof`_ ``payload_type``. http_request (google.cloud.tasks_v2beta3.types.HttpRequest): HTTP request that is sent to the task's target. An HTTP task is a task that has [HttpRequest][google.cloud.tasks.v2beta3.HttpRequest] set. + This field is a member of `oneof`_ ``payload_type``. pull_message (google.cloud.tasks_v2beta3.types.PullMessage): Pull Message contained in a task in a [PULL][google.cloud.tasks.v2beta3.Queue.type] queue type. @@ -76,6 +85,7 @@ class Task(proto.Message): queues to provide a way to inspect contents of pull tasks through the [CloudTasks.GetTask][google.cloud.tasks.v2beta3.CloudTasks.GetTask]. + This field is a member of `oneof`_ ``payload_type``. schedule_time (google.protobuf.timestamp_pb2.Timestamp): The time when the task is scheduled to be attempted. diff --git a/setup.py b/setup.py index bf9d3bfb..4826e29c 100644 --- a/setup.py +++ b/setup.py @@ -27,10 +27,9 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", "proto-plus >= 0.4.0", - "packaging >= 14.3", ] extras = {"libcst": "libcst >= 0.2.5"} diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index c4ecfd63..17787c01 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,9 +5,7 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 grpc-google-iam-v1==0.12.3 proto-plus==0.4.0 libcst==0.2.5 -packaging==14.3 -google-auth==1.24.0 # TODO: remove after google-auth>=1.25.0 is transitively required through google-api-core diff --git a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py index 53f8ab22..3531564f 100644 --- a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,9 +35,6 @@ from google.cloud.tasks_v2.services.cloud_tasks import CloudTasksClient from google.cloud.tasks_v2.services.cloud_tasks import pagers from google.cloud.tasks_v2.services.cloud_tasks import transports -from google.cloud.tasks_v2.services.cloud_tasks.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue from google.cloud.tasks_v2.types import queue as gct_queue @@ -58,20 +54,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -219,7 +201,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -236,7 +218,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -253,7 +235,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -282,7 +264,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -339,7 +321,7 @@ def test_cloud_tasks_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -381,7 +363,7 @@ def test_cloud_tasks_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -403,7 +385,7 @@ def test_cloud_tasks_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -434,7 +416,7 @@ def test_cloud_tasks_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -465,7 +447,7 @@ def test_cloud_tasks_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4096,7 +4078,6 @@ def test_cloud_tasks_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -4117,26 +4098,6 @@ def test_cloud_tasks_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.tasks_v2.services.cloud_tasks.transports.CloudTasksTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_cloud_tasks_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -4148,7 +4109,6 @@ def test_cloud_tasks_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -4161,23 +4121,10 @@ def test_cloud_tasks_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CloudTasksClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -4191,23 +4138,6 @@ def test_cloud_tasks_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py index 4e093123..d3c4871f 100644 --- a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,9 +35,6 @@ from google.cloud.tasks_v2beta2.services.cloud_tasks import CloudTasksClient from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers from google.cloud.tasks_v2beta2.services.cloud_tasks import transports -from google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue from google.cloud.tasks_v2beta2.types import queue as gct_queue @@ -58,20 +54,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -219,7 +201,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -236,7 +218,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -253,7 +235,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -282,7 +264,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -339,7 +321,7 @@ def test_cloud_tasks_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -381,7 +363,7 @@ def test_cloud_tasks_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -403,7 +385,7 @@ def test_cloud_tasks_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -434,7 +416,7 @@ def test_cloud_tasks_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -465,7 +447,7 @@ def test_cloud_tasks_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4953,7 +4935,6 @@ def test_cloud_tasks_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -4974,26 +4955,6 @@ def test_cloud_tasks_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.tasks_v2beta2.services.cloud_tasks.transports.CloudTasksTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_cloud_tasks_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -5005,7 +4966,6 @@ def test_cloud_tasks_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -5018,23 +4978,10 @@ def test_cloud_tasks_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CloudTasksClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -5048,23 +4995,6 @@ def test_cloud_tasks_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py index c600963e..b011faf9 100644 --- a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,9 +35,6 @@ from google.cloud.tasks_v2beta3.services.cloud_tasks import CloudTasksClient from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers from google.cloud.tasks_v2beta3.services.cloud_tasks import transports -from google.cloud.tasks_v2beta3.services.cloud_tasks.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue from google.cloud.tasks_v2beta3.types import queue as gct_queue @@ -58,20 +54,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -219,7 +201,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -236,7 +218,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -253,7 +235,7 @@ def test_cloud_tasks_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -282,7 +264,7 @@ def test_cloud_tasks_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -339,7 +321,7 @@ def test_cloud_tasks_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -381,7 +363,7 @@ def test_cloud_tasks_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -403,7 +385,7 @@ def test_cloud_tasks_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -434,7 +416,7 @@ def test_cloud_tasks_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -465,7 +447,7 @@ def test_cloud_tasks_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4174,7 +4156,6 @@ def test_cloud_tasks_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -4195,26 +4176,6 @@ def test_cloud_tasks_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.tasks_v2beta3.services.cloud_tasks.transports.CloudTasksTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_cloud_tasks_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -4226,7 +4187,6 @@ def test_cloud_tasks_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -4239,23 +4199,10 @@ def test_cloud_tasks_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CloudTasksClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -4269,23 +4216,6 @@ def test_cloud_tasks_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_cloud_tasks_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [