Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit b1e7d4a

Browse files
feat: add Cloud Asset List API (#719)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/37d82fa3-d601-4df7-a493-2f7c7619c4d8/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) PiperOrigin-RevId: 375731640 Source-Link: googleapis/googleapis@de04592 feat: add access time as condition context in request and evaluation value in response for Cloud Asset AnalyzeIamPolicy API feat: add more info (folders, organizations, kms_key, create_time, update_time, state, parent_full_resource_name, parent_asset_type) in response for Cloud Asset SearchAllResources API
1 parent e5b831e commit b1e7d4a

35 files changed

+11833
-1461
lines changed

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java

Lines changed: 273 additions & 20 deletions
Large diffs are not rendered by default.

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceSettings.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.asset.v1;
1818

19+
import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
1920
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
2021
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;
2122

@@ -83,6 +84,12 @@ public UnaryCallSettings<ExportAssetsRequest, Operation> exportAssetsSettings()
8384
return ((AssetServiceStubSettings) getStubSettings()).exportAssetsOperationSettings();
8485
}
8586

87+
/** Returns the object with the settings used for calls to listAssets. */
88+
public PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
89+
listAssetsSettings() {
90+
return ((AssetServiceStubSettings) getStubSettings()).listAssetsSettings();
91+
}
92+
8693
/** Returns the object with the settings used for calls to batchGetAssetsHistory. */
8794
public UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
8895
batchGetAssetsHistorySettings() {
@@ -262,6 +269,12 @@ public UnaryCallSettings.Builder<ExportAssetsRequest, Operation> exportAssetsSet
262269
return getStubSettingsBuilder().exportAssetsOperationSettings();
263270
}
264271

272+
/** Returns the builder for the settings used for calls to listAssets. */
273+
public PagedCallSettings.Builder<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
274+
listAssetsSettings() {
275+
return getStubSettingsBuilder().listAssetsSettings();
276+
}
277+
265278
/** Returns the builder for the settings used for calls to batchGetAssetsHistory. */
266279
public UnaryCallSettings.Builder<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
267280
batchGetAssetsHistorySettings() {

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/gapic_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"GetFeed": {
3232
"methods": ["getFeed", "getFeed", "getFeed", "getFeedCallable"]
3333
},
34+
"ListAssets": {
35+
"methods": ["listAssets", "listAssets", "listAssets", "listAssetsPagedCallable", "listAssetsCallable"]
36+
},
3437
"ListFeeds": {
3538
"methods": ["listFeeds", "listFeeds", "listFeedsCallable"]
3639
},

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/AssetServiceStub.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.asset.v1.stub;
1818

19+
import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
1920
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
2021
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;
2122

@@ -34,6 +35,8 @@
3435
import com.google.cloud.asset.v1.ExportAssetsResponse;
3536
import com.google.cloud.asset.v1.Feed;
3637
import com.google.cloud.asset.v1.GetFeedRequest;
38+
import com.google.cloud.asset.v1.ListAssetsRequest;
39+
import com.google.cloud.asset.v1.ListAssetsResponse;
3740
import com.google.cloud.asset.v1.ListFeedsRequest;
3841
import com.google.cloud.asset.v1.ListFeedsResponse;
3942
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
@@ -68,6 +71,14 @@ public UnaryCallable<ExportAssetsRequest, Operation> exportAssetsCallable() {
6871
throw new UnsupportedOperationException("Not implemented: exportAssetsCallable()");
6972
}
7073

74+
public UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable() {
75+
throw new UnsupportedOperationException("Not implemented: listAssetsPagedCallable()");
76+
}
77+
78+
public UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable() {
79+
throw new UnsupportedOperationException("Not implemented: listAssetsCallable()");
80+
}
81+
7182
public UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
7283
batchGetAssetsHistoryCallable() {
7384
throw new UnsupportedOperationException("Not implemented: batchGetAssetsHistoryCallable()");

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.asset.v1.stub;
1818

19+
import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
1920
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
2021
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;
2122

@@ -49,6 +50,7 @@
4950
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse;
5051
import com.google.cloud.asset.v1.AnalyzeIamPolicyRequest;
5152
import com.google.cloud.asset.v1.AnalyzeIamPolicyResponse;
53+
import com.google.cloud.asset.v1.Asset;
5254
import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest;
5355
import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse;
5456
import com.google.cloud.asset.v1.CreateFeedRequest;
@@ -58,6 +60,8 @@
5860
import com.google.cloud.asset.v1.Feed;
5961
import com.google.cloud.asset.v1.GetFeedRequest;
6062
import com.google.cloud.asset.v1.IamPolicySearchResult;
63+
import com.google.cloud.asset.v1.ListAssetsRequest;
64+
import com.google.cloud.asset.v1.ListAssetsResponse;
6165
import com.google.cloud.asset.v1.ListFeedsRequest;
6266
import com.google.cloud.asset.v1.ListFeedsResponse;
6367
import com.google.cloud.asset.v1.ResourceSearchResult;
@@ -119,6 +123,8 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
119123
private final OperationCallSettings<
120124
ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
121125
exportAssetsOperationSettings;
126+
private final PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
127+
listAssetsSettings;
122128
private final UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
123129
batchGetAssetsHistorySettings;
124130
private final UnaryCallSettings<CreateFeedRequest, Feed> createFeedSettings;
@@ -144,6 +150,42 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
144150
AnalyzeIamPolicyLongrunningRequest>
145151
analyzeIamPolicyLongrunningOperationSettings;
146152

153+
private static final PagedListDescriptor<ListAssetsRequest, ListAssetsResponse, Asset>
154+
LIST_ASSETS_PAGE_STR_DESC =
155+
new PagedListDescriptor<ListAssetsRequest, ListAssetsResponse, Asset>() {
156+
@Override
157+
public String emptyToken() {
158+
return "";
159+
}
160+
161+
@Override
162+
public ListAssetsRequest injectToken(ListAssetsRequest payload, String token) {
163+
return ListAssetsRequest.newBuilder(payload).setPageToken(token).build();
164+
}
165+
166+
@Override
167+
public ListAssetsRequest injectPageSize(ListAssetsRequest payload, int pageSize) {
168+
return ListAssetsRequest.newBuilder(payload).setPageSize(pageSize).build();
169+
}
170+
171+
@Override
172+
public Integer extractPageSize(ListAssetsRequest payload) {
173+
return payload.getPageSize();
174+
}
175+
176+
@Override
177+
public String extractNextToken(ListAssetsResponse payload) {
178+
return payload.getNextPageToken();
179+
}
180+
181+
@Override
182+
public Iterable<Asset> extractResources(ListAssetsResponse payload) {
183+
return payload.getAssetsList() == null
184+
? ImmutableList.<Asset>of()
185+
: payload.getAssetsList();
186+
}
187+
};
188+
147189
private static final PagedListDescriptor<
148190
SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult>
149191
SEARCH_ALL_RESOURCES_PAGE_STR_DESC =
@@ -226,6 +268,23 @@ public Iterable<IamPolicySearchResult> extractResources(
226268
}
227269
};
228270

271+
private static final PagedListResponseFactory<
272+
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
273+
LIST_ASSETS_PAGE_STR_FACT =
274+
new PagedListResponseFactory<
275+
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>() {
276+
@Override
277+
public ApiFuture<ListAssetsPagedResponse> getFuturePagedResponse(
278+
UnaryCallable<ListAssetsRequest, ListAssetsResponse> callable,
279+
ListAssetsRequest request,
280+
ApiCallContext context,
281+
ApiFuture<ListAssetsResponse> futureResponse) {
282+
PageContext<ListAssetsRequest, ListAssetsResponse, Asset> pageContext =
283+
PageContext.create(callable, LIST_ASSETS_PAGE_STR_DESC, request, context);
284+
return ListAssetsPagedResponse.createAsync(pageContext, futureResponse);
285+
}
286+
};
287+
229288
private static final PagedListResponseFactory<
230289
SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse>
231290
SEARCH_ALL_RESOURCES_PAGE_STR_FACT =
@@ -285,6 +344,12 @@ public UnaryCallSettings<ExportAssetsRequest, Operation> exportAssetsSettings()
285344
return exportAssetsOperationSettings;
286345
}
287346

347+
/** Returns the object with the settings used for calls to listAssets. */
348+
public PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
349+
listAssetsSettings() {
350+
return listAssetsSettings;
351+
}
352+
288353
/** Returns the object with the settings used for calls to batchGetAssetsHistory. */
289354
public UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
290355
batchGetAssetsHistorySettings() {
@@ -424,6 +489,7 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException {
424489

425490
exportAssetsSettings = settingsBuilder.exportAssetsSettings().build();
426491
exportAssetsOperationSettings = settingsBuilder.exportAssetsOperationSettings().build();
492+
listAssetsSettings = settingsBuilder.listAssetsSettings().build();
427493
batchGetAssetsHistorySettings = settingsBuilder.batchGetAssetsHistorySettings().build();
428494
createFeedSettings = settingsBuilder.createFeedSettings().build();
429495
getFeedSettings = settingsBuilder.getFeedSettings().build();
@@ -446,6 +512,9 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
446512
private final OperationCallSettings.Builder<
447513
ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
448514
exportAssetsOperationSettings;
515+
private final PagedCallSettings.Builder<
516+
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
517+
listAssetsSettings;
449518
private final UnaryCallSettings.Builder<
450519
BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
451520
batchGetAssetsHistorySettings;
@@ -553,6 +622,7 @@ protected Builder(ClientContext clientContext) {
553622

554623
exportAssetsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
555624
exportAssetsOperationSettings = OperationCallSettings.newBuilder();
625+
listAssetsSettings = PagedCallSettings.newBuilder(LIST_ASSETS_PAGE_STR_FACT);
556626
batchGetAssetsHistorySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
557627
createFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
558628
getFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
@@ -569,6 +639,7 @@ protected Builder(ClientContext clientContext) {
569639
unaryMethodSettingsBuilders =
570640
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
571641
exportAssetsSettings,
642+
listAssetsSettings,
572643
batchGetAssetsHistorySettings,
573644
createFeedSettings,
574645
getFeedSettings,
@@ -587,6 +658,7 @@ protected Builder(AssetServiceStubSettings settings) {
587658

588659
exportAssetsSettings = settings.exportAssetsSettings.toBuilder();
589660
exportAssetsOperationSettings = settings.exportAssetsOperationSettings.toBuilder();
661+
listAssetsSettings = settings.listAssetsSettings.toBuilder();
590662
batchGetAssetsHistorySettings = settings.batchGetAssetsHistorySettings.toBuilder();
591663
createFeedSettings = settings.createFeedSettings.toBuilder();
592664
getFeedSettings = settings.getFeedSettings.toBuilder();
@@ -604,6 +676,7 @@ protected Builder(AssetServiceStubSettings settings) {
604676
unaryMethodSettingsBuilders =
605677
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
606678
exportAssetsSettings,
679+
listAssetsSettings,
607680
batchGetAssetsHistorySettings,
608681
createFeedSettings,
609682
getFeedSettings,
@@ -633,6 +706,11 @@ private static Builder initDefaults(Builder builder) {
633706
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
634707
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
635708

709+
builder
710+
.listAssetsSettings()
711+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
712+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
713+
636714
builder
637715
.batchGetAssetsHistorySettings()
638716
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
@@ -767,6 +845,12 @@ public UnaryCallSettings.Builder<ExportAssetsRequest, Operation> exportAssetsSet
767845
return exportAssetsOperationSettings;
768846
}
769847

848+
/** Returns the builder for the settings used for calls to listAssets. */
849+
public PagedCallSettings.Builder<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
850+
listAssetsSettings() {
851+
return listAssetsSettings;
852+
}
853+
770854
/** Returns the builder for the settings used for calls to batchGetAssetsHistory. */
771855
public UnaryCallSettings.Builder<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
772856
batchGetAssetsHistorySettings() {

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.asset.v1.stub;
1818

19+
import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
1920
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
2021
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;
2122

@@ -39,6 +40,8 @@
3940
import com.google.cloud.asset.v1.ExportAssetsResponse;
4041
import com.google.cloud.asset.v1.Feed;
4142
import com.google.cloud.asset.v1.GetFeedRequest;
43+
import com.google.cloud.asset.v1.ListAssetsRequest;
44+
import com.google.cloud.asset.v1.ListAssetsResponse;
4245
import com.google.cloud.asset.v1.ListFeedsRequest;
4346
import com.google.cloud.asset.v1.ListFeedsResponse;
4447
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
@@ -74,6 +77,15 @@ public class GrpcAssetServiceStub extends AssetServiceStub {
7477
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
7578
.build();
7679

80+
private static final MethodDescriptor<ListAssetsRequest, ListAssetsResponse>
81+
listAssetsMethodDescriptor =
82+
MethodDescriptor.<ListAssetsRequest, ListAssetsResponse>newBuilder()
83+
.setType(MethodDescriptor.MethodType.UNARY)
84+
.setFullMethodName("google.cloud.asset.v1.AssetService/ListAssets")
85+
.setRequestMarshaller(ProtoUtils.marshaller(ListAssetsRequest.getDefaultInstance()))
86+
.setResponseMarshaller(ProtoUtils.marshaller(ListAssetsResponse.getDefaultInstance()))
87+
.build();
88+
7789
private static final MethodDescriptor<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
7890
batchGetAssetsHistoryMethodDescriptor =
7991
MethodDescriptor.<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>newBuilder()
@@ -172,6 +184,8 @@ public class GrpcAssetServiceStub extends AssetServiceStub {
172184
private final UnaryCallable<ExportAssetsRequest, Operation> exportAssetsCallable;
173185
private final OperationCallable<ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
174186
exportAssetsOperationCallable;
187+
private final UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable;
188+
private final UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable;
175189
private final UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
176190
batchGetAssetsHistoryCallable;
177191
private final UnaryCallable<CreateFeedRequest, Feed> createFeedCallable;
@@ -252,6 +266,19 @@ public Map<String, String> extract(ExportAssetsRequest request) {
252266
}
253267
})
254268
.build();
269+
GrpcCallSettings<ListAssetsRequest, ListAssetsResponse> listAssetsTransportSettings =
270+
GrpcCallSettings.<ListAssetsRequest, ListAssetsResponse>newBuilder()
271+
.setMethodDescriptor(listAssetsMethodDescriptor)
272+
.setParamsExtractor(
273+
new RequestParamsExtractor<ListAssetsRequest>() {
274+
@Override
275+
public Map<String, String> extract(ListAssetsRequest request) {
276+
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
277+
params.put("parent", String.valueOf(request.getParent()));
278+
return params.build();
279+
}
280+
})
281+
.build();
255282
GrpcCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
256283
batchGetAssetsHistoryTransportSettings =
257284
GrpcCallSettings
@@ -403,6 +430,12 @@ public Map<String, String> extract(
403430
settings.exportAssetsOperationSettings(),
404431
clientContext,
405432
operationsStub);
433+
this.listAssetsCallable =
434+
callableFactory.createUnaryCallable(
435+
listAssetsTransportSettings, settings.listAssetsSettings(), clientContext);
436+
this.listAssetsPagedCallable =
437+
callableFactory.createPagedCallable(
438+
listAssetsTransportSettings, settings.listAssetsSettings(), clientContext);
406439
this.batchGetAssetsHistoryCallable =
407440
callableFactory.createUnaryCallable(
408441
batchGetAssetsHistoryTransportSettings,
@@ -477,6 +510,16 @@ public UnaryCallable<ExportAssetsRequest, Operation> exportAssetsCallable() {
477510
return exportAssetsOperationCallable;
478511
}
479512

513+
@Override
514+
public UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable() {
515+
return listAssetsCallable;
516+
}
517+
518+
@Override
519+
public UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable() {
520+
return listAssetsPagedCallable;
521+
}
522+
480523
@Override
481524
public UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
482525
batchGetAssetsHistoryCallable() {

0 commit comments

Comments
 (0)