From fd7fdd7f7ef666f1c9ff64ac27f98b4573a5d1f3 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 15:12:11 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#83) - [ ] 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/applications/async_client.py | 28 ++--- .../services/applications/client.py | 10 +- .../services/applications/transports/base.py | 37 +------ .../services/applications/transports/grpc.py | 2 +- .../applications/transports/grpc_asyncio.py | 3 +- .../authorized_certificates/async_client.py | 34 +++--- .../authorized_certificates/client.py | 12 +- .../transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - .../authorized_domains/async_client.py | 10 +- .../services/authorized_domains/client.py | 4 +- .../authorized_domains/transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - .../services/domain_mappings/async_client.py | 34 +++--- .../services/domain_mappings/client.py | 12 +- .../domain_mappings/transports/base.py | 37 +------ .../domain_mappings/transports/grpc.py | 2 +- .../transports/grpc_asyncio.py | 3 +- .../services/firewall/async_client.py | 40 +++---- .../services/firewall/client.py | 14 ++- .../services/firewall/transports/base.py | 35 +----- .../firewall/transports/grpc_asyncio.py | 1 - .../services/instances/async_client.py | 28 ++--- .../services/instances/client.py | 10 +- .../services/instances/transports/base.py | 37 +------ .../services/instances/transports/grpc.py | 2 +- .../instances/transports/grpc_asyncio.py | 3 +- .../services/services/async_client.py | 28 ++--- .../services/services/client.py | 10 +- .../services/services/transports/base.py | 37 +------ .../services/services/transports/grpc.py | 2 +- .../services/transports/grpc_asyncio.py | 3 +- .../services/versions/async_client.py | 34 +++--- .../services/versions/client.py | 12 +- .../services/versions/transports/base.py | 37 +------ .../services/versions/transports/grpc.py | 2 +- .../versions/transports/grpc_asyncio.py | 3 +- .../appengine_admin_v1/types/app_yaml.py | 10 ++ .../appengine_admin_v1/types/audit_data.py | 9 ++ .../appengine_admin_v1/types/operation.py | 4 + .../cloud/appengine_admin_v1/types/version.py | 13 +++ setup.py | 3 +- testing/constraints-3.6.txt | 3 +- .../appengine_admin_v1/test_applications.py | 103 ++---------------- .../test_authorized_certificates.py | 103 ++---------------- .../test_authorized_domains.py | 103 ++---------------- .../test_domain_mappings.py | 103 ++---------------- .../gapic/appengine_admin_v1/test_firewall.py | 100 ++--------------- .../appengine_admin_v1/test_instances.py | 100 ++--------------- .../gapic/appengine_admin_v1/test_services.py | 100 ++--------------- .../gapic/appengine_admin_v1/test_versions.py | 100 ++--------------- 51 files changed, 309 insertions(+), 1183 deletions(-) diff --git a/google/cloud/appengine_admin_v1/services/applications/async_client.py b/google/cloud/appengine_admin_v1/services/applications/async_client.py index d7535b3..081746a 100644 --- a/google/cloud/appengine_admin_v1/services/applications/async_client.py +++ b/google/cloud/appengine_admin_v1/services/applications/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.types import appengine @@ -161,16 +163,16 @@ def __init__( async def get_application( self, - request: appengine.GetApplicationRequest = None, + request: Union[appengine.GetApplicationRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> application.Application: r"""Gets information about an application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetApplicationRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetApplicationRequest, dict]): The request object. Request message for `Applications.GetApplication`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -211,9 +213,9 @@ async def get_application( async def create_application( self, - request: appengine.CreateApplicationRequest = None, + request: Union[appengine.CreateApplicationRequest, dict] = 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: @@ -230,7 +232,7 @@ async def create_application( Billing `__. Args: - request (:class:`google.cloud.appengine_admin_v1.types.CreateApplicationRequest`): + request (Union[google.cloud.appengine_admin_v1.types.CreateApplicationRequest, dict]): The request object. Request message for `Applications.CreateApplication`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -274,9 +276,9 @@ async def create_application( async def update_application( self, - request: appengine.UpdateApplicationRequest = None, + request: Union[appengine.UpdateApplicationRequest, dict] = 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: @@ -289,7 +291,7 @@ async def update_application( the application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateApplicationRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateApplicationRequest, dict]): The request object. Request message for `Applications.UpdateApplication`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -339,9 +341,9 @@ async def update_application( async def repair_application( self, - request: appengine.RepairApplicationRequest = None, + request: Union[appengine.RepairApplicationRequest, dict] = 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: @@ -358,7 +360,7 @@ async def repair_application( Cloud Console Activity Log. Args: - request (:class:`google.cloud.appengine_admin_v1.types.RepairApplicationRequest`): + request (Union[google.cloud.appengine_admin_v1.types.RepairApplicationRequest, dict]): The request object. Request message for 'Applications.RepairApplication'. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/applications/client.py b/google/cloud/appengine_admin_v1/services/applications/client.py index 79ad4fc..9de6bd9 100644 --- a/google/cloud/appengine_admin_v1/services/applications/client.py +++ b/google/cloud/appengine_admin_v1/services/applications/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.types import appengine @@ -337,7 +339,7 @@ def get_application( self, request: Union[appengine.GetApplicationRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> application.Application: @@ -388,7 +390,7 @@ def create_application( self, request: Union[appengine.CreateApplicationRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -452,7 +454,7 @@ def update_application( self, request: Union[appengine.UpdateApplicationRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -518,7 +520,7 @@ def repair_application( self, request: Union[appengine.RepairApplicationRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: diff --git a/google/cloud/appengine_admin_v1/services/applications/transports/base.py b/google/cloud/appengine_admin_v1/services/applications/transports/base.py index 5aaa063..51e5281 100644 --- a/google/cloud/appengine_admin_v1/services/applications/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/applications/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 @@ -40,15 +39,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 ApplicationsTransport(abc.ABC): """Abstract transport class for Applications.""" @@ -102,7 +92,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 @@ -135,29 +125,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 = { @@ -185,7 +152,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/appengine_admin_v1/services/applications/transports/grpc.py b/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py index 352667e..d40eab7 100644 --- a/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py +++ b/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py @@ -113,7 +113,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/appengine_admin_v1/services/applications/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py index 7c448e9..141ebf1 100644 --- a/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/applications/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 @@ -160,7 +159,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/appengine_admin_v1/services/authorized_certificates/async_client.py b/google/cloud/appengine_admin_v1/services/authorized_certificates/async_client.py index b10fbf9..a63f1eb 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_certificates/async_client.py +++ b/google/cloud/appengine_admin_v1/services/authorized_certificates/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.appengine_admin_v1.services.authorized_certificates import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import certificate @@ -169,9 +171,9 @@ def __init__( async def list_authorized_certificates( self, - request: appengine.ListAuthorizedCertificatesRequest = None, + request: Union[appengine.ListAuthorizedCertificatesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizedCertificatesAsyncPager: @@ -179,7 +181,7 @@ async def list_authorized_certificates( administer. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListAuthorizedCertificatesRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListAuthorizedCertificatesRequest, dict]): The request object. Request message for `AuthorizedCertificates.ListAuthorizedCertificates`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -228,16 +230,16 @@ async def list_authorized_certificates( async def get_authorized_certificate( self, - request: appengine.GetAuthorizedCertificateRequest = None, + request: Union[appengine.GetAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: r"""Gets the specified SSL certificate. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetAuthorizedCertificateRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetAuthorizedCertificateRequest, dict]): The request object. Request message for `AuthorizedCertificates.GetAuthorizedCertificate`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -280,16 +282,16 @@ async def get_authorized_certificate( async def create_authorized_certificate( self, - request: appengine.CreateAuthorizedCertificateRequest = None, + request: Union[appengine.CreateAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: r"""Uploads the specified SSL certificate. Args: - request (:class:`google.cloud.appengine_admin_v1.types.CreateAuthorizedCertificateRequest`): + request (Union[google.cloud.appengine_admin_v1.types.CreateAuthorizedCertificateRequest, dict]): The request object. Request message for `AuthorizedCertificates.CreateAuthorizedCertificate`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -332,9 +334,9 @@ async def create_authorized_certificate( async def update_authorized_certificate( self, - request: appengine.UpdateAuthorizedCertificateRequest = None, + request: Union[appengine.UpdateAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: @@ -346,7 +348,7 @@ async def update_authorized_certificate( updated. Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateAuthorizedCertificateRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateAuthorizedCertificateRequest, dict]): The request object. Request message for `AuthorizedCertificates.UpdateAuthorizedCertificate`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -389,16 +391,16 @@ async def update_authorized_certificate( async def delete_authorized_certificate( self, - request: appengine.DeleteAuthorizedCertificateRequest = None, + request: Union[appengine.DeleteAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified SSL certificate. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteAuthorizedCertificateRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteAuthorizedCertificateRequest, dict]): The request object. Request message for `AuthorizedCertificates.DeleteAuthorizedCertificate`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py b/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py index 940b3ca..02b3c8c 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py +++ b/google/cloud/appengine_admin_v1/services/authorized_certificates/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.appengine_admin_v1.services.authorized_certificates import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import certificate @@ -342,7 +344,7 @@ def list_authorized_certificates( self, request: Union[appengine.ListAuthorizedCertificatesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizedCertificatesPager: @@ -404,7 +406,7 @@ def get_authorized_certificate( self, request: Union[appengine.GetAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: @@ -459,7 +461,7 @@ def create_authorized_certificate( self, request: Union[appengine.CreateAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: @@ -514,7 +516,7 @@ def update_authorized_certificate( self, request: Union[appengine.UpdateAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> certificate.AuthorizedCertificate: @@ -574,7 +576,7 @@ def delete_authorized_certificate( self, request: Union[appengine.DeleteAuthorizedCertificateRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py b/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py index c467d95..54287d1 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/authorized_certificates/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 AuthorizedCertificatesTransport(abc.ABC): """Abstract transport class for AuthorizedCertificates.""" @@ -101,7 +91,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 @@ -134,29 +124,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/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py index 5999184..f73d6c4 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/authorized_certificates/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/appengine_admin_v1/services/authorized_domains/async_client.py b/google/cloud/appengine_admin_v1/services/authorized_domains/async_client.py index 5665df4..ecd2f4b 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_domains/async_client.py +++ b/google/cloud/appengine_admin_v1/services/authorized_domains/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.appengine_admin_v1.services.authorized_domains import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import domain @@ -165,9 +167,9 @@ def __init__( async def list_authorized_domains( self, - request: appengine.ListAuthorizedDomainsRequest = None, + request: Union[appengine.ListAuthorizedDomainsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizedDomainsAsyncPager: @@ -175,7 +177,7 @@ async def list_authorized_domains( administer. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListAuthorizedDomainsRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListAuthorizedDomainsRequest, dict]): The request object. Request message for `AuthorizedDomains.ListAuthorizedDomains`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/authorized_domains/client.py b/google/cloud/appengine_admin_v1/services/authorized_domains/client.py index bffcce0..956b3a0 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_domains/client.py +++ b/google/cloud/appengine_admin_v1/services/authorized_domains/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.appengine_admin_v1.services.authorized_domains import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import domain @@ -341,7 +343,7 @@ def list_authorized_domains( self, request: Union[appengine.ListAuthorizedDomainsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizedDomainsPager: diff --git a/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py b/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py index fd3ab73..56463d0 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/authorized_domains/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 AuthorizedDomainsTransport(abc.ABC): """Abstract transport class for AuthorizedDomains.""" @@ -99,7 +89,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 @@ -132,29 +122,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/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py index 97dd4da..0c93027 100644 --- a/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/authorized_domains/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/appengine_admin_v1/services/domain_mappings/async_client.py b/google/cloud/appengine_admin_v1/services/domain_mappings/async_client.py index 2d07ccc..3c31106 100644 --- a/google/cloud/appengine_admin_v1/services/domain_mappings/async_client.py +++ b/google/cloud/appengine_admin_v1/services/domain_mappings/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.domain_mappings import pagers @@ -166,16 +168,16 @@ def __init__( async def list_domain_mappings( self, - request: appengine.ListDomainMappingsRequest = None, + request: Union[appengine.ListDomainMappingsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDomainMappingsAsyncPager: r"""Lists the domain mappings on an application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListDomainMappingsRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListDomainMappingsRequest, dict]): The request object. Request message for `DomainMappings.ListDomainMappings`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -223,16 +225,16 @@ async def list_domain_mappings( async def get_domain_mapping( self, - request: appengine.GetDomainMappingRequest = None, + request: Union[appengine.GetDomainMappingRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domain_mapping.DomainMapping: r"""Gets the specified domain mapping. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetDomainMappingRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetDomainMappingRequest, dict]): The request object. Request message for `DomainMappings.GetDomainMapping`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -272,9 +274,9 @@ async def get_domain_mapping( async def create_domain_mapping( self, - request: appengine.CreateDomainMappingRequest = None, + request: Union[appengine.CreateDomainMappingRequest, dict] = 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: @@ -284,7 +286,7 @@ async def create_domain_mapping( ```AuthorizedDomains.ListAuthorizedDomains`` <>`__. Args: - request (:class:`google.cloud.appengine_admin_v1.types.CreateDomainMappingRequest`): + request (Union[google.cloud.appengine_admin_v1.types.CreateDomainMappingRequest, dict]): The request object. Request message for `DomainMappings.CreateDomainMapping`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -335,9 +337,9 @@ async def create_domain_mapping( async def update_domain_mapping( self, - request: appengine.UpdateDomainMappingRequest = None, + request: Union[appengine.UpdateDomainMappingRequest, dict] = 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: @@ -348,7 +350,7 @@ async def update_domain_mapping( ``DomainMapping`` resource. Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateDomainMappingRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateDomainMappingRequest, dict]): The request object. Request message for `DomainMappings.UpdateDomainMapping`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -399,9 +401,9 @@ async def update_domain_mapping( async def delete_domain_mapping( self, - request: appengine.DeleteDomainMappingRequest = None, + request: Union[appengine.DeleteDomainMappingRequest, dict] = 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: @@ -410,7 +412,7 @@ async def delete_domain_mapping( ``DomainMapping`` resource. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteDomainMappingRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteDomainMappingRequest, dict]): The request object. Request message for `DomainMappings.DeleteDomainMapping`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/domain_mappings/client.py b/google/cloud/appengine_admin_v1/services/domain_mappings/client.py index 5182ceb..3dbf495 100644 --- a/google/cloud/appengine_admin_v1/services/domain_mappings/client.py +++ b/google/cloud/appengine_admin_v1/services/domain_mappings/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.domain_mappings import pagers @@ -340,7 +342,7 @@ def list_domain_mappings( self, request: Union[appengine.ListDomainMappingsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDomainMappingsPager: @@ -398,7 +400,7 @@ def get_domain_mapping( self, request: Union[appengine.GetDomainMappingRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domain_mapping.DomainMapping: @@ -448,7 +450,7 @@ def create_domain_mapping( self, request: Union[appengine.CreateDomainMappingRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -512,7 +514,7 @@ def update_domain_mapping( self, request: Union[appengine.UpdateDomainMappingRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -577,7 +579,7 @@ def delete_domain_mapping( self, request: Union[appengine.DeleteDomainMappingRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: diff --git a/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py b/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py index 9c8a596..2dd6ff6 100644 --- a/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/domain_mappings/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 @@ -40,15 +39,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 DomainMappingsTransport(abc.ABC): """Abstract transport class for DomainMappings.""" @@ -102,7 +92,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 @@ -135,29 +125,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 = { @@ -196,7 +163,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/appengine_admin_v1/services/domain_mappings/transports/grpc.py b/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py index 5eaac3e..16aea3c 100644 --- a/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py +++ b/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py @@ -113,7 +113,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/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py index 9ba3f67..71d0f59 100644 --- a/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/domain_mappings/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 @@ -160,7 +159,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/appengine_admin_v1/services/firewall/async_client.py b/google/cloud/appengine_admin_v1/services/firewall/async_client.py index 69b4196..237ce9a 100644 --- a/google/cloud/appengine_admin_v1/services/firewall/async_client.py +++ b/google/cloud/appengine_admin_v1/services/firewall/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.appengine_admin_v1.services.firewall import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import firewall @@ -165,16 +167,16 @@ def __init__( async def list_ingress_rules( self, - request: appengine.ListIngressRulesRequest = None, + request: Union[appengine.ListIngressRulesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListIngressRulesAsyncPager: r"""Lists the firewall rules of an application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListIngressRulesRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListIngressRulesRequest, dict]): The request object. Request message for `Firewall.ListIngressRules`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -222,9 +224,9 @@ async def list_ingress_rules( async def batch_update_ingress_rules( self, - request: appengine.BatchUpdateIngressRulesRequest = None, + request: Union[appengine.BatchUpdateIngressRulesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> appengine.BatchUpdateIngressRulesResponse: @@ -237,7 +239,7 @@ async def batch_update_ingress_rules( end of the list. Args: - request (:class:`google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesRequest`): + request (Union[google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesRequest, dict]): The request object. Request message for `Firewall.BatchUpdateIngressRules`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -275,16 +277,16 @@ async def batch_update_ingress_rules( async def create_ingress_rule( self, - request: appengine.CreateIngressRuleRequest = None, + request: Union[appengine.CreateIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: r"""Creates a firewall rule for the application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.CreateIngressRuleRequest`): + request (Union[google.cloud.appengine_admin_v1.types.CreateIngressRuleRequest, dict]): The request object. Request message for `Firewall.CreateIngressRule`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -326,16 +328,16 @@ async def create_ingress_rule( async def get_ingress_rule( self, - request: appengine.GetIngressRuleRequest = None, + request: Union[appengine.GetIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: r"""Gets the specified firewall rule. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetIngressRuleRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetIngressRuleRequest, dict]): The request object. Request message for `Firewall.GetIngressRule`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -377,16 +379,16 @@ async def get_ingress_rule( async def update_ingress_rule( self, - request: appengine.UpdateIngressRuleRequest = None, + request: Union[appengine.UpdateIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: r"""Updates the specified firewall rule. Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateIngressRuleRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateIngressRuleRequest, dict]): The request object. Request message for `Firewall.UpdateIngressRule`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -428,16 +430,16 @@ async def update_ingress_rule( async def delete_ingress_rule( self, - request: appengine.DeleteIngressRuleRequest = None, + request: Union[appengine.DeleteIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified firewall rule. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteIngressRuleRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteIngressRuleRequest, dict]): The request object. Request message for `Firewall.DeleteIngressRule`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/firewall/client.py b/google/cloud/appengine_admin_v1/services/firewall/client.py index 6e5ef6c..495b873 100644 --- a/google/cloud/appengine_admin_v1/services/firewall/client.py +++ b/google/cloud/appengine_admin_v1/services/firewall/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.appengine_admin_v1.services.firewall import pagers from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import firewall @@ -345,7 +347,7 @@ def list_ingress_rules( self, request: Union[appengine.ListIngressRulesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListIngressRulesPager: @@ -403,7 +405,7 @@ def batch_update_ingress_rules( self, request: Union[appengine.BatchUpdateIngressRulesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> appengine.BatchUpdateIngressRulesResponse: @@ -459,7 +461,7 @@ def create_ingress_rule( self, request: Union[appengine.CreateIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: @@ -511,7 +513,7 @@ def get_ingress_rule( self, request: Union[appengine.GetIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: @@ -563,7 +565,7 @@ def update_ingress_rule( self, request: Union[appengine.UpdateIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> firewall.FirewallRule: @@ -615,7 +617,7 @@ def delete_ingress_rule( self, request: Union[appengine.DeleteIngressRuleRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/appengine_admin_v1/services/firewall/transports/base.py b/google/cloud/appengine_admin_v1/services/firewall/transports/base.py index a9bcf9c..f6d01be 100644 --- a/google/cloud/appengine_admin_v1/services/firewall/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/firewall/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 FirewallTransport(abc.ABC): """Abstract transport class for Firewall.""" @@ -101,7 +91,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 @@ -134,29 +124,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/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py index ab20af5..a2b3c2a 100644 --- a/google/cloud/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/firewall/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/appengine_admin_v1/services/instances/async_client.py b/google/cloud/appengine_admin_v1/services/instances/async_client.py index ec2e849..e94c473 100644 --- a/google/cloud/appengine_admin_v1/services/instances/async_client.py +++ b/google/cloud/appengine_admin_v1/services/instances/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.instances import pagers @@ -163,9 +165,9 @@ def __init__( async def list_instances( self, - request: appengine.ListInstancesRequest = None, + request: Union[appengine.ListInstancesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListInstancesAsyncPager: @@ -176,7 +178,7 @@ async def list_instances( API `__. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListInstancesRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListInstancesRequest, dict]): The request object. Request message for `Instances.ListInstances`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -224,16 +226,16 @@ async def list_instances( async def get_instance( self, - request: appengine.GetInstanceRequest = None, + request: Union[appengine.GetInstanceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> instance.Instance: r"""Gets instance information. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetInstanceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetInstanceRequest, dict]): The request object. Request message for `Instances.GetInstance`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -274,9 +276,9 @@ async def get_instance( async def delete_instance( self, - request: appengine.DeleteInstanceRequest = None, + request: Union[appengine.DeleteInstanceRequest, dict] = 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: @@ -297,7 +299,7 @@ async def delete_instance( method. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteInstanceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteInstanceRequest, dict]): The request object. Request message for `Instances.DeleteInstance`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -358,9 +360,9 @@ async def delete_instance( async def debug_instance( self, - request: appengine.DebugInstanceRequest = None, + request: Union[appengine.DebugInstanceRequest, dict] = 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: @@ -376,7 +378,7 @@ async def debug_instance( environment. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DebugInstanceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DebugInstanceRequest, dict]): The request object. Request message for `Instances.DebugInstance`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/instances/client.py b/google/cloud/appengine_admin_v1/services/instances/client.py index d937126..c2b7ef7 100644 --- a/google/cloud/appengine_admin_v1/services/instances/client.py +++ b/google/cloud/appengine_admin_v1/services/instances/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.instances import pagers @@ -355,7 +357,7 @@ def list_instances( self, request: Union[appengine.ListInstancesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListInstancesPager: @@ -417,7 +419,7 @@ def get_instance( self, request: Union[appengine.GetInstanceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> instance.Instance: @@ -468,7 +470,7 @@ def delete_instance( self, request: Union[appengine.DeleteInstanceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -553,7 +555,7 @@ def debug_instance( self, request: Union[appengine.DebugInstanceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: diff --git a/google/cloud/appengine_admin_v1/services/instances/transports/base.py b/google/cloud/appengine_admin_v1/services/instances/transports/base.py index 6903d56..53e72d8 100644 --- a/google/cloud/appengine_admin_v1/services/instances/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/instances/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 @@ -40,15 +39,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 InstancesTransport(abc.ABC): """Abstract transport class for Instances.""" @@ -102,7 +92,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 @@ -135,29 +125,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 = { @@ -185,7 +152,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/appengine_admin_v1/services/instances/transports/grpc.py b/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py index 2fa6b60..61f9fd0 100644 --- a/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py +++ b/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py @@ -113,7 +113,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/appengine_admin_v1/services/instances/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/instances/transports/grpc_asyncio.py index 5f84080..507b83d 100644 --- a/google/cloud/appengine_admin_v1/services/instances/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/instances/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 @@ -160,7 +159,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/appengine_admin_v1/services/services/async_client.py b/google/cloud/appengine_admin_v1/services/services/async_client.py index 5880026..4a49f44 100644 --- a/google/cloud/appengine_admin_v1/services/services/async_client.py +++ b/google/cloud/appengine_admin_v1/services/services/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.services import pagers @@ -159,16 +161,16 @@ def __init__( async def list_services( self, - request: appengine.ListServicesRequest = None, + request: Union[appengine.ListServicesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists all the services in the application. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListServicesRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListServicesRequest, dict]): The request object. Request message for `Services.ListServices`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -216,9 +218,9 @@ async def list_services( async def get_service( self, - request: appengine.GetServiceRequest = None, + request: Union[appengine.GetServiceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> service.Service: @@ -226,7 +228,7 @@ async def get_service( service. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetServiceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetServiceRequest, dict]): The request object. Request message for `Services.GetService`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -276,16 +278,16 @@ async def get_service( async def update_service( self, - request: appengine.UpdateServiceRequest = None, + request: Union[appengine.UpdateServiceRequest, dict] = 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 the configuration of the specified service. Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateServiceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateServiceRequest, dict]): The request object. Request message for `Services.UpdateService`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -342,9 +344,9 @@ async def update_service( async def delete_service( self, - request: appengine.DeleteServiceRequest = None, + request: Union[appengine.DeleteServiceRequest, dict] = 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: @@ -352,7 +354,7 @@ async def delete_service( versions. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteServiceRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteServiceRequest, dict]): The request object. Request message for `Services.DeleteService`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/services/client.py b/google/cloud/appengine_admin_v1/services/services/client.py index dcaecca..b47e7b1 100644 --- a/google/cloud/appengine_admin_v1/services/services/client.py +++ b/google/cloud/appengine_admin_v1/services/services/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.services import pagers @@ -339,7 +341,7 @@ def list_services( self, request: Union[appengine.ListServicesRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServicesPager: @@ -397,7 +399,7 @@ def get_service( self, request: Union[appengine.GetServiceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> service.Service: @@ -458,7 +460,7 @@ def update_service( self, request: Union[appengine.UpdateServiceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -525,7 +527,7 @@ def delete_service( self, request: Union[appengine.DeleteServiceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: diff --git a/google/cloud/appengine_admin_v1/services/services/transports/base.py b/google/cloud/appengine_admin_v1/services/services/transports/base.py index 2a637c9..3d7eef4 100644 --- a/google/cloud/appengine_admin_v1/services/services/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/services/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 @@ -40,15 +39,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 ServicesTransport(abc.ABC): """Abstract transport class for Services.""" @@ -102,7 +92,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 @@ -135,29 +125,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 = { @@ -185,7 +152,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/appengine_admin_v1/services/services/transports/grpc.py b/google/cloud/appengine_admin_v1/services/services/transports/grpc.py index e4df27f..fafc93d 100644 --- a/google/cloud/appengine_admin_v1/services/services/transports/grpc.py +++ b/google/cloud/appengine_admin_v1/services/services/transports/grpc.py @@ -113,7 +113,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/appengine_admin_v1/services/services/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/services/transports/grpc_asyncio.py index af666f0..b30a349 100644 --- a/google/cloud/appengine_admin_v1/services/services/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/services/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 @@ -160,7 +159,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/appengine_admin_v1/services/versions/async_client.py b/google/cloud/appengine_admin_v1/services/versions/async_client.py index f0a057f..f9741fe 100644 --- a/google/cloud/appengine_admin_v1/services/versions/async_client.py +++ b/google/cloud/appengine_admin_v1/services/versions/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.versions import pagers @@ -162,16 +164,16 @@ def __init__( async def list_versions( self, - request: appengine.ListVersionsRequest = None, + request: Union[appengine.ListVersionsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListVersionsAsyncPager: r"""Lists the versions of a service. Args: - request (:class:`google.cloud.appengine_admin_v1.types.ListVersionsRequest`): + request (Union[google.cloud.appengine_admin_v1.types.ListVersionsRequest, dict]): The request object. Request message for `Versions.ListVersions`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -219,9 +221,9 @@ async def list_versions( async def get_version( self, - request: appengine.GetVersionRequest = None, + request: Union[appengine.GetVersionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> version.Version: @@ -230,7 +232,7 @@ async def get_version( parameter to get the full resource. Args: - request (:class:`google.cloud.appengine_admin_v1.types.GetVersionRequest`): + request (Union[google.cloud.appengine_admin_v1.types.GetVersionRequest, dict]): The request object. Request message for `Versions.GetVersion`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -271,16 +273,16 @@ async def get_version( async def create_version( self, - request: appengine.CreateVersionRequest = None, + request: Union[appengine.CreateVersionRequest, dict] = 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"""Deploys code and resource files to a new version. Args: - request (:class:`google.cloud.appengine_admin_v1.types.CreateVersionRequest`): + request (Union[google.cloud.appengine_admin_v1.types.CreateVersionRequest, dict]): The request object. Request message for `Versions.CreateVersion`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -330,9 +332,9 @@ async def create_version( async def update_version( self, - request: appengine.UpdateVersionRequest = None, + request: Union[appengine.UpdateVersionRequest, dict] = 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: @@ -374,7 +376,7 @@ async def update_version( - ```manual_scaling.instances`` `__ Args: - request (:class:`google.cloud.appengine_admin_v1.types.UpdateVersionRequest`): + request (Union[google.cloud.appengine_admin_v1.types.UpdateVersionRequest, dict]): The request object. Request message for `Versions.UpdateVersion`. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -424,16 +426,16 @@ async def update_version( async def delete_version( self, - request: appengine.DeleteVersionRequest = None, + request: Union[appengine.DeleteVersionRequest, dict] = 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"""Deletes an existing Version resource. Args: - request (:class:`google.cloud.appengine_admin_v1.types.DeleteVersionRequest`): + request (Union[google.cloud.appengine_admin_v1.types.DeleteVersionRequest, dict]): The request object. Request message for `Versions.DeleteVersion`. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/appengine_admin_v1/services/versions/client.py b/google/cloud/appengine_admin_v1/services/versions/client.py index a8a5cb4..f68c594 100644 --- a/google/cloud/appengine_admin_v1/services/versions/client.py +++ b/google/cloud/appengine_admin_v1/services/versions/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.appengine_admin_v1.services.versions import pagers @@ -342,7 +344,7 @@ def list_versions( self, request: Union[appengine.ListVersionsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListVersionsPager: @@ -400,7 +402,7 @@ def get_version( self, request: Union[appengine.GetVersionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> version.Version: @@ -453,7 +455,7 @@ def create_version( self, request: Union[appengine.CreateVersionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -513,7 +515,7 @@ def update_version( self, request: Union[appengine.UpdateVersionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: @@ -608,7 +610,7 @@ def delete_version( self, request: Union[appengine.DeleteVersionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: diff --git a/google/cloud/appengine_admin_v1/services/versions/transports/base.py b/google/cloud/appengine_admin_v1/services/versions/transports/base.py index 883d0eb..f3b7e92 100644 --- a/google/cloud/appengine_admin_v1/services/versions/transports/base.py +++ b/google/cloud/appengine_admin_v1/services/versions/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 @@ -40,15 +39,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 VersionsTransport(abc.ABC): """Abstract transport class for Versions.""" @@ -102,7 +92,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 @@ -135,29 +125,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 = { @@ -188,7 +155,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/appengine_admin_v1/services/versions/transports/grpc.py b/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py index 8b61c61..7abaca2 100644 --- a/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py +++ b/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py @@ -113,7 +113,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/appengine_admin_v1/services/versions/transports/grpc_asyncio.py b/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py index 1ada908..9069dc8 100644 --- a/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/appengine_admin_v1/services/versions/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 @@ -160,7 +159,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/appengine_admin_v1/types/app_yaml.py b/google/cloud/appengine_admin_v1/types/app_yaml.py index f6acd01..56cf0dc 100644 --- a/google/cloud/appengine_admin_v1/types/app_yaml.py +++ b/google/cloud/appengine_admin_v1/types/app_yaml.py @@ -124,6 +124,13 @@ class UrlMap(proto.Message): serving static files uploaded with the version, such as images, CSS, or JavaScript. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: url_regex (str): URL prefix. Uses regular expression syntax, @@ -135,13 +142,16 @@ class UrlMap(proto.Message): static_files (google.cloud.appengine_admin_v1.types.StaticFilesHandler): Returns the contents of a file, such as an image, as the response. + This field is a member of `oneof`_ ``handler_type``. script (google.cloud.appengine_admin_v1.types.ScriptHandler): Executes a script to handle the requests that match this URL pattern. Only the ``auto`` value is supported for Node.js in the App Engine standard environment, for example ``"script": "auto"``. + This field is a member of `oneof`_ ``handler_type``. api_endpoint (google.cloud.appengine_admin_v1.types.ApiEndpointHandler): Uses API Endpoints to handle requests. + This field is a member of `oneof`_ ``handler_type``. security_level (google.cloud.appengine_admin_v1.types.SecurityLevel): Security (HTTPS) enforcement for this URL. login (google.cloud.appengine_admin_v1.types.LoginRequirement): diff --git a/google/cloud/appengine_admin_v1/types/audit_data.py b/google/cloud/appengine_admin_v1/types/audit_data.py index eb59c60..a72792b 100644 --- a/google/cloud/appengine_admin_v1/types/audit_data.py +++ b/google/cloud/appengine_admin_v1/types/audit_data.py @@ -27,13 +27,22 @@ class AuditData(proto.Message): r"""App Engine admin service audit log. + 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: update_service (google.cloud.appengine_admin_v1.types.UpdateServiceMethod): Detailed information about UpdateService call. + This field is a member of `oneof`_ ``method``. create_version (google.cloud.appengine_admin_v1.types.CreateVersionMethod): Detailed information about CreateVersion call. + This field is a member of `oneof`_ ``method``. """ update_service = proto.Field( diff --git a/google/cloud/appengine_admin_v1/types/operation.py b/google/cloud/appengine_admin_v1/types/operation.py index 4c0c35a..f5b89c4 100644 --- a/google/cloud/appengine_admin_v1/types/operation.py +++ b/google/cloud/appengine_admin_v1/types/operation.py @@ -28,6 +28,9 @@ class OperationMetadataV1(proto.Message): r"""Metadata for the given [google.longrunning.Operation][google.longrunning.Operation]. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: method (str): API method that initiated this operation. Example: @@ -56,6 +59,7 @@ class OperationMetadataV1(proto.Message): operation poll. @OutputOnly create_version_metadata (google.cloud.appengine_admin_v1.types.CreateVersionMetadataV1): + This field is a member of `oneof`_ ``method_metadata``. """ method = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/appengine_admin_v1/types/version.py b/google/cloud/appengine_admin_v1/types/version.py index f1d353f..3a24b70 100644 --- a/google/cloud/appengine_admin_v1/types/version.py +++ b/google/cloud/appengine_admin_v1/types/version.py @@ -69,6 +69,13 @@ class Version(proto.Message): r"""A Version resource is a specific set of source code and configuration files that are deployed into a service. + 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): Full path to the Version resource in the API. Example: @@ -85,6 +92,7 @@ class Version(proto.Message): response latencies, and other application metrics. Instances are dynamically created and destroyed as needed in order to handle traffic. + This field is a member of `oneof`_ ``scaling``. basic_scaling (google.cloud.appengine_admin_v1.types.BasicScaling): A service with basic scaling will create an instance when the application receives a @@ -92,12 +100,14 @@ class Version(proto.Message): the app becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. + This field is a member of `oneof`_ ``scaling``. manual_scaling (google.cloud.appengine_admin_v1.types.ManualScaling): A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. Manually scaled versions are sometimes referred to as "backends". + This field is a member of `oneof`_ ``scaling``. inbound_services (Sequence[google.cloud.appengine_admin_v1.types.InboundServiceType]): Before an application can receive email or XMPP messages, the application must be @@ -698,10 +708,13 @@ class VpcAccessConnector(proto.Message): class Entrypoint(proto.Message): r"""The entrypoint for the application. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: shell (str): The format should be a shell command that can be fed to ``bash -c``. + This field is a member of `oneof`_ ``command``. """ shell = proto.Field(proto.STRING, number=1, oneof="command",) diff --git a/setup.py b/setup.py index d53a40e..e2b55b3 100644 --- a/setup.py +++ b/setup.py @@ -28,9 +28,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.18.1", - "packaging >= 14.3", "grpc-google-iam-v1", "six", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index b86813c..f4ff370 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,8 +5,7 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.18.1 grpc-google-iam-v1==0.12.3 six==1.13.0 -packaging==14.3 diff --git a/tests/unit/gapic/appengine_admin_v1/test_applications.py b/tests/unit/gapic/appengine_admin_v1/test_applications.py index 7c034b5..a99ea93 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_applications.py +++ b/tests/unit/gapic/appengine_admin_v1/test_applications.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,9 +39,6 @@ ) from google.cloud.appengine_admin_v1.services.applications import ApplicationsClient from google.cloud.appengine_admin_v1.services.applications import transports -from google.cloud.appengine_admin_v1.services.applications.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import application from google.cloud.appengine_admin_v1.types import operation as ga_operation @@ -53,20 +49,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" @@ -214,7 +196,7 @@ def test_applications_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, @@ -231,7 +213,7 @@ def test_applications_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, @@ -248,7 +230,7 @@ def test_applications_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, @@ -277,7 +259,7 @@ def test_applications_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, @@ -334,7 +316,7 @@ def test_applications_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 @@ -376,7 +358,7 @@ def test_applications_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, @@ -398,7 +380,7 @@ def test_applications_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, @@ -429,7 +411,7 @@ def test_applications_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, @@ -460,7 +442,7 @@ def test_applications_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", @@ -1147,7 +1129,6 @@ def test_applications_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_applications_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1172,30 +1153,6 @@ def test_applications_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_applications_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.appengine_admin_v1.services.applications.transports.ApplicationsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ApplicationsTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_applications_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( @@ -1207,7 +1164,6 @@ def test_applications_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_applications_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1224,22 +1180,6 @@ def test_applications_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_applications_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) - ApplicationsClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1247,7 +1187,6 @@ def test_applications_auth_adc_old_google_auth(): transports.ApplicationsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_applications_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1265,30 +1204,6 @@ def test_applications_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationsGrpcTransport, - transports.ApplicationsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_applications_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py b/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py index 6de2281..300dbfa 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py +++ b/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,9 +39,6 @@ ) from google.cloud.appengine_admin_v1.services.authorized_certificates import pagers from google.cloud.appengine_admin_v1.services.authorized_certificates import transports -from google.cloud.appengine_admin_v1.services.authorized_certificates.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import certificate from google.oauth2 import service_account @@ -51,20 +47,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" @@ -226,7 +208,7 @@ def test_authorized_certificates_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, @@ -243,7 +225,7 @@ def test_authorized_certificates_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, @@ -260,7 +242,7 @@ def test_authorized_certificates_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, @@ -289,7 +271,7 @@ def test_authorized_certificates_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, @@ -358,7 +340,7 @@ def test_authorized_certificates_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 @@ -400,7 +382,7 @@ def test_authorized_certificates_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, @@ -422,7 +404,7 @@ def test_authorized_certificates_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, @@ -457,7 +439,7 @@ def test_authorized_certificates_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, @@ -492,7 +474,7 @@ def test_authorized_certificates_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", @@ -1623,7 +1605,6 @@ def test_authorized_certificates_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_authorized_certificates_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1648,30 +1629,6 @@ def test_authorized_certificates_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_authorized_certificates_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.appengine_admin_v1.services.authorized_certificates.transports.AuthorizedCertificatesTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.AuthorizedCertificatesTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_authorized_certificates_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( @@ -1683,7 +1640,6 @@ def test_authorized_certificates_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_authorized_certificates_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1700,22 +1656,6 @@ def test_authorized_certificates_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_authorized_certificates_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) - AuthorizedCertificatesClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1723,7 +1663,6 @@ def test_authorized_certificates_auth_adc_old_google_auth(): transports.AuthorizedCertificatesGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_authorized_certificates_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1741,30 +1680,6 @@ def test_authorized_certificates_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.AuthorizedCertificatesGrpcTransport, - transports.AuthorizedCertificatesGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_authorized_certificates_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py b/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py index 4d570ea..ea20035 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py +++ b/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.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.appengine_admin_v1.services.authorized_domains import pagers from google.cloud.appengine_admin_v1.services.authorized_domains import transports -from google.cloud.appengine_admin_v1.services.authorized_domains.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import domain from google.oauth2 import service_account 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" @@ -220,7 +202,7 @@ def test_authorized_domains_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, @@ -237,7 +219,7 @@ def test_authorized_domains_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, @@ -254,7 +236,7 @@ def test_authorized_domains_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, @@ -283,7 +265,7 @@ def test_authorized_domains_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, @@ -352,7 +334,7 @@ def test_authorized_domains_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 @@ -394,7 +376,7 @@ def test_authorized_domains_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, @@ -416,7 +398,7 @@ def test_authorized_domains_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, @@ -447,7 +429,7 @@ def test_authorized_domains_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, @@ -478,7 +460,7 @@ def test_authorized_domains_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", @@ -914,7 +896,6 @@ def test_authorized_domains_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_authorized_domains_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -939,30 +920,6 @@ def test_authorized_domains_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_authorized_domains_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.appengine_admin_v1.services.authorized_domains.transports.AuthorizedDomainsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.AuthorizedDomainsTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_authorized_domains_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( @@ -974,7 +931,6 @@ def test_authorized_domains_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_authorized_domains_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -991,22 +947,6 @@ def test_authorized_domains_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_authorized_domains_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) - AuthorizedDomainsClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1014,7 +954,6 @@ def test_authorized_domains_auth_adc_old_google_auth(): transports.AuthorizedDomainsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_authorized_domains_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1032,30 +971,6 @@ def test_authorized_domains_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.AuthorizedDomainsGrpcTransport, - transports.AuthorizedDomainsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_authorized_domains_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py b/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py index 9a13770..1ed3557 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py +++ b/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.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.appengine_admin_v1.services.domain_mappings import pagers from google.cloud.appengine_admin_v1.services.domain_mappings import transports -from google.cloud.appengine_admin_v1.services.domain_mappings.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import domain_mapping from google.cloud.appengine_admin_v1.types import operation as ga_operation @@ -55,20 +51,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" @@ -225,7 +207,7 @@ def test_domain_mappings_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, @@ -242,7 +224,7 @@ def test_domain_mappings_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, @@ -259,7 +241,7 @@ def test_domain_mappings_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, @@ -288,7 +270,7 @@ def test_domain_mappings_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, @@ -347,7 +329,7 @@ def test_domain_mappings_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 @@ -389,7 +371,7 @@ def test_domain_mappings_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, @@ -411,7 +393,7 @@ def test_domain_mappings_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, @@ -442,7 +424,7 @@ def test_domain_mappings_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, @@ -473,7 +455,7 @@ def test_domain_mappings_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", @@ -1514,7 +1496,6 @@ def test_domain_mappings_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_domain_mappings_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1539,30 +1520,6 @@ def test_domain_mappings_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_domain_mappings_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.appengine_admin_v1.services.domain_mappings.transports.DomainMappingsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.DomainMappingsTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_domain_mappings_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( @@ -1574,7 +1531,6 @@ def test_domain_mappings_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_domain_mappings_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1591,22 +1547,6 @@ def test_domain_mappings_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_domain_mappings_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) - DomainMappingsClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1614,7 +1554,6 @@ def test_domain_mappings_auth_adc_old_google_auth(): transports.DomainMappingsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_domain_mappings_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1632,30 +1571,6 @@ def test_domain_mappings_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.DomainMappingsGrpcTransport, - transports.DomainMappingsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_domain_mappings_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_firewall.py b/tests/unit/gapic/appengine_admin_v1/test_firewall.py index b60e491..a05bec5 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_firewall.py +++ b/tests/unit/gapic/appengine_admin_v1/test_firewall.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,9 +35,6 @@ from google.cloud.appengine_admin_v1.services.firewall import FirewallClient from google.cloud.appengine_admin_v1.services.firewall import pagers from google.cloud.appengine_admin_v1.services.firewall import transports -from google.cloud.appengine_admin_v1.services.firewall.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import firewall from google.oauth2 import service_account @@ -46,20 +42,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" @@ -199,7 +181,7 @@ def test_firewall_client_client_options(client_class, transport_class, transport 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, @@ -216,7 +198,7 @@ def test_firewall_client_client_options(client_class, transport_class, transport 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, @@ -233,7 +215,7 @@ def test_firewall_client_client_options(client_class, transport_class, transport 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, @@ -262,7 +244,7 @@ def test_firewall_client_client_options(client_class, transport_class, transport 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, @@ -319,7 +301,7 @@ def test_firewall_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 @@ -361,7 +343,7 @@ def test_firewall_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, @@ -383,7 +365,7 @@ def test_firewall_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, @@ -410,7 +392,7 @@ def test_firewall_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, @@ -437,7 +419,7 @@ def test_firewall_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", @@ -1616,7 +1598,6 @@ def test_firewall_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_firewall_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1641,30 +1622,6 @@ def test_firewall_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_firewall_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.appengine_admin_v1.services.firewall.transports.FirewallTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.FirewallTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_firewall_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( @@ -1676,7 +1633,6 @@ def test_firewall_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_firewall_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1693,27 +1649,10 @@ def test_firewall_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_firewall_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) - FirewallClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.FirewallGrpcTransport, transports.FirewallGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_firewall_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1731,27 +1670,6 @@ def test_firewall_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.FirewallGrpcTransport, transports.FirewallGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_firewall_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_instances.py b/tests/unit/gapic/appengine_admin_v1/test_instances.py index d51b0a8..75d66d2 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_instances.py +++ b/tests/unit/gapic/appengine_admin_v1/test_instances.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.appengine_admin_v1.services.instances import InstancesClient from google.cloud.appengine_admin_v1.services.instances import pagers from google.cloud.appengine_admin_v1.services.instances import transports -from google.cloud.appengine_admin_v1.services.instances.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import instance from google.cloud.appengine_admin_v1.types import operation as ga_operation @@ -51,20 +47,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" @@ -208,7 +190,7 @@ def test_instances_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, @@ -225,7 +207,7 @@ def test_instances_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, @@ -242,7 +224,7 @@ def test_instances_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, @@ -271,7 +253,7 @@ def test_instances_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, @@ -328,7 +310,7 @@ def test_instances_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_instances_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_instances_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_instances_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_instances_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", @@ -1323,7 +1305,6 @@ def test_instances_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_instances_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1348,30 +1329,6 @@ def test_instances_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_instances_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.appengine_admin_v1.services.instances.transports.InstancesTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.InstancesTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_instances_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( @@ -1383,7 +1340,6 @@ def test_instances_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_instances_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1400,27 +1356,10 @@ def test_instances_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_instances_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) - InstancesClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.InstancesGrpcTransport, transports.InstancesGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_instances_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1438,27 +1377,6 @@ def test_instances_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.InstancesGrpcTransport, transports.InstancesGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_instances_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_services.py b/tests/unit/gapic/appengine_admin_v1/test_services.py index 168aded..811d07f 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_services.py +++ b/tests/unit/gapic/appengine_admin_v1/test_services.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.appengine_admin_v1.services.services import ServicesClient from google.cloud.appengine_admin_v1.services.services import pagers from google.cloud.appengine_admin_v1.services.services import transports -from google.cloud.appengine_admin_v1.services.services.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import network_settings from google.cloud.appengine_admin_v1.types import operation as ga_operation @@ -52,20 +48,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" @@ -205,7 +187,7 @@ def test_services_client_client_options(client_class, transport_class, transport 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, @@ -222,7 +204,7 @@ def test_services_client_client_options(client_class, transport_class, transport 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, @@ -239,7 +221,7 @@ def test_services_client_client_options(client_class, transport_class, transport 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, @@ -268,7 +250,7 @@ def test_services_client_client_options(client_class, transport_class, transport 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, @@ -325,7 +307,7 @@ def test_services_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 @@ -367,7 +349,7 @@ def test_services_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, @@ -389,7 +371,7 @@ def test_services_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, @@ -416,7 +398,7 @@ def test_services_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, @@ -443,7 +425,7 @@ def test_services_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", @@ -1232,7 +1214,6 @@ def test_services_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_services_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1257,30 +1238,6 @@ def test_services_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_services_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.appengine_admin_v1.services.services.transports.ServicesTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ServicesTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_services_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( @@ -1292,7 +1249,6 @@ def test_services_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_services_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1309,27 +1265,10 @@ def test_services_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_services_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) - ServicesClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.ServicesGrpcTransport, transports.ServicesGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_services_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1347,27 +1286,6 @@ def test_services_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.ServicesGrpcTransport, transports.ServicesGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_services_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/appengine_admin_v1/test_versions.py b/tests/unit/gapic/appengine_admin_v1/test_versions.py index 84a0499..ef9622d 100644 --- a/tests/unit/gapic/appengine_admin_v1/test_versions.py +++ b/tests/unit/gapic/appengine_admin_v1/test_versions.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.appengine_admin_v1.services.versions import VersionsClient from google.cloud.appengine_admin_v1.services.versions import pagers from google.cloud.appengine_admin_v1.services.versions import transports -from google.cloud.appengine_admin_v1.services.versions.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.appengine_admin_v1.types import app_yaml from google.cloud.appengine_admin_v1.types import appengine from google.cloud.appengine_admin_v1.types import deploy @@ -55,20 +51,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" @@ -208,7 +190,7 @@ def test_versions_client_client_options(client_class, transport_class, transport 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_versions_client_client_options(client_class, transport_class, transport 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_versions_client_client_options(client_class, transport_class, transport 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_versions_client_client_options(client_class, transport_class, transport 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_versions_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_versions_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_versions_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, @@ -419,7 +401,7 @@ def test_versions_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, @@ -446,7 +428,7 @@ def test_versions_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", @@ -1443,7 +1425,6 @@ def test_versions_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_versions_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1468,30 +1449,6 @@ def test_versions_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_versions_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.appengine_admin_v1.services.versions.transports.VersionsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.VersionsTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - def test_versions_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( @@ -1503,7 +1460,6 @@ def test_versions_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_versions_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1520,27 +1476,10 @@ def test_versions_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_versions_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) - VersionsClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_versions_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1558,27 +1497,6 @@ def test_versions_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_versions_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/appengine.admin", - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [