Skip to content

Commit

Permalink
feat: add context manager support in client (#187)
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] authored Oct 8, 2021
1 parent 6d0468d commit a77ff6f
Show file tree
Hide file tree
Showing 216 changed files with 2,696 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,12 @@ async def get_agent_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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,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_agents(
Expand Down Expand Up @@ -1151,6 +1148,19 @@ def get_agent_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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 operations_client(self) -> operations_v1.OperationsClient:
"""Return the client designed to process long-running operations."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,5 +515,8 @@ def get_agent_validation_result(
)
return self._stubs["get_agent_validation_result"]

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


__all__ = ("AgentsGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -524,5 +524,8 @@ def get_agent_validation_result(
)
return self._stubs["get_agent_validation_result"]

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


__all__ = ("AgentsGrpcAsyncIOTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ async def get_deployment(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,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_deployments(
Expand Down Expand Up @@ -581,6 +578,19 @@ def get_deployment(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -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 list_deployments(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,8 @@ def get_deployment(
)
return self._stubs["get_deployment"]

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


__all__ = ("DeploymentsGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,8 @@ def get_deployment(
)
return self._stubs["get_deployment"]

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


__all__ = ("DeploymentsGrpcAsyncIOTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ async def delete_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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -839,6 +836,19 @@ def delete_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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_entity_types(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,8 @@ def delete_entity_type(
)
return self._stubs["delete_entity_type"]

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


__all__ = ("EntityTypesGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -385,5 +385,8 @@ def delete_entity_type(
)
return self._stubs["delete_entity_type"]

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


__all__ = ("EntityTypesGrpcAsyncIOTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,12 @@ async def deploy_flow(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,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(
Expand Down Expand Up @@ -1219,6 +1216,19 @@ def deploy_flow(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,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
Original file line number Diff line number Diff line change
Expand Up @@ -541,5 +541,8 @@ def deploy_flow(
)
return self._stubs["deploy_flow"]

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


__all__ = ("EnvironmentsGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,8 @@ def deploy_flow(
)
return self._stubs["deploy_flow"]

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


__all__ = ("EnvironmentsGrpcAsyncIOTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,12 @@ async def stop_experiment(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,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_experiments(
Expand Down Expand Up @@ -918,6 +915,19 @@ def stop_experiment(
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -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 list_experiments(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,8 @@ def stop_experiment(
)
return self._stubs["stop_experiment"]

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


__all__ = ("ExperimentsGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,8 @@ def stop_experiment(
)
return self._stubs["stop_experiment"]

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


__all__ = ("ExperimentsGrpcAsyncIOTransport",)
Loading

0 comments on commit a77ff6f

Please sign in to comment.