Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit a242adc

Browse files
feat: Change metadata field for the AnalyzeIamPolicyLongrunning (#245)
*the metadata field change for AnalyzeIamPolicyLongrunning is BACKWARD INCOMPATIBLE. Adding this change expand our ability to return richer metadata information for the longrunning operation. Due to the small usage of this API, we've contacted all the customers to make sure they are not using the metadata field and hence won't be broken by this change. Committer: @aaronlichen-hp PiperOrigin-RevId: 386530026 Source-Link: googleapis/googleapis@746461e Source-Link: https://github.com/googleapis/googleapis-gen/commit/c2c174583aa7c18ab206bf8c54e6b1143a0e6d5c feat: Add AnalyzeMove API feat: Add read_mask field for SearchAllResourcesRequest feat: Add VersionedResource field for ResourceSearchResult feat: Add AttachedResource field for ResourceSearchResult
1 parent a15e185 commit a242adc

File tree

13 files changed

+647
-22
lines changed

13 files changed

+647
-22
lines changed

google/cloud/asset/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
AssetServiceAsyncClient,
2020
)
2121

22+
from google.cloud.asset_v1.types.asset_service import (
23+
AnalyzeIamPolicyLongrunningMetadata,
24+
)
2225
from google.cloud.asset_v1.types.asset_service import AnalyzeIamPolicyLongrunningRequest
2326
from google.cloud.asset_v1.types.asset_service import (
2427
AnalyzeIamPolicyLongrunningResponse,
2528
)
2629
from google.cloud.asset_v1.types.asset_service import AnalyzeIamPolicyRequest
2730
from google.cloud.asset_v1.types.asset_service import AnalyzeIamPolicyResponse
31+
from google.cloud.asset_v1.types.asset_service import AnalyzeMoveRequest
32+
from google.cloud.asset_v1.types.asset_service import AnalyzeMoveResponse
2833
from google.cloud.asset_v1.types.asset_service import BatchGetAssetsHistoryRequest
2934
from google.cloud.asset_v1.types.asset_service import BatchGetAssetsHistoryResponse
3035
from google.cloud.asset_v1.types.asset_service import BigQueryDestination
@@ -43,6 +48,9 @@
4348
from google.cloud.asset_v1.types.asset_service import ListAssetsResponse
4449
from google.cloud.asset_v1.types.asset_service import ListFeedsRequest
4550
from google.cloud.asset_v1.types.asset_service import ListFeedsResponse
51+
from google.cloud.asset_v1.types.asset_service import MoveAnalysis
52+
from google.cloud.asset_v1.types.asset_service import MoveAnalysisResult
53+
from google.cloud.asset_v1.types.asset_service import MoveImpact
4654
from google.cloud.asset_v1.types.asset_service import OutputConfig
4755
from google.cloud.asset_v1.types.asset_service import OutputResult
4856
from google.cloud.asset_v1.types.asset_service import PartitionSpec
@@ -54,6 +62,7 @@
5462
from google.cloud.asset_v1.types.asset_service import UpdateFeedRequest
5563
from google.cloud.asset_v1.types.asset_service import ContentType
5664
from google.cloud.asset_v1.types.assets import Asset
65+
from google.cloud.asset_v1.types.assets import AttachedResource
5766
from google.cloud.asset_v1.types.assets import ConditionEvaluation
5867
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisResult
5968
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisState
@@ -62,14 +71,18 @@
6271
from google.cloud.asset_v1.types.assets import ResourceSearchResult
6372
from google.cloud.asset_v1.types.assets import TemporalAsset
6473
from google.cloud.asset_v1.types.assets import TimeWindow
74+
from google.cloud.asset_v1.types.assets import VersionedResource
6575

6676
__all__ = (
6777
"AssetServiceClient",
6878
"AssetServiceAsyncClient",
79+
"AnalyzeIamPolicyLongrunningMetadata",
6980
"AnalyzeIamPolicyLongrunningRequest",
7081
"AnalyzeIamPolicyLongrunningResponse",
7182
"AnalyzeIamPolicyRequest",
7283
"AnalyzeIamPolicyResponse",
84+
"AnalyzeMoveRequest",
85+
"AnalyzeMoveResponse",
7386
"BatchGetAssetsHistoryRequest",
7487
"BatchGetAssetsHistoryResponse",
7588
"BigQueryDestination",
@@ -88,6 +101,9 @@
88101
"ListAssetsResponse",
89102
"ListFeedsRequest",
90103
"ListFeedsResponse",
104+
"MoveAnalysis",
105+
"MoveAnalysisResult",
106+
"MoveImpact",
91107
"OutputConfig",
92108
"OutputResult",
93109
"PartitionSpec",
@@ -99,6 +115,7 @@
99115
"UpdateFeedRequest",
100116
"ContentType",
101117
"Asset",
118+
"AttachedResource",
102119
"ConditionEvaluation",
103120
"IamPolicyAnalysisResult",
104121
"IamPolicyAnalysisState",
@@ -107,4 +124,5 @@
107124
"ResourceSearchResult",
108125
"TemporalAsset",
109126
"TimeWindow",
127+
"VersionedResource",
110128
)

google/cloud/asset_v1/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
from .services.asset_service import AssetServiceClient
1818
from .services.asset_service import AssetServiceAsyncClient
1919

20+
from .types.asset_service import AnalyzeIamPolicyLongrunningMetadata
2021
from .types.asset_service import AnalyzeIamPolicyLongrunningRequest
2122
from .types.asset_service import AnalyzeIamPolicyLongrunningResponse
2223
from .types.asset_service import AnalyzeIamPolicyRequest
2324
from .types.asset_service import AnalyzeIamPolicyResponse
25+
from .types.asset_service import AnalyzeMoveRequest
26+
from .types.asset_service import AnalyzeMoveResponse
2427
from .types.asset_service import BatchGetAssetsHistoryRequest
2528
from .types.asset_service import BatchGetAssetsHistoryResponse
2629
from .types.asset_service import BigQueryDestination
@@ -39,6 +42,9 @@
3942
from .types.asset_service import ListAssetsResponse
4043
from .types.asset_service import ListFeedsRequest
4144
from .types.asset_service import ListFeedsResponse
45+
from .types.asset_service import MoveAnalysis
46+
from .types.asset_service import MoveAnalysisResult
47+
from .types.asset_service import MoveImpact
4248
from .types.asset_service import OutputConfig
4349
from .types.asset_service import OutputResult
4450
from .types.asset_service import PartitionSpec
@@ -50,6 +56,7 @@
5056
from .types.asset_service import UpdateFeedRequest
5157
from .types.asset_service import ContentType
5258
from .types.assets import Asset
59+
from .types.assets import AttachedResource
5360
from .types.assets import ConditionEvaluation
5461
from .types.assets import IamPolicyAnalysisResult
5562
from .types.assets import IamPolicyAnalysisState
@@ -58,15 +65,20 @@
5865
from .types.assets import ResourceSearchResult
5966
from .types.assets import TemporalAsset
6067
from .types.assets import TimeWindow
68+
from .types.assets import VersionedResource
6169

6270
__all__ = (
6371
"AssetServiceAsyncClient",
72+
"AnalyzeIamPolicyLongrunningMetadata",
6473
"AnalyzeIamPolicyLongrunningRequest",
6574
"AnalyzeIamPolicyLongrunningResponse",
6675
"AnalyzeIamPolicyRequest",
6776
"AnalyzeIamPolicyResponse",
77+
"AnalyzeMoveRequest",
78+
"AnalyzeMoveResponse",
6879
"Asset",
6980
"AssetServiceClient",
81+
"AttachedResource",
7082
"BatchGetAssetsHistoryRequest",
7183
"BatchGetAssetsHistoryResponse",
7284
"BigQueryDestination",
@@ -90,6 +102,9 @@
90102
"ListAssetsResponse",
91103
"ListFeedsRequest",
92104
"ListFeedsResponse",
105+
"MoveAnalysis",
106+
"MoveAnalysisResult",
107+
"MoveImpact",
93108
"OutputConfig",
94109
"OutputResult",
95110
"PartitionSpec",
@@ -103,4 +118,5 @@
103118
"TemporalAsset",
104119
"TimeWindow",
105120
"UpdateFeedRequest",
121+
"VersionedResource",
106122
)

google/cloud/asset_v1/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"analyze_iam_policy_longrunning"
2121
]
2222
},
23+
"AnalyzeMove": {
24+
"methods": [
25+
"analyze_move"
26+
]
27+
},
2328
"BatchGetAssetsHistory": {
2429
"methods": [
2530
"batch_get_assets_history"
@@ -85,6 +90,11 @@
8590
"analyze_iam_policy_longrunning"
8691
]
8792
},
93+
"AnalyzeMove": {
94+
"methods": [
95+
"analyze_move"
96+
]
97+
},
8898
"BatchGetAssetsHistory": {
8999
"methods": [
90100
"batch_get_assets_history"

google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ async def search_all_resources(
864864
the word "key".
865865
- ``state:ACTIVE`` to find Cloud resources whose state
866866
contains "ACTIVE" as a word.
867-
- ``NOT state:ACTIVE`` to find {{gcp_name}} resources
868-
whose state doesn't contain "ACTIVE" as a word.
867+
- ``NOT state:ACTIVE`` to find Cloud resources whose
868+
state doesn't contain "ACTIVE" as a word.
869869
- ``createTime<1609459200`` to find Cloud resources
870870
that were created before "2021-01-01 00:00:00 UTC".
871871
1609459200 is the epoch timestamp of "2021-01-01
@@ -1221,8 +1221,8 @@ async def analyze_iam_policy_longrunning(
12211221
[google.longrunning.Operation][google.longrunning.Operation],
12221222
which allows you to track the operation status. We recommend
12231223
intervals of at least 2 seconds with exponential backoff retry
1224-
to poll the operation result. The metadata contains the request
1225-
to help callers to map responses to requests.
1224+
to poll the operation result. The metadata contains the metadata
1225+
for the long-running operation.
12261226
12271227
Args:
12281228
request (:class:`google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningRequest`):
@@ -1271,12 +1271,67 @@ async def analyze_iam_policy_longrunning(
12711271
response,
12721272
self._client._transport.operations_client,
12731273
asset_service.AnalyzeIamPolicyLongrunningResponse,
1274-
metadata_type=asset_service.AnalyzeIamPolicyLongrunningRequest,
1274+
metadata_type=asset_service.AnalyzeIamPolicyLongrunningMetadata,
12751275
)
12761276

12771277
# Done; return the response.
12781278
return response
12791279

1280+
async def analyze_move(
1281+
self,
1282+
request: asset_service.AnalyzeMoveRequest = None,
1283+
*,
1284+
retry: retries.Retry = gapic_v1.method.DEFAULT,
1285+
timeout: float = None,
1286+
metadata: Sequence[Tuple[str, str]] = (),
1287+
) -> asset_service.AnalyzeMoveResponse:
1288+
r"""Analyze moving a resource to a specified destination
1289+
without kicking off the actual move. The analysis is
1290+
best effort depending on the user's permissions of
1291+
viewing different hierarchical policies and
1292+
configurations. The policies and configuration are
1293+
subject to change before the actual resource migration
1294+
takes place.
1295+
1296+
Args:
1297+
request (:class:`google.cloud.asset_v1.types.AnalyzeMoveRequest`):
1298+
The request object. The request message for performing
1299+
resource move analysis.
1300+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1301+
should be retried.
1302+
timeout (float): The timeout for this request.
1303+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1304+
sent along with the request as metadata.
1305+
1306+
Returns:
1307+
google.cloud.asset_v1.types.AnalyzeMoveResponse:
1308+
The response message for resource
1309+
move analysis.
1310+
1311+
"""
1312+
# Create or coerce a protobuf request object.
1313+
request = asset_service.AnalyzeMoveRequest(request)
1314+
1315+
# Wrap the RPC method; this adds retry and timeout information,
1316+
# and friendly error handling.
1317+
rpc = gapic_v1.method_async.wrap_method(
1318+
self._client._transport.analyze_move,
1319+
default_timeout=None,
1320+
client_info=DEFAULT_CLIENT_INFO,
1321+
)
1322+
1323+
# Certain fields should be provided within the metadata header;
1324+
# add these here.
1325+
metadata = tuple(metadata) + (
1326+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1327+
)
1328+
1329+
# Send the request.
1330+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1331+
1332+
# Done; return the response.
1333+
return response
1334+
12801335

12811336
try:
12821337
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,8 @@ def search_all_resources(
10051005
the word "key".
10061006
- ``state:ACTIVE`` to find Cloud resources whose state
10071007
contains "ACTIVE" as a word.
1008-
- ``NOT state:ACTIVE`` to find {{gcp_name}} resources
1009-
whose state doesn't contain "ACTIVE" as a word.
1008+
- ``NOT state:ACTIVE`` to find Cloud resources whose
1009+
state doesn't contain "ACTIVE" as a word.
10101010
- ``createTime<1609459200`` to find Cloud resources
10111011
that were created before "2021-01-01 00:00:00 UTC".
10121012
1609459200 is the epoch timestamp of "2021-01-01
@@ -1336,8 +1336,8 @@ def analyze_iam_policy_longrunning(
13361336
[google.longrunning.Operation][google.longrunning.Operation],
13371337
which allows you to track the operation status. We recommend
13381338
intervals of at least 2 seconds with exponential backoff retry
1339-
to poll the operation result. The metadata contains the request
1340-
to help callers to map responses to requests.
1339+
to poll the operation result. The metadata contains the metadata
1340+
for the long-running operation.
13411341
13421342
Args:
13431343
request (google.cloud.asset_v1.types.AnalyzeIamPolicyLongrunningRequest):
@@ -1389,12 +1389,68 @@ def analyze_iam_policy_longrunning(
13891389
response,
13901390
self._transport.operations_client,
13911391
asset_service.AnalyzeIamPolicyLongrunningResponse,
1392-
metadata_type=asset_service.AnalyzeIamPolicyLongrunningRequest,
1392+
metadata_type=asset_service.AnalyzeIamPolicyLongrunningMetadata,
13931393
)
13941394

13951395
# Done; return the response.
13961396
return response
13971397

1398+
def analyze_move(
1399+
self,
1400+
request: asset_service.AnalyzeMoveRequest = None,
1401+
*,
1402+
retry: retries.Retry = gapic_v1.method.DEFAULT,
1403+
timeout: float = None,
1404+
metadata: Sequence[Tuple[str, str]] = (),
1405+
) -> asset_service.AnalyzeMoveResponse:
1406+
r"""Analyze moving a resource to a specified destination
1407+
without kicking off the actual move. The analysis is
1408+
best effort depending on the user's permissions of
1409+
viewing different hierarchical policies and
1410+
configurations. The policies and configuration are
1411+
subject to change before the actual resource migration
1412+
takes place.
1413+
1414+
Args:
1415+
request (google.cloud.asset_v1.types.AnalyzeMoveRequest):
1416+
The request object. The request message for performing
1417+
resource move analysis.
1418+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1419+
should be retried.
1420+
timeout (float): The timeout for this request.
1421+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1422+
sent along with the request as metadata.
1423+
1424+
Returns:
1425+
google.cloud.asset_v1.types.AnalyzeMoveResponse:
1426+
The response message for resource
1427+
move analysis.
1428+
1429+
"""
1430+
# Create or coerce a protobuf request object.
1431+
# Minor optimization to avoid making a copy if the user passes
1432+
# in a asset_service.AnalyzeMoveRequest.
1433+
# There's no risk of modifying the input as we've already verified
1434+
# there are no flattened fields.
1435+
if not isinstance(request, asset_service.AnalyzeMoveRequest):
1436+
request = asset_service.AnalyzeMoveRequest(request)
1437+
1438+
# Wrap the RPC method; this adds retry and timeout information,
1439+
# and friendly error handling.
1440+
rpc = self._transport._wrapped_methods[self._transport.analyze_move]
1441+
1442+
# Certain fields should be provided within the metadata header;
1443+
# add these here.
1444+
metadata = tuple(metadata) + (
1445+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1446+
)
1447+
1448+
# Send the request.
1449+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1450+
1451+
# Done; return the response.
1452+
return response
1453+
13981454

13991455
try:
14001456
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/cloud/asset_v1/services/asset_service/transports/base.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ def _prep_wrapped_messages(self, client_info):
286286
default_timeout=60.0,
287287
client_info=client_info,
288288
),
289+
self.analyze_move: gapic_v1.method.wrap_method(
290+
self.analyze_move, default_timeout=None, client_info=client_info,
291+
),
289292
}
290293

291294
@property
@@ -418,5 +421,17 @@ def analyze_iam_policy_longrunning(
418421
]:
419422
raise NotImplementedError()
420423

424+
@property
425+
def analyze_move(
426+
self,
427+
) -> Callable[
428+
[asset_service.AnalyzeMoveRequest],
429+
Union[
430+
asset_service.AnalyzeMoveResponse,
431+
Awaitable[asset_service.AnalyzeMoveResponse],
432+
],
433+
]:
434+
raise NotImplementedError()
435+
421436

422437
__all__ = ("AssetServiceTransport",)

0 commit comments

Comments
 (0)