Skip to content
Permalink
Browse files
feat: add context manager support in client (#93)
- [ ] 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 ff106ef commit 5df0cf1696c5908faa079ae702d6da4c36bd3f72
Showing with 370 additions and 16 deletions.
  1. +6 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py
  2. +14 −4 google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py
  3. +9 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py
  4. +3 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py
  5. +3 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py
  6. +6 −0 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py
  7. +14 −4 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py
  8. +9 −0 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py
  9. +3 −0 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py
  10. +3 −0 ...loud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py
  11. +6 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py
  12. +14 −4 google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py
  13. +9 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py
  14. +3 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py
  15. +3 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py
  16. +6 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py
  17. +14 −4 google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py
  18. +9 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py
  19. +3 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py
  20. +3 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py
  21. +3 −0 google/cloud/recommendationengine_v1beta1/types/catalog.py
  22. +6 −0 google/cloud/recommendationengine_v1beta1/types/catalog_service.py
  23. +2 −0 google/cloud/recommendationengine_v1beta1/types/common.py
  24. +4 −0 google/cloud/recommendationengine_v1beta1/types/import_.py
  25. +4 −0 google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py
  26. +2 −0 google/cloud/recommendationengine_v1beta1/types/prediction_service.py
  27. +4 −0 google/cloud/recommendationengine_v1beta1/types/user_event.py
  28. +5 −0 google/cloud/recommendationengine_v1beta1/types/user_event_service.py
  29. +50 −0 tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py
  30. +50 −0 tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py
  31. +50 −0 tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py
  32. +50 −0 tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py
@@ -751,6 +751,12 @@ async def import_catalog_items(
# 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(
@@ -352,10 +352,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_catalog_item(
@@ -879,6 +876,19 @@ def import_catalog_items(
# 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(
@@ -251,6 +251,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."""
@@ -412,5 +412,8 @@ def import_catalog_items(
)
return self._stubs["import_catalog_items"]

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


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

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


__all__ = ("CatalogServiceGrpcAsyncIOTransport",)
@@ -445,6 +445,12 @@ async def delete_prediction_api_key_registration(
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(
@@ -387,10 +387,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_prediction_api_key_registration(
@@ -650,6 +647,19 @@ def delete_prediction_api_key_registration(
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(
@@ -204,6 +204,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_prediction_api_key_registration(
self,
@@ -330,5 +330,8 @@ def delete_prediction_api_key_registration(
)
return self._stubs["delete_prediction_api_key_registration"]

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


__all__ = ("PredictionApiKeyRegistryGrpcTransport",)
@@ -335,5 +335,8 @@ def delete_prediction_api_key_registration(
)
return self._stubs["delete_prediction_api_key_registration"]

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


__all__ = ("PredictionApiKeyRegistryGrpcAsyncIOTransport",)
@@ -304,6 +304,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(
@@ -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 predict(
@@ -491,6 +488,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(
@@ -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 predict(
self,
@@ -257,5 +257,8 @@ def predict(
)
return self._stubs["predict"]

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


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

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


__all__ = ("PredictionServiceGrpcAsyncIOTransport",)
@@ -837,6 +837,12 @@ async def import_user_events(
# 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(
@@ -359,10 +359,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 write_user_event(
@@ -981,6 +978,19 @@ def import_user_events(
# 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(
@@ -236,6 +236,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."""
@@ -397,5 +397,8 @@ def import_user_events(
)
return self._stubs["import_user_events"]

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


__all__ = ("UserEventServiceGrpcTransport",)
@@ -408,5 +408,8 @@ def import_user_events(
)
return self._stubs["import_user_events"]

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


__all__ = ("UserEventServiceGrpcAsyncIOTransport",)
@@ -92,6 +92,7 @@ class CatalogItem(proto.Message):

class CategoryHierarchy(proto.Message):
r"""Category represents catalog item category hierarchy.
Attributes:
categories (Sequence[str]):
Required. Catalog item categories. Each
@@ -172,6 +173,7 @@ class StockState(proto.Enum):

class ExactPrice(proto.Message):
r"""Exact product price.
Attributes:
display_price (float):
Optional. Display price of the product.
@@ -214,6 +216,7 @@ class PriceRange(proto.Message):

class Image(proto.Message):
r"""Catalog item thumbnail/detail image.
Attributes:
uri (str):
Required. URL of the image with a length
@@ -34,6 +34,7 @@

class CreateCatalogItemRequest(proto.Message):
r"""Request message for CreateCatalogItem method.
Attributes:
parent (str):
Required. The parent catalog resource name, such as
@@ -48,6 +49,7 @@ class CreateCatalogItemRequest(proto.Message):

class GetCatalogItemRequest(proto.Message):
r"""Request message for GetCatalogItem method.
Attributes:
name (str):
Required. Full resource name of catalog item, such as
@@ -59,6 +61,7 @@ class GetCatalogItemRequest(proto.Message):

class ListCatalogItemsRequest(proto.Message):
r"""Request message for ListCatalogItems method.
Attributes:
parent (str):
Required. The parent catalog resource name, such as
@@ -83,6 +86,7 @@ class ListCatalogItemsRequest(proto.Message):

class ListCatalogItemsResponse(proto.Message):
r"""Response message for ListCatalogItems method.
Attributes:
catalog_items (Sequence[google.cloud.recommendationengine_v1beta1.types.CatalogItem]):
The catalog items.
@@ -104,6 +108,7 @@ def raw_page(self):

class UpdateCatalogItemRequest(proto.Message):
r"""Request message for UpdateCatalogItem method.
Attributes:
name (str):
Required. Full resource name of catalog item, such as
@@ -126,6 +131,7 @@ class UpdateCatalogItemRequest(proto.Message):

class DeleteCatalogItemRequest(proto.Message):
r"""Request message for DeleteCatalogItem method.
Attributes:
name (str):
Required. Full resource name of catalog item, such as
Loading

0 comments on commit 5df0cf1

Please sign in to comment.