diff --git a/google/cloud/domains_v1/services/domains/async_client.py b/google/cloud/domains_v1/services/domains/async_client.py index 604dbb4..0049385 100644 --- a/google/cloud/domains_v1/services/domains/async_client.py +++ b/google/cloud/domains_v1/services/domains/async_client.py @@ -248,7 +248,7 @@ async def search_domains( Response for the SearchDomains method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, query]) if request is not None and has_flattened_params: @@ -330,7 +330,7 @@ async def retrieve_register_parameters( Response for the RetrieveRegisterParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -457,7 +457,7 @@ async def register_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, registration, yearly_price]) if request is not None and has_flattened_params: @@ -551,7 +551,7 @@ async def retrieve_transfer_parameters( Response for the RetrieveTransferParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -703,7 +703,7 @@ async def transfer_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [parent, registration, yearly_price, authorization_code] @@ -793,7 +793,7 @@ async def list_registrations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -890,7 +890,7 @@ async def get_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -999,7 +999,7 @@ async def update_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, update_mask]) if request is not None and has_flattened_params: @@ -1121,7 +1121,7 @@ async def configure_management_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, management_settings, update_mask]) if request is not None and has_flattened_params: @@ -1252,7 +1252,7 @@ async def configure_dns_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, dns_settings, update_mask]) if request is not None and has_flattened_params: @@ -1377,7 +1377,7 @@ async def configure_contact_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, contact_settings, update_mask]) if request is not None and has_flattened_params: @@ -1493,7 +1493,7 @@ async def export_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1606,7 +1606,7 @@ async def delete_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1688,7 +1688,7 @@ async def retrieve_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: @@ -1764,7 +1764,7 @@ async def reset_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: diff --git a/google/cloud/domains_v1/services/domains/client.py b/google/cloud/domains_v1/services/domains/client.py index c913086..5779d11 100644 --- a/google/cloud/domains_v1/services/domains/client.py +++ b/google/cloud/domains_v1/services/domains/client.py @@ -451,7 +451,7 @@ def search_domains( Response for the SearchDomains method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, query]) if request is not None and has_flattened_params: @@ -533,7 +533,7 @@ def retrieve_register_parameters( Response for the RetrieveRegisterParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -662,7 +662,7 @@ def register_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, registration, yearly_price]) if request is not None and has_flattened_params: @@ -756,7 +756,7 @@ def retrieve_transfer_parameters( Response for the RetrieveTransferParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -910,7 +910,7 @@ def transfer_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [parent, registration, yearly_price, authorization_code] @@ -1000,7 +1000,7 @@ def list_registrations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1097,7 +1097,7 @@ def get_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1206,7 +1206,7 @@ def update_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, update_mask]) if request is not None and has_flattened_params: @@ -1328,7 +1328,7 @@ def configure_management_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, management_settings, update_mask]) if request is not None and has_flattened_params: @@ -1461,7 +1461,7 @@ def configure_dns_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, dns_settings, update_mask]) if request is not None and has_flattened_params: @@ -1586,7 +1586,7 @@ def configure_contact_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, contact_settings, update_mask]) if request is not None and has_flattened_params: @@ -1704,7 +1704,7 @@ def export_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1817,7 +1817,7 @@ def delete_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1899,7 +1899,7 @@ def retrieve_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: @@ -1977,7 +1977,7 @@ def reset_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: diff --git a/google/cloud/domains_v1/services/domains/transports/grpc.py b/google/cloud/domains_v1/services/domains/transports/grpc.py index b8758b9..36cab51 100644 --- a/google/cloud/domains_v1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1/services/domains/transports/grpc.py @@ -162,8 +162,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -236,7 +239,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 b4e385b..c3f6509 100644 --- a/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1/services/domains/transports/grpc_asyncio.py @@ -207,8 +207,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/domains_v1beta1/services/domains/async_client.py b/google/cloud/domains_v1beta1/services/domains/async_client.py index 58e8360..76998a2 100644 --- a/google/cloud/domains_v1beta1/services/domains/async_client.py +++ b/google/cloud/domains_v1beta1/services/domains/async_client.py @@ -248,7 +248,7 @@ async def search_domains( Response for the SearchDomains method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, query]) if request is not None and has_flattened_params: @@ -330,7 +330,7 @@ async def retrieve_register_parameters( Response for the RetrieveRegisterParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -457,7 +457,7 @@ async def register_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, registration, yearly_price]) if request is not None and has_flattened_params: @@ -551,7 +551,7 @@ async def retrieve_transfer_parameters( Response for the RetrieveTransferParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -703,7 +703,7 @@ async def transfer_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [parent, registration, yearly_price, authorization_code] @@ -793,7 +793,7 @@ async def list_registrations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -890,7 +890,7 @@ async def get_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -999,7 +999,7 @@ async def update_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, update_mask]) if request is not None and has_flattened_params: @@ -1121,7 +1121,7 @@ async def configure_management_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, management_settings, update_mask]) if request is not None and has_flattened_params: @@ -1252,7 +1252,7 @@ async def configure_dns_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, dns_settings, update_mask]) if request is not None and has_flattened_params: @@ -1377,7 +1377,7 @@ async def configure_contact_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, contact_settings, update_mask]) if request is not None and has_flattened_params: @@ -1493,7 +1493,7 @@ async def export_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1606,7 +1606,7 @@ async def delete_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1688,7 +1688,7 @@ async def retrieve_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: @@ -1764,7 +1764,7 @@ async def reset_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: diff --git a/google/cloud/domains_v1beta1/services/domains/client.py b/google/cloud/domains_v1beta1/services/domains/client.py index 3c3e87b..2c892a4 100644 --- a/google/cloud/domains_v1beta1/services/domains/client.py +++ b/google/cloud/domains_v1beta1/services/domains/client.py @@ -451,7 +451,7 @@ def search_domains( Response for the SearchDomains method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, query]) if request is not None and has_flattened_params: @@ -533,7 +533,7 @@ def retrieve_register_parameters( Response for the RetrieveRegisterParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -662,7 +662,7 @@ def register_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, registration, yearly_price]) if request is not None and has_flattened_params: @@ -756,7 +756,7 @@ def retrieve_transfer_parameters( Response for the RetrieveTransferParameters method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([location, domain_name]) if request is not None and has_flattened_params: @@ -910,7 +910,7 @@ def transfer_domain( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [parent, registration, yearly_price, authorization_code] @@ -1000,7 +1000,7 @@ def list_registrations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1097,7 +1097,7 @@ def get_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1206,7 +1206,7 @@ def update_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, update_mask]) if request is not None and has_flattened_params: @@ -1328,7 +1328,7 @@ def configure_management_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, management_settings, update_mask]) if request is not None and has_flattened_params: @@ -1461,7 +1461,7 @@ def configure_dns_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, dns_settings, update_mask]) if request is not None and has_flattened_params: @@ -1586,7 +1586,7 @@ def configure_contact_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration, contact_settings, update_mask]) if request is not None and has_flattened_params: @@ -1704,7 +1704,7 @@ def export_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1817,7 +1817,7 @@ def delete_registration( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1899,7 +1899,7 @@ def retrieve_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: @@ -1977,7 +1977,7 @@ def reset_authorization_code( Defines an authorization code. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([registration]) if request is not None and has_flattened_params: diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index 54b6af6..7c77a2a 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -162,8 +162,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -236,7 +239,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 e924fff..ce2dbbd 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -207,8 +207,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/tests/unit/gapic/domains_v1/test_domains.py b/tests/unit/gapic/domains_v1/test_domains.py index 0c51f6a..9a98586 100644 --- a/tests/unit/gapic/domains_v1/test_domains.py +++ b/tests/unit/gapic/domains_v1/test_domains.py @@ -29,6 +29,7 @@ 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 from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -480,17 +481,23 @@ def test_domains_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (DomainsClient, transports.DomainsGrpcTransport, "grpc"), - (DomainsAsyncClient, transports.DomainsGrpcAsyncIOTransport, "grpc_asyncio"), + (DomainsClient, transports.DomainsGrpcTransport, "grpc", grpc_helpers), + ( + DomainsAsyncClient, + transports.DomainsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_domains_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. 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, transport=transport_name) @@ -524,6 +531,67 @@ def test_domains_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (DomainsClient, transports.DomainsGrpcTransport, "grpc", grpc_helpers), + ( + DomainsAsyncClient, + transports.DomainsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_domains_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + 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, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "domains.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="domains.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [domains.SearchDomainsRequest, dict,]) def test_search_domains(request_type, transport: str = "grpc"): client = DomainsClient( diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index 0986dc6..aa663dc 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -29,6 +29,7 @@ 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 from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -480,17 +481,23 @@ def test_domains_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (DomainsClient, transports.DomainsGrpcTransport, "grpc"), - (DomainsAsyncClient, transports.DomainsGrpcAsyncIOTransport, "grpc_asyncio"), + (DomainsClient, transports.DomainsGrpcTransport, "grpc", grpc_helpers), + ( + DomainsAsyncClient, + transports.DomainsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_domains_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. 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, transport=transport_name) @@ -524,6 +531,67 @@ def test_domains_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (DomainsClient, transports.DomainsGrpcTransport, "grpc", grpc_helpers), + ( + DomainsAsyncClient, + transports.DomainsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_domains_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + 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, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "domains.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="domains.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [domains.SearchDomainsRequest, dict,]) def test_search_domains(request_type, transport: str = "grpc"): client = DomainsClient(