From a294177e4d23f35e60fdcaa2023efea9bce366a4 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:00:18 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#110) - [ ] 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/executions/async_client.py | 28 +++--- .../services/executions/client.py | 10 ++- .../services/executions/transports/base.py | 35 +------- .../executions/transports/grpc_asyncio.py | 1 - .../services/executions/async_client.py | 28 +++--- .../services/executions/client.py | 10 ++- .../services/executions/transports/base.py | 35 +------- .../executions/transports/grpc_asyncio.py | 1 - .../services/workflows/async_client.py | 34 +++---- .../workflows_v1/services/workflows/client.py | 12 +-- .../services/workflows/transports/base.py | 37 +------- .../services/workflows/transports/grpc.py | 2 +- .../workflows/transports/grpc_asyncio.py | 3 +- google/cloud/workflows_v1/types/workflows.py | 3 + .../services/workflows/async_client.py | 34 +++---- .../services/workflows/client.py | 12 +-- .../services/workflows/transports/base.py | 37 +------- .../services/workflows/transports/grpc.py | 2 +- .../workflows/transports/grpc_asyncio.py | 3 +- .../cloud/workflows_v1beta/types/workflows.py | 3 + setup.py | 3 +- testing/constraints-3.6.txt | 4 +- .../gapic/executions_v1/test_executions.py | 88 ++----------------- .../executions_v1beta/test_executions.py | 88 ++----------------- .../unit/gapic/workflows_v1/test_workflows.py | 88 ++----------------- .../gapic/workflows_v1beta/test_workflows.py | 88 ++----------------- 26 files changed, 146 insertions(+), 543 deletions(-) diff --git a/google/cloud/workflows/executions_v1/services/executions/async_client.py b/google/cloud/workflows/executions_v1/services/executions/async_client.py index 1fcf9f4..ff1605f 100644 --- a/google/cloud/workflows/executions_v1/services/executions/async_client.py +++ b/google/cloud/workflows/executions_v1/services/executions/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.workflows.executions_v1.services.executions import pagers from google.cloud.workflows.executions_v1.types import executions from google.protobuf import timestamp_pb2 # type: ignore @@ -162,10 +164,10 @@ def __init__( async def list_executions( self, - request: executions.ListExecutionsRequest = None, + request: Union[executions.ListExecutionsRequest, 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.ListExecutionsAsyncPager: @@ -176,7 +178,7 @@ async def list_executions( first). Args: - request (:class:`google.cloud.workflows.executions_v1.types.ListExecutionsRequest`): + request (Union[google.cloud.workflows.executions_v1.types.ListExecutionsRequest, dict]): The request object. Request for the [ListExecutions][] method. @@ -250,11 +252,11 @@ async def list_executions( async def create_execution( self, - request: executions.CreateExecutionRequest = None, + request: Union[executions.CreateExecutionRequest, dict] = None, *, parent: str = None, execution: executions.Execution = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> executions.Execution: @@ -262,7 +264,7 @@ async def create_execution( the given workflow. Args: - request (:class:`google.cloud.workflows.executions_v1.types.CreateExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1.types.CreateExecutionRequest, dict]): The request object. Request for the [CreateExecution][google.cloud.workflows.executions.v1.Executions.CreateExecution] method. @@ -335,17 +337,17 @@ async def create_execution( async def get_execution( self, - request: executions.GetExecutionRequest = None, + request: Union[executions.GetExecutionRequest, 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]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. Args: - request (:class:`google.cloud.workflows.executions_v1.types.GetExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1.types.GetExecutionRequest, dict]): The request object. Request for the [GetExecution][google.cloud.workflows.executions.v1.Executions.GetExecution] method. @@ -408,17 +410,17 @@ async def get_execution( async def cancel_execution( self, - request: executions.CancelExecutionRequest = None, + request: Union[executions.CancelExecutionRequest, 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]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. Args: - request (:class:`google.cloud.workflows.executions_v1.types.CancelExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1.types.CancelExecutionRequest, dict]): The request object. Request for the [CancelExecution][google.cloud.workflows.executions.v1.Executions.CancelExecution] method. diff --git a/google/cloud/workflows/executions_v1/services/executions/client.py b/google/cloud/workflows/executions_v1/services/executions/client.py index 5938c21..584f81a 100644 --- a/google/cloud/workflows/executions_v1/services/executions/client.py +++ b/google/cloud/workflows/executions_v1/services/executions/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.workflows.executions_v1.services.executions import pagers from google.cloud.workflows.executions_v1.types import executions from google.protobuf import timestamp_pb2 # type: ignore @@ -371,7 +373,7 @@ def list_executions( request: Union[executions.ListExecutionsRequest, 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.ListExecutionsPager: @@ -460,7 +462,7 @@ def create_execution( *, parent: str = None, execution: executions.Execution = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> executions.Execution: @@ -544,7 +546,7 @@ def get_execution( request: Union[executions.GetExecutionRequest, 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]] = (), ) -> executions.Execution: @@ -617,7 +619,7 @@ def cancel_execution( request: Union[executions.CancelExecutionRequest, 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]] = (), ) -> executions.Execution: diff --git a/google/cloud/workflows/executions_v1/services/executions/transports/base.py b/google/cloud/workflows/executions_v1/services/executions/transports/base.py index 139193c..e06f16a 100644 --- a/google/cloud/workflows/executions_v1/services/executions/transports/base.py +++ b/google/cloud/workflows/executions_v1/services/executions/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 @@ -35,15 +34,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 ExecutionsTransport(abc.ABC): """Abstract transport class for Executions.""" @@ -93,7 +83,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 @@ -126,29 +116,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/workflows/executions_v1/services/executions/transports/grpc_asyncio.py b/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py index da997e1..7601fa8 100644 --- a/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py +++ b/google/cloud/workflows/executions_v1/services/executions/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/workflows/executions_v1beta/services/executions/async_client.py b/google/cloud/workflows/executions_v1beta/services/executions/async_client.py index 8a0b571..c0ab2be 100644 --- a/google/cloud/workflows/executions_v1beta/services/executions/async_client.py +++ b/google/cloud/workflows/executions_v1beta/services/executions/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.workflows.executions_v1beta.services.executions import pagers from google.cloud.workflows.executions_v1beta.types import executions from google.protobuf import timestamp_pb2 # type: ignore @@ -163,10 +165,10 @@ def __init__( async def list_executions( self, - request: executions.ListExecutionsRequest = None, + request: Union[executions.ListExecutionsRequest, 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.ListExecutionsAsyncPager: @@ -177,7 +179,7 @@ async def list_executions( first). Args: - request (:class:`google.cloud.workflows.executions_v1beta.types.ListExecutionsRequest`): + request (Union[google.cloud.workflows.executions_v1beta.types.ListExecutionsRequest, dict]): The request object. Request for the [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] method. @@ -251,11 +253,11 @@ async def list_executions( async def create_execution( self, - request: executions.CreateExecutionRequest = None, + request: Union[executions.CreateExecutionRequest, dict] = None, *, parent: str = None, execution: executions.Execution = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> executions.Execution: @@ -263,7 +265,7 @@ async def create_execution( the given workflow. Args: - request (:class:`google.cloud.workflows.executions_v1beta.types.CreateExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1beta.types.CreateExecutionRequest, dict]): The request object. Request for the [CreateExecution][google.cloud.workflows.executions.v1beta.Executions.CreateExecution] method. @@ -336,17 +338,17 @@ async def create_execution( async def get_execution( self, - request: executions.GetExecutionRequest = None, + request: Union[executions.GetExecutionRequest, 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]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. Args: - request (:class:`google.cloud.workflows.executions_v1beta.types.GetExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1beta.types.GetExecutionRequest, dict]): The request object. Request for the [GetExecution][google.cloud.workflows.executions.v1beta.Executions.GetExecution] method. @@ -409,17 +411,17 @@ async def get_execution( async def cancel_execution( self, - request: executions.CancelExecutionRequest = None, + request: Union[executions.CancelExecutionRequest, 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]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. Args: - request (:class:`google.cloud.workflows.executions_v1beta.types.CancelExecutionRequest`): + request (Union[google.cloud.workflows.executions_v1beta.types.CancelExecutionRequest, dict]): The request object. Request for the [CancelExecution][google.cloud.workflows.executions.v1beta.Executions.CancelExecution] method. diff --git a/google/cloud/workflows/executions_v1beta/services/executions/client.py b/google/cloud/workflows/executions_v1beta/services/executions/client.py index f0fec3c..d294c2b 100644 --- a/google/cloud/workflows/executions_v1beta/services/executions/client.py +++ b/google/cloud/workflows/executions_v1beta/services/executions/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.workflows.executions_v1beta.services.executions import pagers from google.cloud.workflows.executions_v1beta.types import executions from google.protobuf import timestamp_pb2 # type: ignore @@ -372,7 +374,7 @@ def list_executions( request: Union[executions.ListExecutionsRequest, 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.ListExecutionsPager: @@ -461,7 +463,7 @@ def create_execution( *, parent: str = None, execution: executions.Execution = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> executions.Execution: @@ -545,7 +547,7 @@ def get_execution( request: Union[executions.GetExecutionRequest, 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]] = (), ) -> executions.Execution: @@ -618,7 +620,7 @@ def cancel_execution( request: Union[executions.CancelExecutionRequest, 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]] = (), ) -> executions.Execution: diff --git a/google/cloud/workflows/executions_v1beta/services/executions/transports/base.py b/google/cloud/workflows/executions_v1beta/services/executions/transports/base.py index 191d144..6e779e9 100644 --- a/google/cloud/workflows/executions_v1beta/services/executions/transports/base.py +++ b/google/cloud/workflows/executions_v1beta/services/executions/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 @@ -35,15 +34,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 ExecutionsTransport(abc.ABC): """Abstract transport class for Executions.""" @@ -93,7 +83,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 @@ -126,29 +116,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/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py b/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py index 2f6710d..4050dae 100644 --- a/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py +++ b/google/cloud/workflows/executions_v1beta/services/executions/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/workflows_v1/services/workflows/async_client.py b/google/cloud/workflows_v1/services/workflows/async_client.py index 01eb68f..5118c7e 100644 --- a/google/cloud/workflows_v1/services/workflows/async_client.py +++ b/google/cloud/workflows_v1/services/workflows/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.workflows_v1.services.workflows import pagers @@ -165,10 +167,10 @@ def __init__( async def list_workflows( self, - request: workflows.ListWorkflowsRequest = None, + request: Union[workflows.ListWorkflowsRequest, 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.ListWorkflowsAsyncPager: @@ -176,7 +178,7 @@ async def list_workflows( The default order is not specified. Args: - request (:class:`google.cloud.workflows_v1.types.ListWorkflowsRequest`): + request (Union[google.cloud.workflows_v1.types.ListWorkflowsRequest, dict]): The request object. Request for the [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows] method. @@ -250,17 +252,17 @@ async def list_workflows( async def get_workflow( self, - request: workflows.GetWorkflowRequest = None, + request: Union[workflows.GetWorkflowRequest, 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]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. Args: - request (:class:`google.cloud.workflows_v1.types.GetWorkflowRequest`): + request (Union[google.cloud.workflows_v1.types.GetWorkflowRequest, dict]): The request object. Request for the [GetWorkflow][google.cloud.workflows.v1.Workflows.GetWorkflow] method. @@ -323,12 +325,12 @@ async def get_workflow( async def create_workflow( self, - request: workflows.CreateWorkflowRequest = None, + request: Union[workflows.CreateWorkflowRequest, dict] = None, *, parent: str = None, workflow: workflows.Workflow = None, workflow_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -338,7 +340,7 @@ async def create_workflow( [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. Args: - request (:class:`google.cloud.workflows_v1.types.CreateWorkflowRequest`): + request (Union[google.cloud.workflows_v1.types.CreateWorkflowRequest, dict]): The request object. Request for the [CreateWorkflow][google.cloud.workflows.v1.Workflows.CreateWorkflow] method. @@ -437,10 +439,10 @@ async def create_workflow( async def delete_workflow( self, - request: workflows.DeleteWorkflowRequest = None, + request: Union[workflows.DeleteWorkflowRequest, 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]] = (), ) -> operation_async.AsyncOperation: @@ -449,7 +451,7 @@ async def delete_workflow( executions of the workflow. Args: - request (:class:`google.cloud.workflows_v1.types.DeleteWorkflowRequest`): + request (Union[google.cloud.workflows_v1.types.DeleteWorkflowRequest, dict]): The request object. Request for the [DeleteWorkflow][google.cloud.workflows.v1.Workflows.DeleteWorkflow] method. @@ -533,11 +535,11 @@ async def delete_workflow( async def update_workflow( self, - request: workflows.UpdateWorkflowRequest = None, + request: Union[workflows.UpdateWorkflowRequest, dict] = None, *, workflow: workflows.Workflow = 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]] = (), ) -> operation_async.AsyncOperation: @@ -549,7 +551,7 @@ async def update_workflow( used in new workflow executions. Args: - request (:class:`google.cloud.workflows_v1.types.UpdateWorkflowRequest`): + request (Union[google.cloud.workflows_v1.types.UpdateWorkflowRequest, dict]): The request object. Request for the [UpdateWorkflow][google.cloud.workflows.v1.Workflows.UpdateWorkflow] method. diff --git a/google/cloud/workflows_v1/services/workflows/client.py b/google/cloud/workflows_v1/services/workflows/client.py index 964efae..19022d0 100644 --- a/google/cloud/workflows_v1/services/workflows/client.py +++ b/google/cloud/workflows_v1/services/workflows/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.workflows_v1.services.workflows import pagers @@ -358,7 +360,7 @@ def list_workflows( request: Union[workflows.ListWorkflowsRequest, 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.ListWorkflowsPager: @@ -443,7 +445,7 @@ def get_workflow( request: Union[workflows.GetWorkflowRequest, 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]] = (), ) -> workflows.Workflow: @@ -518,7 +520,7 @@ def create_workflow( parent: str = None, workflow: workflows.Workflow = None, workflow_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -630,7 +632,7 @@ def delete_workflow( request: Union[workflows.DeleteWorkflowRequest, 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]] = (), ) -> operation.Operation: @@ -727,7 +729,7 @@ def update_workflow( *, workflow: workflows.Workflow = 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]] = (), ) -> operation.Operation: diff --git a/google/cloud/workflows_v1/services/workflows/transports/base.py b/google/cloud/workflows_v1/services/workflows/transports/base.py index adb90a3..9a72531 100644 --- a/google/cloud/workflows_v1/services/workflows/transports/base.py +++ b/google/cloud/workflows_v1/services/workflows/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 @@ -37,15 +36,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 WorkflowsTransport(abc.ABC): """Abstract transport class for Workflows.""" @@ -95,7 +85,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 @@ -128,29 +118,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 = { @@ -181,7 +148,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/workflows_v1/services/workflows/transports/grpc.py b/google/cloud/workflows_v1/services/workflows/transports/grpc.py index e08aafc..0404663 100644 --- a/google/cloud/workflows_v1/services/workflows/transports/grpc.py +++ b/google/cloud/workflows_v1/services/workflows/transports/grpc.py @@ -114,7 +114,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py b/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py index 29b2bf0..0bc50a9 100644 --- a/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py +++ b/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # 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 @@ -161,7 +160,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/workflows_v1/types/workflows.py b/google/cloud/workflows_v1/types/workflows.py index 69a6efe..1aaef1f 100644 --- a/google/cloud/workflows_v1/types/workflows.py +++ b/google/cloud/workflows_v1/types/workflows.py @@ -37,6 +37,8 @@ class Workflow(proto.Message): r"""Workflow program to be executed by Workflows. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): The resource name of the workflow. @@ -97,6 +99,7 @@ class Workflow(proto.Message): source_contents (str): Workflow code to be executed. The size limit is 128KB. + This field is a member of `oneof`_ ``source_code``. """ class State(proto.Enum): diff --git a/google/cloud/workflows_v1beta/services/workflows/async_client.py b/google/cloud/workflows_v1beta/services/workflows/async_client.py index f15ca49..088829f 100644 --- a/google/cloud/workflows_v1beta/services/workflows/async_client.py +++ b/google/cloud/workflows_v1beta/services/workflows/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.workflows_v1beta.services.workflows import pagers @@ -165,10 +167,10 @@ def __init__( async def list_workflows( self, - request: workflows.ListWorkflowsRequest = None, + request: Union[workflows.ListWorkflowsRequest, 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.ListWorkflowsAsyncPager: @@ -176,7 +178,7 @@ async def list_workflows( The default order is not specified. Args: - request (:class:`google.cloud.workflows_v1beta.types.ListWorkflowsRequest`): + request (Union[google.cloud.workflows_v1beta.types.ListWorkflowsRequest, dict]): The request object. Request for the [ListWorkflows][google.cloud.workflows.v1beta.Workflows.ListWorkflows] method. @@ -250,17 +252,17 @@ async def list_workflows( async def get_workflow( self, - request: workflows.GetWorkflowRequest = None, + request: Union[workflows.GetWorkflowRequest, 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]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. Args: - request (:class:`google.cloud.workflows_v1beta.types.GetWorkflowRequest`): + request (Union[google.cloud.workflows_v1beta.types.GetWorkflowRequest, dict]): The request object. Request for the [GetWorkflow][google.cloud.workflows.v1beta.Workflows.GetWorkflow] method. @@ -323,12 +325,12 @@ async def get_workflow( async def create_workflow( self, - request: workflows.CreateWorkflowRequest = None, + request: Union[workflows.CreateWorkflowRequest, dict] = None, *, parent: str = None, workflow: workflows.Workflow = None, workflow_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -338,7 +340,7 @@ async def create_workflow( [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. Args: - request (:class:`google.cloud.workflows_v1beta.types.CreateWorkflowRequest`): + request (Union[google.cloud.workflows_v1beta.types.CreateWorkflowRequest, dict]): The request object. Request for the [CreateWorkflow][google.cloud.workflows.v1beta.Workflows.CreateWorkflow] method. @@ -437,10 +439,10 @@ async def create_workflow( async def delete_workflow( self, - request: workflows.DeleteWorkflowRequest = None, + request: Union[workflows.DeleteWorkflowRequest, 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]] = (), ) -> operation_async.AsyncOperation: @@ -449,7 +451,7 @@ async def delete_workflow( executions of the workflow. Args: - request (:class:`google.cloud.workflows_v1beta.types.DeleteWorkflowRequest`): + request (Union[google.cloud.workflows_v1beta.types.DeleteWorkflowRequest, dict]): The request object. Request for the [DeleteWorkflow][google.cloud.workflows.v1beta.Workflows.DeleteWorkflow] method. @@ -533,11 +535,11 @@ async def delete_workflow( async def update_workflow( self, - request: workflows.UpdateWorkflowRequest = None, + request: Union[workflows.UpdateWorkflowRequest, dict] = None, *, workflow: workflows.Workflow = 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]] = (), ) -> operation_async.AsyncOperation: @@ -549,7 +551,7 @@ async def update_workflow( used in new workflow executions. Args: - request (:class:`google.cloud.workflows_v1beta.types.UpdateWorkflowRequest`): + request (Union[google.cloud.workflows_v1beta.types.UpdateWorkflowRequest, dict]): The request object. Request for the [UpdateWorkflow][google.cloud.workflows.v1beta.Workflows.UpdateWorkflow] method. diff --git a/google/cloud/workflows_v1beta/services/workflows/client.py b/google/cloud/workflows_v1beta/services/workflows/client.py index c975a68..1be074a 100644 --- a/google/cloud/workflows_v1beta/services/workflows/client.py +++ b/google/cloud/workflows_v1beta/services/workflows/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.workflows_v1beta.services.workflows import pagers @@ -358,7 +360,7 @@ def list_workflows( request: Union[workflows.ListWorkflowsRequest, 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.ListWorkflowsPager: @@ -443,7 +445,7 @@ def get_workflow( request: Union[workflows.GetWorkflowRequest, 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]] = (), ) -> workflows.Workflow: @@ -518,7 +520,7 @@ def create_workflow( parent: str = None, workflow: workflows.Workflow = None, workflow_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -630,7 +632,7 @@ def delete_workflow( request: Union[workflows.DeleteWorkflowRequest, 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]] = (), ) -> operation.Operation: @@ -727,7 +729,7 @@ def update_workflow( *, workflow: workflows.Workflow = 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]] = (), ) -> operation.Operation: diff --git a/google/cloud/workflows_v1beta/services/workflows/transports/base.py b/google/cloud/workflows_v1beta/services/workflows/transports/base.py index 76c8529..210ab3f 100644 --- a/google/cloud/workflows_v1beta/services/workflows/transports/base.py +++ b/google/cloud/workflows_v1beta/services/workflows/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 @@ -37,15 +36,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 WorkflowsTransport(abc.ABC): """Abstract transport class for Workflows.""" @@ -95,7 +85,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 @@ -128,29 +118,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 = { @@ -181,7 +148,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py b/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py index 7888fbc..64e243c 100644 --- a/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py +++ b/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py @@ -114,7 +114,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py b/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py index 5e721d3..c3c56f3 100644 --- a/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py +++ b/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # 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 @@ -161,7 +160,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/workflows_v1beta/types/workflows.py b/google/cloud/workflows_v1beta/types/workflows.py index 1cdd498..f7d4dda 100644 --- a/google/cloud/workflows_v1beta/types/workflows.py +++ b/google/cloud/workflows_v1beta/types/workflows.py @@ -37,6 +37,8 @@ class Workflow(proto.Message): r"""Workflow program to be executed by Workflows. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): The resource name of the workflow. @@ -94,6 +96,7 @@ class Workflow(proto.Message): source_contents (str): Workflow code to be executed. The size limit is 32KB. + This field is a member of `oneof`_ ``source_code``. """ class State(proto.Enum): diff --git a/setup.py b/setup.py index b448d74..d9942cf 100644 --- a/setup.py +++ b/setup.py @@ -49,10 +49,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", "libcst >= 0.2.5", "proto-plus >= 1.4.0", - "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 9371b39..96d3604 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,8 +5,6 @@ # # 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 libcst==0.2.5 proto-plus==1.4.0 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is required through google-api-core diff --git a/tests/unit/gapic/executions_v1/test_executions.py b/tests/unit/gapic/executions_v1/test_executions.py index b24a12d..41a5ffa 100644 --- a/tests/unit/gapic/executions_v1/test_executions.py +++ b/tests/unit/gapic/executions_v1/test_executions.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -38,29 +37,12 @@ from google.cloud.workflows.executions_v1.services.executions import ExecutionsClient from google.cloud.workflows.executions_v1.services.executions import pagers from google.cloud.workflows.executions_v1.services.executions import transports -from google.cloud.workflows.executions_v1.services.executions.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.workflows.executions_v1.types import executions from google.oauth2 import service_account from google.protobuf import timestamp_pb2 # type: ignore 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" @@ -208,7 +190,7 @@ def test_executions_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, @@ -225,7 +207,7 @@ def test_executions_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, @@ -242,7 +224,7 @@ def test_executions_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, @@ -271,7 +253,7 @@ def test_executions_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, @@ -328,7 +310,7 @@ def test_executions_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 @@ -370,7 +352,7 @@ def test_executions_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, @@ -392,7 +374,7 @@ def test_executions_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, @@ -423,7 +405,7 @@ def test_executions_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, @@ -454,7 +436,7 @@ def test_executions_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", @@ -1586,7 +1568,6 @@ def test_executions_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_executions_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1607,26 +1588,6 @@ def test_executions_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_executions_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.workflows.executions_v1.services.executions.transports.ExecutionsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ExecutionsTransport( - 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_executions_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( @@ -1638,7 +1599,6 @@ def test_executions_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_executions_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1651,23 +1611,10 @@ def test_executions_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_executions_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) - ExecutionsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.ExecutionsGrpcTransport, transports.ExecutionsGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_executions_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1681,23 +1628,6 @@ def test_executions_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.ExecutionsGrpcTransport, transports.ExecutionsGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_executions_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/executions_v1beta/test_executions.py b/tests/unit/gapic/executions_v1beta/test_executions.py index cdfdc08..520c76a 100644 --- a/tests/unit/gapic/executions_v1beta/test_executions.py +++ b/tests/unit/gapic/executions_v1beta/test_executions.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,29 +39,12 @@ ) from google.cloud.workflows.executions_v1beta.services.executions import pagers from google.cloud.workflows.executions_v1beta.services.executions import transports -from google.cloud.workflows.executions_v1beta.services.executions.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.workflows.executions_v1beta.types import executions from google.oauth2 import service_account from google.protobuf import timestamp_pb2 # type: ignore 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" @@ -210,7 +192,7 @@ def test_executions_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, @@ -227,7 +209,7 @@ def test_executions_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, @@ -244,7 +226,7 @@ def test_executions_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, @@ -273,7 +255,7 @@ def test_executions_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, @@ -330,7 +312,7 @@ def test_executions_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 @@ -372,7 +354,7 @@ def test_executions_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, @@ -394,7 +376,7 @@ def test_executions_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, @@ -425,7 +407,7 @@ def test_executions_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, @@ -456,7 +438,7 @@ def test_executions_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", @@ -1588,7 +1570,6 @@ def test_executions_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_executions_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1609,26 +1590,6 @@ def test_executions_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_executions_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.workflows.executions_v1beta.services.executions.transports.ExecutionsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ExecutionsTransport( - 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_executions_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( @@ -1640,7 +1601,6 @@ def test_executions_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_executions_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1653,23 +1613,10 @@ def test_executions_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_executions_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) - ExecutionsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.ExecutionsGrpcTransport, transports.ExecutionsGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_executions_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1683,23 +1630,6 @@ def test_executions_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.ExecutionsGrpcTransport, transports.ExecutionsGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_executions_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/workflows_v1/test_workflows.py b/tests/unit/gapic/workflows_v1/test_workflows.py index 0e6a8e1..65eaf88 100644 --- a/tests/unit/gapic/workflows_v1/test_workflows.py +++ b/tests/unit/gapic/workflows_v1/test_workflows.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.workflows_v1.services.workflows import WorkflowsClient from google.cloud.workflows_v1.services.workflows import pagers from google.cloud.workflows_v1.services.workflows import transports -from google.cloud.workflows_v1.services.workflows.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.workflows_v1.types import workflows from google.longrunning import operations_pb2 from google.oauth2 import service_account @@ -50,20 +46,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" @@ -207,7 +189,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -224,7 +206,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -241,7 +223,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -270,7 +252,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -327,7 +309,7 @@ def test_workflows_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 @@ -369,7 +351,7 @@ def test_workflows_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, @@ -391,7 +373,7 @@ def test_workflows_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, @@ -422,7 +404,7 @@ def test_workflows_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, @@ -453,7 +435,7 @@ def test_workflows_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", @@ -1767,7 +1749,6 @@ def test_workflows_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_workflows_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1788,26 +1769,6 @@ def test_workflows_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_workflows_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.workflows_v1.services.workflows.transports.WorkflowsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.WorkflowsTransport( - 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_workflows_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( @@ -1819,7 +1780,6 @@ def test_workflows_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_workflows_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1832,23 +1792,10 @@ def test_workflows_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_workflows_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) - WorkflowsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.WorkflowsGrpcTransport, transports.WorkflowsGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_workflows_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1862,23 +1809,6 @@ def test_workflows_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.WorkflowsGrpcTransport, transports.WorkflowsGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_workflows_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/workflows_v1beta/test_workflows.py b/tests/unit/gapic/workflows_v1beta/test_workflows.py index f9168cc..175ed7f 100644 --- a/tests/unit/gapic/workflows_v1beta/test_workflows.py +++ b/tests/unit/gapic/workflows_v1beta/test_workflows.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.workflows_v1beta.services.workflows import WorkflowsClient from google.cloud.workflows_v1beta.services.workflows import pagers from google.cloud.workflows_v1beta.services.workflows import transports -from google.cloud.workflows_v1beta.services.workflows.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.workflows_v1beta.types import workflows from google.longrunning import operations_pb2 from google.oauth2 import service_account @@ -50,20 +46,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" @@ -207,7 +189,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -224,7 +206,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -241,7 +223,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -270,7 +252,7 @@ def test_workflows_client_client_options(client_class, transport_class, transpor 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, @@ -327,7 +309,7 @@ def test_workflows_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 @@ -369,7 +351,7 @@ def test_workflows_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, @@ -391,7 +373,7 @@ def test_workflows_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, @@ -422,7 +404,7 @@ def test_workflows_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, @@ -453,7 +435,7 @@ def test_workflows_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", @@ -1767,7 +1749,6 @@ def test_workflows_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_workflows_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1788,26 +1769,6 @@ def test_workflows_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_workflows_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.workflows_v1beta.services.workflows.transports.WorkflowsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.WorkflowsTransport( - 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_workflows_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( @@ -1819,7 +1780,6 @@ def test_workflows_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_workflows_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1832,23 +1792,10 @@ def test_workflows_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_workflows_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) - WorkflowsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.WorkflowsGrpcTransport, transports.WorkflowsGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_workflows_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1862,23 +1809,6 @@ def test_workflows_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.WorkflowsGrpcTransport, transports.WorkflowsGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_workflows_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", [