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

Commit

Permalink
feat: add context manager support in client (#32)
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 7, 2021
1 parent f61e81b commit e88a664
Show file tree
Hide file tree
Showing 28 changed files with 347 additions and 18 deletions.
Expand Up @@ -759,6 +759,12 @@ async def delete_environment(
# 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 @@ -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 create_environment(
Expand Down Expand Up @@ -950,6 +947,19 @@ def delete_environment(
# 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 @@ -173,6 +173,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 @@ -374,5 +374,8 @@ def delete_environment(
)
return self._stubs["delete_environment"]

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


__all__ = ("EnvironmentsGrpcTransport",)
Expand Up @@ -388,5 +388,8 @@ def delete_environment(
)
return self._stubs["delete_environment"]

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


__all__ = ("EnvironmentsGrpcAsyncIOTransport",)
Expand Up @@ -240,6 +240,12 @@ async def list_image_versions(
# 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 @@ -326,10 +326,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_image_versions(
Expand Down Expand Up @@ -413,6 +410,19 @@ def list_image_versions(
# 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 @@ -159,6 +159,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_image_versions(
self,
Expand Down
Expand Up @@ -254,5 +254,8 @@ def list_image_versions(
)
return self._stubs["list_image_versions"]

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


__all__ = ("ImageVersionsGrpcTransport",)
Expand Up @@ -257,5 +257,8 @@ def list_image_versions(
)
return self._stubs["list_image_versions"]

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


__all__ = ("ImageVersionsGrpcAsyncIOTransport",)
Expand Up @@ -380,6 +380,7 @@ class WebServerNetworkAccessControl(proto.Message):

class AllowedIpRange(proto.Message):
r"""Allowed IP range with user-provided description.
Attributes:
value (str):
IP address or range, defined using CIDR notation, of
Expand Down
Expand Up @@ -71,7 +71,7 @@ def raw_page(self):


class ImageVersion(proto.Message):
r"""ImageVersion informatio.
r"""ImageVersion information
Attributes:
image_version_id (str):
Expand Down
Expand Up @@ -904,6 +904,12 @@ async def check_upgrade(
# 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 @@ -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 create_environment(
Expand Down Expand Up @@ -1097,6 +1094,19 @@ def check_upgrade(
# 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 @@ -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 operations_client(self) -> operations_v1.OperationsClient:
"""Return the client designed to process long-running operations."""
Expand Down
Expand Up @@ -429,5 +429,8 @@ def check_upgrade(
)
return self._stubs["check_upgrade"]

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


__all__ = ("EnvironmentsGrpcTransport",)
Expand Up @@ -447,5 +447,8 @@ def check_upgrade(
)
return self._stubs["check_upgrade"]

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


__all__ = ("EnvironmentsGrpcAsyncIOTransport",)
Expand Up @@ -242,6 +242,12 @@ async def list_image_versions(
# 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 @@ -328,10 +328,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_image_versions(
Expand Down Expand Up @@ -415,6 +412,19 @@ def list_image_versions(
# 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 @@ -159,6 +159,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_image_versions(
self,
Expand Down
Expand Up @@ -254,5 +254,8 @@ def list_image_versions(
)
return self._stubs["list_image_versions"]

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


__all__ = ("ImageVersionsGrpcTransport",)
Expand Up @@ -257,5 +257,8 @@ def list_image_versions(
)
return self._stubs["list_image_versions"]

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


__all__ = ("ImageVersionsGrpcAsyncIOTransport",)
Expand Up @@ -462,6 +462,7 @@ class WebServerNetworkAccessControl(proto.Message):

class AllowedIpRange(proto.Message):
r"""Allowed IP range with user-provided description.
Attributes:
value (str):
IP address or range, defined using CIDR notation, of
Expand Down Expand Up @@ -964,6 +965,7 @@ class WorkloadsConfig(proto.Message):

class SchedulerResource(proto.Message):
r"""Configuration for resources used by Airflow schedulers.
Attributes:
cpu (float):
Optional. CPU request and limit for a single
Expand All @@ -985,6 +987,7 @@ class SchedulerResource(proto.Message):

class WebServerResource(proto.Message):
r"""Configuration for resources used by Airflow web server.
Attributes:
cpu (float):
Optional. CPU request and limit for Airflow
Expand All @@ -1003,6 +1006,7 @@ class WebServerResource(proto.Message):

class WorkerResource(proto.Message):
r"""Configuration for resources used by Airflow workers.
Attributes:
cpu (float):
Optional. CPU request and limit for a single
Expand Down
Expand Up @@ -71,7 +71,7 @@ def raw_page(self):


class ImageVersion(proto.Message):
r"""Image Version informatio.
r"""Image Version information
Attributes:
image_version_id (str):
Expand Down

0 comments on commit e88a664

Please sign in to comment.