Skip to content

Commit

Permalink
feat: add context manager support in client (#314)
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 cea745c commit 95cd6ae
Show file tree
Hide file tree
Showing 40 changed files with 506 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,12 @@ async def analyze_move(
# 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 @@ -405,10 +405,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 export_assets(
Expand Down Expand Up @@ -1510,6 +1507,19 @@ def analyze_move(
# 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 @@ -291,6 +291,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 @@ -642,5 +642,8 @@ def analyze_move(
)
return self._stubs["analyze_move"]

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


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

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


__all__ = ("AssetServiceGrpcAsyncIOTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class AnalyzeIamPolicyLongrunningMetadata(proto.Message):

class ExportAssetsRequest(proto.Message):
r"""Export asset request.
Attributes:
parent (str):
Required. The relative name of the root
Expand Down Expand Up @@ -196,6 +197,7 @@ class ExportAssetsResponse(proto.Message):

class ListAssetsRequest(proto.Message):
r"""ListAssets request.
Attributes:
parent (str):
Required. Name of the organization or project the assets
Expand Down Expand Up @@ -278,6 +280,7 @@ class ListAssetsRequest(proto.Message):

class ListAssetsResponse(proto.Message):
r"""ListAssets response.
Attributes:
read_time (google.protobuf.timestamp_pb2.Timestamp):
Time the snapshot was taken.
Expand All @@ -301,6 +304,7 @@ def raw_page(self):

class BatchGetAssetsHistoryRequest(proto.Message):
r"""Batch get assets history request.
Attributes:
parent (str):
Required. The relative name of the root
Expand Down Expand Up @@ -358,6 +362,7 @@ class BatchGetAssetsHistoryRequest(proto.Message):

class BatchGetAssetsHistoryResponse(proto.Message):
r"""Batch get assets history response.
Attributes:
assets (Sequence[google.cloud.asset_v1.types.TemporalAsset]):
A list of assets with valid time windows.
Expand All @@ -370,6 +375,7 @@ class BatchGetAssetsHistoryResponse(proto.Message):

class CreateFeedRequest(proto.Message):
r"""Create asset feed request.
Attributes:
parent (str):
Required. The name of the
Expand Down Expand Up @@ -399,6 +405,7 @@ class CreateFeedRequest(proto.Message):

class GetFeedRequest(proto.Message):
r"""Get asset feed request.
Attributes:
name (str):
Required. The name of the Feed and it must be in the format
Expand All @@ -412,6 +419,7 @@ class GetFeedRequest(proto.Message):

class ListFeedsRequest(proto.Message):
r"""List asset feeds request.
Attributes:
parent (str):
Required. The parent
Expand All @@ -427,6 +435,7 @@ class ListFeedsRequest(proto.Message):

class ListFeedsResponse(proto.Message):
r"""
Attributes:
feeds (Sequence[google.cloud.asset_v1.types.Feed]):
A list of feeds.
Expand All @@ -437,6 +446,7 @@ class ListFeedsResponse(proto.Message):

class UpdateFeedRequest(proto.Message):
r"""Update asset feed request.
Attributes:
feed (google.cloud.asset_v1.types.Feed):
Required. The new values of feed details. It must match an
Expand All @@ -458,6 +468,7 @@ class UpdateFeedRequest(proto.Message):

class DeleteFeedRequest(proto.Message):
r"""
Attributes:
name (str):
Required. The name of the feed and it must be in the format
Expand All @@ -471,6 +482,7 @@ class DeleteFeedRequest(proto.Message):

class OutputConfig(proto.Message):
r"""Output configuration for export assets destination.
Attributes:
gcs_destination (google.cloud.asset_v1.types.GcsDestination):
Destination on Cloud Storage.
Expand All @@ -490,6 +502,7 @@ class OutputConfig(proto.Message):

class OutputResult(proto.Message):
r"""Output result of export assets.
Attributes:
gcs_result (google.cloud.asset_v1.types.GcsOutputResult):
Export result on Cloud Storage.
Expand All @@ -502,6 +515,7 @@ class OutputResult(proto.Message):

class GcsOutputResult(proto.Message):
r"""A Cloud Storage output result.
Attributes:
uris (Sequence[str]):
List of uris of the Cloud Storage objects. Example:
Expand All @@ -513,6 +527,7 @@ class GcsOutputResult(proto.Message):

class GcsDestination(proto.Message):
r"""A Cloud Storage location.
Attributes:
uri (str):
The uri of the Cloud Storage object. It's the same uri that
Expand Down Expand Up @@ -543,6 +558,7 @@ class GcsDestination(proto.Message):

class BigQueryDestination(proto.Message):
r"""A BigQuery destination for exporting assets to.
Attributes:
dataset (str):
Required. The BigQuery dataset in format
Expand Down Expand Up @@ -651,6 +667,7 @@ class PartitionKey(proto.Enum):

class PubsubDestination(proto.Message):
r"""A Pub/Sub destination.
Attributes:
topic (str):
The name of the Pub/Sub topic to publish to. Example:
Expand All @@ -662,6 +679,7 @@ class PubsubDestination(proto.Message):

class FeedOutputConfig(proto.Message):
r"""Output configuration for asset feed destination.
Attributes:
pubsub_destination (google.cloud.asset_v1.types.PubsubDestination):
Destination on Pub/Sub.
Expand Down Expand Up @@ -765,6 +783,7 @@ class Feed(proto.Message):

class SearchAllResourcesRequest(proto.Message):
r"""Search all resources request.
Attributes:
scope (str):
Required. A scope can be a project, a folder, or an
Expand Down Expand Up @@ -925,6 +944,7 @@ class SearchAllResourcesRequest(proto.Message):

class SearchAllResourcesResponse(proto.Message):
r"""Search all resources response.
Attributes:
results (Sequence[google.cloud.asset_v1.types.ResourceSearchResult]):
A list of Resources that match the search
Expand All @@ -949,6 +969,7 @@ def raw_page(self):

class SearchAllIamPoliciesRequest(proto.Message):
r"""Search all IAM policies request.
Attributes:
scope (str):
Required. A scope can be a project, a folder, or an
Expand Down Expand Up @@ -1069,6 +1090,7 @@ class SearchAllIamPoliciesRequest(proto.Message):

class SearchAllIamPoliciesResponse(proto.Message):
r"""Search all IAM policies response.
Attributes:
results (Sequence[google.cloud.asset_v1.types.IamPolicySearchResult]):
A list of IamPolicy that match the search
Expand All @@ -1093,6 +1115,7 @@ def raw_page(self):

class IamPolicyAnalysisQuery(proto.Message):
r"""## IAM policy analysis query message.
Attributes:
scope (str):
Required. The relative name of the root asset. Only
Expand Down Expand Up @@ -1181,6 +1204,7 @@ class AccessSelector(proto.Message):

class Options(proto.Message):
r"""Contains query options.
Attributes:
expand_groups (bool):
Optional. If true, the identities section of the result will
Expand Down Expand Up @@ -1279,6 +1303,7 @@ class Options(proto.Message):

class ConditionContext(proto.Message):
r"""The IAM conditions context.
Attributes:
access_time (google.protobuf.timestamp_pb2.Timestamp):
The hypothetical access timestamp to evaluate IAM
Expand Down Expand Up @@ -1354,6 +1379,7 @@ class AnalyzeIamPolicyResponse(proto.Message):

class IamPolicyAnalysis(proto.Message):
r"""An analysis message to group the query and results.
Attributes:
analysis_query (google.cloud.asset_v1.types.IamPolicyAnalysisQuery):
The analysis query.
Expand Down Expand Up @@ -1402,6 +1428,7 @@ class IamPolicyAnalysisOutputConfig(proto.Message):

class GcsDestination(proto.Message):
r"""A Cloud Storage location.
Attributes:
uri (str):
Required. The uri of the Cloud Storage object. It's the same
Expand All @@ -1421,6 +1448,7 @@ class GcsDestination(proto.Message):

class BigQueryDestination(proto.Message):
r"""A BigQuery destination.
Attributes:
dataset (str):
Required. The BigQuery dataset in format
Expand Down Expand Up @@ -1512,11 +1540,13 @@ class AnalyzeIamPolicyLongrunningRequest(proto.Message):
class AnalyzeIamPolicyLongrunningResponse(proto.Message):
r"""A response message for
[AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning].
"""
"""


class AnalyzeMoveRequest(proto.Message):
r"""The request message for performing resource move analysis.
Attributes:
resource (str):
Required. Name of the resource to perform the
Expand Down Expand Up @@ -1552,6 +1582,7 @@ class AnalysisView(proto.Enum):

class AnalyzeMoveResponse(proto.Message):
r"""The response message for resource move analysis.
Attributes:
move_analysis (Sequence[google.cloud.asset_v1.types.MoveAnalysis]):
The list of analyses returned from performing
Expand All @@ -1566,6 +1597,7 @@ class AnalyzeMoveResponse(proto.Message):

class MoveAnalysis(proto.Message):
r"""A message to group the analysis information.
Attributes:
display_name (str):
The user friendly display name of the
Expand All @@ -1589,6 +1621,7 @@ class MoveAnalysis(proto.Message):

class MoveAnalysisResult(proto.Message):
r"""An analysis result including blockers and warnings.
Attributes:
blockers (Sequence[google.cloud.asset_v1.types.MoveImpact]):
Blocking information that would prevent the
Expand All @@ -1608,6 +1641,7 @@ class MoveAnalysisResult(proto.Message):

class MoveImpact(proto.Message):
r"""A message to group impacts of moving the target resource.
Attributes:
detail (str):
User friendly impact detail in a free form
Expand Down
Loading

0 comments on commit 95cd6ae

Please sign in to comment.