From 7076c62bf0d9ba93c1ad2726978224f1f7402ab9 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 14:40:13 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#128) - [ ] 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 --- .../cloud_functions_service/async_client.py | 70 +++++++------- .../cloud_functions_service/client.py | 24 ++--- .../transports/base.py | 37 +------- .../transports/grpc.py | 2 +- .../transports/grpc_asyncio.py | 3 +- google/cloud/functions_v1/types/functions.py | 16 ++++ setup.py | 3 +- testing/constraints-3.6.txt | 6 +- .../test_cloud_functions_service.py | 91 ++----------------- 9 files changed, 80 insertions(+), 172 deletions(-) diff --git a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py b/google/cloud/functions_v1/services/cloud_functions_service/async_client.py index 50ef31b..ca6f0a0 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/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.functions_v1.services.cloud_functions_service import pagers @@ -178,9 +180,9 @@ def __init__( async def list_functions( self, - request: functions.ListFunctionsRequest = None, + request: Union[functions.ListFunctionsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListFunctionsAsyncPager: @@ -188,7 +190,7 @@ async def list_functions( requested project. Args: - request (:class:`google.cloud.functions_v1.types.ListFunctionsRequest`): + request (Union[google.cloud.functions_v1.types.ListFunctionsRequest, dict]): The request object. Request for the `ListFunctions` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -246,10 +248,10 @@ async def list_functions( async def get_function( self, - request: functions.GetFunctionRequest = None, + request: Union[functions.GetFunctionRequest, 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]] = (), ) -> functions.CloudFunction: @@ -257,7 +259,7 @@ async def get_function( requested project. Args: - request (:class:`google.cloud.functions_v1.types.GetFunctionRequest`): + request (Union[google.cloud.functions_v1.types.GetFunctionRequest, dict]): The request object. Request for the `GetFunction` method. name (:class:`str`): @@ -330,11 +332,11 @@ async def get_function( async def create_function( self, - request: functions.CreateFunctionRequest = None, + request: Union[functions.CreateFunctionRequest, dict] = None, *, location: str = None, function: functions.CloudFunction = 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: @@ -343,7 +345,7 @@ async def create_function( operation will return ``ALREADY_EXISTS`` error. Args: - request (:class:`google.cloud.functions_v1.types.CreateFunctionRequest`): + request (Union[google.cloud.functions_v1.types.CreateFunctionRequest, dict]): The request object. Request for the `CreateFunction` method. location (:class:`str`): @@ -423,17 +425,17 @@ async def create_function( async def update_function( self, - request: functions.UpdateFunctionRequest = None, + request: Union[functions.UpdateFunctionRequest, dict] = None, *, function: functions.CloudFunction = 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: r"""Updates existing function. Args: - request (:class:`google.cloud.functions_v1.types.UpdateFunctionRequest`): + request (Union[google.cloud.functions_v1.types.UpdateFunctionRequest, dict]): The request object. Request for the `UpdateFunction` method. function (:class:`google.cloud.functions_v1.types.CloudFunction`): @@ -517,10 +519,10 @@ async def update_function( async def delete_function( self, - request: functions.DeleteFunctionRequest = None, + request: Union[functions.DeleteFunctionRequest, 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: @@ -530,7 +532,7 @@ async def delete_function( function. Args: - request (:class:`google.cloud.functions_v1.types.DeleteFunctionRequest`): + request (Union[google.cloud.functions_v1.types.DeleteFunctionRequest, dict]): The request object. Request for the `DeleteFunction` method. name (:class:`str`): @@ -622,11 +624,11 @@ async def delete_function( async def call_function( self, - request: functions.CallFunctionRequest = None, + request: Union[functions.CallFunctionRequest, dict] = None, *, name: str = None, data: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.CallFunctionResponse: @@ -636,7 +638,7 @@ async def call_function( Limits `__. Args: - request (:class:`google.cloud.functions_v1.types.CallFunctionRequest`): + request (Union[google.cloud.functions_v1.types.CallFunctionRequest, dict]): The request object. Request for the `CallFunction` method. name (:class:`str`): @@ -704,9 +706,9 @@ async def call_function( async def generate_upload_url( self, - request: functions.GenerateUploadUrlRequest = None, + request: Union[functions.GenerateUploadUrlRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.GenerateUploadUrlResponse: @@ -740,7 +742,7 @@ async def generate_upload_url( - ``Authorization: Bearer YOUR_TOKEN`` Args: - request (:class:`google.cloud.functions_v1.types.GenerateUploadUrlRequest`): + request (Union[google.cloud.functions_v1.types.GenerateUploadUrlRequest, dict]): The request object. Request of `GenerateSourceUploadUrl` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -778,9 +780,9 @@ async def generate_upload_url( async def generate_download_url( self, - request: functions.GenerateDownloadUrlRequest = None, + request: Union[functions.GenerateDownloadUrlRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.GenerateDownloadUrlResponse: @@ -793,7 +795,7 @@ async def generate_download_url( control/signed-urls Args: - request (:class:`google.cloud.functions_v1.types.GenerateDownloadUrlRequest`): + request (Union[google.cloud.functions_v1.types.GenerateDownloadUrlRequest, dict]): The request object. Request of `GenerateDownloadUrl` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -831,9 +833,9 @@ async def generate_download_url( async def set_iam_policy( self, - request: iam_policy_pb2.SetIamPolicyRequest = None, + request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = 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: @@ -841,7 +843,7 @@ async def set_iam_policy( function. Replaces any existing policy. 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. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -937,9 +939,9 @@ async def set_iam_policy( async def get_iam_policy( self, - request: iam_policy_pb2.GetIamPolicyRequest = None, + request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = 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: @@ -948,7 +950,7 @@ async def get_iam_policy( not have a policy set. 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. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1044,9 +1046,9 @@ async def get_iam_policy( async def test_iam_permissions( self, - request: iam_policy_pb2.TestIamPermissionsRequest = None, + request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = 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: @@ -1055,7 +1057,7 @@ async def test_iam_permissions( return an empty set of permissions, not a NOT_FOUND error. 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. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/functions_v1/services/cloud_functions_service/client.py b/google/cloud/functions_v1/services/cloud_functions_service/client.py index 6b81864..c47deb7 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/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.functions_v1.services.cloud_functions_service import pagers @@ -363,7 +365,7 @@ def list_functions( self, request: Union[functions.ListFunctionsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListFunctionsPager: @@ -423,7 +425,7 @@ def get_function( request: Union[functions.GetFunctionRequest, 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]] = (), ) -> functions.CloudFunction: @@ -498,7 +500,7 @@ def create_function( *, location: str = None, function: functions.CloudFunction = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -590,7 +592,7 @@ def update_function( request: Union[functions.UpdateFunctionRequest, dict] = None, *, function: functions.CloudFunction = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -674,7 +676,7 @@ def delete_function( request: Union[functions.DeleteFunctionRequest, 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: @@ -770,7 +772,7 @@ def call_function( *, name: str = None, data: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.CallFunctionResponse: @@ -850,7 +852,7 @@ def generate_upload_url( self, request: Union[functions.GenerateUploadUrlRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.GenerateUploadUrlResponse: @@ -925,7 +927,7 @@ def generate_download_url( self, request: Union[functions.GenerateDownloadUrlRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> functions.GenerateDownloadUrlResponse: @@ -979,7 +981,7 @@ def set_iam_policy( self, request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = 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: @@ -1084,7 +1086,7 @@ def get_iam_policy( self, request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = 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: @@ -1190,7 +1192,7 @@ def test_iam_permissions( self, request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = 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: diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py index fa749c6..52ead42 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/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 @@ -39,15 +38,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 CloudFunctionsServiceTransport(abc.ABC): """Abstract transport class for CloudFunctionsService.""" @@ -97,7 +87,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 @@ -130,29 +120,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 = { @@ -253,7 +220,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/functions_v1/services/cloud_functions_service/transports/grpc.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py index 65db179..423a664 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py @@ -115,7 +115,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/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py index e65968e..bda271f 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/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 @@ -162,7 +161,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/functions_v1/types/functions.py b/google/cloud/functions_v1/types/functions.py index 8e20708..e4a5441 100644 --- a/google/cloud/functions_v1/types/functions.py +++ b/google/cloud/functions_v1/types/functions.py @@ -60,6 +60,13 @@ class CloudFunction(proto.Message): executed in response to an event. It encapsulate function and triggers configurations. + 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): A user-defined name of the function. Function names must be @@ -70,10 +77,12 @@ class CloudFunction(proto.Message): source_archive_url (str): The Google Cloud Storage URL, starting with ``gs://``, pointing to the zip archive which contains the function. + This field is a member of `oneof`_ ``source_code``. source_repository (google.cloud.functions_v1.types.SourceRepository): **Beta Feature** The source repository where a function is hosted. + This field is a member of `oneof`_ ``source_code``. source_upload_url (str): The Google Cloud Storage signed URL used for source uploading, generated by calling @@ -82,12 +91,15 @@ class CloudFunction(proto.Message): The signature is validated on write methods (Create, Update) The signature is stripped from the Function object on read methods (Get, List) + This field is a member of `oneof`_ ``source_code``. https_trigger (google.cloud.functions_v1.types.HttpsTrigger): An HTTPS endpoint type of source that can be triggered via URL. + This field is a member of `oneof`_ ``trigger``. event_trigger (google.cloud.functions_v1.types.EventTrigger): A source that fires events in response to a condition in another service. + This field is a member of `oneof`_ ``trigger``. status (google.cloud.functions_v1.types.CloudFunctionStatus): Output only. Status of the function deployment. @@ -351,10 +363,14 @@ class FailurePolicy(proto.Message): If empty, then defaults to ignoring failures (i.e. not retrying them). + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: retry (google.cloud.functions_v1.types.FailurePolicy.Retry): If specified, then the function will be retried in case of a failure. + This field is a member of `oneof`_ ``action``. """ class Retry(proto.Message): diff --git a/setup.py b/setup.py index 7e3e87a..3d55830 100644 --- a/setup.py +++ b/setup.py @@ -48,9 +48,8 @@ # 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", "proto-plus >= 1.10.0", - "packaging >= 14.3", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", ), python_requires=">=3.6", diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 7ee8dfc..2bbe8b4 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,10 +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 proto-plus==1.10.0 grpc-google-iam-v1==0.12.3 -packaging==14.3 -# TODO: remove once google-auth>=1.25.0 is required transitively -# through google-api-core>=1.28.0 -google-auth==1.24.0 diff --git a/tests/unit/gapic/functions_v1/test_cloud_functions_service.py b/tests/unit/gapic/functions_v1/test_cloud_functions_service.py index 7d36623..100d9a9 100644 --- a/tests/unit/gapic/functions_v1/test_cloud_functions_service.py +++ b/tests/unit/gapic/functions_v1/test_cloud_functions_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -43,9 +42,6 @@ ) from google.cloud.functions_v1.services.cloud_functions_service import pagers from google.cloud.functions_v1.services.cloud_functions_service import transports -from google.cloud.functions_v1.services.cloud_functions_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.functions_v1.types import functions from google.cloud.functions_v1.types import operations from google.iam.v1 import iam_policy_pb2 # type: ignore @@ -60,20 +56,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" @@ -235,7 +217,7 @@ def test_cloud_functions_service_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, @@ -252,7 +234,7 @@ def test_cloud_functions_service_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, @@ -269,7 +251,7 @@ def test_cloud_functions_service_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, @@ -298,7 +280,7 @@ def test_cloud_functions_service_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, @@ -367,7 +349,7 @@ def test_cloud_functions_service_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 @@ -409,7 +391,7 @@ def test_cloud_functions_service_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, @@ -431,7 +413,7 @@ def test_cloud_functions_service_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, @@ -466,7 +448,7 @@ def test_cloud_functions_service_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, @@ -501,7 +483,7 @@ def test_cloud_functions_service_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", @@ -2857,7 +2839,6 @@ def test_cloud_functions_service_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_cloud_functions_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2878,26 +2859,6 @@ def test_cloud_functions_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_functions_service_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.functions_v1.services.cloud_functions_service.transports.CloudFunctionsServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudFunctionsServiceTransport( - 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_functions_service_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( @@ -2909,7 +2870,6 @@ def test_cloud_functions_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_cloud_functions_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2922,18 +2882,6 @@ def test_cloud_functions_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_cloud_functions_service_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) - CloudFunctionsServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2941,7 +2889,6 @@ def test_cloud_functions_service_auth_adc_old_google_auth(): transports.CloudFunctionsServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_cloud_functions_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2955,26 +2902,6 @@ def test_cloud_functions_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.CloudFunctionsServiceGrpcTransport, - transports.CloudFunctionsServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_cloud_functions_service_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", [