diff --git a/google/cloud/domains_v1/services/domains/async_client.py b/google/cloud/domains_v1/services/domains/async_client.py index 9a293f0..f746bd0 100644 --- a/google/cloud/domains_v1/services/domains/async_client.py +++ b/google/cloud/domains_v1/services/domains/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.domains_v1.services.domains import pagers @@ -163,11 +165,11 @@ def __init__( async def search_domains( self, - request: domains.SearchDomainsRequest = None, + request: Union[domains.SearchDomainsRequest, dict] = None, *, location: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.SearchDomainsResponse: @@ -179,7 +181,7 @@ async def search_domains( confirm availability. Args: - request (:class:`google.cloud.domains_v1.types.SearchDomainsRequest`): + request (Union[google.cloud.domains_v1.types.SearchDomainsRequest, dict]): The request object. Request for the `SearchDomains` method. location (:class:`str`): @@ -247,11 +249,11 @@ async def search_domains( async def retrieve_register_parameters( self, - request: domains.RetrieveRegisterParametersRequest = None, + request: Union[domains.RetrieveRegisterParametersRequest, dict] = None, *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveRegisterParametersResponse: @@ -260,7 +262,7 @@ async def retrieve_register_parameters( call ``RegisterDomain``. Args: - request (:class:`google.cloud.domains_v1.types.RetrieveRegisterParametersRequest`): + request (Union[google.cloud.domains_v1.types.RetrieveRegisterParametersRequest, dict]): The request object. Request for the `RetrieveRegisterParameters` method. location (:class:`str`): @@ -329,12 +331,12 @@ async def retrieve_register_parameters( async def register_domain( self, - request: domains.RegisterDomainRequest = None, + request: Union[domains.RegisterDomainRequest, dict] = None, *, parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -354,7 +356,7 @@ async def register_domain( and retry registration. Args: - request (:class:`google.cloud.domains_v1.types.RegisterDomainRequest`): + request (Union[google.cloud.domains_v1.types.RegisterDomainRequest, dict]): The request object. Request for the `RegisterDomain` method. parent (:class:`str`): @@ -466,11 +468,11 @@ async def register_domain( async def retrieve_transfer_parameters( self, - request: domains.RetrieveTransferParametersRequest = None, + request: Union[domains.RetrieveTransferParametersRequest, dict] = None, *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveTransferParametersResponse: @@ -481,7 +483,7 @@ async def retrieve_transfer_parameters( Use the returned values to call ``TransferDomain``. Args: - request (:class:`google.cloud.domains_v1.types.RetrieveTransferParametersRequest`): + request (Union[google.cloud.domains_v1.types.RetrieveTransferParametersRequest, dict]): The request object. Request for the `RetrieveTransferParameters` method. location (:class:`str`): @@ -550,13 +552,13 @@ async def retrieve_transfer_parameters( async def transfer_domain( self, - request: domains.TransferDomainRequest = None, + request: Union[domains.TransferDomainRequest, dict] = None, *, parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, authorization_code: domains.AuthorizationCode = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -586,7 +588,7 @@ async def transfer_domain( the resource and retry the transfer. Args: - request (:class:`google.cloud.domains_v1.types.TransferDomainRequest`): + request (Union[google.cloud.domains_v1.types.TransferDomainRequest, dict]): The request object. Request for the `TransferDomain` method. parent (:class:`str`): @@ -716,17 +718,17 @@ async def transfer_domain( async def list_registrations( self, - request: domains.ListRegistrationsRequest = None, + request: Union[domains.ListRegistrationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRegistrationsAsyncPager: r"""Lists the ``Registration`` resources in a project. Args: - request (:class:`google.cloud.domains_v1.types.ListRegistrationsRequest`): + request (Union[google.cloud.domains_v1.types.ListRegistrationsRequest, dict]): The request object. Request for the `ListRegistrations` method. parent (:class:`str`): @@ -796,17 +798,17 @@ async def list_registrations( async def get_registration( self, - request: domains.GetRegistrationRequest = None, + request: Union[domains.GetRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.Registration: r"""Gets the details of a ``Registration`` resource. Args: - request (:class:`google.cloud.domains_v1.types.GetRegistrationRequest`): + request (Union[google.cloud.domains_v1.types.GetRegistrationRequest, dict]): The request object. Request for the `GetRegistration` method. name (:class:`str`): @@ -887,11 +889,11 @@ async def get_registration( async def update_registration( self, - request: domains.UpdateRegistrationRequest = None, + request: Union[domains.UpdateRegistrationRequest, dict] = None, *, registration: domains.Registration = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -906,7 +908,7 @@ async def update_registration( ``ConfigureContactSettings`` Args: - request (:class:`google.cloud.domains_v1.types.UpdateRegistrationRequest`): + request (Union[google.cloud.domains_v1.types.UpdateRegistrationRequest, dict]): The request object. Request for the `UpdateRegistration` method. registration (:class:`google.cloud.domains_v1.types.Registration`): @@ -1008,19 +1010,19 @@ async def update_registration( async def configure_management_settings( self, - request: domains.ConfigureManagementSettingsRequest = None, + request: Union[domains.ConfigureManagementSettingsRequest, dict] = None, *, registration: str = None, management_settings: domains.ManagementSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``Registration``'s management settings. Args: - request (:class:`google.cloud.domains_v1.types.ConfigureManagementSettingsRequest`): + request (Union[google.cloud.domains_v1.types.ConfigureManagementSettingsRequest, dict]): The request object. Request for the `ConfigureManagementSettings` method. registration (:class:`str`): @@ -1132,19 +1134,19 @@ async def configure_management_settings( async def configure_dns_settings( self, - request: domains.ConfigureDnsSettingsRequest = None, + request: Union[domains.ConfigureDnsSettingsRequest, dict] = None, *, registration: str = None, dns_settings: domains.DnsSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``Registration``'s DNS settings. Args: - request (:class:`google.cloud.domains_v1.types.ConfigureDnsSettingsRequest`): + request (Union[google.cloud.domains_v1.types.ConfigureDnsSettingsRequest, dict]): The request object. Request for the `ConfigureDnsSettings` method. registration (:class:`str`): @@ -1263,12 +1265,12 @@ async def configure_dns_settings( async def configure_contact_settings( self, - request: domains.ConfigureContactSettingsRequest = None, + request: Union[domains.ConfigureContactSettingsRequest, dict] = None, *, registration: str = None, contact_settings: domains.ContactSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1276,7 +1278,7 @@ async def configure_contact_settings( require confirmation by the domain's registrant contact . Args: - request (:class:`google.cloud.domains_v1.types.ConfigureContactSettingsRequest`): + request (Union[google.cloud.domains_v1.types.ConfigureContactSettingsRequest, dict]): The request object. Request for the `ConfigureContactSettings` method. registration (:class:`str`): @@ -1388,10 +1390,10 @@ async def configure_contact_settings( async def export_registration( self, - request: domains.ExportRegistrationRequest = None, + request: Union[domains.ExportRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1407,7 +1409,7 @@ async def export_registration( sets up billing in Google Domains. Args: - request (:class:`google.cloud.domains_v1.types.ExportRegistrationRequest`): + request (Union[google.cloud.domains_v1.types.ExportRegistrationRequest, dict]): The request object. Request for the `ExportRegistration` method. name (:class:`str`): @@ -1498,10 +1500,10 @@ async def export_registration( async def delete_registration( self, - request: domains.DeleteRegistrationRequest = None, + request: Union[domains.DeleteRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1529,7 +1531,7 @@ async def delete_registration( sets up billing in Google Domains. Args: - request (:class:`google.cloud.domains_v1.types.DeleteRegistrationRequest`): + request (Union[google.cloud.domains_v1.types.DeleteRegistrationRequest, dict]): The request object. Request for the `DeleteRegistration` method. name (:class:`str`): @@ -1611,10 +1613,10 @@ async def delete_registration( async def retrieve_authorization_code( self, - request: domains.RetrieveAuthorizationCodeRequest = None, + request: Union[domains.RetrieveAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1625,7 +1627,7 @@ async def retrieve_authorization_code( the initial domain registration. Args: - request (:class:`google.cloud.domains_v1.types.RetrieveAuthorizationCodeRequest`): + request (Union[google.cloud.domains_v1.types.RetrieveAuthorizationCodeRequest, dict]): The request object. Request for the `RetrieveAuthorizationCode` method. registration (:class:`str`): @@ -1687,10 +1689,10 @@ async def retrieve_authorization_code( async def reset_authorization_code( self, - request: domains.ResetAuthorizationCodeRequest = None, + request: Union[domains.ResetAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1701,7 +1703,7 @@ async def reset_authorization_code( the initial domain registration. Args: - request (:class:`google.cloud.domains_v1.types.ResetAuthorizationCodeRequest`): + request (Union[google.cloud.domains_v1.types.ResetAuthorizationCodeRequest, dict]): The request object. Request for the `ResetAuthorizationCode` method. registration (:class:`str`): diff --git a/google/cloud/domains_v1/services/domains/client.py b/google/cloud/domains_v1/services/domains/client.py index 6774df5..b7727a8 100644 --- a/google/cloud/domains_v1/services/domains/client.py +++ b/google/cloud/domains_v1/services/domains/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.domains_v1.services.domains import pagers @@ -359,7 +361,7 @@ def search_domains( *, location: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.SearchDomainsResponse: @@ -443,7 +445,7 @@ def retrieve_register_parameters( *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveRegisterParametersResponse: @@ -528,7 +530,7 @@ def register_domain( parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -664,7 +666,7 @@ def retrieve_transfer_parameters( *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveTransferParametersResponse: @@ -752,7 +754,7 @@ def transfer_domain( registration: domains.Registration = None, yearly_price: money_pb2.Money = None, authorization_code: domains.AuthorizationCode = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -915,7 +917,7 @@ def list_registrations( request: Union[domains.ListRegistrationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRegistrationsPager: @@ -995,7 +997,7 @@ def get_registration( request: Union[domains.GetRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.Registration: @@ -1087,7 +1089,7 @@ def update_registration( *, registration: domains.Registration = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1209,7 +1211,7 @@ def configure_management_settings( registration: str = None, management_settings: domains.ManagementSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1335,7 +1337,7 @@ def configure_dns_settings( registration: str = None, dns_settings: domains.DnsSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1466,7 +1468,7 @@ def configure_contact_settings( registration: str = None, contact_settings: domains.ContactSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1591,7 +1593,7 @@ def export_registration( request: Union[domains.ExportRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1701,7 +1703,7 @@ def delete_registration( request: Union[domains.DeleteRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1814,7 +1816,7 @@ def retrieve_authorization_code( request: Union[domains.RetrieveAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1892,7 +1894,7 @@ def reset_authorization_code( request: Union[domains.ResetAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: diff --git a/google/cloud/domains_v1/services/domains/transports/base.py b/google/cloud/domains_v1/services/domains/transports/base.py index 522654d..4d8b6a6 100644 --- a/google/cloud/domains_v1/services/domains/transports/base.py +++ b/google/cloud/domains_v1/services/domains/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class DomainsTransport(abc.ABC): """Abstract transport class for Domains.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -225,7 +192,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/domains_v1/services/domains/transports/grpc.py b/google/cloud/domains_v1/services/domains/transports/grpc.py index d4c7f2d..fc80444 100644 --- a/google/cloud/domains_v1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1/services/domains/transports/grpc.py @@ -113,7 +113,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py index 50c2521..aa52fa8 100644 --- a/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -160,7 +159,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/domains_v1/types/domains.py b/google/cloud/domains_v1/types/domains.py index 266855f..72242a2 100644 --- a/google/cloud/domains_v1/types/domains.py +++ b/google/cloud/domains_v1/types/domains.py @@ -231,13 +231,22 @@ class DnsSettings(proto.Message): r"""Defines the DNS configuration of a ``Registration``, including name servers, DNSSEC, and glue records. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: custom_dns (google.cloud.domains_v1.types.DnsSettings.CustomDns): An arbitrary DNS provider identified by its name servers. + This field is a member of `oneof`_ ``dns_provider``. google_domains_dns (google.cloud.domains_v1.types.DnsSettings.GoogleDomainsDns): The free DNS zone provided by `Google Domains `__. + This field is a member of `oneof`_ ``dns_provider``. glue_records (Sequence[google.cloud.domains_v1.types.DnsSettings.GlueRecord]): The list of glue records for this ``Registration``. Commonly empty. diff --git a/google/cloud/domains_v1beta1/services/domains/async_client.py b/google/cloud/domains_v1beta1/services/domains/async_client.py index 4deada9..5552879 100644 --- a/google/cloud/domains_v1beta1/services/domains/async_client.py +++ b/google/cloud/domains_v1beta1/services/domains/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers @@ -163,11 +165,11 @@ def __init__( async def search_domains( self, - request: domains.SearchDomainsRequest = None, + request: Union[domains.SearchDomainsRequest, dict] = None, *, location: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.SearchDomainsResponse: @@ -179,7 +181,7 @@ async def search_domains( confirm availability. Args: - request (:class:`google.cloud.domains_v1beta1.types.SearchDomainsRequest`): + request (Union[google.cloud.domains_v1beta1.types.SearchDomainsRequest, dict]): The request object. Request for the `SearchDomains` method. location (:class:`str`): @@ -247,11 +249,11 @@ async def search_domains( async def retrieve_register_parameters( self, - request: domains.RetrieveRegisterParametersRequest = None, + request: Union[domains.RetrieveRegisterParametersRequest, dict] = None, *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveRegisterParametersResponse: @@ -260,7 +262,7 @@ async def retrieve_register_parameters( call ``RegisterDomain``. Args: - request (:class:`google.cloud.domains_v1beta1.types.RetrieveRegisterParametersRequest`): + request (Union[google.cloud.domains_v1beta1.types.RetrieveRegisterParametersRequest, dict]): The request object. Request for the `RetrieveRegisterParameters` method. location (:class:`str`): @@ -329,12 +331,12 @@ async def retrieve_register_parameters( async def register_domain( self, - request: domains.RegisterDomainRequest = None, + request: Union[domains.RegisterDomainRequest, dict] = None, *, parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -354,7 +356,7 @@ async def register_domain( and retry registration. Args: - request (:class:`google.cloud.domains_v1beta1.types.RegisterDomainRequest`): + request (Union[google.cloud.domains_v1beta1.types.RegisterDomainRequest, dict]): The request object. Request for the `RegisterDomain` method. parent (:class:`str`): @@ -466,11 +468,11 @@ async def register_domain( async def retrieve_transfer_parameters( self, - request: domains.RetrieveTransferParametersRequest = None, + request: Union[domains.RetrieveTransferParametersRequest, dict] = None, *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveTransferParametersResponse: @@ -481,7 +483,7 @@ async def retrieve_transfer_parameters( Use the returned values to call ``TransferDomain``. Args: - request (:class:`google.cloud.domains_v1beta1.types.RetrieveTransferParametersRequest`): + request (Union[google.cloud.domains_v1beta1.types.RetrieveTransferParametersRequest, dict]): The request object. Request for the `RetrieveTransferParameters` method. location (:class:`str`): @@ -550,13 +552,13 @@ async def retrieve_transfer_parameters( async def transfer_domain( self, - request: domains.TransferDomainRequest = None, + request: Union[domains.TransferDomainRequest, dict] = None, *, parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, authorization_code: domains.AuthorizationCode = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -586,7 +588,7 @@ async def transfer_domain( the resource and retry the transfer. Args: - request (:class:`google.cloud.domains_v1beta1.types.TransferDomainRequest`): + request (Union[google.cloud.domains_v1beta1.types.TransferDomainRequest, dict]): The request object. Request for the `TransferDomain` method. parent (:class:`str`): @@ -716,17 +718,17 @@ async def transfer_domain( async def list_registrations( self, - request: domains.ListRegistrationsRequest = None, + request: Union[domains.ListRegistrationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRegistrationsAsyncPager: r"""Lists the ``Registration`` resources in a project. Args: - request (:class:`google.cloud.domains_v1beta1.types.ListRegistrationsRequest`): + request (Union[google.cloud.domains_v1beta1.types.ListRegistrationsRequest, dict]): The request object. Request for the `ListRegistrations` method. parent (:class:`str`): @@ -796,17 +798,17 @@ async def list_registrations( async def get_registration( self, - request: domains.GetRegistrationRequest = None, + request: Union[domains.GetRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.Registration: r"""Gets the details of a ``Registration`` resource. Args: - request (:class:`google.cloud.domains_v1beta1.types.GetRegistrationRequest`): + request (Union[google.cloud.domains_v1beta1.types.GetRegistrationRequest, dict]): The request object. Request for the `GetRegistration` method. name (:class:`str`): @@ -887,11 +889,11 @@ async def get_registration( async def update_registration( self, - request: domains.UpdateRegistrationRequest = None, + request: Union[domains.UpdateRegistrationRequest, dict] = None, *, registration: domains.Registration = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -906,7 +908,7 @@ async def update_registration( ``ConfigureContactSettings`` Args: - request (:class:`google.cloud.domains_v1beta1.types.UpdateRegistrationRequest`): + request (Union[google.cloud.domains_v1beta1.types.UpdateRegistrationRequest, dict]): The request object. Request for the `UpdateRegistration` method. registration (:class:`google.cloud.domains_v1beta1.types.Registration`): @@ -1008,19 +1010,19 @@ async def update_registration( async def configure_management_settings( self, - request: domains.ConfigureManagementSettingsRequest = None, + request: Union[domains.ConfigureManagementSettingsRequest, dict] = None, *, registration: str = None, management_settings: domains.ManagementSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``Registration``'s management settings. Args: - request (:class:`google.cloud.domains_v1beta1.types.ConfigureManagementSettingsRequest`): + request (Union[google.cloud.domains_v1beta1.types.ConfigureManagementSettingsRequest, dict]): The request object. Request for the `ConfigureManagementSettings` method. registration (:class:`str`): @@ -1132,19 +1134,19 @@ async def configure_management_settings( async def configure_dns_settings( self, - request: domains.ConfigureDnsSettingsRequest = None, + request: Union[domains.ConfigureDnsSettingsRequest, dict] = None, *, registration: str = None, dns_settings: domains.DnsSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``Registration``'s DNS settings. Args: - request (:class:`google.cloud.domains_v1beta1.types.ConfigureDnsSettingsRequest`): + request (Union[google.cloud.domains_v1beta1.types.ConfigureDnsSettingsRequest, dict]): The request object. Request for the `ConfigureDnsSettings` method. registration (:class:`str`): @@ -1263,12 +1265,12 @@ async def configure_dns_settings( async def configure_contact_settings( self, - request: domains.ConfigureContactSettingsRequest = None, + request: Union[domains.ConfigureContactSettingsRequest, dict] = None, *, registration: str = None, contact_settings: domains.ContactSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1276,7 +1278,7 @@ async def configure_contact_settings( require confirmation by the domain's registrant contact . Args: - request (:class:`google.cloud.domains_v1beta1.types.ConfigureContactSettingsRequest`): + request (Union[google.cloud.domains_v1beta1.types.ConfigureContactSettingsRequest, dict]): The request object. Request for the `ConfigureContactSettings` method. registration (:class:`str`): @@ -1388,10 +1390,10 @@ async def configure_contact_settings( async def export_registration( self, - request: domains.ExportRegistrationRequest = None, + request: Union[domains.ExportRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1407,7 +1409,7 @@ async def export_registration( sets up billing in Google Domains. Args: - request (:class:`google.cloud.domains_v1beta1.types.ExportRegistrationRequest`): + request (Union[google.cloud.domains_v1beta1.types.ExportRegistrationRequest, dict]): The request object. Request for the `ExportRegistration` method. name (:class:`str`): @@ -1498,10 +1500,10 @@ async def export_registration( async def delete_registration( self, - request: domains.DeleteRegistrationRequest = None, + request: Union[domains.DeleteRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1529,7 +1531,7 @@ async def delete_registration( sets up billing in Google Domains. Args: - request (:class:`google.cloud.domains_v1beta1.types.DeleteRegistrationRequest`): + request (Union[google.cloud.domains_v1beta1.types.DeleteRegistrationRequest, dict]): The request object. Request for the `DeleteRegistration` method. name (:class:`str`): @@ -1611,10 +1613,10 @@ async def delete_registration( async def retrieve_authorization_code( self, - request: domains.RetrieveAuthorizationCodeRequest = None, + request: Union[domains.RetrieveAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1625,7 +1627,7 @@ async def retrieve_authorization_code( the initial domain registration. Args: - request (:class:`google.cloud.domains_v1beta1.types.RetrieveAuthorizationCodeRequest`): + request (Union[google.cloud.domains_v1beta1.types.RetrieveAuthorizationCodeRequest, dict]): The request object. Request for the `RetrieveAuthorizationCode` method. registration (:class:`str`): @@ -1687,10 +1689,10 @@ async def retrieve_authorization_code( async def reset_authorization_code( self, - request: domains.ResetAuthorizationCodeRequest = None, + request: Union[domains.ResetAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1701,7 +1703,7 @@ async def reset_authorization_code( the initial domain registration. Args: - request (:class:`google.cloud.domains_v1beta1.types.ResetAuthorizationCodeRequest`): + request (Union[google.cloud.domains_v1beta1.types.ResetAuthorizationCodeRequest, dict]): The request object. Request for the `ResetAuthorizationCode` method. registration (:class:`str`): diff --git a/google/cloud/domains_v1beta1/services/domains/client.py b/google/cloud/domains_v1beta1/services/domains/client.py index 182e94e..59a0417 100644 --- a/google/cloud/domains_v1beta1/services/domains/client.py +++ b/google/cloud/domains_v1beta1/services/domains/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers @@ -359,7 +361,7 @@ def search_domains( *, location: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.SearchDomainsResponse: @@ -443,7 +445,7 @@ def retrieve_register_parameters( *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveRegisterParametersResponse: @@ -528,7 +530,7 @@ def register_domain( parent: str = None, registration: domains.Registration = None, yearly_price: money_pb2.Money = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -664,7 +666,7 @@ def retrieve_transfer_parameters( *, location: str = None, domain_name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.RetrieveTransferParametersResponse: @@ -752,7 +754,7 @@ def transfer_domain( registration: domains.Registration = None, yearly_price: money_pb2.Money = None, authorization_code: domains.AuthorizationCode = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -915,7 +917,7 @@ def list_registrations( request: Union[domains.ListRegistrationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRegistrationsPager: @@ -995,7 +997,7 @@ def get_registration( request: Union[domains.GetRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.Registration: @@ -1087,7 +1089,7 @@ def update_registration( *, registration: domains.Registration = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1209,7 +1211,7 @@ def configure_management_settings( registration: str = None, management_settings: domains.ManagementSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1335,7 +1337,7 @@ def configure_dns_settings( registration: str = None, dns_settings: domains.DnsSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1466,7 +1468,7 @@ def configure_contact_settings( registration: str = None, contact_settings: domains.ContactSettings = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1591,7 +1593,7 @@ def export_registration( request: Union[domains.ExportRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1701,7 +1703,7 @@ def delete_registration( request: Union[domains.DeleteRegistrationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1814,7 +1816,7 @@ def retrieve_authorization_code( request: Union[domains.RetrieveAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: @@ -1892,7 +1894,7 @@ def reset_authorization_code( request: Union[domains.ResetAuthorizationCodeRequest, dict] = None, *, registration: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> domains.AuthorizationCode: diff --git a/google/cloud/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index f95e6f9..3ba6000 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class DomainsTransport(abc.ABC): """Abstract transport class for Domains.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -225,7 +192,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index a7b69f1..a8f3c90 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -113,7 +113,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index dc5afa2..fae581a 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -160,7 +159,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/domains_v1beta1/types/domains.py b/google/cloud/domains_v1beta1/types/domains.py index cb78f6c..ef9c829 100644 --- a/google/cloud/domains_v1beta1/types/domains.py +++ b/google/cloud/domains_v1beta1/types/domains.py @@ -231,13 +231,22 @@ class DnsSettings(proto.Message): r"""Defines the DNS configuration of a ``Registration``, including name servers, DNSSEC, and glue records. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: custom_dns (google.cloud.domains_v1beta1.types.DnsSettings.CustomDns): An arbitrary DNS provider identified by its name servers. + This field is a member of `oneof`_ ``dns_provider``. google_domains_dns (google.cloud.domains_v1beta1.types.DnsSettings.GoogleDomainsDns): The free DNS zone provided by `Google Domains `__. + This field is a member of `oneof`_ ``dns_provider``. glue_records (Sequence[google.cloud.domains_v1beta1.types.DnsSettings.GlueRecord]): The list of glue records for this ``Registration``. Commonly empty. diff --git a/setup.py b/setup.py index bc3711f..e01e747 100644 --- a/setup.py +++ b/setup.py @@ -46,9 +46,8 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.15.0", - "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index a1b329d..c77c322 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -19,7 +19,5 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.15.0 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is required through google-api-core diff --git a/tests/unit/gapic/domains_v1/test_domains.py b/tests/unit/gapic/domains_v1/test_domains.py index 02c853f..971c9b8 100644 --- a/tests/unit/gapic/domains_v1/test_domains.py +++ b/tests/unit/gapic/domains_v1/test_domains.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.domains_v1.services.domains import DomainsClient from google.cloud.domains_v1.services.domains import pagers from google.cloud.domains_v1.services.domains import transports -from google.cloud.domains_v1.services.domains.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.domains_v1.types import domains from google.longrunning import operations_pb2 from google.oauth2 import service_account @@ -52,20 +48,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -200,7 +182,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -217,7 +199,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -234,7 +216,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -263,7 +245,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -318,7 +300,7 @@ def test_domains_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -360,7 +342,7 @@ def test_domains_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -382,7 +364,7 @@ def test_domains_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -409,7 +391,7 @@ def test_domains_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -436,7 +418,7 @@ def test_domains_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4065,7 +4047,6 @@ 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( @@ -4086,26 +4067,6 @@ def test_domains_base_transport_with_credentials_file(): ) -@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_v1.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", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_domains_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -4117,7 +4078,6 @@ def test_domains_base_transport_with_adc(): 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(google.auth, "default", autospec=True) as adc: @@ -4130,23 +4090,10 @@ def test_domains_auth_adc(): ) -@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",), - quota_project_id=None, - ) - - @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. @@ -4160,23 +4107,6 @@ def test_domains_transport_auth_adc(transport_class): ) -@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", [ diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index 88d273c..2975393 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.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 ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.domains_v1beta1.types import domains from google.longrunning import operations_pb2 from google.oauth2 import service_account @@ -52,20 +48,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -200,7 +182,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -217,7 +199,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -234,7 +216,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -263,7 +245,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -318,7 +300,7 @@ def test_domains_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -360,7 +342,7 @@ def test_domains_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -382,7 +364,7 @@ def test_domains_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -409,7 +391,7 @@ def test_domains_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -436,7 +418,7 @@ def test_domains_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4065,7 +4047,6 @@ 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( @@ -4086,26 +4067,6 @@ def test_domains_base_transport_with_credentials_file(): ) -@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", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_domains_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -4117,7 +4078,6 @@ def test_domains_base_transport_with_adc(): 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(google.auth, "default", autospec=True) as adc: @@ -4130,23 +4090,10 @@ def test_domains_auth_adc(): ) -@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",), - quota_project_id=None, - ) - - @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. @@ -4160,23 +4107,6 @@ def test_domains_transport_auth_adc(transport_class): ) -@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", [