Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
feat: add context manager support in client (#202)
Browse files Browse the repository at this point in the history
- [ ] 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[bot] committed Oct 8, 2021
1 parent a0cc28d commit 2b0a6de
Show file tree
Hide file tree
Showing 58 changed files with 741 additions and 32 deletions.
Expand Up @@ -822,6 +822,12 @@ async def preview_update_game_server_cluster(
# 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(
Expand Down
Expand Up @@ -356,10 +356,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_game_server_clusters(
Expand Down Expand Up @@ -1000,6 +997,19 @@ def preview_update_game_server_cluster(
# 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(
Expand Down
Expand Up @@ -243,6 +243,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."""
Expand Down
Expand Up @@ -484,5 +484,8 @@ def preview_update_game_server_cluster(
)
return self._stubs["preview_update_game_server_cluster"]

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


__all__ = ("GameServerClustersServiceGrpcTransport",)
Expand Up @@ -492,5 +492,8 @@ def preview_update_game_server_cluster(
)
return self._stubs["preview_update_game_server_cluster"]

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


__all__ = ("GameServerClustersServiceGrpcAsyncIOTransport",)
Expand Up @@ -539,6 +539,12 @@ async def delete_game_server_config(
# 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(
Expand Down
Expand Up @@ -355,10 +355,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_game_server_configs(
Expand Down Expand Up @@ -709,6 +706,19 @@ def delete_game_server_config(
# 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(
Expand Down
Expand Up @@ -196,6 +196,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."""
Expand Down
Expand Up @@ -364,5 +364,8 @@ def delete_game_server_config(
)
return self._stubs["delete_game_server_config"]

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


__all__ = ("GameServerConfigsServiceGrpcTransport",)
Expand Up @@ -371,5 +371,8 @@ def delete_game_server_config(
)
return self._stubs["delete_game_server_config"]

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


__all__ = ("GameServerConfigsServiceGrpcAsyncIOTransport",)
Expand Up @@ -951,6 +951,12 @@ async def fetch_deployment_state(
# 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(
Expand Down
Expand Up @@ -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 list_game_server_deployments(
Expand Down Expand Up @@ -1158,6 +1155,19 @@ def fetch_deployment_state(
# 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(
Expand Down
Expand Up @@ -248,6 +248,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."""
Expand Down
Expand Up @@ -531,5 +531,8 @@ def fetch_deployment_state(
)
return self._stubs["fetch_deployment_state"]

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


__all__ = ("GameServerDeploymentsServiceGrpcTransport",)
Expand Up @@ -538,5 +538,8 @@ def fetch_deployment_state(
)
return self._stubs["fetch_deployment_state"]

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


__all__ = ("GameServerDeploymentsServiceGrpcAsyncIOTransport",)
Expand Up @@ -687,6 +687,12 @@ async def preview_realm_update(
# 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(
Expand Down
18 changes: 14 additions & 4 deletions google/cloud/gaming_v1/services/realms_service/client.py
Expand Up @@ -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_realms(
Expand Down Expand Up @@ -848,6 +845,19 @@ def preview_realm_update(
# 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(
Expand Down
Expand Up @@ -209,6 +209,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."""
Expand Down
Expand Up @@ -399,5 +399,8 @@ def preview_realm_update(
)
return self._stubs["preview_realm_update"]

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


__all__ = ("RealmsServiceGrpcTransport",)
Expand Up @@ -404,5 +404,8 @@ def preview_realm_update(
)
return self._stubs["preview_realm_update"]

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


__all__ = ("RealmsServiceGrpcAsyncIOTransport",)

0 comments on commit 2b0a6de

Please sign in to comment.