From 317187cbaacc6889d6fff5d7ea483fe1bc2cd9ee Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 14:16:33 +0000 Subject: [PATCH] feat: add context manager support in client (#416) - [ ] Regenerate this pull request now. chore: fix docstring for first attribute of protos committer: @busunkim96 PiperOrigin-RevId: 401271153 Source-Link: https://github.com/googleapis/googleapis/commit/787f8c9a731f44e74a90b9847d48659ca9462d10 Source-Link: https://github.com/googleapis/googleapis-gen/commit/81decffe9fc72396a8153e756d1d67a6eecfd620 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9 --- .../services/agents/async_client.py | 6 +++ .../dialogflow_v2/services/agents/client.py | 18 +++++-- .../services/agents/transports/base.py | 9 ++++ .../services/agents/transports/grpc.py | 3 ++ .../agents/transports/grpc_asyncio.py | 3 ++ .../services/answer_records/async_client.py | 6 +++ .../services/answer_records/client.py | 18 +++++-- .../answer_records/transports/base.py | 9 ++++ .../answer_records/transports/grpc.py | 3 ++ .../answer_records/transports/grpc_asyncio.py | 3 ++ .../services/contexts/async_client.py | 6 +++ .../dialogflow_v2/services/contexts/client.py | 18 +++++-- .../services/contexts/transports/base.py | 9 ++++ .../services/contexts/transports/grpc.py | 3 ++ .../contexts/transports/grpc_asyncio.py | 3 ++ .../conversation_profiles/async_client.py | 6 +++ .../services/conversation_profiles/client.py | 18 +++++-- .../conversation_profiles/transports/base.py | 9 ++++ .../conversation_profiles/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/conversations/async_client.py | 6 +++ .../services/conversations/client.py | 18 +++++-- .../services/conversations/transports/base.py | 9 ++++ .../services/conversations/transports/grpc.py | 3 ++ .../conversations/transports/grpc_asyncio.py | 3 ++ .../services/documents/async_client.py | 6 +++ .../services/documents/client.py | 18 +++++-- .../services/documents/transports/base.py | 9 ++++ .../services/documents/transports/grpc.py | 3 ++ .../documents/transports/grpc_asyncio.py | 3 ++ .../services/entity_types/async_client.py | 6 +++ .../services/entity_types/client.py | 18 +++++-- .../services/entity_types/transports/base.py | 9 ++++ .../services/entity_types/transports/grpc.py | 3 ++ .../entity_types/transports/grpc_asyncio.py | 3 ++ .../services/environments/async_client.py | 6 +++ .../services/environments/client.py | 18 +++++-- .../services/environments/transports/base.py | 9 ++++ .../services/environments/transports/grpc.py | 3 ++ .../environments/transports/grpc_asyncio.py | 3 ++ .../services/fulfillments/async_client.py | 6 +++ .../services/fulfillments/client.py | 18 +++++-- .../services/fulfillments/transports/base.py | 9 ++++ .../services/fulfillments/transports/grpc.py | 3 ++ .../fulfillments/transports/grpc_asyncio.py | 3 ++ .../services/intents/async_client.py | 6 +++ .../dialogflow_v2/services/intents/client.py | 18 +++++-- .../services/intents/transports/base.py | 9 ++++ .../services/intents/transports/grpc.py | 3 ++ .../intents/transports/grpc_asyncio.py | 3 ++ .../services/knowledge_bases/async_client.py | 6 +++ .../services/knowledge_bases/client.py | 18 +++++-- .../knowledge_bases/transports/base.py | 9 ++++ .../knowledge_bases/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/participants/async_client.py | 6 +++ .../services/participants/client.py | 18 +++++-- .../services/participants/transports/base.py | 9 ++++ .../services/participants/transports/grpc.py | 3 ++ .../participants/transports/grpc_asyncio.py | 3 ++ .../session_entity_types/async_client.py | 6 +++ .../services/session_entity_types/client.py | 18 +++++-- .../session_entity_types/transports/base.py | 9 ++++ .../session_entity_types/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/sessions/async_client.py | 6 +++ .../dialogflow_v2/services/sessions/client.py | 18 +++++-- .../services/sessions/transports/base.py | 9 ++++ .../services/sessions/transports/grpc.py | 3 ++ .../sessions/transports/grpc_asyncio.py | 3 ++ .../services/versions/async_client.py | 6 +++ .../dialogflow_v2/services/versions/client.py | 18 +++++-- .../services/versions/transports/base.py | 9 ++++ .../services/versions/transports/grpc.py | 3 ++ .../versions/transports/grpc_asyncio.py | 3 ++ .../dialogflow_v2/types/answer_record.py | 2 + .../cloud/dialogflow_v2/types/audio_config.py | 3 ++ .../types/conversation_profile.py | 9 ++++ google/cloud/dialogflow_v2/types/document.py | 1 + .../cloud/dialogflow_v2/types/entity_type.py | 1 + .../cloud/dialogflow_v2/types/environment.py | 1 + .../cloud/dialogflow_v2/types/fulfillment.py | 1 + google/cloud/dialogflow_v2/types/intent.py | 25 ++++++++++ .../cloud/dialogflow_v2/types/participant.py | 5 ++ google/cloud/dialogflow_v2/types/session.py | 5 ++ .../dialogflow_v2/types/validation_result.py | 2 + google/cloud/dialogflow_v2/types/webhook.py | 1 + .../services/agents/async_client.py | 6 +++ .../services/agents/client.py | 18 +++++-- .../services/agents/transports/base.py | 9 ++++ .../services/agents/transports/grpc.py | 3 ++ .../agents/transports/grpc_asyncio.py | 3 ++ .../services/answer_records/async_client.py | 6 +++ .../services/answer_records/client.py | 18 +++++-- .../answer_records/transports/base.py | 9 ++++ .../answer_records/transports/grpc.py | 3 ++ .../answer_records/transports/grpc_asyncio.py | 3 ++ .../services/contexts/async_client.py | 6 +++ .../services/contexts/client.py | 18 +++++-- .../services/contexts/transports/base.py | 9 ++++ .../services/contexts/transports/grpc.py | 3 ++ .../contexts/transports/grpc_asyncio.py | 3 ++ .../conversation_profiles/async_client.py | 6 +++ .../services/conversation_profiles/client.py | 18 +++++-- .../conversation_profiles/transports/base.py | 9 ++++ .../conversation_profiles/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/conversations/async_client.py | 6 +++ .../services/conversations/client.py | 18 +++++-- .../services/conversations/transports/base.py | 9 ++++ .../services/conversations/transports/grpc.py | 3 ++ .../conversations/transports/grpc_asyncio.py | 3 ++ .../services/documents/async_client.py | 6 +++ .../services/documents/client.py | 18 +++++-- .../services/documents/transports/base.py | 9 ++++ .../services/documents/transports/grpc.py | 3 ++ .../documents/transports/grpc_asyncio.py | 3 ++ .../services/entity_types/async_client.py | 6 +++ .../services/entity_types/client.py | 18 +++++-- .../services/entity_types/transports/base.py | 9 ++++ .../services/entity_types/transports/grpc.py | 3 ++ .../entity_types/transports/grpc_asyncio.py | 3 ++ .../services/environments/async_client.py | 6 +++ .../services/environments/client.py | 18 +++++-- .../services/environments/transports/base.py | 9 ++++ .../services/environments/transports/grpc.py | 3 ++ .../environments/transports/grpc_asyncio.py | 3 ++ .../services/fulfillments/async_client.py | 6 +++ .../services/fulfillments/client.py | 18 +++++-- .../services/fulfillments/transports/base.py | 9 ++++ .../services/fulfillments/transports/grpc.py | 3 ++ .../fulfillments/transports/grpc_asyncio.py | 3 ++ .../services/intents/async_client.py | 6 +++ .../services/intents/client.py | 18 +++++-- .../services/intents/transports/base.py | 9 ++++ .../services/intents/transports/grpc.py | 3 ++ .../intents/transports/grpc_asyncio.py | 3 ++ .../services/knowledge_bases/async_client.py | 6 +++ .../services/knowledge_bases/client.py | 18 +++++-- .../knowledge_bases/transports/base.py | 9 ++++ .../knowledge_bases/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/participants/async_client.py | 6 +++ .../services/participants/client.py | 18 +++++-- .../services/participants/transports/base.py | 9 ++++ .../services/participants/transports/grpc.py | 3 ++ .../participants/transports/grpc_asyncio.py | 3 ++ .../session_entity_types/async_client.py | 6 +++ .../services/session_entity_types/client.py | 18 +++++-- .../session_entity_types/transports/base.py | 9 ++++ .../session_entity_types/transports/grpc.py | 3 ++ .../transports/grpc_asyncio.py | 3 ++ .../services/sessions/async_client.py | 6 +++ .../services/sessions/client.py | 18 +++++-- .../services/sessions/transports/base.py | 9 ++++ .../services/sessions/transports/grpc.py | 3 ++ .../sessions/transports/grpc_asyncio.py | 3 ++ .../services/versions/async_client.py | 6 +++ .../services/versions/client.py | 18 +++++-- .../services/versions/transports/base.py | 9 ++++ .../services/versions/transports/grpc.py | 3 ++ .../versions/transports/grpc_asyncio.py | 3 ++ .../cloud/dialogflow_v2beta1/types/agent.py | 1 + .../dialogflow_v2beta1/types/answer_record.py | 3 ++ .../dialogflow_v2beta1/types/audio_config.py | 4 ++ .../types/conversation_profile.py | 8 +++ .../dialogflow_v2beta1/types/document.py | 2 + .../dialogflow_v2beta1/types/entity_type.py | 1 + .../dialogflow_v2beta1/types/environment.py | 1 + .../dialogflow_v2beta1/types/fulfillment.py | 1 + google/cloud/dialogflow_v2beta1/types/gcs.py | 2 + .../cloud/dialogflow_v2beta1/types/intent.py | 32 +++++++++++- .../dialogflow_v2beta1/types/participant.py | 13 ++++- .../cloud/dialogflow_v2beta1/types/session.py | 7 +++ .../types/validation_result.py | 2 + .../cloud/dialogflow_v2beta1/types/webhook.py | 1 + tests/unit/gapic/dialogflow_v2/test_agents.py | 50 +++++++++++++++++++ .../dialogflow_v2/test_answer_records.py | 50 +++++++++++++++++++ .../unit/gapic/dialogflow_v2/test_contexts.py | 50 +++++++++++++++++++ .../test_conversation_profiles.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_conversations.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_documents.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_entity_types.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_environments.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_fulfillments.py | 50 +++++++++++++++++++ .../unit/gapic/dialogflow_v2/test_intents.py | 50 +++++++++++++++++++ .../dialogflow_v2/test_knowledge_bases.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2/test_participants.py | 50 +++++++++++++++++++ .../test_session_entity_types.py | 50 +++++++++++++++++++ .../unit/gapic/dialogflow_v2/test_sessions.py | 50 +++++++++++++++++++ .../unit/gapic/dialogflow_v2/test_versions.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2beta1/test_agents.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_answer_records.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2beta1/test_contexts.py | 50 +++++++++++++++++++ .../test_conversation_profiles.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_conversations.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_documents.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_entity_types.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_environments.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_fulfillments.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2beta1/test_intents.py | 50 +++++++++++++++++++ .../test_knowledge_bases.py | 50 +++++++++++++++++++ .../dialogflow_v2beta1/test_participants.py | 50 +++++++++++++++++++ .../test_session_entity_types.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2beta1/test_sessions.py | 50 +++++++++++++++++++ .../gapic/dialogflow_v2beta1/test_versions.py | 50 +++++++++++++++++++ 206 files changed, 2682 insertions(+), 122 deletions(-) diff --git a/google/cloud/dialogflow_v2/services/agents/async_client.py b/google/cloud/dialogflow_v2/services/agents/async_client.py index 0c6102e66..5f6815aa4 100644 --- a/google/cloud/dialogflow_v2/services/agents/async_client.py +++ b/google/cloud/dialogflow_v2/services/agents/async_client.py @@ -915,6 +915,12 @@ async def get_validation_result( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/agents/client.py b/google/cloud/dialogflow_v2/services/agents/client.py index d032f7d09..4a74e1694 100644 --- a/google/cloud/dialogflow_v2/services/agents/client.py +++ b/google/cloud/dialogflow_v2/services/agents/client.py @@ -343,10 +343,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def get_agent( @@ -1110,6 +1107,19 @@ def get_validation_result( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/agents/transports/base.py b/google/cloud/dialogflow_v2/services/agents/transports/base.py index ee669cb6c..f7a10e47f 100644 --- a/google/cloud/dialogflow_v2/services/agents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/agents/transports/base.py @@ -193,6 +193,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2/services/agents/transports/grpc.py b/google/cloud/dialogflow_v2/services/agents/transports/grpc.py index 58268d24e..6e52a4e0e 100644 --- a/google/cloud/dialogflow_v2/services/agents/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/agents/transports/grpc.py @@ -565,5 +565,8 @@ def get_validation_result( ) return self._stubs["get_validation_result"] + def close(self): + self.grpc_channel.close() + __all__ = ("AgentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py index a3cb0e2f3..bc71955a0 100644 --- a/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py @@ -575,5 +575,8 @@ def get_validation_result( ) return self._stubs["get_validation_result"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AgentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/answer_records/async_client.py b/google/cloud/dialogflow_v2/services/answer_records/async_client.py index 75452cd4f..8bdbb5ac2 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/async_client.py +++ b/google/cloud/dialogflow_v2/services/answer_records/async_client.py @@ -361,6 +361,12 @@ async def update_answer_record( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/answer_records/client.py b/google/cloud/dialogflow_v2/services/answer_records/client.py index b14ffed51..a0246bec1 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/client.py +++ b/google/cloud/dialogflow_v2/services/answer_records/client.py @@ -345,10 +345,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_answer_records( @@ -545,6 +542,19 @@ def update_answer_record( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2/services/answer_records/transports/base.py index 07847fcac..ee70ced70 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/base.py @@ -168,6 +168,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_answer_records( self, diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py index 9d91e029b..720dab62f 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py @@ -285,5 +285,8 @@ def update_answer_record( ) return self._stubs["update_answer_record"] + def close(self): + self.grpc_channel.close() + __all__ = ("AnswerRecordsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py index eb6474085..7f70b48fb 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py @@ -289,5 +289,8 @@ def update_answer_record( ) return self._stubs["update_answer_record"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AnswerRecordsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/contexts/async_client.py b/google/cloud/dialogflow_v2/services/contexts/async_client.py index d2c4bcd8e..1e5135a9e 100644 --- a/google/cloud/dialogflow_v2/services/contexts/async_client.py +++ b/google/cloud/dialogflow_v2/services/contexts/async_client.py @@ -672,6 +672,12 @@ async def delete_all_contexts( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/contexts/client.py b/google/cloud/dialogflow_v2/services/contexts/client.py index 16f08d9eb..06e29095f 100644 --- a/google/cloud/dialogflow_v2/services/contexts/client.py +++ b/google/cloud/dialogflow_v2/services/contexts/client.py @@ -345,10 +345,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_contexts( @@ -867,6 +864,19 @@ def delete_all_contexts( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/base.py b/google/cloud/dialogflow_v2/services/contexts/transports/base.py index 79ea93826..dda6e53e2 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/base.py @@ -179,6 +179,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_contexts( self, diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py b/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py index 60fd684c6..016e8b2f5 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py @@ -384,5 +384,8 @@ def delete_all_contexts( ) return self._stubs["delete_all_contexts"] + def close(self): + self.grpc_channel.close() + __all__ = ("ContextsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py index 0c956b74a..1cb2fca64 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py @@ -391,5 +391,8 @@ def delete_all_contexts( ) return self._stubs["delete_all_contexts"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ContextsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py b/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py index 08003bf43..ca633fb2f 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py @@ -586,6 +586,12 @@ async def delete_conversation_profile( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/client.py b/google/cloud/dialogflow_v2/services/conversation_profiles/client.py index 91e39a7d5..0b2807157 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/client.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/client.py @@ -414,10 +414,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_conversation_profiles( @@ -842,6 +839,19 @@ def delete_conversation_profile( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py index a06996a74..87fe87c1e 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_conversation_profiles( self, diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py index 8df0f1baa..890686786 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py @@ -387,5 +387,8 @@ def delete_conversation_profile( ) return self._stubs["delete_conversation_profile"] + def close(self): + self.grpc_channel.close() + __all__ = ("ConversationProfilesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py index 1a207529f..b3d0d2d00 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py @@ -391,5 +391,8 @@ def delete_conversation_profile( ) return self._stubs["delete_conversation_profile"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ConversationProfilesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/conversations/async_client.py b/google/cloud/dialogflow_v2/services/conversations/async_client.py index 3a717bc8f..ee94e904a 100644 --- a/google/cloud/dialogflow_v2/services/conversations/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversations/async_client.py @@ -601,6 +601,12 @@ async def list_messages( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/conversations/client.py b/google/cloud/dialogflow_v2/services/conversations/client.py index 3233e5909..ae05f5ff4 100644 --- a/google/cloud/dialogflow_v2/services/conversations/client.py +++ b/google/cloud/dialogflow_v2/services/conversations/client.py @@ -378,10 +378,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_conversation( @@ -811,6 +808,19 @@ def list_messages( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/base.py b/google/cloud/dialogflow_v2/services/conversations/transports/base.py index 960e154f0..1834009d5 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/base.py @@ -177,6 +177,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_conversation( self, diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py b/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py index 35f8c4d3a..4fc12e15e 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py @@ -392,5 +392,8 @@ def list_messages( ) return self._stubs["list_messages"] + def close(self): + self.grpc_channel.close() + __all__ = ("ConversationsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py index abdd8ba01..9a6d9cfda 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py @@ -399,5 +399,8 @@ def list_messages( ) return self._stubs["list_messages"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ConversationsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/documents/async_client.py b/google/cloud/dialogflow_v2/services/documents/async_client.py index 5290615b6..c0e708525 100644 --- a/google/cloud/dialogflow_v2/services/documents/async_client.py +++ b/google/cloud/dialogflow_v2/services/documents/async_client.py @@ -761,6 +761,12 @@ async def reload_document( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/documents/client.py b/google/cloud/dialogflow_v2/services/documents/client.py index c6f07bed5..cfa9dc907 100644 --- a/google/cloud/dialogflow_v2/services/documents/client.py +++ b/google/cloud/dialogflow_v2/services/documents/client.py @@ -349,10 +349,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_documents( @@ -954,6 +951,19 @@ def reload_document( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/documents/transports/base.py b/google/cloud/dialogflow_v2/services/documents/transports/base.py index 37cc6d0fd..875f1df70 100644 --- a/google/cloud/dialogflow_v2/services/documents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/documents/transports/base.py @@ -180,6 +180,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2/services/documents/transports/grpc.py b/google/cloud/dialogflow_v2/services/documents/transports/grpc.py index 7fb63a137..ca40d991a 100644 --- a/google/cloud/dialogflow_v2/services/documents/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/documents/transports/grpc.py @@ -445,5 +445,8 @@ def reload_document( ) return self._stubs["reload_document"] + def close(self): + self.grpc_channel.close() + __all__ = ("DocumentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py index e712a9f6d..eadfb102c 100644 --- a/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py @@ -460,5 +460,8 @@ def reload_document( ) return self._stubs["reload_document"] + def close(self): + return self.grpc_channel.close() + __all__ = ("DocumentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/entity_types/async_client.py b/google/cloud/dialogflow_v2/services/entity_types/async_client.py index 3ad711d39..6dbe7224f 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/async_client.py +++ b/google/cloud/dialogflow_v2/services/entity_types/async_client.py @@ -1215,6 +1215,12 @@ async def batch_delete_entities( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/entity_types/client.py b/google/cloud/dialogflow_v2/services/entity_types/client.py index 6ef51e7f6..99c67e884 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/client.py +++ b/google/cloud/dialogflow_v2/services/entity_types/client.py @@ -348,10 +348,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_entity_types( @@ -1410,6 +1407,19 @@ def batch_delete_entities( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/entity_types/transports/base.py b/google/cloud/dialogflow_v2/services/entity_types/transports/base.py index 4b79a0b2a..f0be661d2 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2/services/entity_types/transports/base.py @@ -203,6 +203,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py b/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py index 5eaafd97e..93ac606df 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py @@ -600,5 +600,8 @@ def batch_delete_entities( ) return self._stubs["batch_delete_entities"] + def close(self): + self.grpc_channel.close() + __all__ = ("EntityTypesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py index 49a22ee82..6f3f42d4c 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py @@ -614,5 +614,8 @@ def batch_delete_entities( ) return self._stubs["batch_delete_entities"] + def close(self): + return self.grpc_channel.close() + __all__ = ("EntityTypesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/environments/async_client.py b/google/cloud/dialogflow_v2/services/environments/async_client.py index e34bde50f..4d83b3aa8 100644 --- a/google/cloud/dialogflow_v2/services/environments/async_client.py +++ b/google/cloud/dialogflow_v2/services/environments/async_client.py @@ -568,6 +568,12 @@ async def get_environment_history( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/environments/client.py b/google/cloud/dialogflow_v2/services/environments/client.py index 7d9d1c2c0..157714ec0 100644 --- a/google/cloud/dialogflow_v2/services/environments/client.py +++ b/google/cloud/dialogflow_v2/services/environments/client.py @@ -371,10 +371,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_environments( @@ -785,6 +782,19 @@ def get_environment_history( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/environments/transports/base.py b/google/cloud/dialogflow_v2/services/environments/transports/base.py index 82aa2d233..3e9662f0d 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/base.py @@ -180,6 +180,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_environments( self, diff --git a/google/cloud/dialogflow_v2/services/environments/transports/grpc.py b/google/cloud/dialogflow_v2/services/environments/transports/grpc.py index df74ed8f8..54b3d51a4 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/grpc.py @@ -401,5 +401,8 @@ def get_environment_history( ) return self._stubs["get_environment_history"] + def close(self): + self.grpc_channel.close() + __all__ = ("EnvironmentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py index a96252330..659106463 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py @@ -412,5 +412,8 @@ def get_environment_history( ) return self._stubs["get_environment_history"] + def close(self): + return self.grpc_channel.close() + __all__ = ("EnvironmentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/fulfillments/async_client.py b/google/cloud/dialogflow_v2/services/fulfillments/async_client.py index 28fb7fc0b..95c4d08ea 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/async_client.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/async_client.py @@ -333,6 +333,12 @@ async def update_fulfillment( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/fulfillments/client.py b/google/cloud/dialogflow_v2/services/fulfillments/client.py index fca89942b..22f4d67a8 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/client.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/client.py @@ -340,10 +340,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def get_fulfillment( @@ -519,6 +516,19 @@ def update_fulfillment( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py index 21f130998..372a1e3d7 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py @@ -166,6 +166,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def get_fulfillment( self, diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py index f4954a8a4..806afed34 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py @@ -281,5 +281,8 @@ def update_fulfillment( ) return self._stubs["update_fulfillment"] + def close(self): + self.grpc_channel.close() + __all__ = ("FulfillmentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py index 867a98788..7c2aa28b4 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py @@ -287,5 +287,8 @@ def update_fulfillment( ) return self._stubs["update_fulfillment"] + def close(self): + return self.grpc_channel.close() + __all__ = ("FulfillmentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/intents/async_client.py b/google/cloud/dialogflow_v2/services/intents/async_client.py index 6f175859d..e4a353208 100644 --- a/google/cloud/dialogflow_v2/services/intents/async_client.py +++ b/google/cloud/dialogflow_v2/services/intents/async_client.py @@ -877,6 +877,12 @@ async def batch_delete_intents( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/intents/client.py b/google/cloud/dialogflow_v2/services/intents/client.py index f6afa3b9a..1363372a8 100644 --- a/google/cloud/dialogflow_v2/services/intents/client.py +++ b/google/cloud/dialogflow_v2/services/intents/client.py @@ -362,10 +362,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_intents( @@ -1083,6 +1080,19 @@ def batch_delete_intents( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/intents/transports/base.py b/google/cloud/dialogflow_v2/services/intents/transports/base.py index f2d539e30..1c7e61b3a 100644 --- a/google/cloud/dialogflow_v2/services/intents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/intents/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2/services/intents/transports/grpc.py b/google/cloud/dialogflow_v2/services/intents/transports/grpc.py index d33ae9476..748c1bf42 100644 --- a/google/cloud/dialogflow_v2/services/intents/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/intents/transports/grpc.py @@ -464,5 +464,8 @@ def batch_delete_intents( ) return self._stubs["batch_delete_intents"] + def close(self): + self.grpc_channel.close() + __all__ = ("IntentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py index 8d2c49c47..f2570e27c 100644 --- a/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py @@ -477,5 +477,8 @@ def batch_delete_intents( ) return self._stubs["batch_delete_intents"] + def close(self): + return self.grpc_channel.close() + __all__ = ("IntentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py b/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py index 3a047d909..0416e1590 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py @@ -582,6 +582,12 @@ async def update_knowledge_base( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/client.py b/google/cloud/dialogflow_v2/services/knowledge_bases/client.py index 3b5b0f0dd..68fe63e09 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/client.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/client.py @@ -347,10 +347,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_knowledge_bases( @@ -768,6 +765,19 @@ def update_knowledge_base( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py index 8387997bc..268d72127 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py @@ -184,6 +184,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_knowledge_bases( self, diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py index 0a4abd200..2a72b6ab3 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py @@ -370,5 +370,8 @@ def update_knowledge_base( ) return self._stubs["update_knowledge_base"] + def close(self): + self.grpc_channel.close() + __all__ = ("KnowledgeBasesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py index b07a712f2..dabb41d2a 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py @@ -376,5 +376,8 @@ def update_knowledge_base( ) return self._stubs["update_knowledge_base"] + def close(self): + return self.grpc_channel.close() + __all__ = ("KnowledgeBasesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/participants/async_client.py b/google/cloud/dialogflow_v2/services/participants/async_client.py index ff13a6d05..d7b55107d 100644 --- a/google/cloud/dialogflow_v2/services/participants/async_client.py +++ b/google/cloud/dialogflow_v2/services/participants/async_client.py @@ -738,6 +738,12 @@ async def suggest_faq_answers( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/participants/client.py b/google/cloud/dialogflow_v2/services/participants/client.py index 03d020e5e..27bfaba9a 100644 --- a/google/cloud/dialogflow_v2/services/participants/client.py +++ b/google/cloud/dialogflow_v2/services/participants/client.py @@ -408,10 +408,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_participant( @@ -971,6 +968,19 @@ def suggest_faq_answers( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/participants/transports/base.py b/google/cloud/dialogflow_v2/services/participants/transports/base.py index b31b19626..0f180787e 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/base.py @@ -192,6 +192,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_participant( self, diff --git a/google/cloud/dialogflow_v2/services/participants/transports/grpc.py b/google/cloud/dialogflow_v2/services/participants/transports/grpc.py index ab59e81b5..f35687748 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/grpc.py @@ -429,5 +429,8 @@ def suggest_faq_answers( ) return self._stubs["suggest_faq_answers"] + def close(self): + self.grpc_channel.close() + __all__ = ("ParticipantsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py index 3b5bbf9f0..df6a33c4b 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py @@ -440,5 +440,8 @@ def suggest_faq_answers( ) return self._stubs["suggest_faq_answers"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ParticipantsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py b/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py index 738a174d3..35aeccfa9 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py @@ -615,6 +615,12 @@ async def delete_session_entity_type( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/client.py b/google/cloud/dialogflow_v2/services/session_entity_types/client.py index 03194d780..b174431ce 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/client.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/client.py @@ -353,10 +353,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_session_entity_types( @@ -817,6 +814,19 @@ def delete_session_entity_type( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py index 538b8bc25..cf7b13128 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_session_entity_types( self, diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py index 52f38cd97..b33d50a3b 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py @@ -393,5 +393,8 @@ def delete_session_entity_type( ) return self._stubs["delete_session_entity_type"] + def close(self): + self.grpc_channel.close() + __all__ = ("SessionEntityTypesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py index d67638595..a6d8f3b3b 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py @@ -396,5 +396,8 @@ def delete_session_entity_type( ) return self._stubs["delete_session_entity_type"] + def close(self): + return self.grpc_channel.close() + __all__ = ("SessionEntityTypesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/sessions/async_client.py b/google/cloud/dialogflow_v2/services/sessions/async_client.py index dd5dca4cd..69201880c 100644 --- a/google/cloud/dialogflow_v2/services/sessions/async_client.py +++ b/google/cloud/dialogflow_v2/services/sessions/async_client.py @@ -392,6 +392,12 @@ def streaming_detect_intent( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/sessions/client.py b/google/cloud/dialogflow_v2/services/sessions/client.py index 23cba476e..5d468cb9d 100644 --- a/google/cloud/dialogflow_v2/services/sessions/client.py +++ b/google/cloud/dialogflow_v2/services/sessions/client.py @@ -392,10 +392,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def detect_intent( @@ -601,6 +598,19 @@ def streaming_detect_intent( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/base.py b/google/cloud/dialogflow_v2/services/sessions/transports/base.py index 8f7a7a2ea..e3c1432b6 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/base.py @@ -179,6 +179,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def detect_intent( self, diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py b/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py index 0f496e5a7..3108ab140 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py @@ -297,5 +297,8 @@ def streaming_detect_intent( ) return self._stubs["streaming_detect_intent"] + def close(self): + self.grpc_channel.close() + __all__ = ("SessionsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py index e230d4965..3fcc25296 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py @@ -303,5 +303,8 @@ def streaming_detect_intent( ) return self._stubs["streaming_detect_intent"] + def close(self): + return self.grpc_channel.close() + __all__ = ("SessionsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/services/versions/async_client.py b/google/cloud/dialogflow_v2/services/versions/async_client.py index 395c6b0d4..70fca103f 100644 --- a/google/cloud/dialogflow_v2/services/versions/async_client.py +++ b/google/cloud/dialogflow_v2/services/versions/async_client.py @@ -610,6 +610,12 @@ async def delete_version( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/versions/client.py b/google/cloud/dialogflow_v2/services/versions/client.py index ca4b4c264..64a1a55fd 100644 --- a/google/cloud/dialogflow_v2/services/versions/client.py +++ b/google/cloud/dialogflow_v2/services/versions/client.py @@ -344,10 +344,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_versions( @@ -804,6 +801,19 @@ def delete_version( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2/services/versions/transports/base.py b/google/cloud/dialogflow_v2/services/versions/transports/base.py index 94464d5cd..7f54bedbf 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/base.py @@ -176,6 +176,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_versions( self, diff --git a/google/cloud/dialogflow_v2/services/versions/transports/grpc.py b/google/cloud/dialogflow_v2/services/versions/transports/grpc.py index 4163e690b..db028479c 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/grpc.py @@ -362,5 +362,8 @@ def delete_version( ) return self._stubs["delete_version"] + def close(self): + self.grpc_channel.close() + __all__ = ("VersionsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py index 9618017e5..ea3c282a3 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py @@ -369,5 +369,8 @@ def delete_version( ) return self._stubs["delete_version"] + def close(self): + return self.grpc_channel.close() + __all__ = ("VersionsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2/types/answer_record.py b/google/cloud/dialogflow_v2/types/answer_record.py index 92a8accd9..93f3c4caf 100644 --- a/google/cloud/dialogflow_v2/types/answer_record.py +++ b/google/cloud/dialogflow_v2/types/answer_record.py @@ -209,6 +209,7 @@ class CorrectnessLevel(proto.Enum): class AgentAssistantFeedback(proto.Message): r"""Detail feedback of Agent Assist result. + Attributes: answer_relevance (google.cloud.dialogflow_v2.types.AgentAssistantFeedback.AnswerRelevance): Optional. Whether or not the suggested answer is relevant. @@ -267,6 +268,7 @@ class DocumentEfficiency(proto.Enum): class AgentAssistantRecord(proto.Message): r"""Represents a record of a human agent assist answer. + Attributes: article_suggestion_answer (google.cloud.dialogflow_v2.types.ArticleAnswer): Output only. The article suggestion answer. diff --git a/google/cloud/dialogflow_v2/types/audio_config.py b/google/cloud/dialogflow_v2/types/audio_config.py index 5cca3a22f..d3204c5ef 100644 --- a/google/cloud/dialogflow_v2/types/audio_config.py +++ b/google/cloud/dialogflow_v2/types/audio_config.py @@ -130,6 +130,7 @@ class SpeechContext(proto.Message): class SpeechWordInfo(proto.Message): r"""Information for a word recognized by the speech recognizer. + Attributes: word (str): The word this info is for. @@ -261,6 +262,7 @@ class InputAudioConfig(proto.Message): class VoiceSelectionParams(proto.Message): r"""Description of which voice to use for speech synthesis. + Attributes: name (str): Optional. The name of the voice. If not set, the service @@ -284,6 +286,7 @@ class VoiceSelectionParams(proto.Message): class SynthesizeSpeechConfig(proto.Message): r"""Configuration of how speech should be synthesized. + Attributes: speaking_rate (float): Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 diff --git a/google/cloud/dialogflow_v2/types/conversation_profile.py b/google/cloud/dialogflow_v2/types/conversation_profile.py index b7022be1b..d76938f1c 100644 --- a/google/cloud/dialogflow_v2/types/conversation_profile.py +++ b/google/cloud/dialogflow_v2/types/conversation_profile.py @@ -235,6 +235,7 @@ class DeleteConversationProfileRequest(proto.Message): class AutomatedAgentConfig(proto.Message): r"""Defines the Automated Agent to connect to a conversation. + Attributes: agent (str): Required. ID of the Dialogflow agent environment to use. @@ -257,6 +258,7 @@ class AutomatedAgentConfig(proto.Message): class HumanAgentAssistantConfig(proto.Message): r"""Defines the Human Agent Assist to connect to a conversation. + Attributes: notification_config (google.cloud.dialogflow_v2.types.NotificationConfig): Pub/Sub topic on which to publish new agent @@ -275,6 +277,7 @@ class HumanAgentAssistantConfig(proto.Message): class SuggestionTriggerSettings(proto.Message): r"""Settings of suggestion trigger. + Attributes: no_smalltalk (bool): Do not trigger if last utterance is small @@ -289,6 +292,7 @@ class SuggestionTriggerSettings(proto.Message): class SuggestionFeatureConfig(proto.Message): r"""Config for suggestion features. + Attributes: suggestion_feature (google.cloud.dialogflow_v2.types.SuggestionFeature): The suggestion feature. @@ -331,6 +335,7 @@ class SuggestionFeatureConfig(proto.Message): class SuggestionConfig(proto.Message): r"""Detail human agent assistant config. + Attributes: feature_configs (Sequence[google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionFeatureConfig]): Configuration of different suggestion @@ -359,6 +364,7 @@ class SuggestionConfig(proto.Message): class SuggestionQueryConfig(proto.Message): r"""Config for suggestion query. + Attributes: knowledge_base_query_source (google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionQueryConfig.KnowledgeBaseQuerySource): Query from knowledgebase. It is used by: ARTICLE_SUGGESTION, @@ -587,6 +593,7 @@ class LivePersonConfig(proto.Message): class SalesforceLiveAgentConfig(proto.Message): r"""Configuration specific to Salesforce Live Agent. + Attributes: organization_id (str): Required. The organization ID of the @@ -621,6 +628,7 @@ class SalesforceLiveAgentConfig(proto.Message): class NotificationConfig(proto.Message): r"""Defines notification behavior. + Attributes: topic (str): Name of the Pub/Sub topic to publish conversation events @@ -653,6 +661,7 @@ class MessageFormat(proto.Enum): class LoggingConfig(proto.Message): r"""Defines logging behavior for conversation lifecycle events. + Attributes: enable_stackdriver_logging (bool): Whether to log conversation events like diff --git a/google/cloud/dialogflow_v2/types/document.py b/google/cloud/dialogflow_v2/types/document.py index c65907b64..45efa7a75 100644 --- a/google/cloud/dialogflow_v2/types/document.py +++ b/google/cloud/dialogflow_v2/types/document.py @@ -115,6 +115,7 @@ class KnowledgeType(proto.Enum): class ReloadStatus(proto.Message): r"""The status of a reload attempt. + Attributes: time (google.protobuf.timestamp_pb2.Timestamp): The time of a reload attempt. diff --git a/google/cloud/dialogflow_v2/types/entity_type.py b/google/cloud/dialogflow_v2/types/entity_type.py index acb5cece1..8384ae360 100644 --- a/google/cloud/dialogflow_v2/types/entity_type.py +++ b/google/cloud/dialogflow_v2/types/entity_type.py @@ -95,6 +95,7 @@ class AutoExpansionMode(proto.Enum): class Entity(proto.Message): r"""An **entity entry** for an associated entity type. + Attributes: value (str): Required. The primary value associated with this entity diff --git a/google/cloud/dialogflow_v2/types/environment.py b/google/cloud/dialogflow_v2/types/environment.py index 1beb7ed50..63b3872aa 100644 --- a/google/cloud/dialogflow_v2/types/environment.py +++ b/google/cloud/dialogflow_v2/types/environment.py @@ -343,6 +343,7 @@ class EnvironmentHistory(proto.Message): class Entry(proto.Message): r"""Represents an environment history entry. + Attributes: agent_version (str): The agent version loaded into this diff --git a/google/cloud/dialogflow_v2/types/fulfillment.py b/google/cloud/dialogflow_v2/types/fulfillment.py index c867a5c3f..a54cb19d0 100644 --- a/google/cloud/dialogflow_v2/types/fulfillment.py +++ b/google/cloud/dialogflow_v2/types/fulfillment.py @@ -96,6 +96,7 @@ class GenericWebService(proto.Message): class Feature(proto.Message): r"""Whether fulfillment is enabled for the specific feature. + Attributes: type_ (google.cloud.dialogflow_v2.types.Fulfillment.Feature.Type): The type of the feature that enabled for diff --git a/google/cloud/dialogflow_v2/types/intent.py b/google/cloud/dialogflow_v2/types/intent.py index a71b07449..f53b9b3fb 100644 --- a/google/cloud/dialogflow_v2/types/intent.py +++ b/google/cloud/dialogflow_v2/types/intent.py @@ -175,6 +175,7 @@ class WebhookState(proto.Enum): class TrainingPhrase(proto.Message): r"""Represents an example that the agent is trained on. + Attributes: name (str): Output only. The unique identifier of this @@ -221,6 +222,7 @@ class Type(proto.Enum): class Part(proto.Message): r"""Represents a part of a training phrase. + Attributes: text (str): Required. The text for this part. @@ -255,6 +257,7 @@ class Part(proto.Message): class Parameter(proto.Message): r"""Represents intent parameters. + Attributes: name (str): The unique identifier of this parameter. @@ -362,6 +365,7 @@ class Platform(proto.Enum): class Text(proto.Message): r"""The text response message. + Attributes: text (Sequence[str]): Optional. The collection of the agent's @@ -372,6 +376,7 @@ class Text(proto.Message): class Image(proto.Message): r"""The image response message. + Attributes: image_uri (str): Optional. The public URI to an image file. @@ -385,6 +390,7 @@ class Image(proto.Message): class QuickReplies(proto.Message): r"""The quick replies response message. + Attributes: title (str): Optional. The title of the collection of @@ -398,6 +404,7 @@ class QuickReplies(proto.Message): class Card(proto.Message): r"""The card response message. + Attributes: title (str): Optional. The title of the card. @@ -412,6 +419,7 @@ class Card(proto.Message): class Button(proto.Message): r"""Contains information about a button. + Attributes: text (str): Optional. The text to show on the button. @@ -432,6 +440,7 @@ class Button(proto.Message): class SimpleResponse(proto.Message): r"""The simple response message containing speech or text. + Attributes: text_to_speech (str): One of text_to_speech or ssml must be provided. The plain @@ -465,6 +474,7 @@ class SimpleResponses(proto.Message): class BasicCard(proto.Message): r"""The basic card message. Useful for displaying information. + Attributes: title (str): Optional. The title of the card. @@ -481,6 +491,7 @@ class BasicCard(proto.Message): class Button(proto.Message): r"""The button object that appears at the bottom of a card. + Attributes: title (str): Required. The title of the button. @@ -491,6 +502,7 @@ class Button(proto.Message): class OpenUriAction(proto.Message): r"""Opens the given URI. + Attributes: uri (str): Required. The HTTP or HTTPS scheme URI. @@ -529,6 +541,7 @@ class Suggestion(proto.Message): class Suggestions(proto.Message): r"""The collection of suggestions. + Attributes: suggestions (Sequence[google.cloud.dialogflow_v2.types.Intent.Message.Suggestion]): Required. The list of suggested replies. @@ -556,6 +569,7 @@ class LinkOutSuggestion(proto.Message): class ListSelect(proto.Message): r"""The card for presenting a list of options to select from. + Attributes: title (str): Optional. The overall title of the list. @@ -567,6 +581,7 @@ class ListSelect(proto.Message): class Item(proto.Message): r"""An item in the list. + Attributes: info (google.cloud.dialogflow_v2.types.Intent.Message.SelectItemInfo): Required. Additional information about this @@ -596,6 +611,7 @@ class Item(proto.Message): class CarouselSelect(proto.Message): r"""The card for presenting a carousel of options to select from. + Attributes: items (Sequence[google.cloud.dialogflow_v2.types.Intent.Message.CarouselSelect.Item]): Required. Carousel items. @@ -603,6 +619,7 @@ class CarouselSelect(proto.Message): class Item(proto.Message): r"""An item in the carousel. + Attributes: info (google.cloud.dialogflow_v2.types.Intent.Message.SelectItemInfo): Required. Additional info about the option @@ -646,6 +663,7 @@ class SelectItemInfo(proto.Message): class MediaContent(proto.Message): r"""The media content card for Actions on Google. + Attributes: media_type (google.cloud.dialogflow_v2.types.Intent.Message.MediaContent.ResponseMediaType): Optional. What type of media is the content @@ -661,6 +679,7 @@ class ResponseMediaType(proto.Enum): class ResponseMediaObject(proto.Message): r"""Response media object for media content card. + Attributes: name (str): Required. Name of media card. @@ -731,6 +750,7 @@ class ImageDisplayOptions(proto.Enum): class BrowseCarouselCardItem(proto.Message): r"""Browsing carousel tile + Attributes: open_uri_action (google.cloud.dialogflow_v2.types.Intent.Message.BrowseCarouselCard.BrowseCarouselCardItem.OpenUrlAction): Required. Action to present to the user. @@ -750,6 +770,7 @@ class BrowseCarouselCardItem(proto.Message): class OpenUrlAction(proto.Message): r"""Actions on Google action to open a given url. + Attributes: url (str): Required. URL @@ -797,6 +818,7 @@ class UrlTypeHint(proto.Enum): class TableCard(proto.Message): r"""Table card for Actions on Google. + Attributes: title (str): Required. Title of the card. @@ -960,6 +982,7 @@ class TableCardCell(proto.Message): class FollowupIntentInfo(proto.Message): r"""Represents a single followup intent in the chain. + Attributes: followup_intent_name (str): The unique identifier of the followup intent. Format: @@ -1163,6 +1186,7 @@ class DeleteIntentRequest(proto.Message): class BatchUpdateIntentsRequest(proto.Message): r""" + Attributes: parent (str): Required. The name of the agent to update or create intents @@ -1233,6 +1257,7 @@ class BatchDeleteIntentsRequest(proto.Message): class IntentBatch(proto.Message): r"""This message is a wrapper around a collection of intents. + Attributes: intents (Sequence[google.cloud.dialogflow_v2.types.Intent]): A collection of intents. diff --git a/google/cloud/dialogflow_v2/types/participant.py b/google/cloud/dialogflow_v2/types/participant.py index bbc03af91..0194fd9f8 100644 --- a/google/cloud/dialogflow_v2/types/participant.py +++ b/google/cloud/dialogflow_v2/types/participant.py @@ -87,6 +87,7 @@ class Role(proto.Enum): class Message(proto.Message): r"""Represents a message posted into a conversation. + Attributes: name (str): The unique identifier of the message. Format: @@ -464,6 +465,7 @@ class OutputAudio(proto.Message): class AutomatedAgentReply(proto.Message): r"""Represents a response from an automated agent. + Attributes: detect_intent_response (google.cloud.dialogflow_v2.types.DetectIntentResponse): Response of the Dialogflow @@ -496,6 +498,7 @@ class AutomatedAgentReplyType(proto.Enum): class ArticleAnswer(proto.Message): r"""Represents article answer. + Attributes: title (str): The article title. @@ -528,6 +531,7 @@ class ArticleAnswer(proto.Message): class FaqAnswer(proto.Message): r"""Represents answer from "frequently asked questions". + Attributes: answer (str): The piece of text from the ``source`` knowledge base @@ -633,6 +637,7 @@ class AnnotatedMessagePart(proto.Message): class MessageAnnotation(proto.Message): r"""Represents the result of annotation for the message. + Attributes: parts (Sequence[google.cloud.dialogflow_v2.types.AnnotatedMessagePart]): The collection of annotated message parts ordered by their diff --git a/google/cloud/dialogflow_v2/types/session.py b/google/cloud/dialogflow_v2/types/session.py index 17289a15e..ab8932dba 100644 --- a/google/cloud/dialogflow_v2/types/session.py +++ b/google/cloud/dialogflow_v2/types/session.py @@ -48,6 +48,7 @@ class DetectIntentRequest(proto.Message): r"""The request to detect user's intent. + Attributes: session (str): Required. The name of the session this query is sent to. @@ -118,6 +119,7 @@ class DetectIntentRequest(proto.Message): class DetectIntentResponse(proto.Message): r"""The message returned from the DetectIntent method. + Attributes: response_id (str): The unique identifier of the response. It can @@ -157,6 +159,7 @@ class DetectIntentResponse(proto.Message): class QueryParameters(proto.Message): r"""Represents the parameters of the conversational query. + Attributes: time_zone (str): The time zone of this conversational query from the `time @@ -652,6 +655,7 @@ class MessageType(proto.Enum): class TextInput(proto.Message): r"""Represents the natural language text to be processed. + Attributes: text (str): Required. The UTF-8 encoded natural language @@ -716,6 +720,7 @@ class EventInput(proto.Message): class SentimentAnalysisRequestConfig(proto.Message): r"""Configures the types of sentiment analysis to perform. + Attributes: analyze_query_text_sentiment (bool): Instructs the service to perform sentiment analysis on diff --git a/google/cloud/dialogflow_v2/types/validation_result.py b/google/cloud/dialogflow_v2/types/validation_result.py index b1008264b..e065363b7 100644 --- a/google/cloud/dialogflow_v2/types/validation_result.py +++ b/google/cloud/dialogflow_v2/types/validation_result.py @@ -24,6 +24,7 @@ class ValidationError(proto.Message): r"""Represents a single validation error. + Attributes: severity (google.cloud.dialogflow_v2.types.ValidationError.Severity): The severity of the error. @@ -66,6 +67,7 @@ class Severity(proto.Enum): class ValidationResult(proto.Message): r"""Represents the output of agent validation. + Attributes: validation_errors (Sequence[google.cloud.dialogflow_v2.types.ValidationError]): Contains all validation errors. diff --git a/google/cloud/dialogflow_v2/types/webhook.py b/google/cloud/dialogflow_v2/types/webhook.py index 8c96b6676..6dd218aa5 100644 --- a/google/cloud/dialogflow_v2/types/webhook.py +++ b/google/cloud/dialogflow_v2/types/webhook.py @@ -30,6 +30,7 @@ class WebhookRequest(proto.Message): r"""The request message for a webhook call. + Attributes: session (str): The unique identifier of detectIntent request session. Can diff --git a/google/cloud/dialogflow_v2beta1/services/agents/async_client.py b/google/cloud/dialogflow_v2beta1/services/agents/async_client.py index af66e7981..a326d0ed9 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/async_client.py @@ -923,6 +923,12 @@ async def get_validation_result( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/agents/client.py b/google/cloud/dialogflow_v2beta1/services/agents/client.py index d0f5f44a6..8356aa25b 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/client.py @@ -345,10 +345,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def get_agent( @@ -1118,6 +1115,19 @@ def get_validation_result( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py index 698507989..52eda1d9a 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py @@ -193,6 +193,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py index 98f4eb5e9..7039ecdaa 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py @@ -567,5 +567,8 @@ def get_validation_result( ) return self._stubs["get_validation_result"] + def close(self): + self.grpc_channel.close() + __all__ = ("AgentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py index 4a88d1d43..f6e5ef2cc 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py @@ -577,5 +577,8 @@ def get_validation_result( ) return self._stubs["get_validation_result"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AgentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py b/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py index 93c491233..04a9c89a4 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py @@ -448,6 +448,12 @@ async def update_answer_record( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/client.py b/google/cloud/dialogflow_v2beta1/services/answer_records/client.py index 3eb74fb44..15753c253 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/client.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/client.py @@ -346,10 +346,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def get_answer_record( @@ -632,6 +629,19 @@ def update_answer_record( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py index be768eb7a..45289e34d 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py @@ -171,6 +171,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def get_answer_record( self, diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py index f4fd6f955..831ae49c7 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py @@ -312,5 +312,8 @@ def update_answer_record( ) return self._stubs["update_answer_record"] + def close(self): + self.grpc_channel.close() + __all__ = ("AnswerRecordsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py index 8a5dbf1b4..a0a58b327 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py @@ -318,5 +318,8 @@ def update_answer_record( ) return self._stubs["update_answer_record"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AnswerRecordsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py b/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py index 775dc4f81..a5f84a254 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py @@ -700,6 +700,12 @@ async def delete_all_contexts( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/client.py b/google/cloud/dialogflow_v2beta1/services/contexts/client.py index 1c91533eb..83de06ec8 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/client.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/client.py @@ -347,10 +347,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_contexts( @@ -895,6 +892,19 @@ def delete_all_contexts( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py index 49b7a23b0..1c78c1438 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py @@ -179,6 +179,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_contexts( self, diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py index e9956be43..9f27ed021 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py @@ -385,5 +385,8 @@ def delete_all_contexts( ) return self._stubs["delete_all_contexts"] + def close(self): + self.grpc_channel.close() + __all__ = ("ContextsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py index 8f205b5bf..787b76711 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py @@ -392,5 +392,8 @@ def delete_all_contexts( ) return self._stubs["delete_all_contexts"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ContextsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py index fb09ac4ac..c39cf892f 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py @@ -592,6 +592,12 @@ async def delete_conversation_profile( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py index 86262a0af..36390e7ac 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py @@ -432,10 +432,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_conversation_profiles( @@ -860,6 +857,19 @@ def delete_conversation_profile( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py index 9451cf98d..5449ff769 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_conversation_profiles( self, diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py index 18fc3858d..4707c4b80 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py @@ -387,5 +387,8 @@ def delete_conversation_profile( ) return self._stubs["delete_conversation_profile"] + def close(self): + self.grpc_channel.close() + __all__ = ("ConversationProfilesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py index c8971022f..18aded68f 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py @@ -391,5 +391,8 @@ def delete_conversation_profile( ) return self._stubs["delete_conversation_profile"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ConversationProfilesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py b/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py index 37a293a49..3fbacbcd7 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py @@ -675,6 +675,12 @@ async def list_messages( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/client.py b/google/cloud/dialogflow_v2beta1/services/conversations/client.py index 9ae7303eb..0bef29367 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/client.py @@ -378,10 +378,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_conversation( @@ -885,6 +882,19 @@ def list_messages( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py index ce4b549fb..56052daae 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py @@ -182,6 +182,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_conversation( self, diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py index 3b00aff3b..ac668a5e8 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py @@ -423,5 +423,8 @@ def list_messages( ) return self._stubs["list_messages"] + def close(self): + self.grpc_channel.close() + __all__ = ("ConversationsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py index d20fee018..4c3d93a62 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py @@ -430,5 +430,8 @@ def list_messages( ) return self._stubs["list_messages"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ConversationsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/documents/async_client.py b/google/cloud/dialogflow_v2beta1/services/documents/async_client.py index 53e4b07d3..b00b957cf 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/async_client.py @@ -855,6 +855,12 @@ async def reload_document( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/documents/client.py b/google/cloud/dialogflow_v2beta1/services/documents/client.py index ef24cbc5d..47356b4a5 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/client.py @@ -350,10 +350,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_documents( @@ -1049,6 +1046,19 @@ def reload_document( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py index cfb3e2e03..5641d1a96 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py @@ -183,6 +183,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py index a959ca976..6722914c5 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py @@ -504,5 +504,8 @@ def reload_document( ) return self._stubs["reload_document"] + def close(self): + self.grpc_channel.close() + __all__ = ("DocumentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py index 8584dbc22..cfaad0c1f 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py @@ -521,5 +521,8 @@ def reload_document( ) return self._stubs["reload_document"] + def close(self): + return self.grpc_channel.close() + __all__ = ("DocumentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py b/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py index 4e1f861cc..ad0c87258 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py @@ -1247,6 +1247,12 @@ async def batch_delete_entities( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/client.py b/google/cloud/dialogflow_v2beta1/services/entity_types/client.py index 988c878fb..ac3dd274f 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/client.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/client.py @@ -349,10 +349,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_entity_types( @@ -1442,6 +1439,19 @@ def batch_delete_entities( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py index 8a18dff81..c05259169 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py @@ -203,6 +203,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py index d665a461e..5d6708fb4 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py @@ -600,5 +600,8 @@ def batch_delete_entities( ) return self._stubs["batch_delete_entities"] + def close(self): + self.grpc_channel.close() + __all__ = ("EntityTypesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py index 474ffef0d..b00b22f00 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py @@ -614,5 +614,8 @@ def batch_delete_entities( ) return self._stubs["batch_delete_entities"] + def close(self): + return self.grpc_channel.close() + __all__ = ("EntityTypesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/environments/async_client.py b/google/cloud/dialogflow_v2beta1/services/environments/async_client.py index 3fd4e5fca..a6ddd0bcd 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/async_client.py @@ -567,6 +567,12 @@ async def get_environment_history( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/environments/client.py b/google/cloud/dialogflow_v2beta1/services/environments/client.py index eb45bdf34..4128a3b92 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/client.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/client.py @@ -371,10 +371,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_environments( @@ -784,6 +781,19 @@ def get_environment_history( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py index 66ef0e6d8..763c346f6 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py @@ -180,6 +180,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_environments( self, diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py index 1ba07220f..da16fad8f 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py @@ -400,5 +400,8 @@ def get_environment_history( ) return self._stubs["get_environment_history"] + def close(self): + self.grpc_channel.close() + __all__ = ("EnvironmentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py index dc3628da1..fd9980680 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py @@ -411,5 +411,8 @@ def get_environment_history( ) return self._stubs["get_environment_history"] + def close(self): + return self.grpc_channel.close() + __all__ = ("EnvironmentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py index 5f2a149b4..bbe089bbb 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py @@ -336,6 +336,12 @@ async def update_fulfillment( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py index b072db119..d10f10499 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py @@ -340,10 +340,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def get_fulfillment( @@ -522,6 +519,19 @@ def update_fulfillment( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py index 82e05d968..3ca8956a1 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py @@ -166,6 +166,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def get_fulfillment( self, diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py index 85627dc90..b8d12c4bf 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py @@ -281,5 +281,8 @@ def update_fulfillment( ) return self._stubs["update_fulfillment"] + def close(self): + self.grpc_channel.close() + __all__ = ("FulfillmentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py index 191446b41..aeefa86bd 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py @@ -287,5 +287,8 @@ def update_fulfillment( ) return self._stubs["update_fulfillment"] + def close(self): + return self.grpc_channel.close() + __all__ = ("FulfillmentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/intents/async_client.py b/google/cloud/dialogflow_v2beta1/services/intents/async_client.py index 463806566..12c00278f 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/async_client.py @@ -895,6 +895,12 @@ async def batch_delete_intents( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/intents/client.py b/google/cloud/dialogflow_v2beta1/services/intents/client.py index ecc368fbe..280d15741 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/client.py @@ -364,10 +364,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_intents( @@ -1101,6 +1098,19 @@ def batch_delete_intents( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py index 51326baa7..1f27cddb9 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py index 4daeef6f6..42a414a2e 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py @@ -465,5 +465,8 @@ def batch_delete_intents( ) return self._stubs["batch_delete_intents"] + def close(self): + self.grpc_channel.close() + __all__ = ("IntentsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py index 8eb39795c..46d8e3e6d 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py @@ -478,5 +478,8 @@ def batch_delete_intents( ) return self._stubs["batch_delete_intents"] + def close(self): + return self.grpc_channel.close() + __all__ = ("IntentsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py index b621ba17a..5c7784662 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py @@ -596,6 +596,12 @@ async def update_knowledge_base( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py index c6ba32c12..6d0acf2f4 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py @@ -347,10 +347,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_knowledge_bases( @@ -782,6 +779,19 @@ def update_knowledge_base( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py index 77e56056b..0c0d2ff2c 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py @@ -184,6 +184,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_knowledge_bases( self, diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py index e9186816d..23b3a89de 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py @@ -384,5 +384,8 @@ def update_knowledge_base( ) return self._stubs["update_knowledge_base"] + def close(self): + self.grpc_channel.close() + __all__ = ("KnowledgeBasesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py index 3541a6952..d02786d4b 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py @@ -390,5 +390,8 @@ def update_knowledge_base( ) return self._stubs["update_knowledge_base"] + def close(self): + return self.grpc_channel.close() + __all__ = ("KnowledgeBasesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/participants/async_client.py b/google/cloud/dialogflow_v2beta1/services/participants/async_client.py index 7665ce6fd..60a9a6e76 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/async_client.py @@ -970,6 +970,12 @@ async def compile_suggestion( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/participants/client.py b/google/cloud/dialogflow_v2beta1/services/participants/client.py index 1e53bb3ed..9f639afb3 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/client.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/client.py @@ -425,10 +425,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_participant( @@ -1218,6 +1215,19 @@ def compile_suggestion( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py index 012be1e4e..cac2d2624 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py @@ -203,6 +203,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_participant( self, diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py index 7ea56fbc2..0feb49740 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py @@ -555,5 +555,8 @@ def compile_suggestion( ) return self._stubs["compile_suggestion"] + def close(self): + self.grpc_channel.close() + __all__ = ("ParticipantsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py index a284d77c1..8cac31f55 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py @@ -568,5 +568,8 @@ def compile_suggestion( ) return self._stubs["compile_suggestion"] + def close(self): + return self.grpc_channel.close() + __all__ = ("ParticipantsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py index da8d49e7f..9c6a2343a 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py @@ -635,6 +635,12 @@ async def delete_session_entity_type( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py index e898ecd4f..fae84b7e1 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py @@ -353,10 +353,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_session_entity_types( @@ -837,6 +834,19 @@ def delete_session_entity_type( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py index 7f17aaf12..291a54f86 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py @@ -188,6 +188,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_session_entity_types( self, diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py index af6fb4de9..1552ec0ce 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py @@ -393,5 +393,8 @@ def delete_session_entity_type( ) return self._stubs["delete_session_entity_type"] + def close(self): + self.grpc_channel.close() + __all__ = ("SessionEntityTypesGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py index ff6bb820b..9f2fba0ce 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py @@ -396,5 +396,8 @@ def delete_session_entity_type( ) return self._stubs["delete_session_entity_type"] + def close(self): + return self.grpc_channel.close() + __all__ = ("SessionEntityTypesGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py b/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py index 7ee96e0f1..1ea4f0601 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py @@ -402,6 +402,12 @@ def streaming_detect_intent( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/client.py b/google/cloud/dialogflow_v2beta1/services/sessions/client.py index f27f16997..251ead75f 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/client.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/client.py @@ -408,10 +408,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def detect_intent( @@ -625,6 +622,19 @@ def streaming_detect_intent( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py index eeee66bd9..2405c4855 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py @@ -179,6 +179,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def detect_intent( self, diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py index e0abc222d..818880a72 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py @@ -297,5 +297,8 @@ def streaming_detect_intent( ) return self._stubs["streaming_detect_intent"] + def close(self): + self.grpc_channel.close() + __all__ = ("SessionsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py index 82f0f1e1b..26fe23a9c 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py @@ -303,5 +303,8 @@ def streaming_detect_intent( ) return self._stubs["streaming_detect_intent"] + def close(self): + return self.grpc_channel.close() + __all__ = ("SessionsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/versions/async_client.py b/google/cloud/dialogflow_v2beta1/services/versions/async_client.py index 05f84d7fa..7a110a13f 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/async_client.py @@ -612,6 +612,12 @@ async def delete_version( request, retry=retry, timeout=timeout, metadata=metadata, ) + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/versions/client.py b/google/cloud/dialogflow_v2beta1/services/versions/client.py index 40b0118cc..bb797812e 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/client.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/client.py @@ -346,10 +346,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_versions( @@ -806,6 +803,19 @@ def delete_version( request, retry=retry, timeout=timeout, metadata=metadata, ) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py index 5997854da..5c94d418b 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py @@ -176,6 +176,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def list_versions( self, diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py index b63e8c128..ecb698345 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py @@ -363,5 +363,8 @@ def delete_version( ) return self._stubs["delete_version"] + def close(self): + self.grpc_channel.close() + __all__ = ("VersionsGrpcTransport",) diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py index 27e7a8e5f..e315e4190 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py @@ -370,5 +370,8 @@ def delete_version( ) return self._stubs["delete_version"] + def close(self): + return self.grpc_channel.close() + __all__ = ("VersionsGrpcAsyncIOTransport",) diff --git a/google/cloud/dialogflow_v2beta1/types/agent.py b/google/cloud/dialogflow_v2beta1/types/agent.py index fc51cfd93..a7ef49936 100644 --- a/google/cloud/dialogflow_v2beta1/types/agent.py +++ b/google/cloud/dialogflow_v2beta1/types/agent.py @@ -194,6 +194,7 @@ class DeleteAgentRequest(proto.Message): class SubAgent(proto.Message): r"""Contains basic configuration for a sub-agent. + Attributes: project (str): Required. The project of this agent. Format: diff --git a/google/cloud/dialogflow_v2beta1/types/answer_record.py b/google/cloud/dialogflow_v2beta1/types/answer_record.py index b645483eb..95dc47038 100644 --- a/google/cloud/dialogflow_v2beta1/types/answer_record.py +++ b/google/cloud/dialogflow_v2beta1/types/answer_record.py @@ -90,6 +90,7 @@ class AnswerRecord(proto.Message): class AgentAssistantRecord(proto.Message): r"""Represents a record of a human agent assistant answer. + Attributes: article_suggestion_answer (google.cloud.dialogflow_v2beta1.types.ArticleAnswer): Output only. The article suggestion answer. @@ -152,6 +153,7 @@ class CorrectnessLevel(proto.Enum): class AgentAssistantFeedback(proto.Message): r"""Detail feedback of Agent Assistant result. + Attributes: answer_relevance (google.cloud.dialogflow_v2beta1.types.AgentAssistantFeedback.AnswerRelevance): Optional. Whether or not the suggested answer is relevant. @@ -207,6 +209,7 @@ class DocumentEfficiency(proto.Enum): class SummarizationFeedback(proto.Message): r"""Feedback for conversation summarization. + Attributes: start_timestamp (google.protobuf.timestamp_pb2.Timestamp): Timestamp when composing of the summary diff --git a/google/cloud/dialogflow_v2beta1/types/audio_config.py b/google/cloud/dialogflow_v2beta1/types/audio_config.py index 737f9c059..e0d0e772e 100644 --- a/google/cloud/dialogflow_v2beta1/types/audio_config.py +++ b/google/cloud/dialogflow_v2beta1/types/audio_config.py @@ -156,6 +156,7 @@ class SpeechContext(proto.Message): class SpeechWordInfo(proto.Message): r"""Information for a word recognized by the speech recognizer. + Attributes: word (str): The word this info is for. @@ -287,6 +288,7 @@ class InputAudioConfig(proto.Message): class VoiceSelectionParams(proto.Message): r"""Description of which voice to use for speech synthesis. + Attributes: name (str): Optional. The name of the voice. If not set, the service @@ -314,6 +316,7 @@ class VoiceSelectionParams(proto.Message): class SynthesizeSpeechConfig(proto.Message): r"""Configuration of how speech should be synthesized. + Attributes: speaking_rate (float): Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 @@ -387,6 +390,7 @@ class OutputAudioConfig(proto.Message): class TelephonyDtmfEvents(proto.Message): r"""A wrapper of repeated TelephonyDtmf digits. + Attributes: dtmf_events (Sequence[google.cloud.dialogflow_v2beta1.types.TelephonyDtmf]): A sequence of TelephonyDtmf digits. diff --git a/google/cloud/dialogflow_v2beta1/types/conversation_profile.py b/google/cloud/dialogflow_v2beta1/types/conversation_profile.py index 74039c0b8..0cb67df87 100644 --- a/google/cloud/dialogflow_v2beta1/types/conversation_profile.py +++ b/google/cloud/dialogflow_v2beta1/types/conversation_profile.py @@ -131,6 +131,7 @@ class ConversationProfile(proto.Message): class AutomatedAgentConfig(proto.Message): r"""Defines the Automated Agent to connect to a conversation. + Attributes: agent (str): Required. ID of the Dialogflow agent environment to use. @@ -178,6 +179,7 @@ class HumanAgentAssistantConfig(proto.Message): class SuggestionTriggerSettings(proto.Message): r"""Settings of suggestion trigger. + Attributes: no_small_talk (bool): Do not trigger if last utterance is small @@ -192,6 +194,7 @@ class SuggestionTriggerSettings(proto.Message): class SuggestionFeatureConfig(proto.Message): r"""Config for suggestion features. + Attributes: suggestion_feature (google.cloud.dialogflow_v2beta1.types.SuggestionFeature): The suggestion feature. @@ -234,6 +237,7 @@ class SuggestionFeatureConfig(proto.Message): class SuggestionConfig(proto.Message): r"""Detail human agent assistant config. + Attributes: feature_configs (Sequence[google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionFeatureConfig]): Configuration of different suggestion @@ -262,6 +266,7 @@ class SuggestionConfig(proto.Message): class SuggestionQueryConfig(proto.Message): r"""Config for suggestion query. + Attributes: knowledge_base_query_source (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionQueryConfig.KnowledgeBaseQuerySource): Query from knowledgebase. It is used by: ARTICLE_SUGGESTION, @@ -491,6 +496,7 @@ class LivePersonConfig(proto.Message): class SalesforceLiveAgentConfig(proto.Message): r"""Configuration specific to Salesforce Live Agent. + Attributes: organization_id (str): Required. The organization ID of the @@ -525,6 +531,7 @@ class SalesforceLiveAgentConfig(proto.Message): class NotificationConfig(proto.Message): r"""Defines notification behavior. + Attributes: topic (str): Name of the Pub/Sub topic to publish conversation events @@ -557,6 +564,7 @@ class MessageFormat(proto.Enum): class LoggingConfig(proto.Message): r"""Defines logging behavior for conversation lifecycle events. + Attributes: enable_stackdriver_logging (bool): Whether to log conversation events like diff --git a/google/cloud/dialogflow_v2beta1/types/document.py b/google/cloud/dialogflow_v2beta1/types/document.py index 4597aeb95..cf33e0898 100644 --- a/google/cloud/dialogflow_v2beta1/types/document.py +++ b/google/cloud/dialogflow_v2beta1/types/document.py @@ -125,6 +125,7 @@ class KnowledgeType(proto.Enum): class ReloadStatus(proto.Message): r"""The status of a reload attempt. + Attributes: time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time of a reload attempt. @@ -291,6 +292,7 @@ class ImportDocumentsRequest(proto.Message): class ImportDocumentTemplate(proto.Message): r"""The template used for importing documents. + Attributes: mime_type (str): Required. The MIME type of the document. diff --git a/google/cloud/dialogflow_v2beta1/types/entity_type.py b/google/cloud/dialogflow_v2beta1/types/entity_type.py index 1143c6b55..1a7bf7754 100644 --- a/google/cloud/dialogflow_v2beta1/types/entity_type.py +++ b/google/cloud/dialogflow_v2beta1/types/entity_type.py @@ -97,6 +97,7 @@ class AutoExpansionMode(proto.Enum): class Entity(proto.Message): r"""An **entity entry** for an associated entity type. + Attributes: value (str): Required. The primary value associated with this entity diff --git a/google/cloud/dialogflow_v2beta1/types/environment.py b/google/cloud/dialogflow_v2beta1/types/environment.py index 5ee003e2f..f24d1e574 100644 --- a/google/cloud/dialogflow_v2beta1/types/environment.py +++ b/google/cloud/dialogflow_v2beta1/types/environment.py @@ -333,6 +333,7 @@ class EnvironmentHistory(proto.Message): class Entry(proto.Message): r"""Represents an environment history entry. + Attributes: agent_version (str): The agent version loaded into this diff --git a/google/cloud/dialogflow_v2beta1/types/fulfillment.py b/google/cloud/dialogflow_v2beta1/types/fulfillment.py index a77f89e38..ed3d1a3db 100644 --- a/google/cloud/dialogflow_v2beta1/types/fulfillment.py +++ b/google/cloud/dialogflow_v2beta1/types/fulfillment.py @@ -94,6 +94,7 @@ class GenericWebService(proto.Message): class Feature(proto.Message): r"""Whether fulfillment is enabled for the specific feature. + Attributes: type_ (google.cloud.dialogflow_v2beta1.types.Fulfillment.Feature.Type): The type of the feature that enabled for diff --git a/google/cloud/dialogflow_v2beta1/types/gcs.py b/google/cloud/dialogflow_v2beta1/types/gcs.py index 6905e49cc..99cf2bad4 100644 --- a/google/cloud/dialogflow_v2beta1/types/gcs.py +++ b/google/cloud/dialogflow_v2beta1/types/gcs.py @@ -23,6 +23,7 @@ class GcsSources(proto.Message): r"""Google Cloud Storage locations for the inputs. + Attributes: uris (Sequence[str]): Required. Google Cloud Storage URIs for the @@ -37,6 +38,7 @@ class GcsSources(proto.Message): class GcsSource(proto.Message): r"""Google Cloud Storage location for single input. + Attributes: uri (str): Required. The Google Cloud Storage URIs for diff --git a/google/cloud/dialogflow_v2beta1/types/intent.py b/google/cloud/dialogflow_v2beta1/types/intent.py index 8d3245bd1..19e65cb00 100644 --- a/google/cloud/dialogflow_v2beta1/types/intent.py +++ b/google/cloud/dialogflow_v2beta1/types/intent.py @@ -192,6 +192,7 @@ class WebhookState(proto.Enum): class TrainingPhrase(proto.Message): r"""Represents an example that the agent is trained on. + Attributes: name (str): Output only. The unique identifier of this @@ -238,6 +239,7 @@ class Type(proto.Enum): class Part(proto.Message): r"""Represents a part of a training phrase. + Attributes: text (str): Required. The text for this part. @@ -272,6 +274,7 @@ class Part(proto.Message): class Parameter(proto.Message): r"""Represents intent parameters. + Attributes: name (str): The unique identifier of this parameter. @@ -320,6 +323,7 @@ class Parameter(proto.Message): class Message(proto.Message): r"""Corresponds to the ``Response`` field in the Dialogflow console. + Attributes: text (google.cloud.dialogflow_v2beta1.types.Intent.Message.Text): Returns a text response. @@ -393,6 +397,7 @@ class Platform(proto.Enum): class Text(proto.Message): r"""The text response message. + Attributes: text (Sequence[str]): Optional. The collection of the agent's @@ -403,6 +408,7 @@ class Text(proto.Message): class Image(proto.Message): r"""The image response message. + Attributes: image_uri (str): Optional. The public URI to an image file. @@ -417,6 +423,7 @@ class Image(proto.Message): class QuickReplies(proto.Message): r"""The quick replies response message. + Attributes: title (str): Optional. The title of the collection of @@ -430,6 +437,7 @@ class QuickReplies(proto.Message): class Card(proto.Message): r"""The card response message. + Attributes: title (str): Optional. The title of the card. @@ -444,6 +452,7 @@ class Card(proto.Message): class Button(proto.Message): r"""Optional. Contains information about a button. + Attributes: text (str): Optional. The text to show on the button. @@ -464,6 +473,7 @@ class Button(proto.Message): class SimpleResponse(proto.Message): r"""The simple response message containing speech or text. + Attributes: text_to_speech (str): One of text_to_speech or ssml must be provided. The plain @@ -497,6 +507,7 @@ class SimpleResponses(proto.Message): class BasicCard(proto.Message): r"""The basic card message. Useful for displaying information. + Attributes: title (str): Optional. The title of the card. @@ -513,6 +524,7 @@ class BasicCard(proto.Message): class Button(proto.Message): r"""The button object that appears at the bottom of a card. + Attributes: title (str): Required. The title of the button. @@ -523,6 +535,7 @@ class Button(proto.Message): class OpenUriAction(proto.Message): r"""Opens the given URI. + Attributes: uri (str): Required. The HTTP or HTTPS scheme URI. @@ -561,6 +574,7 @@ class Suggestion(proto.Message): class Suggestions(proto.Message): r"""The collection of suggestions. + Attributes: suggestions (Sequence[google.cloud.dialogflow_v2beta1.types.Intent.Message.Suggestion]): Required. The list of suggested replies. @@ -588,6 +602,7 @@ class LinkOutSuggestion(proto.Message): class ListSelect(proto.Message): r"""The card for presenting a list of options to select from. + Attributes: title (str): Optional. The overall title of the list. @@ -599,6 +614,7 @@ class ListSelect(proto.Message): class Item(proto.Message): r"""An item in the list. + Attributes: info (google.cloud.dialogflow_v2beta1.types.Intent.Message.SelectItemInfo): Required. Additional information about this @@ -628,6 +644,7 @@ class Item(proto.Message): class CarouselSelect(proto.Message): r"""The card for presenting a carousel of options to select from. + Attributes: items (Sequence[google.cloud.dialogflow_v2beta1.types.Intent.Message.CarouselSelect.Item]): Required. Carousel items. @@ -635,6 +652,7 @@ class CarouselSelect(proto.Message): class Item(proto.Message): r"""An item in the carousel. + Attributes: info (google.cloud.dialogflow_v2beta1.types.Intent.Message.SelectItemInfo): Required. Additional info about the option @@ -678,6 +696,7 @@ class SelectItemInfo(proto.Message): class TelephonyPlayAudio(proto.Message): r"""Plays audio from a file in Telephony Gateway. + Attributes: audio_uri (str): Required. URI to a Google Cloud Storage object containing @@ -721,6 +740,7 @@ class TelephonySynthesizeSpeech(proto.Message): class TelephonyTransferCall(proto.Message): r"""Transfers the call in Telephony Gateway. + Attributes: phone_number (str): Required. The phone number to transfer the call to in `E.164 @@ -734,6 +754,7 @@ class TelephonyTransferCall(proto.Message): class RbmText(proto.Message): r"""Rich Business Messaging (RBM) text response with suggestions. + Attributes: text (str): Required. Text sent and displayed to the @@ -833,6 +854,7 @@ class ThumbnailImageAlignment(proto.Enum): class RbmCardContent(proto.Message): r"""Rich Business Messaging (RBM) Card content + Attributes: title (str): Optional. Title of the card (at most 200 @@ -1023,7 +1045,8 @@ class RbmSuggestedActionOpenUri(proto.Message): class RbmSuggestedActionShareLocation(proto.Message): r"""Opens the device's location chooser so the user can pick a location to send back to the agent. - """ + + """ text = proto.Field(proto.STRING, number=1,) postback_data = proto.Field(proto.STRING, number=2,) @@ -1048,6 +1071,7 @@ class RbmSuggestedActionShareLocation(proto.Message): class MediaContent(proto.Message): r"""The media content card for Actions on Google. + Attributes: media_type (google.cloud.dialogflow_v2beta1.types.Intent.Message.MediaContent.ResponseMediaType): Optional. What type of media is the content @@ -1063,6 +1087,7 @@ class ResponseMediaType(proto.Enum): class ResponseMediaObject(proto.Message): r"""Response media object for media content card. + Attributes: name (str): Required. Name of media card. @@ -1133,6 +1158,7 @@ class ImageDisplayOptions(proto.Enum): class BrowseCarouselCardItem(proto.Message): r"""Browsing carousel tile + Attributes: open_uri_action (google.cloud.dialogflow_v2beta1.types.Intent.Message.BrowseCarouselCard.BrowseCarouselCardItem.OpenUrlAction): Required. Action to present to the user. @@ -1152,6 +1178,7 @@ class BrowseCarouselCardItem(proto.Message): class OpenUrlAction(proto.Message): r"""Actions on Google action to open a given url. + Attributes: url (str): Required. URL @@ -1199,6 +1226,7 @@ class UrlTypeHint(proto.Enum): class TableCard(proto.Message): r"""Table card for Actions on Google. + Attributes: title (str): Required. Title of the card. @@ -1395,6 +1423,7 @@ class TableCardCell(proto.Message): class FollowupIntentInfo(proto.Message): r"""Represents a single followup intent in the chain. + Attributes: followup_intent_name (str): The unique identifier of the followup intent. Format: @@ -1686,6 +1715,7 @@ class BatchDeleteIntentsRequest(proto.Message): class IntentBatch(proto.Message): r"""This message is a wrapper around a collection of intents. + Attributes: intents (Sequence[google.cloud.dialogflow_v2beta1.types.Intent]): A collection of intents. diff --git a/google/cloud/dialogflow_v2beta1/types/participant.py b/google/cloud/dialogflow_v2beta1/types/participant.py index 0f3e087b5..05ff2cf9b 100644 --- a/google/cloud/dialogflow_v2beta1/types/participant.py +++ b/google/cloud/dialogflow_v2beta1/types/participant.py @@ -127,6 +127,7 @@ class Role(proto.Enum): class Message(proto.Message): r"""Represents a message posted into a conversation. + Attributes: name (str): Optional. The unique identifier of the message. Format: @@ -281,6 +282,7 @@ class OutputAudio(proto.Message): class AutomatedAgentReply(proto.Message): r"""Represents a response from an automated agent. + Attributes: detect_intent_response (google.cloud.dialogflow_v2beta1.types.DetectIntentResponse): Response of the Dialogflow @@ -548,6 +550,7 @@ class AnnotatedMessagePart(proto.Message): class MessageAnnotation(proto.Message): r"""Represents the result of annotation for the message. + Attributes: parts (Sequence[google.cloud.dialogflow_v2beta1.types.AnnotatedMessagePart]): Optional. The collection of annotated message parts ordered @@ -567,6 +570,7 @@ class MessageAnnotation(proto.Message): class ArticleAnswer(proto.Message): r"""Represents article answer. + Attributes: title (str): The article title. @@ -592,6 +596,7 @@ class ArticleAnswer(proto.Message): class FaqAnswer(proto.Message): r"""Represents answer from "frequently asked questions". + Attributes: answer (str): The piece of text from the ``source`` knowledge base @@ -626,6 +631,7 @@ class FaqAnswer(proto.Message): class SmartReplyAnswer(proto.Message): r"""Represents a smart reply answer. + Attributes: reply (str): The content of the reply. @@ -874,6 +880,7 @@ class SuggestSmartRepliesResponse(proto.Message): class Suggestion(proto.Message): r"""Represents a suggestion for a human agent. + Attributes: name (str): Output only. The name of this suggestion. Format: @@ -897,6 +904,7 @@ class Suggestion(proto.Message): class Article(proto.Message): r"""Represents suggested article. + Attributes: title (str): Output only. The article title. @@ -1079,6 +1087,7 @@ class CompileSuggestionResponse(proto.Message): class ResponseMessage(proto.Message): r"""Response messages from an automated agent. + Attributes: text (google.cloud.dialogflow_v2beta1.types.ResponseMessage.Text): Returns a text response. @@ -1098,6 +1107,7 @@ class ResponseMessage(proto.Message): class Text(proto.Message): r"""The text response message. + Attributes: text (Sequence[str]): A collection of text responses. @@ -1131,7 +1141,8 @@ class LiveAgentHandoff(proto.Message): class EndInteraction(proto.Message): r"""Indicates that interaction with the Dialogflow agent has ended. - """ + + """ class TelephonyTransferCall(proto.Message): r"""Represents the signal that telles the client to transfer the diff --git a/google/cloud/dialogflow_v2beta1/types/session.py b/google/cloud/dialogflow_v2beta1/types/session.py index e84afb1e0..4f915db4b 100644 --- a/google/cloud/dialogflow_v2beta1/types/session.py +++ b/google/cloud/dialogflow_v2beta1/types/session.py @@ -50,6 +50,7 @@ class DetectIntentRequest(proto.Message): r"""The request to detect user's intent. + Attributes: session (str): Required. The name of the session this query is sent to. @@ -123,6 +124,7 @@ class DetectIntentRequest(proto.Message): class DetectIntentResponse(proto.Message): r"""The message returned from the DetectIntent method. + Attributes: response_id (str): The unique identifier of the response. It can @@ -175,6 +177,7 @@ class DetectIntentResponse(proto.Message): class QueryParameters(proto.Message): r"""Represents the parameters of the conversational query. + Attributes: time_zone (str): The time zone of this conversational query from the `time @@ -440,6 +443,7 @@ class QueryResult(proto.Message): class KnowledgeAnswers(proto.Message): r"""Represents the result of querying a Knowledge base. + Attributes: answers (Sequence[google.cloud.dialogflow_v2beta1.types.KnowledgeAnswers.Answer]): A list of answers from Knowledge Connector. @@ -447,6 +451,7 @@ class KnowledgeAnswers(proto.Message): class Answer(proto.Message): r"""An answer from Knowledge Connector. + Attributes: source (str): Indicates which Knowledge Document this answer was extracted @@ -806,6 +811,7 @@ class MessageType(proto.Enum): class TextInput(proto.Message): r"""Represents the natural language text to be processed. + Attributes: text (str): Required. The UTF-8 encoded natural language @@ -870,6 +876,7 @@ class EventInput(proto.Message): class SentimentAnalysisRequestConfig(proto.Message): r"""Configures the types of sentiment analysis to perform. + Attributes: analyze_query_text_sentiment (bool): Instructs the service to perform sentiment analysis on diff --git a/google/cloud/dialogflow_v2beta1/types/validation_result.py b/google/cloud/dialogflow_v2beta1/types/validation_result.py index 292857fc7..05c1cd38e 100644 --- a/google/cloud/dialogflow_v2beta1/types/validation_result.py +++ b/google/cloud/dialogflow_v2beta1/types/validation_result.py @@ -24,6 +24,7 @@ class ValidationError(proto.Message): r"""Represents a single validation error. + Attributes: severity (google.cloud.dialogflow_v2beta1.types.ValidationError.Severity): The severity of the error. @@ -66,6 +67,7 @@ class Severity(proto.Enum): class ValidationResult(proto.Message): r"""Represents the output of agent validation. + Attributes: validation_errors (Sequence[google.cloud.dialogflow_v2beta1.types.ValidationError]): Contains all validation errors. diff --git a/google/cloud/dialogflow_v2beta1/types/webhook.py b/google/cloud/dialogflow_v2beta1/types/webhook.py index cc7911ca4..b494938f2 100644 --- a/google/cloud/dialogflow_v2beta1/types/webhook.py +++ b/google/cloud/dialogflow_v2beta1/types/webhook.py @@ -30,6 +30,7 @@ class WebhookRequest(proto.Message): r"""The request message for a webhook call. + Attributes: session (str): The unique identifier of detectIntent request session. Can diff --git a/tests/unit/gapic/dialogflow_v2/test_agents.py b/tests/unit/gapic/dialogflow_v2/test_agents.py index fa1c841dd..3ee58070e 100644 --- a/tests/unit/gapic/dialogflow_v2/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2/test_agents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.agents import AgentsAsyncClient @@ -2330,6 +2331,9 @@ def test_agents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2841,3 +2845,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AgentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AgentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AgentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_answer_records.py b/tests/unit/gapic/dialogflow_v2/test_answer_records.py index 18afa50dd..45e45f6af 100644 --- a/tests/unit/gapic/dialogflow_v2/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2/test_answer_records.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.answer_records import AnswerRecordsAsyncClient @@ -1232,6 +1233,9 @@ def test_answer_records_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_answer_records_base_transport_with_credentials_file(): @@ -1731,3 +1735,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AnswerRecordsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_contexts.py b/tests/unit/gapic/dialogflow_v2/test_contexts.py index ce304f252..dbe31e5c0 100644 --- a/tests/unit/gapic/dialogflow_v2/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2/test_contexts.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.contexts import ContextsAsyncClient @@ -1889,6 +1890,9 @@ def test_contexts_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_contexts_base_transport_with_credentials_file(): @@ -2375,3 +2379,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ContextsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ContextsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ContextsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py index f44a0dcdc..a71f91d10 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.conversation_profiles import ( @@ -2034,6 +2035,9 @@ def test_conversation_profiles_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_conversation_profiles_base_transport_with_credentials_file(): @@ -2629,3 +2633,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ConversationProfilesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ConversationProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ConversationProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_conversations.py b/tests/unit/gapic/dialogflow_v2/test_conversations.py index 7ad642f4a..3b3e1d7b4 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversations.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.conversations import ConversationsAsyncClient @@ -2060,6 +2061,9 @@ def test_conversations_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_conversations_base_transport_with_credentials_file(): @@ -2607,3 +2611,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_documents.py b/tests/unit/gapic/dialogflow_v2/test_documents.py index 4c9f30aef..909e21f43 100644 --- a/tests/unit/gapic/dialogflow_v2/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2/test_documents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.documents import DocumentsAsyncClient @@ -1952,6 +1953,9 @@ def test_documents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2469,3 +2473,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = DocumentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = DocumentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = DocumentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_entity_types.py index 67e11ff5a..555f967fe 100644 --- a/tests/unit/gapic/dialogflow_v2/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_entity_types.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.entity_types import EntityTypesAsyncClient @@ -2955,6 +2956,9 @@ def test_entity_types_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -3470,3 +3474,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = EntityTypesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_environments.py b/tests/unit/gapic/dialogflow_v2/test_environments.py index 6965f6afa..739974e60 100644 --- a/tests/unit/gapic/dialogflow_v2/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2/test_environments.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.environments import EnvironmentsAsyncClient @@ -1878,6 +1879,9 @@ def test_environments_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_environments_base_transport_with_credentials_file(): @@ -2408,3 +2412,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = EnvironmentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2/test_fulfillments.py index 7d333c9b3..b402a42f4 100644 --- a/tests/unit/gapic/dialogflow_v2/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2/test_fulfillments.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.fulfillments import FulfillmentsAsyncClient @@ -1035,6 +1036,9 @@ def test_fulfillments_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_fulfillments_base_transport_with_credentials_file(): @@ -1521,3 +1525,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = FulfillmentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = FulfillmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = FulfillmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_intents.py b/tests/unit/gapic/dialogflow_v2/test_intents.py index c0859159e..62599ff86 100644 --- a/tests/unit/gapic/dialogflow_v2/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2/test_intents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.intents import IntentsAsyncClient @@ -2358,6 +2359,9 @@ def test_intents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2897,3 +2901,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = IntentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = IntentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = IntentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py index 37f0fb813..9902723a3 100644 --- a/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.knowledge_bases import ( @@ -1929,6 +1930,9 @@ def test_knowledge_bases_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_knowledge_bases_base_transport_with_credentials_file(): @@ -2430,3 +2434,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = KnowledgeBasesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_participants.py b/tests/unit/gapic/dialogflow_v2/test_participants.py index 423abaadc..deec9085a 100644 --- a/tests/unit/gapic/dialogflow_v2/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2/test_participants.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.participants import ParticipantsAsyncClient @@ -2281,6 +2282,9 @@ def test_participants_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_participants_base_transport_with_credentials_file(): @@ -2867,3 +2871,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ParticipantsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py index 99853d150..a4099f8e9 100644 --- a/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.session_entity_types import ( @@ -2013,6 +2014,9 @@ def test_session_entity_types_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_session_entity_types_base_transport_with_credentials_file(): @@ -2520,3 +2524,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SessionEntityTypesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_sessions.py b/tests/unit/gapic/dialogflow_v2/test_sessions.py index 16d28e830..4cc063739 100644 --- a/tests/unit/gapic/dialogflow_v2/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2/test_sessions.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.sessions import SessionsAsyncClient @@ -885,6 +886,9 @@ def test_sessions_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_sessions_base_transport_with_credentials_file(): @@ -1439,3 +1443,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SessionsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SessionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = SessionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2/test_versions.py b/tests/unit/gapic/dialogflow_v2/test_versions.py index c385b4980..4a4bdc7fc 100644 --- a/tests/unit/gapic/dialogflow_v2/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2/test_versions.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2.services.versions import VersionsAsyncClient @@ -1728,6 +1729,9 @@ def test_versions_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_versions_base_transport_with_credentials_file(): @@ -2212,3 +2216,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = VersionsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_agents.py b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py index 499c1a598..802b41e69 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.agents import AgentsAsyncClient @@ -2330,6 +2331,9 @@ def test_agents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2841,3 +2845,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AgentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AgentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AgentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py index 08d54de6e..4752acac8 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.answer_records import ( @@ -1384,6 +1385,9 @@ def test_answer_records_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_answer_records_base_transport_with_credentials_file(): @@ -1883,3 +1887,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AnswerRecordsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py index 36be09c2e..759d26a91 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.contexts import ContextsAsyncClient @@ -1889,6 +1890,9 @@ def test_contexts_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_contexts_base_transport_with_credentials_file(): @@ -2375,3 +2379,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ContextsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ContextsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ContextsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py index 8ba444c94..b77252a19 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.conversation_profiles import ( @@ -2059,6 +2060,9 @@ def test_conversation_profiles_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_conversation_profiles_base_transport_with_credentials_file(): @@ -2680,3 +2684,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ConversationProfilesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ConversationProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ConversationProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py index 7ffc811ee..b8f4e880a 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.conversations import ( @@ -2280,6 +2281,9 @@ def test_conversations_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_conversations_base_transport_with_credentials_file(): @@ -2827,3 +2831,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_documents.py b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py index ebf7c46b6..35eed57bf 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.documents import DocumentsAsyncClient @@ -2084,6 +2085,9 @@ def test_documents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2601,3 +2605,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = DocumentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = DocumentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = DocumentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py index 668c37cc5..2f31db3e3 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.entity_types import EntityTypesAsyncClient @@ -2961,6 +2962,9 @@ def test_entity_types_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -3476,3 +3480,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = EntityTypesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_environments.py b/tests/unit/gapic/dialogflow_v2beta1/test_environments.py index 5014e4a71..41e373b8a 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_environments.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.environments import ( @@ -1880,6 +1881,9 @@ def test_environments_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_environments_base_transport_with_credentials_file(): @@ -2410,3 +2414,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = EnvironmentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py index 623eb96df..21b26f833 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.fulfillments import ( @@ -1037,6 +1038,9 @@ def test_fulfillments_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_fulfillments_base_transport_with_credentials_file(): @@ -1523,3 +1527,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = FulfillmentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = FulfillmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = FulfillmentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_intents.py b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py index 423113bc7..f9e411908 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.intents import IntentsAsyncClient @@ -2370,6 +2371,9 @@ def test_intents_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -2909,3 +2913,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = IntentsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = IntentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = IntentsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py index b3df106bf..593d0e8b7 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.knowledge_bases import ( @@ -1931,6 +1932,9 @@ def test_knowledge_bases_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_knowledge_bases_base_transport_with_credentials_file(): @@ -2432,3 +2436,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = KnowledgeBasesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_participants.py b/tests/unit/gapic/dialogflow_v2beta1/test_participants.py index c3b2713b0..8a027f42c 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_participants.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.participants import ( @@ -2926,6 +2927,9 @@ def test_participants_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_participants_base_transport_with_credentials_file(): @@ -3536,3 +3540,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ParticipantsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py index cf07bef1c..33f0c8228 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.session_entity_types import ( @@ -2013,6 +2014,9 @@ def test_session_entity_types_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_session_entity_types_base_transport_with_credentials_file(): @@ -2520,3 +2524,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SessionEntityTypesAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py index 1869b3547..f002b0020 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.sessions import SessionsAsyncClient @@ -886,6 +887,9 @@ def test_sessions_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_sessions_base_transport_with_credentials_file(): @@ -1464,3 +1468,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SessionsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SessionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = SessionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_versions.py b/tests/unit/gapic/dialogflow_v2beta1/test_versions.py index bf5314ce9..66c0dbfc9 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_versions.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 path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.dialogflow_v2beta1.services.versions import VersionsAsyncClient @@ -1728,6 +1729,9 @@ def test_versions_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_versions_base_transport_with_credentials_file(): @@ -2212,3 +2216,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = VersionsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called()