From 4b246112d770cd4d4409b8a84a72f13713a59881 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 10:40:02 +0000 Subject: [PATCH] chore: upgrade gapic-generator-python to 0.46.3 (#24) PiperOrigin-RevId: 373649163 Source-Link: https://github.com/googleapis/googleapis/commit/7e1b14e6c7a9ab96d2db7e4a131981f162446d34 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0a3c7d272d697796db75857bac73905c68e498c3 fix: add async client to %name_%version/init.py chore: add autogenerated snippets chore: remove auth, policy, and options from the reserved names list feat: support self-signed JWT flow for service accounts chore: enable GAPIC metadata generation chore: sort subpackages in %namespace/%name/init.py --- docs/domains_v1beta1/domains.rst | 1 - google/cloud/domains/__init__.py | 24 +- google/cloud/domains_v1beta1/__init__.py | 15 +- .../cloud/domains_v1beta1/gapic_metadata.json | 153 ++++ .../domains_v1beta1/services/__init__.py | 1 - .../services/domains/__init__.py | 2 - .../services/domains/async_client.py | 70 +- .../services/domains/client.py | 120 +-- .../services/domains/pagers.py | 4 +- .../services/domains/transports/__init__.py | 2 - .../services/domains/transports/base.py | 163 ++-- .../services/domains/transports/grpc.py | 54 +- .../domains/transports/grpc_asyncio.py | 60 +- .../cloud/domains_v1beta1/types/__init__.py | 2 - google/cloud/domains_v1beta1/types/domains.py | 199 ++--- scripts/fixup_domains_v1beta1_keywords.py | 31 +- tests/__init__.py | 15 + tests/unit/__init__.py | 15 + tests/unit/gapic/__init__.py | 15 + tests/unit/gapic/domains_v1beta1/__init__.py | 1 - .../gapic/domains_v1beta1/test_domains.py | 793 +++++++++--------- 21 files changed, 942 insertions(+), 798 deletions(-) create mode 100644 google/cloud/domains_v1beta1/gapic_metadata.json create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/gapic/__init__.py diff --git a/docs/domains_v1beta1/domains.rst b/docs/domains_v1beta1/domains.rst index 0a8924a..13d490a 100644 --- a/docs/domains_v1beta1/domains.rst +++ b/docs/domains_v1beta1/domains.rst @@ -5,7 +5,6 @@ Domains :members: :inherited-members: - .. automodule:: google.cloud.domains_v1beta1.services.domains.pagers :members: :inherited-members: diff --git a/google/cloud/domains/__init__.py b/google/cloud/domains/__init__.py index 37e149b..c65bbe7 100644 --- a/google/cloud/domains/__init__.py +++ b/google/cloud/domains/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,22 +14,20 @@ # limitations under the License. # +from google.cloud.domains_v1beta1.services.domains.client import DomainsClient from google.cloud.domains_v1beta1.services.domains.async_client import ( DomainsAsyncClient, ) -from google.cloud.domains_v1beta1.services.domains.client import DomainsClient + from google.cloud.domains_v1beta1.types.domains import AuthorizationCode from google.cloud.domains_v1beta1.types.domains import ConfigureContactSettingsRequest from google.cloud.domains_v1beta1.types.domains import ConfigureDnsSettingsRequest from google.cloud.domains_v1beta1.types.domains import ( ConfigureManagementSettingsRequest, ) -from google.cloud.domains_v1beta1.types.domains import ContactNotice -from google.cloud.domains_v1beta1.types.domains import ContactPrivacy from google.cloud.domains_v1beta1.types.domains import ContactSettings from google.cloud.domains_v1beta1.types.domains import DeleteRegistrationRequest from google.cloud.domains_v1beta1.types.domains import DnsSettings -from google.cloud.domains_v1beta1.types.domains import DomainNotice from google.cloud.domains_v1beta1.types.domains import ExportRegistrationRequest from google.cloud.domains_v1beta1.types.domains import GetRegistrationRequest from google.cloud.domains_v1beta1.types.domains import ListRegistrationsRequest @@ -48,22 +45,22 @@ ) from google.cloud.domains_v1beta1.types.domains import SearchDomainsRequest from google.cloud.domains_v1beta1.types.domains import SearchDomainsResponse -from google.cloud.domains_v1beta1.types.domains import TransferLockState from google.cloud.domains_v1beta1.types.domains import UpdateRegistrationRequest +from google.cloud.domains_v1beta1.types.domains import ContactNotice +from google.cloud.domains_v1beta1.types.domains import ContactPrivacy +from google.cloud.domains_v1beta1.types.domains import DomainNotice +from google.cloud.domains_v1beta1.types.domains import TransferLockState __all__ = ( + "DomainsClient", + "DomainsAsyncClient", "AuthorizationCode", "ConfigureContactSettingsRequest", "ConfigureDnsSettingsRequest", "ConfigureManagementSettingsRequest", - "ContactNotice", - "ContactPrivacy", "ContactSettings", "DeleteRegistrationRequest", "DnsSettings", - "DomainNotice", - "DomainsAsyncClient", - "DomainsClient", "ExportRegistrationRequest", "GetRegistrationRequest", "ListRegistrationsRequest", @@ -79,6 +76,9 @@ "RetrieveRegisterParametersResponse", "SearchDomainsRequest", "SearchDomainsResponse", - "TransferLockState", "UpdateRegistrationRequest", + "ContactNotice", + "ContactPrivacy", + "DomainNotice", + "TransferLockState", ) diff --git a/google/cloud/domains_v1beta1/__init__.py b/google/cloud/domains_v1beta1/__init__.py index ad37849..7e9ede1 100644 --- a/google/cloud/domains_v1beta1/__init__.py +++ b/google/cloud/domains_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,16 +15,15 @@ # from .services.domains import DomainsClient +from .services.domains import DomainsAsyncClient + from .types.domains import AuthorizationCode from .types.domains import ConfigureContactSettingsRequest from .types.domains import ConfigureDnsSettingsRequest from .types.domains import ConfigureManagementSettingsRequest -from .types.domains import ContactNotice -from .types.domains import ContactPrivacy from .types.domains import ContactSettings from .types.domains import DeleteRegistrationRequest from .types.domains import DnsSettings -from .types.domains import DomainNotice from .types.domains import ExportRegistrationRequest from .types.domains import GetRegistrationRequest from .types.domains import ListRegistrationsRequest @@ -41,11 +39,14 @@ from .types.domains import RetrieveRegisterParametersResponse from .types.domains import SearchDomainsRequest from .types.domains import SearchDomainsResponse -from .types.domains import TransferLockState from .types.domains import UpdateRegistrationRequest - +from .types.domains import ContactNotice +from .types.domains import ContactPrivacy +from .types.domains import DomainNotice +from .types.domains import TransferLockState __all__ = ( + "DomainsAsyncClient", "AuthorizationCode", "ConfigureContactSettingsRequest", "ConfigureDnsSettingsRequest", @@ -56,6 +57,7 @@ "DeleteRegistrationRequest", "DnsSettings", "DomainNotice", + "DomainsClient", "ExportRegistrationRequest", "GetRegistrationRequest", "ListRegistrationsRequest", @@ -73,5 +75,4 @@ "SearchDomainsResponse", "TransferLockState", "UpdateRegistrationRequest", - "DomainsClient", ) diff --git a/google/cloud/domains_v1beta1/gapic_metadata.json b/google/cloud/domains_v1beta1/gapic_metadata.json new file mode 100644 index 0000000..dd05252 --- /dev/null +++ b/google/cloud/domains_v1beta1/gapic_metadata.json @@ -0,0 +1,153 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.domains_v1beta1", + "protoPackage": "google.cloud.domains.v1beta1", + "schema": "1.0", + "services": { + "Domains": { + "clients": { + "grpc": { + "libraryClient": "DomainsClient", + "rpcs": { + "ConfigureContactSettings": { + "methods": [ + "configure_contact_settings" + ] + }, + "ConfigureDnsSettings": { + "methods": [ + "configure_dns_settings" + ] + }, + "ConfigureManagementSettings": { + "methods": [ + "configure_management_settings" + ] + }, + "DeleteRegistration": { + "methods": [ + "delete_registration" + ] + }, + "ExportRegistration": { + "methods": [ + "export_registration" + ] + }, + "GetRegistration": { + "methods": [ + "get_registration" + ] + }, + "ListRegistrations": { + "methods": [ + "list_registrations" + ] + }, + "RegisterDomain": { + "methods": [ + "register_domain" + ] + }, + "ResetAuthorizationCode": { + "methods": [ + "reset_authorization_code" + ] + }, + "RetrieveAuthorizationCode": { + "methods": [ + "retrieve_authorization_code" + ] + }, + "RetrieveRegisterParameters": { + "methods": [ + "retrieve_register_parameters" + ] + }, + "SearchDomains": { + "methods": [ + "search_domains" + ] + }, + "UpdateRegistration": { + "methods": [ + "update_registration" + ] + } + } + }, + "grpc-async": { + "libraryClient": "DomainsAsyncClient", + "rpcs": { + "ConfigureContactSettings": { + "methods": [ + "configure_contact_settings" + ] + }, + "ConfigureDnsSettings": { + "methods": [ + "configure_dns_settings" + ] + }, + "ConfigureManagementSettings": { + "methods": [ + "configure_management_settings" + ] + }, + "DeleteRegistration": { + "methods": [ + "delete_registration" + ] + }, + "ExportRegistration": { + "methods": [ + "export_registration" + ] + }, + "GetRegistration": { + "methods": [ + "get_registration" + ] + }, + "ListRegistrations": { + "methods": [ + "list_registrations" + ] + }, + "RegisterDomain": { + "methods": [ + "register_domain" + ] + }, + "ResetAuthorizationCode": { + "methods": [ + "reset_authorization_code" + ] + }, + "RetrieveAuthorizationCode": { + "methods": [ + "retrieve_authorization_code" + ] + }, + "RetrieveRegisterParameters": { + "methods": [ + "retrieve_register_parameters" + ] + }, + "SearchDomains": { + "methods": [ + "search_domains" + ] + }, + "UpdateRegistration": { + "methods": [ + "update_registration" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/domains_v1beta1/services/__init__.py b/google/cloud/domains_v1beta1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/domains_v1beta1/services/__init__.py +++ b/google/cloud/domains_v1beta1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/domains_v1beta1/services/domains/__init__.py b/google/cloud/domains_v1beta1/services/domains/__init__.py index 9a3fe5a..cd7bb44 100644 --- a/google/cloud/domains_v1beta1/services/domains/__init__.py +++ b/google/cloud/domains_v1beta1/services/domains/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import DomainsClient from .async_client import DomainsAsyncClient diff --git a/google/cloud/domains_v1beta1/services/domains/async_client.py b/google/cloud/domains_v1beta1/services/domains/async_client.py index 3c95c9b..c92d177 100644 --- a/google/cloud/domains_v1beta1/services/domains/async_client.py +++ b/google/cloud/domains_v1beta1/services/domains/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,21 +20,20 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # 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 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.types import domains -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import DomainsTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import DomainsGrpcAsyncIOTransport from .client import DomainsClient @@ -54,31 +51,27 @@ class DomainsAsyncClient: registration_path = staticmethod(DomainsClient.registration_path) parse_registration_path = staticmethod(DomainsClient.parse_registration_path) - common_billing_account_path = staticmethod( DomainsClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( DomainsClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(DomainsClient.common_folder_path) parse_common_folder_path = staticmethod(DomainsClient.parse_common_folder_path) - common_organization_path = staticmethod(DomainsClient.common_organization_path) parse_common_organization_path = staticmethod( DomainsClient.parse_common_organization_path ) - common_project_path = staticmethod(DomainsClient.common_project_path) parse_common_project_path = staticmethod(DomainsClient.parse_common_project_path) - common_location_path = staticmethod(DomainsClient.common_location_path) parse_common_location_path = staticmethod(DomainsClient.parse_common_location_path) @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -93,7 +86,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -110,7 +103,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> DomainsTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: DomainsTransport: The transport used by the client instance. @@ -124,12 +117,12 @@ def transport(self) -> DomainsTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, DomainsTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the domains client. + """Instantiates the domains client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -161,7 +154,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = DomainsClient( credentials=credentials, transport=transport, @@ -204,7 +196,6 @@ async def search_domains( This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -229,7 +220,6 @@ async def search_domains( # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if query is not None: @@ -288,7 +278,6 @@ async def retrieve_register_parameters( This corresponds to the ``domain_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -313,7 +302,6 @@ async def retrieve_register_parameters( # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if domain_name is not None: @@ -345,7 +333,7 @@ async def register_domain( *, parent: str = None, registration: domains.Registration = None, - yearly_price: money.Money = None, + yearly_price: money_pb2.Money = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -393,7 +381,6 @@ async def register_domain( This corresponds to the ``yearly_price`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -430,7 +417,6 @@ async def register_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if registration is not None: @@ -489,7 +475,6 @@ async def list_registrations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -518,7 +503,6 @@ async def list_registrations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -570,7 +554,6 @@ async def get_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -605,7 +588,6 @@ async def get_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -634,7 +616,7 @@ async def update_registration( request: domains.UpdateRegistrationRequest = None, *, registration: domains.Registration = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -667,7 +649,6 @@ async def update_registration( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -704,7 +685,6 @@ async def update_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if update_mask is not None: @@ -746,7 +726,7 @@ async def configure_management_settings( *, registration: str = None, management_settings: domains.ManagementSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -779,7 +759,6 @@ async def configure_management_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -816,7 +795,6 @@ async def configure_management_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if management_settings is not None: @@ -860,7 +838,7 @@ async def configure_dns_settings( *, registration: str = None, dns_settings: domains.DnsSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -900,7 +878,6 @@ async def configure_dns_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -937,7 +914,6 @@ async def configure_dns_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if dns_settings is not None: @@ -981,7 +957,7 @@ async def configure_contact_settings( *, registration: str = None, contact_settings: domains.ContactSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1015,7 +991,6 @@ async def configure_contact_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1052,7 +1027,6 @@ async def configure_contact_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if contact_settings is not None: @@ -1125,7 +1099,6 @@ async def export_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1162,7 +1135,6 @@ async def export_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1222,7 +1194,6 @@ async def delete_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1262,7 +1233,6 @@ async def delete_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1287,7 +1257,7 @@ async def delete_registration( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=domains.OperationMetadata, ) @@ -1321,7 +1291,6 @@ async def retrieve_authorization_code( This corresponds to the ``registration`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1346,7 +1315,6 @@ async def retrieve_authorization_code( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration @@ -1399,7 +1367,6 @@ async def reset_authorization_code( This corresponds to the ``registration`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1424,7 +1391,6 @@ async def reset_authorization_code( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration diff --git a/google/cloud/domains_v1beta1/services/domains/client.py b/google/cloud/domains_v1beta1/services/domains/client.py index efc3176..d543f42 100644 --- a/google/cloud/domains_v1beta1/services/domains/client.py +++ b/google/cloud/domains_v1beta1/services/domains/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # 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 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -36,11 +34,10 @@ from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.types import domains -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import DomainsTransport, DEFAULT_CLIENT_INFO from .transports.grpc import DomainsGrpcTransport from .transports.grpc_asyncio import DomainsGrpcAsyncIOTransport @@ -59,7 +56,7 @@ class DomainsClientMeta(type): _transport_registry["grpc_asyncio"] = DomainsGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[DomainsTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -84,7 +81,8 @@ class DomainsClient(metaclass=DomainsClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -118,7 +116,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -135,7 +134,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -154,23 +153,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> DomainsTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - DomainsTransport: The transport used by the client instance. + DomainsTransport: The transport used by the client + instance. """ return self._transport @staticmethod def registration_path(project: str, location: str, registration: str,) -> str: - """Return a fully-qualified registration string.""" + """Returns a fully-qualified registration string.""" return "projects/{project}/locations/{location}/registrations/{registration}".format( project=project, location=location, registration=registration, ) @staticmethod def parse_registration_path(path: str) -> Dict[str, str]: - """Parse a registration path into its component segments.""" + """Parses a registration path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/registrations/(?P.+?)$", path, @@ -179,7 +179,7 @@ def parse_registration_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -192,7 +192,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -203,7 +203,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -214,7 +214,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -225,7 +225,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -239,12 +239,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, DomainsTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the domains client. + """Instantiates the domains client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -299,9 +299,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -313,12 +314,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -333,8 +336,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -384,7 +387,6 @@ def search_domains( This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -411,10 +413,8 @@ def search_domains( # there are no flattened fields. if not isinstance(request, domains.SearchDomainsRequest): request = domains.SearchDomainsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if query is not None: @@ -469,7 +469,6 @@ def retrieve_register_parameters( This corresponds to the ``domain_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -496,10 +495,8 @@ def retrieve_register_parameters( # there are no flattened fields. if not isinstance(request, domains.RetrieveRegisterParametersRequest): request = domains.RetrieveRegisterParametersRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if domain_name is not None: @@ -529,7 +526,7 @@ def register_domain( *, parent: str = None, registration: domains.Registration = None, - yearly_price: money.Money = None, + yearly_price: money_pb2.Money = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -577,7 +574,6 @@ def register_domain( This corresponds to the ``yearly_price`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -616,10 +612,8 @@ def register_domain( # there are no flattened fields. if not isinstance(request, domains.RegisterDomainRequest): request = domains.RegisterDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if registration is not None: @@ -674,7 +668,6 @@ def list_registrations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -705,10 +698,8 @@ def list_registrations( # there are no flattened fields. if not isinstance(request, domains.ListRegistrationsRequest): request = domains.ListRegistrationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -756,7 +747,6 @@ def get_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -793,10 +783,8 @@ def get_registration( # there are no flattened fields. if not isinstance(request, domains.GetRegistrationRequest): request = domains.GetRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -821,7 +809,7 @@ def update_registration( request: domains.UpdateRegistrationRequest = None, *, registration: domains.Registration = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -854,7 +842,6 @@ def update_registration( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -893,10 +880,8 @@ def update_registration( # there are no flattened fields. if not isinstance(request, domains.UpdateRegistrationRequest): request = domains.UpdateRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if update_mask is not None: @@ -934,7 +919,7 @@ def configure_management_settings( *, registration: str = None, management_settings: domains.ManagementSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -967,7 +952,6 @@ def configure_management_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1006,10 +990,8 @@ def configure_management_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureManagementSettingsRequest): request = domains.ConfigureManagementSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if management_settings is not None: @@ -1051,7 +1033,7 @@ def configure_dns_settings( *, registration: str = None, dns_settings: domains.DnsSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1091,7 +1073,6 @@ def configure_dns_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1130,10 +1111,8 @@ def configure_dns_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureDnsSettingsRequest): request = domains.ConfigureDnsSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if dns_settings is not None: @@ -1173,7 +1152,7 @@ def configure_contact_settings( *, registration: str = None, contact_settings: domains.ContactSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1207,7 +1186,6 @@ def configure_contact_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1246,10 +1224,8 @@ def configure_contact_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureContactSettingsRequest): request = domains.ConfigureContactSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if contact_settings is not None: @@ -1320,7 +1296,6 @@ def export_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1359,10 +1334,8 @@ def export_registration( # there are no flattened fields. if not isinstance(request, domains.ExportRegistrationRequest): request = domains.ExportRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1418,7 +1391,6 @@ def delete_registration( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1460,10 +1432,8 @@ def delete_registration( # there are no flattened fields. if not isinstance(request, domains.DeleteRegistrationRequest): request = domains.DeleteRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1484,7 +1454,7 @@ def delete_registration( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=domains.OperationMetadata, ) @@ -1518,7 +1488,6 @@ def retrieve_authorization_code( This corresponds to the ``registration`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1545,10 +1514,8 @@ def retrieve_authorization_code( # there are no flattened fields. if not isinstance(request, domains.RetrieveAuthorizationCodeRequest): request = domains.RetrieveAuthorizationCodeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration @@ -1599,7 +1566,6 @@ def reset_authorization_code( This corresponds to the ``registration`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1626,10 +1592,8 @@ def reset_authorization_code( # there are no flattened fields. if not isinstance(request, domains.ResetAuthorizationCodeRequest): request = domains.ResetAuthorizationCodeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration diff --git a/google/cloud/domains_v1beta1/services/domains/pagers.py b/google/cloud/domains_v1beta1/services/domains/pagers.py index 801200a..946e27a 100644 --- a/google/cloud/domains_v1beta1/services/domains/pagers.py +++ b/google/cloud/domains_v1beta1/services/domains/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -117,7 +115,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/domains_v1beta1/services/domains/transports/__init__.py b/google/cloud/domains_v1beta1/services/domains/transports/__init__.py index be552f4..d1eb105 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/__init__.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index 3d94805..11e66a5 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # 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.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.domains_v1beta1.types import domains -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -37,27 +36,41 @@ 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 + +_API_CORE_VERSION = google.api_core.__version__ + class DomainsTransport(abc.ABC): """Abstract transport class for Domains.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "domains.googleapis.com" + def __init__( self, *, - host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are 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 + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -167,23 +227,20 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def search_domains( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.SearchDomainsRequest], - typing.Union[ - domains.SearchDomainsResponse, - typing.Awaitable[domains.SearchDomainsResponse], - ], + Union[domains.SearchDomainsResponse, Awaitable[domains.SearchDomainsResponse]], ]: raise NotImplementedError() @property def retrieve_register_parameters( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RetrieveRegisterParametersRequest], - typing.Union[ + Union[ domains.RetrieveRegisterParametersResponse, - typing.Awaitable[domains.RetrieveRegisterParametersResponse], + Awaitable[domains.RetrieveRegisterParametersResponse], ], ]: raise NotImplementedError() @@ -191,20 +248,20 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RegisterDomainRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_registrations( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ListRegistrationsRequest], - typing.Union[ + Union[ domains.ListRegistrationsResponse, - typing.Awaitable[domains.ListRegistrationsResponse], + Awaitable[domains.ListRegistrationsResponse], ], ]: raise NotImplementedError() @@ -212,85 +269,81 @@ def list_registrations( @property def get_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.GetRegistrationRequest], - typing.Union[domains.Registration, typing.Awaitable[domains.Registration]], + Union[domains.Registration, Awaitable[domains.Registration]], ]: raise NotImplementedError() @property def update_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.UpdateRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_management_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureManagementSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_dns_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureDnsSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_contact_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureContactSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ExportRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.DeleteRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def retrieve_authorization_code( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RetrieveAuthorizationCodeRequest], - typing.Union[ - domains.AuthorizationCode, typing.Awaitable[domains.AuthorizationCode] - ], + Union[domains.AuthorizationCode, Awaitable[domains.AuthorizationCode]], ]: raise NotImplementedError() @property def reset_authorization_code( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ResetAuthorizationCodeRequest], - typing.Union[ - domains.AuthorizationCode, typing.Awaitable[domains.AuthorizationCode] - ], + Union[domains.AuthorizationCode, Awaitable[domains.AuthorizationCode]], ]: raise NotImplementedError() diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index 260bb60..f6700ca 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.domains_v1beta1.types import domains -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DomainsTransport, DEFAULT_CLIENT_INFO @@ -53,7 +50,7 @@ def __init__( self, *, host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -67,7 +64,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -178,7 +176,7 @@ def __init__( def create_channel( cls, host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -209,13 +207,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -304,7 +304,7 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> Callable[[domains.RegisterDomainRequest], operations.Operation]: + ) -> Callable[[domains.RegisterDomainRequest], operations_pb2.Operation]: r"""Return a callable for the register domain method over gRPC. Registers a new domain name and creates a corresponding @@ -336,7 +336,7 @@ def register_domain( self._stubs["register_domain"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/RegisterDomain", request_serializer=domains.RegisterDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["register_domain"] @@ -397,7 +397,7 @@ def get_registration( @property def update_registration( self, - ) -> Callable[[domains.UpdateRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.UpdateRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the update registration method over gRPC. Updates select fields of a ``Registration`` resource, notably @@ -424,14 +424,16 @@ def update_registration( self._stubs["update_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/UpdateRegistration", request_serializer=domains.UpdateRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_registration"] @property def configure_management_settings( self, - ) -> Callable[[domains.ConfigureManagementSettingsRequest], operations.Operation]: + ) -> Callable[ + [domains.ConfigureManagementSettingsRequest], operations_pb2.Operation + ]: r"""Return a callable for the configure management settings method over gRPC. Updates a ``Registration``'s management settings. @@ -452,14 +454,14 @@ def configure_management_settings( ] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureManagementSettings", request_serializer=domains.ConfigureManagementSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_management_settings"] @property def configure_dns_settings( self, - ) -> Callable[[domains.ConfigureDnsSettingsRequest], operations.Operation]: + ) -> Callable[[domains.ConfigureDnsSettingsRequest], operations_pb2.Operation]: r"""Return a callable for the configure dns settings method over gRPC. Updates a ``Registration``'s DNS settings. @@ -478,14 +480,14 @@ def configure_dns_settings( self._stubs["configure_dns_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureDnsSettings", request_serializer=domains.ConfigureDnsSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_dns_settings"] @property def configure_contact_settings( self, - ) -> Callable[[domains.ConfigureContactSettingsRequest], operations.Operation]: + ) -> Callable[[domains.ConfigureContactSettingsRequest], operations_pb2.Operation]: r"""Return a callable for the configure contact settings method over gRPC. Updates a ``Registration``'s contact settings. Some changes @@ -505,14 +507,14 @@ def configure_contact_settings( self._stubs["configure_contact_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureContactSettings", request_serializer=domains.ConfigureContactSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_contact_settings"] @property def export_registration( self, - ) -> Callable[[domains.ExportRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.ExportRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the export registration method over gRPC. Exports a ``Registration`` that you no longer want to use with @@ -544,14 +546,14 @@ def export_registration( self._stubs["export_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ExportRegistration", request_serializer=domains.ExportRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_registration"] @property def delete_registration( self, - ) -> Callable[[domains.DeleteRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.DeleteRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the delete registration method over gRPC. Deletes a ``Registration`` resource. @@ -576,7 +578,7 @@ def delete_registration( self._stubs["delete_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/DeleteRegistration", request_serializer=domains.DeleteRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_registration"] diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index 7ef2167..8ef4a15 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # 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 from google.cloud.domains_v1beta1.types import domains -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DomainsTransport, DEFAULT_CLIENT_INFO from .grpc import DomainsGrpcTransport @@ -56,7 +53,7 @@ class DomainsGrpcAsyncIOTransport(DomainsTransport): def create_channel( cls, host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -83,13 +80,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -97,7 +96,7 @@ def __init__( self, *, host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -111,7 +110,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -170,7 +170,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -312,7 +311,7 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> Callable[[domains.RegisterDomainRequest], Awaitable[operations.Operation]]: + ) -> Callable[[domains.RegisterDomainRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the register domain method over gRPC. Registers a new domain name and creates a corresponding @@ -344,7 +343,7 @@ def register_domain( self._stubs["register_domain"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/RegisterDomain", request_serializer=domains.RegisterDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["register_domain"] @@ -405,7 +404,9 @@ def get_registration( @property def update_registration( self, - ) -> Callable[[domains.UpdateRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.UpdateRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update registration method over gRPC. Updates select fields of a ``Registration`` resource, notably @@ -432,7 +433,7 @@ def update_registration( self._stubs["update_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/UpdateRegistration", request_serializer=domains.UpdateRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_registration"] @@ -440,7 +441,8 @@ def update_registration( def configure_management_settings( self, ) -> Callable[ - [domains.ConfigureManagementSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureManagementSettingsRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the configure management settings method over gRPC. @@ -462,7 +464,7 @@ def configure_management_settings( ] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureManagementSettings", request_serializer=domains.ConfigureManagementSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_management_settings"] @@ -470,7 +472,7 @@ def configure_management_settings( def configure_dns_settings( self, ) -> Callable[ - [domains.ConfigureDnsSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureDnsSettingsRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the configure dns settings method over gRPC. @@ -490,7 +492,7 @@ def configure_dns_settings( self._stubs["configure_dns_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureDnsSettings", request_serializer=domains.ConfigureDnsSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_dns_settings"] @@ -498,7 +500,7 @@ def configure_dns_settings( def configure_contact_settings( self, ) -> Callable[ - [domains.ConfigureContactSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureContactSettingsRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the configure contact settings method over gRPC. @@ -519,14 +521,16 @@ def configure_contact_settings( self._stubs["configure_contact_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureContactSettings", request_serializer=domains.ConfigureContactSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_contact_settings"] @property def export_registration( self, - ) -> Callable[[domains.ExportRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.ExportRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export registration method over gRPC. Exports a ``Registration`` that you no longer want to use with @@ -558,14 +562,16 @@ def export_registration( self._stubs["export_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ExportRegistration", request_serializer=domains.ExportRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_registration"] @property def delete_registration( self, - ) -> Callable[[domains.DeleteRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.DeleteRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete registration method over gRPC. Deletes a ``Registration`` resource. @@ -590,7 +596,7 @@ def delete_registration( self._stubs["delete_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/DeleteRegistration", request_serializer=domains.DeleteRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_registration"] diff --git a/google/cloud/domains_v1beta1/types/__init__.py b/google/cloud/domains_v1beta1/types/__init__.py index c92ebe3..73c9baa1 100644 --- a/google/cloud/domains_v1beta1/types/__init__.py +++ b/google/cloud/domains_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .domains import ( AuthorizationCode, ConfigureContactSettingsRequest, diff --git a/google/cloud/domains_v1beta1/types/domains.py b/google/cloud/domains_v1beta1/types/domains.py index 43374bb..f18a31b 100644 --- a/google/cloud/domains_v1beta1/types/domains.py +++ b/google/cloud/domains_v1beta1/types/domains.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore __protobuf__ = proto.module( @@ -172,32 +169,21 @@ class Issue(proto.Enum): CONTACT_SUPPORT = 1 UNVERIFIED_EMAIL = 2 - name = proto.Field(proto.STRING, number=1) - - domain_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - expire_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + domain_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + expire_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) state = proto.Field(proto.ENUM, number=7, enum=State,) - issues = proto.RepeatedField(proto.ENUM, number=8, enum=Issue,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=9) - + labels = proto.MapField(proto.STRING, proto.STRING, number=9,) management_settings = proto.Field( proto.MESSAGE, number=10, message="ManagementSettings", ) - dns_settings = proto.Field(proto.MESSAGE, number=11, message="DnsSettings",) - contact_settings = proto.Field(proto.MESSAGE, number=12, message="ContactSettings",) - pending_contact_settings = proto.Field( proto.MESSAGE, number=13, message="ContactSettings", ) - supported_privacy = proto.RepeatedField( proto.ENUM, number=14, enum="ContactPrivacy", ) @@ -222,7 +208,6 @@ class RenewalMethod(proto.Enum): MANUAL_RENEWAL = 2 renewal_method = proto.Field(proto.ENUM, number=3, enum=RenewalMethod,) - transfer_lock_state = proto.Field(proto.ENUM, number=4, enum="TransferLockState",) @@ -250,7 +235,6 @@ class DsState(proto.Enum): class CustomDns(proto.Message): r"""Configuration for an arbitrary DNS provider. - Attributes: name_servers (Sequence[str]): Required. A list of name servers that store @@ -264,8 +248,7 @@ class CustomDns(proto.Message): this field is empty, DNSSEC is disabled. """ - name_servers = proto.RepeatedField(proto.STRING, number=1) - + name_servers = proto.RepeatedField(proto.STRING, number=1,) ds_records = proto.RepeatedField( proto.MESSAGE, number=2, message="DnsSettings.DsRecord", ) @@ -295,10 +278,8 @@ class GoogleDomainsDns(proto.Message): remains empty. """ - name_servers = proto.RepeatedField(proto.STRING, number=1) - + name_servers = proto.RepeatedField(proto.STRING, number=1,) ds_state = proto.Field(proto.ENUM, number=2, enum="DnsSettings.DsState",) - ds_records = proto.RepeatedField( proto.MESSAGE, number=3, message="DnsSettings.DsRecord", ) @@ -351,17 +332,14 @@ class DigestType(proto.Enum): GOST3411 = 3 SHA384 = 4 - key_tag = proto.Field(proto.INT32, number=1) - + key_tag = proto.Field(proto.INT32, number=1,) algorithm = proto.Field( proto.ENUM, number=2, enum="DnsSettings.DsRecord.Algorithm", ) - digest_type = proto.Field( proto.ENUM, number=3, enum="DnsSettings.DsRecord.DigestType", ) - - digest = proto.Field(proto.STRING, number=4) + digest = proto.Field(proto.STRING, number=4,) class GlueRecord(proto.Message): r"""Defines a host on your domain that is a DNS name server for your @@ -385,20 +363,16 @@ class GlueRecord(proto.Message): one of ``ipv4_address`` and ``ipv6_address`` must be set. """ - host_name = proto.Field(proto.STRING, number=1) - - ipv4_addresses = proto.RepeatedField(proto.STRING, number=2) - - ipv6_addresses = proto.RepeatedField(proto.STRING, number=3) + host_name = proto.Field(proto.STRING, number=1,) + ipv4_addresses = proto.RepeatedField(proto.STRING, number=2,) + ipv6_addresses = proto.RepeatedField(proto.STRING, number=3,) custom_dns = proto.Field( proto.MESSAGE, number=1, oneof="dns_provider", message=CustomDns, ) - google_domains_dns = proto.Field( proto.MESSAGE, number=2, oneof="dns_provider", message=GoogleDomainsDns, ) - glue_records = proto.RepeatedField(proto.MESSAGE, number=4, message=GlueRecord,) @@ -433,7 +407,6 @@ class ContactSettings(proto.Message): class Contact(proto.Message): r"""Details required for a contact associated with a ``Registration``. - Attributes: postal_address (google.type.postal_address_pb2.PostalAddress): Required. Postal address of the contact. @@ -448,27 +421,20 @@ class Contact(proto.Message): """ postal_address = proto.Field( - proto.MESSAGE, number=1, message=gt_postal_address.PostalAddress, + proto.MESSAGE, number=1, message=postal_address_pb2.PostalAddress, ) - - email = proto.Field(proto.STRING, number=2) - - phone_number = proto.Field(proto.STRING, number=3) - - fax_number = proto.Field(proto.STRING, number=4) + email = proto.Field(proto.STRING, number=2,) + phone_number = proto.Field(proto.STRING, number=3,) + fax_number = proto.Field(proto.STRING, number=4,) privacy = proto.Field(proto.ENUM, number=1, enum="ContactPrivacy",) - registrant_contact = proto.Field(proto.MESSAGE, number=2, message=Contact,) - admin_contact = proto.Field(proto.MESSAGE, number=3, message=Contact,) - technical_contact = proto.Field(proto.MESSAGE, number=4, message=Contact,) class SearchDomainsRequest(proto.Message): r"""Request for the ``SearchDomains`` method. - Attributes: query (str): Required. String used to search for available @@ -478,14 +444,12 @@ class SearchDomainsRequest(proto.Message): ``projects/*/locations/*``. """ - query = proto.Field(proto.STRING, number=1) - - location = proto.Field(proto.STRING, number=2) + query = proto.Field(proto.STRING, number=1,) + location = proto.Field(proto.STRING, number=2,) class SearchDomainsResponse(proto.Message): r"""Response for the ``SearchDomains`` method. - Attributes: register_parameters (Sequence[google.cloud.domains_v1beta1.types.RegisterParameters]): Results of the domain name search. @@ -498,7 +462,6 @@ class SearchDomainsResponse(proto.Message): class RetrieveRegisterParametersRequest(proto.Message): r"""Request for the ``RetrieveRegisterParameters`` method. - Attributes: domain_name (str): Required. The domain name. Unicode domain @@ -508,14 +471,12 @@ class RetrieveRegisterParametersRequest(proto.Message): ``projects/*/locations/*``. """ - domain_name = proto.Field(proto.STRING, number=1) - - location = proto.Field(proto.STRING, number=2) + domain_name = proto.Field(proto.STRING, number=1,) + location = proto.Field(proto.STRING, number=2,) class RetrieveRegisterParametersResponse(proto.Message): r"""Response for the ``RetrieveRegisterParameters`` method. - Attributes: register_parameters (google.cloud.domains_v1beta1.types.RegisterParameters): Parameters to use when calling the ``RegisterDomain`` @@ -529,7 +490,6 @@ class RetrieveRegisterParametersResponse(proto.Message): class RegisterDomainRequest(proto.Message): r"""Request for the ``RegisterDomain`` method. - Attributes: parent (str): Required. The parent resource of the ``Registration``. Must @@ -556,22 +516,16 @@ class RegisterDomainRequest(proto.Message): https://cloud.google.com/apis/design/design_patterns#request_validation """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) registration = proto.Field(proto.MESSAGE, number=2, message="Registration",) - domain_notices = proto.RepeatedField(proto.ENUM, number=3, enum="DomainNotice",) - contact_notices = proto.RepeatedField(proto.ENUM, number=4, enum="ContactNotice",) - - yearly_price = proto.Field(proto.MESSAGE, number=5, message=money.Money,) - - validate_only = proto.Field(proto.BOOL, number=6) + yearly_price = proto.Field(proto.MESSAGE, number=5, message=money_pb2.Money,) + validate_only = proto.Field(proto.BOOL, number=6,) class ListRegistrationsRequest(proto.Message): r"""Request for the ``ListRegistrations`` method. - Attributes: parent (str): Required. The project and location from which to list @@ -605,18 +559,14 @@ class ListRegistrationsRequest(proto.Message): ``(state=SUSPENDED) OR (issue:*)``. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListRegistrationsResponse(proto.Message): r"""Response for the ``ListRegistrations`` method. - Attributes: registrations (Sequence[google.cloud.domains_v1beta1.types.Registration]): A list of ``Registration``\ s. @@ -633,25 +583,22 @@ def raw_page(self): registrations = proto.RepeatedField( proto.MESSAGE, number=1, message="Registration", ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetRegistrationRequest(proto.Message): r"""Request for the ``GetRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to get, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateRegistrationRequest(proto.Message): r"""Request for the ``UpdateRegistration`` method. - Attributes: registration (google.cloud.domains_v1beta1.types.Registration): Fields of the ``Registration`` to update. @@ -663,13 +610,13 @@ class UpdateRegistrationRequest(proto.Message): """ registration = proto.Field(proto.MESSAGE, number=1, message="Registration",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class ConfigureManagementSettingsRequest(proto.Message): r"""Request for the ``ConfigureManagementSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose management @@ -684,18 +631,17 @@ class ConfigureManagementSettingsRequest(proto.Message): ``"transfer_lock_state"``. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) management_settings = proto.Field( proto.MESSAGE, number=2, message="ManagementSettings", ) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) class ConfigureDnsSettingsRequest(proto.Message): r"""Request for the ``ConfigureDnsSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose DNS @@ -720,18 +666,16 @@ class ConfigureDnsSettingsRequest(proto.Message): updating the DNS settings. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) dns_settings = proto.Field(proto.MESSAGE, number=2, message="DnsSettings",) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) - - validate_only = proto.Field(proto.BOOL, number=4) + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) + validate_only = proto.Field(proto.BOOL, number=4,) class ConfigureContactSettingsRequest(proto.Message): r"""Request for the ``ConfigureContactSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose contact @@ -753,44 +697,39 @@ class ConfigureContactSettingsRequest(proto.Message): updating the contact settings. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) contact_settings = proto.Field(proto.MESSAGE, number=2, message="ContactSettings",) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) contact_notices = proto.RepeatedField(proto.ENUM, number=4, enum="ContactNotice",) - - validate_only = proto.Field(proto.BOOL, number=5) + validate_only = proto.Field(proto.BOOL, number=5,) class ExportRegistrationRequest(proto.Message): r"""Request for the ``ExportRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to export, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteRegistrationRequest(proto.Message): r"""Request for the ``DeleteRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to delete, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class RetrieveAuthorizationCodeRequest(proto.Message): r"""Request for the ``RetrieveAuthorizationCode`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose @@ -798,12 +737,11 @@ class RetrieveAuthorizationCodeRequest(proto.Message): ``projects/*/locations/*/registrations/*``. """ - registration = proto.Field(proto.STRING, number=1) + registration = proto.Field(proto.STRING, number=1,) class ResetAuthorizationCodeRequest(proto.Message): r"""Request for the ``ResetAuthorizationCode`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose @@ -811,12 +749,11 @@ class ResetAuthorizationCodeRequest(proto.Message): ``projects/*/locations/*/registrations/*``. """ - registration = proto.Field(proto.STRING, number=1) + registration = proto.Field(proto.STRING, number=1,) class RegisterParameters(proto.Message): r"""Parameters required to register a new domain. - Attributes: domain_name (str): The domain name. Unicode domain names are @@ -845,22 +782,17 @@ class Availability(proto.Enum): UNSUPPORTED = 3 UNKNOWN = 4 - domain_name = proto.Field(proto.STRING, number=1) - + domain_name = proto.Field(proto.STRING, number=1,) availability = proto.Field(proto.ENUM, number=2, enum=Availability,) - supported_privacy = proto.RepeatedField( proto.ENUM, number=3, enum="ContactPrivacy", ) - domain_notices = proto.RepeatedField(proto.ENUM, number=4, enum="DomainNotice",) - - yearly_price = proto.Field(proto.MESSAGE, number=5, message=money.Money,) + yearly_price = proto.Field(proto.MESSAGE, number=5, message=money_pb2.Money,) class AuthorizationCode(proto.Message): r"""Defines an authorization code. - Attributes: code (str): The Authorization Code in ASCII. It can be @@ -868,7 +800,7 @@ class AuthorizationCode(proto.Message): registrar. """ - code = proto.Field(proto.STRING, number=1) + code = proto.Field(proto.STRING, number=1,) class OperationMetadata(proto.Message): @@ -892,17 +824,12 @@ class OperationMetadata(proto.Message): API version used to start the operation. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - target = proto.Field(proto.STRING, number=3) - - verb = proto.Field(proto.STRING, number=4) - - status_detail = proto.Field(proto.STRING, number=5) - - api_version = proto.Field(proto.STRING, number=6) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_detail = proto.Field(proto.STRING, number=5,) + api_version = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_domains_v1beta1_keywords.py b/scripts/fixup_domains_v1beta1_keywords.py index 84e801c..d1ade46 100644 --- a/scripts/fixup_domains_v1beta1_keywords.py +++ b/scripts/fixup_domains_v1beta1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,20 +39,19 @@ def partition( class domainsCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'configure_contact_settings': ('registration', 'update_mask', 'contact_settings', 'contact_notices', 'validate_only', ), - 'configure_dns_settings': ('registration', 'update_mask', 'dns_settings', 'validate_only', ), - 'configure_management_settings': ('registration', 'update_mask', 'management_settings', ), - 'delete_registration': ('name', ), - 'export_registration': ('name', ), - 'get_registration': ('name', ), - 'list_registrations': ('parent', 'page_size', 'page_token', 'filter', ), - 'register_domain': ('parent', 'registration', 'yearly_price', 'domain_notices', 'contact_notices', 'validate_only', ), - 'reset_authorization_code': ('registration', ), - 'retrieve_authorization_code': ('registration', ), - 'retrieve_register_parameters': ('domain_name', 'location', ), - 'search_domains': ('query', 'location', ), - 'update_registration': ('update_mask', 'registration', ), - + 'configure_contact_settings': ('registration', 'update_mask', 'contact_settings', 'contact_notices', 'validate_only', ), + 'configure_dns_settings': ('registration', 'update_mask', 'dns_settings', 'validate_only', ), + 'configure_management_settings': ('registration', 'update_mask', 'management_settings', ), + 'delete_registration': ('name', ), + 'export_registration': ('name', ), + 'get_registration': ('name', ), + 'list_registrations': ('parent', 'page_size', 'page_token', 'filter', ), + 'register_domain': ('parent', 'registration', 'yearly_price', 'domain_notices', 'contact_notices', 'validate_only', ), + 'reset_authorization_code': ('registration', ), + 'retrieve_authorization_code': ('registration', ), + 'retrieve_register_parameters': ('domain_name', 'location', ), + 'search_domains': ('query', 'location', ), + 'update_registration': ('update_mask', 'registration', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -85,7 +82,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/domains_v1beta1/__init__.py b/tests/unit/gapic/domains_v1beta1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/domains_v1beta1/__init__.py +++ b/tests/unit/gapic/domains_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index d8e036f..7e1092f 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,28 +23,58 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.domains_v1beta1.services.domains import DomainsAsyncClient from google.cloud.domains_v1beta1.services.domains import DomainsClient from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.services.domains import transports +from google.cloud.domains_v1beta1.services.domains.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.domains_v1beta1.services.domains.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.domains_v1beta1.types import domains from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as postal_address # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and 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", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -88,7 +117,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) def test_domains_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -103,7 +132,7 @@ def test_domains_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) def test_domains_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -146,7 +175,7 @@ def test_domains_client_get_transport_class(): def test_domains_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. with mock.patch.object(DomainsClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -420,7 +449,7 @@ def test_search_domains( transport: str = "grpc", request_type=domains.SearchDomainsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -431,17 +460,14 @@ def test_search_domains( with mock.patch.object(type(client.transport.search_domains), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.SearchDomainsResponse() - response = client.search_domains(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.SearchDomainsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.SearchDomainsResponse) @@ -453,7 +479,7 @@ def test_search_domains_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -461,7 +487,6 @@ def test_search_domains_empty_call(): client.search_domains() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.SearchDomainsRequest() @@ -470,7 +495,7 @@ async def test_search_domains_async( transport: str = "grpc_asyncio", request_type=domains.SearchDomainsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -483,13 +508,11 @@ async def test_search_domains_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.SearchDomainsResponse() ) - response = await client.search_domains(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.SearchDomainsRequest() # Establish that the response is the type that we expect. @@ -502,17 +525,17 @@ async def test_search_domains_async_from_dict(): def test_search_domains_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.SearchDomainsRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: call.return_value = domains.SearchDomainsResponse() - client.search_domains(request) # Establish that the underlying gRPC stub method was called. @@ -527,11 +550,12 @@ def test_search_domains_field_headers(): @pytest.mark.asyncio async def test_search_domains_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.SearchDomainsRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -539,7 +563,6 @@ async def test_search_domains_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.SearchDomainsResponse() ) - await client.search_domains(request) # Establish that the underlying gRPC stub method was called. @@ -553,13 +576,12 @@ async def test_search_domains_field_headers_async(): def test_search_domains_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.SearchDomainsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_domains( @@ -570,14 +592,12 @@ def test_search_domains_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].query == "query_value" def test_search_domains_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -591,7 +611,7 @@ def test_search_domains_flattened_error(): @pytest.mark.asyncio async def test_search_domains_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: @@ -611,15 +631,13 @@ async def test_search_domains_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].query == "query_value" @pytest.mark.asyncio async def test_search_domains_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -635,7 +653,7 @@ def test_retrieve_register_parameters( transport: str = "grpc", request_type=domains.RetrieveRegisterParametersRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -648,17 +666,14 @@ def test_retrieve_register_parameters( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.RetrieveRegisterParametersResponse() - response = client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.RetrieveRegisterParametersResponse) @@ -670,7 +685,7 @@ def test_retrieve_register_parameters_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -680,7 +695,6 @@ def test_retrieve_register_parameters_empty_call(): client.retrieve_register_parameters() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() @@ -690,7 +704,7 @@ async def test_retrieve_register_parameters_async( request_type=domains.RetrieveRegisterParametersRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -705,13 +719,11 @@ async def test_retrieve_register_parameters_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.RetrieveRegisterParametersResponse() ) - response = await client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() # Establish that the response is the type that we expect. @@ -724,11 +736,12 @@ async def test_retrieve_register_parameters_async_from_dict(): def test_retrieve_register_parameters_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RetrieveRegisterParametersRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -736,7 +749,6 @@ def test_retrieve_register_parameters_field_headers(): type(client.transport.retrieve_register_parameters), "__call__" ) as call: call.return_value = domains.RetrieveRegisterParametersResponse() - client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. @@ -751,11 +763,12 @@ def test_retrieve_register_parameters_field_headers(): @pytest.mark.asyncio async def test_retrieve_register_parameters_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RetrieveRegisterParametersRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -765,7 +778,6 @@ async def test_retrieve_register_parameters_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.RetrieveRegisterParametersResponse() ) - await client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. @@ -779,7 +791,7 @@ async def test_retrieve_register_parameters_field_headers_async(): def test_retrieve_register_parameters_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -787,7 +799,6 @@ def test_retrieve_register_parameters_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.RetrieveRegisterParametersResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retrieve_register_parameters( @@ -798,14 +809,12 @@ def test_retrieve_register_parameters_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].domain_name == "domain_name_value" def test_retrieve_register_parameters_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -819,7 +828,7 @@ def test_retrieve_register_parameters_flattened_error(): @pytest.mark.asyncio async def test_retrieve_register_parameters_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -841,15 +850,13 @@ async def test_retrieve_register_parameters_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].domain_name == "domain_name_value" @pytest.mark.asyncio async def test_retrieve_register_parameters_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -865,7 +872,7 @@ def test_register_domain( transport: str = "grpc", request_type=domains.RegisterDomainRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -876,13 +883,11 @@ def test_register_domain( with mock.patch.object(type(client.transport.register_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.register_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.RegisterDomainRequest() # Establish that the response is the type that we expect. @@ -897,7 +902,7 @@ def test_register_domain_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -905,7 +910,6 @@ def test_register_domain_empty_call(): client.register_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RegisterDomainRequest() @@ -914,7 +918,7 @@ async def test_register_domain_async( transport: str = "grpc_asyncio", request_type=domains.RegisterDomainRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -927,13 +931,11 @@ async def test_register_domain_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.register_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RegisterDomainRequest() # Establish that the response is the type that we expect. @@ -946,17 +948,17 @@ async def test_register_domain_async_from_dict(): def test_register_domain_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RegisterDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_domain), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.register_domain(request) # Establish that the underlying gRPC stub method was called. @@ -971,11 +973,12 @@ def test_register_domain_field_headers(): @pytest.mark.asyncio async def test_register_domain_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RegisterDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -983,7 +986,6 @@ async def test_register_domain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.register_domain(request) # Establish that the underlying gRPC stub method was called. @@ -997,35 +999,33 @@ async def test_register_domain_field_headers_async(): def test_register_domain_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.register_domain( parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].yearly_price == money.Money(currency_code="currency_code_value") + assert args[0].yearly_price == money_pb2.Money( + currency_code="currency_code_value" + ) def test_register_domain_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1034,13 +1034,13 @@ def test_register_domain_flattened_error(): domains.RegisterDomainRequest(), parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) @pytest.mark.asyncio async def test_register_domain_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_domain), "__call__") as call: @@ -1055,24 +1055,23 @@ async def test_register_domain_flattened_async(): response = await client.register_domain( parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].yearly_price == money.Money(currency_code="currency_code_value") + assert args[0].yearly_price == money_pb2.Money( + currency_code="currency_code_value" + ) @pytest.mark.asyncio async def test_register_domain_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1081,7 +1080,7 @@ async def test_register_domain_flattened_error_async(): domains.RegisterDomainRequest(), parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) @@ -1089,7 +1088,7 @@ def test_list_registrations( transport: str = "grpc", request_type=domains.ListRegistrationsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1104,19 +1103,15 @@ def test_list_registrations( call.return_value = domains.ListRegistrationsResponse( next_page_token="next_page_token_value", ) - response = client.list_registrations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRegistrationsPager) - assert response.next_page_token == "next_page_token_value" @@ -1128,7 +1123,7 @@ def test_list_registrations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1138,7 +1133,6 @@ def test_list_registrations_empty_call(): client.list_registrations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() @@ -1147,7 +1141,7 @@ async def test_list_registrations_async( transport: str = "grpc_asyncio", request_type=domains.ListRegistrationsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1162,18 +1156,15 @@ async def test_list_registrations_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.ListRegistrationsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_registrations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListRegistrationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1183,11 +1174,12 @@ async def test_list_registrations_async_from_dict(): def test_list_registrations_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ListRegistrationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1195,7 +1187,6 @@ def test_list_registrations_field_headers(): type(client.transport.list_registrations), "__call__" ) as call: call.return_value = domains.ListRegistrationsResponse() - client.list_registrations(request) # Establish that the underlying gRPC stub method was called. @@ -1210,11 +1201,12 @@ def test_list_registrations_field_headers(): @pytest.mark.asyncio async def test_list_registrations_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ListRegistrationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1224,7 +1216,6 @@ async def test_list_registrations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.ListRegistrationsResponse() ) - await client.list_registrations(request) # Establish that the underlying gRPC stub method was called. @@ -1238,7 +1229,7 @@ async def test_list_registrations_field_headers_async(): def test_list_registrations_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1246,7 +1237,6 @@ def test_list_registrations_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.ListRegistrationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_registrations(parent="parent_value",) @@ -1255,12 +1245,11 @@ def test_list_registrations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_registrations_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1272,7 +1261,7 @@ def test_list_registrations_flattened_error(): @pytest.mark.asyncio async def test_list_registrations_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1292,13 +1281,12 @@ async def test_list_registrations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_registrations_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1309,7 +1297,7 @@ async def test_list_registrations_flattened_error_async(): def test_list_registrations_pager(): - client = DomainsClient(credentials=credentials.AnonymousCredentials,) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1349,7 +1337,7 @@ def test_list_registrations_pager(): def test_list_registrations_pages(): - client = DomainsClient(credentials=credentials.AnonymousCredentials,) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1381,7 +1369,7 @@ def test_list_registrations_pages(): @pytest.mark.asyncio async def test_list_registrations_async_pager(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1420,7 +1408,7 @@ async def test_list_registrations_async_pager(): @pytest.mark.asyncio async def test_list_registrations_async_pages(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1458,7 +1446,7 @@ def test_get_registration( transport: str = "grpc", request_type=domains.GetRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1475,27 +1463,19 @@ def test_get_registration( issues=[domains.Registration.Issue.CONTACT_SUPPORT], supported_privacy=[domains.ContactPrivacy.PUBLIC_CONTACT_DATA], ) - response = client.get_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.Registration) - assert response.name == "name_value" - assert response.domain_name == "domain_name_value" - assert response.state == domains.Registration.State.REGISTRATION_PENDING - assert response.issues == [domains.Registration.Issue.CONTACT_SUPPORT] - assert response.supported_privacy == [domains.ContactPrivacy.PUBLIC_CONTACT_DATA] @@ -1507,7 +1487,7 @@ def test_get_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1515,7 +1495,6 @@ def test_get_registration_empty_call(): client.get_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() @@ -1524,7 +1503,7 @@ async def test_get_registration_async( transport: str = "grpc_asyncio", request_type=domains.GetRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1543,26 +1522,19 @@ async def test_get_registration_async( supported_privacy=[domains.ContactPrivacy.PUBLIC_CONTACT_DATA], ) ) - response = await client.get_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.Registration) - assert response.name == "name_value" - assert response.domain_name == "domain_name_value" - assert response.state == domains.Registration.State.REGISTRATION_PENDING - assert response.issues == [domains.Registration.Issue.CONTACT_SUPPORT] - assert response.supported_privacy == [domains.ContactPrivacy.PUBLIC_CONTACT_DATA] @@ -1572,17 +1544,17 @@ async def test_get_registration_async_from_dict(): def test_get_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.GetRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: call.return_value = domains.Registration() - client.get_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1597,11 +1569,12 @@ def test_get_registration_field_headers(): @pytest.mark.asyncio async def test_get_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.GetRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1609,7 +1582,6 @@ async def test_get_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.Registration() ) - await client.get_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1623,13 +1595,12 @@ async def test_get_registration_field_headers_async(): def test_get_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.Registration() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_registration(name="name_value",) @@ -1638,12 +1609,11 @@ def test_get_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1655,7 +1625,7 @@ def test_get_registration_flattened_error(): @pytest.mark.asyncio async def test_get_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: @@ -1673,13 +1643,12 @@ async def test_get_registration_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1693,7 +1662,7 @@ def test_update_registration( transport: str = "grpc", request_type=domains.UpdateRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1706,13 +1675,11 @@ def test_update_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() # Establish that the response is the type that we expect. @@ -1727,7 +1694,7 @@ def test_update_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1737,7 +1704,6 @@ def test_update_registration_empty_call(): client.update_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() @@ -1746,7 +1712,7 @@ async def test_update_registration_async( transport: str = "grpc_asyncio", request_type=domains.UpdateRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1761,13 +1727,11 @@ async def test_update_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() # Establish that the response is the type that we expect. @@ -1780,11 +1744,12 @@ async def test_update_registration_async_from_dict(): def test_update_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.UpdateRegistrationRequest() + request.registration.name = "registration.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1792,7 +1757,6 @@ def test_update_registration_field_headers(): type(client.transport.update_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1810,11 +1774,12 @@ def test_update_registration_field_headers(): @pytest.mark.asyncio async def test_update_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.UpdateRegistrationRequest() + request.registration.name = "registration.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1824,7 +1789,6 @@ async def test_update_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1841,7 +1805,7 @@ async def test_update_registration_field_headers_async(): def test_update_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1849,26 +1813,23 @@ def test_update_registration_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_registration( registration=domains.Registration(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1876,13 +1837,13 @@ def test_update_registration_flattened_error(): client.update_registration( domains.UpdateRegistrationRequest(), registration=domains.Registration(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1898,22 +1859,20 @@ async def test_update_registration_flattened_async(): # using the keyword arguments to the method. response = await client.update_registration( registration=domains.Registration(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1921,7 +1880,7 @@ async def test_update_registration_flattened_error_async(): await client.update_registration( domains.UpdateRegistrationRequest(), registration=domains.Registration(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1929,7 +1888,7 @@ def test_configure_management_settings( transport: str = "grpc", request_type=domains.ConfigureManagementSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1942,13 +1901,11 @@ def test_configure_management_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() # Establish that the response is the type that we expect. @@ -1963,7 +1920,7 @@ def test_configure_management_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1973,7 +1930,6 @@ def test_configure_management_settings_empty_call(): client.configure_management_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() @@ -1983,7 +1939,7 @@ async def test_configure_management_settings_async( request_type=domains.ConfigureManagementSettingsRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1998,13 +1954,11 @@ async def test_configure_management_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() # Establish that the response is the type that we expect. @@ -2017,11 +1971,12 @@ async def test_configure_management_settings_async_from_dict(): def test_configure_management_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureManagementSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2029,7 +1984,6 @@ def test_configure_management_settings_field_headers(): type(client.transport.configure_management_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2046,11 +2000,12 @@ def test_configure_management_settings_field_headers(): @pytest.mark.asyncio async def test_configure_management_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureManagementSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2060,7 +2015,6 @@ async def test_configure_management_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2076,7 +2030,7 @@ async def test_configure_management_settings_field_headers_async(): def test_configure_management_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2084,7 +2038,6 @@ def test_configure_management_settings_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.configure_management_settings( @@ -2092,25 +2045,22 @@ def test_configure_management_settings_flattened(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].management_settings == domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_configure_management_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2121,13 +2071,13 @@ def test_configure_management_settings_flattened_error(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_management_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2146,26 +2096,23 @@ async def test_configure_management_settings_flattened_async(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].management_settings == domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_configure_management_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2176,7 +2123,7 @@ async def test_configure_management_settings_flattened_error_async(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2184,7 +2131,7 @@ def test_configure_dns_settings( transport: str = "grpc", request_type=domains.ConfigureDnsSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2197,13 +2144,11 @@ def test_configure_dns_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() # Establish that the response is the type that we expect. @@ -2218,7 +2163,7 @@ def test_configure_dns_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2228,7 +2173,6 @@ def test_configure_dns_settings_empty_call(): client.configure_dns_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() @@ -2237,7 +2181,7 @@ async def test_configure_dns_settings_async( transport: str = "grpc_asyncio", request_type=domains.ConfigureDnsSettingsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2252,13 +2196,11 @@ async def test_configure_dns_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() # Establish that the response is the type that we expect. @@ -2271,11 +2213,12 @@ async def test_configure_dns_settings_async_from_dict(): def test_configure_dns_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureDnsSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2283,7 +2226,6 @@ def test_configure_dns_settings_field_headers(): type(client.transport.configure_dns_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2300,11 +2242,12 @@ def test_configure_dns_settings_field_headers(): @pytest.mark.asyncio async def test_configure_dns_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureDnsSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2314,7 +2257,6 @@ async def test_configure_dns_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2330,7 +2272,7 @@ async def test_configure_dns_settings_field_headers_async(): def test_configure_dns_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2338,7 +2280,6 @@ def test_configure_dns_settings_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.configure_dns_settings( @@ -2348,27 +2289,24 @@ def test_configure_dns_settings_flattened(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].dns_settings == domains.DnsSettings( custom_dns=domains.DnsSettings.CustomDns( name_servers=["name_servers_value"] ) ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_configure_dns_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2381,13 +2319,13 @@ def test_configure_dns_settings_flattened_error(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_dns_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2408,28 +2346,25 @@ async def test_configure_dns_settings_flattened_async(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].dns_settings == domains.DnsSettings( custom_dns=domains.DnsSettings.CustomDns( name_servers=["name_servers_value"] ) ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_configure_dns_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2442,7 +2377,7 @@ async def test_configure_dns_settings_flattened_error_async(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2450,7 +2385,7 @@ def test_configure_contact_settings( transport: str = "grpc", request_type=domains.ConfigureContactSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2463,13 +2398,11 @@ def test_configure_contact_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() # Establish that the response is the type that we expect. @@ -2484,7 +2417,7 @@ def test_configure_contact_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2494,7 +2427,6 @@ def test_configure_contact_settings_empty_call(): client.configure_contact_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() @@ -2504,7 +2436,7 @@ async def test_configure_contact_settings_async( request_type=domains.ConfigureContactSettingsRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2519,13 +2451,11 @@ async def test_configure_contact_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() # Establish that the response is the type that we expect. @@ -2538,11 +2468,12 @@ async def test_configure_contact_settings_async_from_dict(): def test_configure_contact_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureContactSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2550,7 +2481,6 @@ def test_configure_contact_settings_field_headers(): type(client.transport.configure_contact_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2567,11 +2497,12 @@ def test_configure_contact_settings_field_headers(): @pytest.mark.asyncio async def test_configure_contact_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ConfigureContactSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2581,7 +2512,6 @@ async def test_configure_contact_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2597,7 +2527,7 @@ async def test_configure_contact_settings_field_headers_async(): def test_configure_contact_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2605,7 +2535,6 @@ def test_configure_contact_settings_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.configure_contact_settings( @@ -2613,25 +2542,22 @@ def test_configure_contact_settings_flattened(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].contact_settings == domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_configure_contact_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2642,13 +2568,13 @@ def test_configure_contact_settings_flattened_error(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_contact_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2667,26 +2593,23 @@ async def test_configure_contact_settings_flattened_async(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" - assert args[0].contact_settings == domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_configure_contact_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2697,7 +2620,7 @@ async def test_configure_contact_settings_flattened_error_async(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2705,7 +2628,7 @@ def test_export_registration( transport: str = "grpc", request_type=domains.ExportRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2718,13 +2641,11 @@ def test_export_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() # Establish that the response is the type that we expect. @@ -2739,7 +2660,7 @@ def test_export_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2749,7 +2670,6 @@ def test_export_registration_empty_call(): client.export_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() @@ -2758,7 +2678,7 @@ async def test_export_registration_async( transport: str = "grpc_asyncio", request_type=domains.ExportRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2773,13 +2693,11 @@ async def test_export_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() # Establish that the response is the type that we expect. @@ -2792,11 +2710,12 @@ async def test_export_registration_async_from_dict(): def test_export_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ExportRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2804,7 +2723,6 @@ def test_export_registration_field_headers(): type(client.transport.export_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_registration(request) # Establish that the underlying gRPC stub method was called. @@ -2819,11 +2737,12 @@ def test_export_registration_field_headers(): @pytest.mark.asyncio async def test_export_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ExportRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2833,7 +2752,6 @@ async def test_export_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_registration(request) # Establish that the underlying gRPC stub method was called. @@ -2847,7 +2765,7 @@ async def test_export_registration_field_headers_async(): def test_export_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2855,7 +2773,6 @@ def test_export_registration_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_registration(name="name_value",) @@ -2864,12 +2781,11 @@ def test_export_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_export_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2881,7 +2797,7 @@ def test_export_registration_flattened_error(): @pytest.mark.asyncio async def test_export_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2901,13 +2817,12 @@ async def test_export_registration_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_export_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2921,7 +2836,7 @@ def test_delete_registration( transport: str = "grpc", request_type=domains.DeleteRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2934,13 +2849,11 @@ def test_delete_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() # Establish that the response is the type that we expect. @@ -2955,7 +2868,7 @@ def test_delete_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2965,7 +2878,6 @@ def test_delete_registration_empty_call(): client.delete_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() @@ -2974,7 +2886,7 @@ async def test_delete_registration_async( transport: str = "grpc_asyncio", request_type=domains.DeleteRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2989,13 +2901,11 @@ async def test_delete_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() # Establish that the response is the type that we expect. @@ -3008,11 +2918,12 @@ async def test_delete_registration_async_from_dict(): def test_delete_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.DeleteRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3020,7 +2931,6 @@ def test_delete_registration_field_headers(): type(client.transport.delete_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_registration(request) # Establish that the underlying gRPC stub method was called. @@ -3035,11 +2945,12 @@ def test_delete_registration_field_headers(): @pytest.mark.asyncio async def test_delete_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.DeleteRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3049,7 +2960,6 @@ async def test_delete_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_registration(request) # Establish that the underlying gRPC stub method was called. @@ -3063,7 +2973,7 @@ async def test_delete_registration_field_headers_async(): def test_delete_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3071,7 +2981,6 @@ def test_delete_registration_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_registration(name="name_value",) @@ -3080,12 +2989,11 @@ def test_delete_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3097,7 +3005,7 @@ def test_delete_registration_flattened_error(): @pytest.mark.asyncio async def test_delete_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3117,13 +3025,12 @@ async def test_delete_registration_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3137,7 +3044,7 @@ def test_retrieve_authorization_code( transport: str = "grpc", request_type=domains.RetrieveAuthorizationCodeRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3150,19 +3057,15 @@ def test_retrieve_authorization_code( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode(code="code_value",) - response = client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3174,7 +3077,7 @@ def test_retrieve_authorization_code_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3184,7 +3087,6 @@ def test_retrieve_authorization_code_empty_call(): client.retrieve_authorization_code() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() @@ -3194,7 +3096,7 @@ async def test_retrieve_authorization_code_async( request_type=domains.RetrieveAuthorizationCodeRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3209,18 +3111,15 @@ async def test_retrieve_authorization_code_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode(code="code_value",) ) - response = await client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3230,11 +3129,12 @@ async def test_retrieve_authorization_code_async_from_dict(): def test_retrieve_authorization_code_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RetrieveAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3242,7 +3142,6 @@ def test_retrieve_authorization_code_field_headers(): type(client.transport.retrieve_authorization_code), "__call__" ) as call: call.return_value = domains.AuthorizationCode() - client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3259,11 +3158,12 @@ def test_retrieve_authorization_code_field_headers(): @pytest.mark.asyncio async def test_retrieve_authorization_code_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.RetrieveAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3273,7 +3173,6 @@ async def test_retrieve_authorization_code_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode() ) - await client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3289,7 +3188,7 @@ async def test_retrieve_authorization_code_field_headers_async(): def test_retrieve_authorization_code_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3297,7 +3196,6 @@ def test_retrieve_authorization_code_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retrieve_authorization_code(registration="registration_value",) @@ -3306,12 +3204,11 @@ def test_retrieve_authorization_code_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" def test_retrieve_authorization_code_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3324,7 +3221,7 @@ def test_retrieve_authorization_code_flattened_error(): @pytest.mark.asyncio async def test_retrieve_authorization_code_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3346,13 +3243,12 @@ async def test_retrieve_authorization_code_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" @pytest.mark.asyncio async def test_retrieve_authorization_code_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3367,7 +3263,7 @@ def test_reset_authorization_code( transport: str = "grpc", request_type=domains.ResetAuthorizationCodeRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3380,19 +3276,15 @@ def test_reset_authorization_code( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode(code="code_value",) - response = client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3404,7 +3296,7 @@ def test_reset_authorization_code_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3414,7 +3306,6 @@ def test_reset_authorization_code_empty_call(): client.reset_authorization_code() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() @@ -3423,7 +3314,7 @@ async def test_reset_authorization_code_async( transport: str = "grpc_asyncio", request_type=domains.ResetAuthorizationCodeRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3438,18 +3329,15 @@ async def test_reset_authorization_code_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode(code="code_value",) ) - response = await client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3459,11 +3347,12 @@ async def test_reset_authorization_code_async_from_dict(): def test_reset_authorization_code_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ResetAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3471,7 +3360,6 @@ def test_reset_authorization_code_field_headers(): type(client.transport.reset_authorization_code), "__call__" ) as call: call.return_value = domains.AuthorizationCode() - client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3488,11 +3376,12 @@ def test_reset_authorization_code_field_headers(): @pytest.mark.asyncio async def test_reset_authorization_code_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = domains.ResetAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3502,7 +3391,6 @@ async def test_reset_authorization_code_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode() ) - await client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3518,7 +3406,7 @@ async def test_reset_authorization_code_field_headers_async(): def test_reset_authorization_code_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3526,7 +3414,6 @@ def test_reset_authorization_code_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.reset_authorization_code(registration="registration_value",) @@ -3535,12 +3422,11 @@ def test_reset_authorization_code_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" def test_reset_authorization_code_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3552,7 +3438,7 @@ def test_reset_authorization_code_flattened_error(): @pytest.mark.asyncio async def test_reset_authorization_code_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3574,13 +3460,12 @@ async def test_reset_authorization_code_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" @pytest.mark.asyncio async def test_reset_authorization_code_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3593,16 +3478,16 @@ async def test_reset_authorization_code_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( @@ -3612,7 +3497,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( @@ -3623,7 +3508,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = DomainsClient(transport=transport) assert client.transport is transport @@ -3632,13 +3517,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.DomainsGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3650,23 +3535,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.DomainsGrpcTransport,) def test_domains_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.DomainsTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3678,7 +3563,7 @@ def test_domains_base_transport(): ) as Transport: Transport.return_value = None transport = transports.DomainsTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3708,15 +3593,37 @@ def test_domains_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_domains_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.domains_v1beta1.services.domains.transports.DomainsTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.DomainsTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_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.domains_v1beta1.services.domains.transports.DomainsTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DomainsTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3729,19 +3636,33 @@ def test_domains_base_transport_with_credentials_file(): def test_domains_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.domains_v1beta1.services.domains.transports.DomainsTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DomainsTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_domains_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + DomainsClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_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) DomainsClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3749,26 +3670,152 @@ def test_domains_auth_adc(): ) -def test_domains_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport,], +) +@requires_google_auth_gte_1_25_0 +def test_domains_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.DomainsGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport,], +) +@requires_google_auth_lt_1_25_0 +def test_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/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_domains_transport_create_channel(transport_class, grpc_helpers): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "domains.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="domains.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_domains_transport_create_channel_old_api_core(transport_class, grpc_helpers): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "domains.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_domains_transport_create_channel_user_scopes(transport_class, grpc_helpers): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "domains.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], ) def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3807,7 +3854,7 @@ def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class): def test_domains_host_no_port(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="domains.googleapis.com" ), @@ -3817,7 +3864,7 @@ def test_domains_host_no_port(): def test_domains_host_with_port(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="domains.googleapis.com:8000" ), @@ -3868,9 +3915,9 @@ def test_domains_transport_channel_mtls_with_client_cert_source(transport_class) mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3943,7 +3990,7 @@ def test_domains_transport_channel_mtls_with_adc(transport_class): def test_domains_grpc_lro_client(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3956,7 +4003,7 @@ def test_domains_grpc_lro_client(): def test_domains_grpc_lro_async_client(): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3971,7 +4018,6 @@ def test_registration_path(): project = "squid" location = "clam" registration = "whelk" - expected = "projects/{project}/locations/{location}/registrations/{registration}".format( project=project, location=location, registration=registration, ) @@ -3994,7 +4040,6 @@ def test_parse_registration_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4015,7 +4060,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = DomainsClient.common_folder_path(folder) assert expected == actual @@ -4034,7 +4078,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = DomainsClient.common_organization_path(organization) assert expected == actual @@ -4053,7 +4096,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = DomainsClient.common_project_path(project) assert expected == actual @@ -4073,7 +4115,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -4100,7 +4141,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.DomainsTransport, "_prep_wrapped_messages" ) as prep: client = DomainsClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4109,6 +4150,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = DomainsClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)