Skip to content
Permalink
Browse files
feat: add context manager support in client (#101)
- [ ] Regenerate this pull request now.

chore: fix docstring for first attribute of protos

committer: @busunkim96
PiperOrigin-RevId: 401271153

Source-Link: googleapis/googleapis@787f8c9

Source-Link: googleapis/googleapis-gen@81decff
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9
  • Loading branch information
gcf-owl-bot committed Oct 7, 2021
1 parent 78cb94d commit 3e68d78e6f0c5d2e65f148935446baa92b5dd8ef
Showing with 569 additions and 32 deletions.
  1. +6 −0 google/cloud/retail_v2/services/catalog_service/async_client.py
  2. +14 −4 google/cloud/retail_v2/services/catalog_service/client.py
  3. +9 −0 google/cloud/retail_v2/services/catalog_service/transports/base.py
  4. +3 −0 google/cloud/retail_v2/services/catalog_service/transports/grpc.py
  5. +3 −0 google/cloud/retail_v2/services/catalog_service/transports/grpc_asyncio.py
  6. +6 −0 google/cloud/retail_v2/services/completion_service/async_client.py
  7. +14 −4 google/cloud/retail_v2/services/completion_service/client.py
  8. +9 −0 google/cloud/retail_v2/services/completion_service/transports/base.py
  9. +3 −0 google/cloud/retail_v2/services/completion_service/transports/grpc.py
  10. +3 −0 google/cloud/retail_v2/services/completion_service/transports/grpc_asyncio.py
  11. +6 −0 google/cloud/retail_v2/services/prediction_service/async_client.py
  12. +14 −4 google/cloud/retail_v2/services/prediction_service/client.py
  13. +9 −0 google/cloud/retail_v2/services/prediction_service/transports/base.py
  14. +3 −0 google/cloud/retail_v2/services/prediction_service/transports/grpc.py
  15. +3 −0 google/cloud/retail_v2/services/prediction_service/transports/grpc_asyncio.py
  16. +6 −0 google/cloud/retail_v2/services/product_service/async_client.py
  17. +14 −4 google/cloud/retail_v2/services/product_service/client.py
  18. +9 −0 google/cloud/retail_v2/services/product_service/transports/base.py
  19. +3 −0 google/cloud/retail_v2/services/product_service/transports/grpc.py
  20. +3 −0 google/cloud/retail_v2/services/product_service/transports/grpc_asyncio.py
  21. +6 −0 google/cloud/retail_v2/services/search_service/async_client.py
  22. +14 −4 google/cloud/retail_v2/services/search_service/client.py
  23. +9 −0 google/cloud/retail_v2/services/search_service/transports/base.py
  24. +3 −0 google/cloud/retail_v2/services/search_service/transports/grpc.py
  25. +3 −0 google/cloud/retail_v2/services/search_service/transports/grpc_asyncio.py
  26. +6 −0 google/cloud/retail_v2/services/user_event_service/async_client.py
  27. +14 −4 google/cloud/retail_v2/services/user_event_service/client.py
  28. +9 −0 google/cloud/retail_v2/services/user_event_service/transports/base.py
  29. +3 −0 google/cloud/retail_v2/services/user_event_service/transports/grpc.py
  30. +3 −0 google/cloud/retail_v2/services/user_event_service/transports/grpc_asyncio.py
  31. +1 −0 google/cloud/retail_v2/types/catalog.py
  32. +1 −0 google/cloud/retail_v2/types/catalog_service.py
  33. +5 −0 google/cloud/retail_v2/types/common.py
  34. +4 −0 google/cloud/retail_v2/types/completion_service.py
  35. +8 −0 google/cloud/retail_v2/types/import_config.py
  36. +2 −0 google/cloud/retail_v2/types/prediction_service.py
  37. +19 −6 google/cloud/retail_v2/types/product_service.py
  38. +3 −1 google/cloud/retail_v2/types/purge_config.py
  39. +8 −0 google/cloud/retail_v2/types/search_service.py
  40. +2 −0 google/cloud/retail_v2/types/user_event.py
  41. +6 −1 google/cloud/retail_v2/types/user_event_service.py
  42. +50 −0 tests/unit/gapic/retail_v2/test_catalog_service.py
  43. +50 −0 tests/unit/gapic/retail_v2/test_completion_service.py
  44. +50 −0 tests/unit/gapic/retail_v2/test_prediction_service.py
  45. +50 −0 tests/unit/gapic/retail_v2/test_product_service.py
  46. +50 −0 tests/unit/gapic/retail_v2/test_search_service.py
  47. +50 −0 tests/unit/gapic/retail_v2/test_user_event_service.py
@@ -529,6 +529,12 @@ async def get_default_branch(
# 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(
@@ -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_catalogs(
@@ -732,6 +729,19 @@ def get_default_branch(
# 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(
@@ -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_catalogs(
self,
@@ -383,5 +383,8 @@ def get_default_branch(
)
return self._stubs["get_default_branch"]

def close(self):
self.grpc_channel.close()


__all__ = ("CatalogServiceGrpcTransport",)
@@ -391,5 +391,8 @@ def get_default_branch(
)
return self._stubs["get_default_branch"]

def close(self):
return self.grpc_channel.close()


__all__ = ("CatalogServiceGrpcAsyncIOTransport",)
@@ -291,6 +291,12 @@ async def import_completion_data(
# 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(
@@ -354,10 +354,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 complete_query(
@@ -484,6 +481,19 @@ def import_completion_data(
# 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(
@@ -165,6 +165,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."""
@@ -318,5 +318,8 @@ def import_completion_data(
)
return self._stubs["import_completion_data"]

def close(self):
self.grpc_channel.close()


__all__ = ("CompletionServiceGrpcTransport",)
@@ -323,5 +323,8 @@ def import_completion_data(
)
return self._stubs["import_completion_data"]

def close(self):
return self.grpc_channel.close()


__all__ = ("CompletionServiceGrpcAsyncIOTransport",)
@@ -208,6 +208,12 @@ async def predict(
# 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(
@@ -351,10 +351,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 predict(
@@ -406,6 +403,19 @@ def predict(
# 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(
@@ -157,6 +157,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 predict(
self,
@@ -253,5 +253,8 @@ def predict(
)
return self._stubs["predict"]

def close(self):
self.grpc_channel.close()


__all__ = ("PredictionServiceGrpcTransport",)
@@ -257,5 +257,8 @@ def predict(
)
return self._stubs["predict"]

def close(self):
return self.grpc_channel.close()


__all__ = ("PredictionServiceGrpcAsyncIOTransport",)
@@ -1115,6 +1115,12 @@ async def remove_fulfillment_places(
# 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(
@@ -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_product(
@@ -1317,6 +1314,19 @@ def remove_fulfillment_places(
# 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(
@@ -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."""
@@ -575,5 +575,8 @@ def remove_fulfillment_places(
)
return self._stubs["remove_fulfillment_places"]

def close(self):
self.grpc_channel.close()


__all__ = ("ProductServiceGrpcTransport",)
@@ -591,5 +591,8 @@ def remove_fulfillment_places(
)
return self._stubs["remove_fulfillment_places"]

def close(self):
return self.grpc_channel.close()


__all__ = ("ProductServiceGrpcAsyncIOTransport",)
@@ -236,6 +236,12 @@ async def search(
# 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(
@@ -370,10 +370,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 search(
@@ -444,6 +441,19 @@ def search(
# 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(
@@ -157,6 +157,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 search(
self,
@@ -261,5 +261,8 @@ def search(
)
return self._stubs["search"]

def close(self):
self.grpc_channel.close()


__all__ = ("SearchServiceGrpcTransport",)
@@ -266,5 +266,8 @@ def search(
)
return self._stubs["search"]

def close(self):
return self.grpc_channel.close()


__all__ = ("SearchServiceGrpcAsyncIOTransport",)
Loading

0 comments on commit 3e68d78

Please sign in to comment.