Skip to content
Permalink
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
  • Loading branch information
yoshi-automation committed May 27, 2021
1 parent e5b831e commit b1e7d4a7c13c9d7da9c4247c9840af9d2bd06ad4
Showing with 11,833 additions and 1,461 deletions.
  1. +273 −20 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java
  2. +13 −0 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceSettings.java
  3. +3 −0 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/gapic_metadata.json
  4. +11 −0 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/AssetServiceStub.java
  5. +84 −0 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java
  6. +43 −0 google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java
  7. +90 −0 google-cloud-asset/src/test/java/com/google/cloud/asset/v1/AssetServiceClientTest.java
  8. +21 −0 google-cloud-asset/src/test/java/com/google/cloud/asset/v1/MockAssetServiceImpl.java
  9. +126 −10 grpc-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/AssetServiceGrpc.java
  10. +4 −2 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/Asset.java
  11. +89 −56 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/AssetProto.java
  12. +285 −222 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/AssetServiceProto.java
  13. +801 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ConditionEvaluation.java
  14. +50 −0 ...o-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ConditionEvaluationOrBuilder.java
  15. +27 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/GcsDestination.java
  16. +9 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/GcsDestinationOrBuilder.java
  17. +63 −27 ...-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicyAnalysisOutputConfig.java
  18. +1,426 −214 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicyAnalysisQuery.java
  19. +42 −0 ...oogle-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicyAnalysisQueryOrBuilder.java
  20. +331 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicyAnalysisResult.java
  21. +7 −7 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicySearchResult.java
  22. +2 −2 ...google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/IamPolicySearchResultOrBuilder.java
  23. +1,880 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ListAssetsRequest.java
  24. +280 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ListAssetsRequestOrBuilder.java
  25. +1,404 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ListAssetsResponse.java
  26. +140 −0 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ListAssetsResponseOrBuilder.java
  27. +2,925 −596 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ResourceSearchResult.java
  28. +444 −26 ...-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/ResourceSearchResultOrBuilder.java
  29. +112 −28 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/SearchAllIamPoliciesRequest.java
  30. +32 −8 ...-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/SearchAllIamPoliciesRequestOrBuilder.java
  31. +370 −147 proto-google-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/SearchAllResourcesRequest.java
  32. +108 −42 ...le-cloud-asset-v1/src/main/java/com/google/cloud/asset/v1/SearchAllResourcesRequestOrBuilder.java
  33. +171 −30 proto-google-cloud-asset-v1/src/main/proto/google/cloud/asset/v1/asset_service.proto
  34. +150 −13 proto-google-cloud-asset-v1/src/main/proto/google/cloud/asset/v1/assets.proto
  35. +17 −11 synth.metadata

Large diffs are not rendered by default.

@@ -16,6 +16,7 @@

package com.google.cloud.asset.v1;

import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;

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

/** Returns the object with the settings used for calls to listAssets. */
public PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings() {
return ((AssetServiceStubSettings) getStubSettings()).listAssetsSettings();
}

/** Returns the object with the settings used for calls to batchGetAssetsHistory. */
public UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings() {
@@ -262,6 +269,12 @@ public UnaryCallSettings.Builder<ExportAssetsRequest, Operation> exportAssetsSet
return getStubSettingsBuilder().exportAssetsOperationSettings();
}

/** Returns the builder for the settings used for calls to listAssets. */
public PagedCallSettings.Builder<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings() {
return getStubSettingsBuilder().listAssetsSettings();
}

/** Returns the builder for the settings used for calls to batchGetAssetsHistory. */
public UnaryCallSettings.Builder<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings() {
@@ -31,6 +31,9 @@
"GetFeed": {
"methods": ["getFeed", "getFeed", "getFeed", "getFeedCallable"]
},
"ListAssets": {
"methods": ["listAssets", "listAssets", "listAssets", "listAssetsPagedCallable", "listAssetsCallable"]
},
"ListFeeds": {
"methods": ["listFeeds", "listFeeds", "listFeedsCallable"]
},
@@ -16,6 +16,7 @@

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

import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;

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

public UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable() {
throw new UnsupportedOperationException("Not implemented: listAssetsPagedCallable()");
}

public UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable() {
throw new UnsupportedOperationException("Not implemented: listAssetsCallable()");
}

public UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistoryCallable() {
throw new UnsupportedOperationException("Not implemented: batchGetAssetsHistoryCallable()");
@@ -16,6 +16,7 @@

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

import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;

@@ -49,6 +50,7 @@
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse;
import com.google.cloud.asset.v1.AnalyzeIamPolicyRequest;
import com.google.cloud.asset.v1.AnalyzeIamPolicyResponse;
import com.google.cloud.asset.v1.Asset;
import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest;
import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse;
import com.google.cloud.asset.v1.CreateFeedRequest;
@@ -58,6 +60,8 @@
import com.google.cloud.asset.v1.Feed;
import com.google.cloud.asset.v1.GetFeedRequest;
import com.google.cloud.asset.v1.IamPolicySearchResult;
import com.google.cloud.asset.v1.ListAssetsRequest;
import com.google.cloud.asset.v1.ListAssetsResponse;
import com.google.cloud.asset.v1.ListFeedsRequest;
import com.google.cloud.asset.v1.ListFeedsResponse;
import com.google.cloud.asset.v1.ResourceSearchResult;
@@ -119,6 +123,8 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
private final OperationCallSettings<
ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
exportAssetsOperationSettings;
private final PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings;
private final UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings;
private final UnaryCallSettings<CreateFeedRequest, Feed> createFeedSettings;
@@ -144,6 +150,42 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
AnalyzeIamPolicyLongrunningRequest>
analyzeIamPolicyLongrunningOperationSettings;

private static final PagedListDescriptor<ListAssetsRequest, ListAssetsResponse, Asset>
LIST_ASSETS_PAGE_STR_DESC =
new PagedListDescriptor<ListAssetsRequest, ListAssetsResponse, Asset>() {
@Override
public String emptyToken() {
return "";
}

@Override
public ListAssetsRequest injectToken(ListAssetsRequest payload, String token) {
return ListAssetsRequest.newBuilder(payload).setPageToken(token).build();
}

@Override
public ListAssetsRequest injectPageSize(ListAssetsRequest payload, int pageSize) {
return ListAssetsRequest.newBuilder(payload).setPageSize(pageSize).build();
}

@Override
public Integer extractPageSize(ListAssetsRequest payload) {
return payload.getPageSize();
}

@Override
public String extractNextToken(ListAssetsResponse payload) {
return payload.getNextPageToken();
}

@Override
public Iterable<Asset> extractResources(ListAssetsResponse payload) {
return payload.getAssetsList() == null
? ImmutableList.<Asset>of()
: payload.getAssetsList();
}
};

private static final PagedListDescriptor<
SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult>
SEARCH_ALL_RESOURCES_PAGE_STR_DESC =
@@ -226,6 +268,23 @@ public Iterable<IamPolicySearchResult> extractResources(
}
};

private static final PagedListResponseFactory<
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
LIST_ASSETS_PAGE_STR_FACT =
new PagedListResponseFactory<
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>() {
@Override
public ApiFuture<ListAssetsPagedResponse> getFuturePagedResponse(
UnaryCallable<ListAssetsRequest, ListAssetsResponse> callable,
ListAssetsRequest request,
ApiCallContext context,
ApiFuture<ListAssetsResponse> futureResponse) {
PageContext<ListAssetsRequest, ListAssetsResponse, Asset> pageContext =
PageContext.create(callable, LIST_ASSETS_PAGE_STR_DESC, request, context);
return ListAssetsPagedResponse.createAsync(pageContext, futureResponse);
}
};

private static final PagedListResponseFactory<
SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse>
SEARCH_ALL_RESOURCES_PAGE_STR_FACT =
@@ -285,6 +344,12 @@ public UnaryCallSettings<ExportAssetsRequest, Operation> exportAssetsSettings()
return exportAssetsOperationSettings;
}

/** Returns the object with the settings used for calls to listAssets. */
public PagedCallSettings<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings() {
return listAssetsSettings;
}

/** Returns the object with the settings used for calls to batchGetAssetsHistory. */
public UnaryCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings() {
@@ -424,6 +489,7 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException {

exportAssetsSettings = settingsBuilder.exportAssetsSettings().build();
exportAssetsOperationSettings = settingsBuilder.exportAssetsOperationSettings().build();
listAssetsSettings = settingsBuilder.listAssetsSettings().build();
batchGetAssetsHistorySettings = settingsBuilder.batchGetAssetsHistorySettings().build();
createFeedSettings = settingsBuilder.createFeedSettings().build();
getFeedSettings = settingsBuilder.getFeedSettings().build();
@@ -446,6 +512,9 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
private final OperationCallSettings.Builder<
ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
exportAssetsOperationSettings;
private final PagedCallSettings.Builder<
ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings;
private final UnaryCallSettings.Builder<
BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings;
@@ -553,6 +622,7 @@ protected Builder(ClientContext clientContext) {

exportAssetsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
exportAssetsOperationSettings = OperationCallSettings.newBuilder();
listAssetsSettings = PagedCallSettings.newBuilder(LIST_ASSETS_PAGE_STR_FACT);
batchGetAssetsHistorySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
createFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
getFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
@@ -569,6 +639,7 @@ protected Builder(ClientContext clientContext) {
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
exportAssetsSettings,
listAssetsSettings,
batchGetAssetsHistorySettings,
createFeedSettings,
getFeedSettings,
@@ -587,6 +658,7 @@ protected Builder(AssetServiceStubSettings settings) {

exportAssetsSettings = settings.exportAssetsSettings.toBuilder();
exportAssetsOperationSettings = settings.exportAssetsOperationSettings.toBuilder();
listAssetsSettings = settings.listAssetsSettings.toBuilder();
batchGetAssetsHistorySettings = settings.batchGetAssetsHistorySettings.toBuilder();
createFeedSettings = settings.createFeedSettings.toBuilder();
getFeedSettings = settings.getFeedSettings.toBuilder();
@@ -604,6 +676,7 @@ protected Builder(AssetServiceStubSettings settings) {
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
exportAssetsSettings,
listAssetsSettings,
batchGetAssetsHistorySettings,
createFeedSettings,
getFeedSettings,
@@ -633,6 +706,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));

builder
.listAssetsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.batchGetAssetsHistorySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
@@ -767,6 +845,12 @@ public UnaryCallSettings.Builder<ExportAssetsRequest, Operation> exportAssetsSet
return exportAssetsOperationSettings;
}

/** Returns the builder for the settings used for calls to listAssets. */
public PagedCallSettings.Builder<ListAssetsRequest, ListAssetsResponse, ListAssetsPagedResponse>
listAssetsSettings() {
return listAssetsSettings;
}

/** Returns the builder for the settings used for calls to batchGetAssetsHistory. */
public UnaryCallSettings.Builder<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistorySettings() {
@@ -16,6 +16,7 @@

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

import static com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse;
import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse;

@@ -39,6 +40,8 @@
import com.google.cloud.asset.v1.ExportAssetsResponse;
import com.google.cloud.asset.v1.Feed;
import com.google.cloud.asset.v1.GetFeedRequest;
import com.google.cloud.asset.v1.ListAssetsRequest;
import com.google.cloud.asset.v1.ListAssetsResponse;
import com.google.cloud.asset.v1.ListFeedsRequest;
import com.google.cloud.asset.v1.ListFeedsResponse;
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
@@ -74,6 +77,15 @@ public class GrpcAssetServiceStub extends AssetServiceStub {
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();

private static final MethodDescriptor<ListAssetsRequest, ListAssetsResponse>
listAssetsMethodDescriptor =
MethodDescriptor.<ListAssetsRequest, ListAssetsResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.asset.v1.AssetService/ListAssets")
.setRequestMarshaller(ProtoUtils.marshaller(ListAssetsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListAssetsResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistoryMethodDescriptor =
MethodDescriptor.<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>newBuilder()
@@ -172,6 +184,8 @@ public class GrpcAssetServiceStub extends AssetServiceStub {
private final UnaryCallable<ExportAssetsRequest, Operation> exportAssetsCallable;
private final OperationCallable<ExportAssetsRequest, ExportAssetsResponse, ExportAssetsRequest>
exportAssetsOperationCallable;
private final UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable;
private final UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable;
private final UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistoryCallable;
private final UnaryCallable<CreateFeedRequest, Feed> createFeedCallable;
@@ -252,6 +266,19 @@ public Map<String, String> extract(ExportAssetsRequest request) {
}
})
.build();
GrpcCallSettings<ListAssetsRequest, ListAssetsResponse> listAssetsTransportSettings =
GrpcCallSettings.<ListAssetsRequest, ListAssetsResponse>newBuilder()
.setMethodDescriptor(listAssetsMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<ListAssetsRequest>() {
@Override
public Map<String, String> extract(ListAssetsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("parent", String.valueOf(request.getParent()));
return params.build();
}
})
.build();
GrpcCallSettings<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistoryTransportSettings =
GrpcCallSettings
@@ -403,6 +430,12 @@ public Map<String, String> extract(
settings.exportAssetsOperationSettings(),
clientContext,
operationsStub);
this.listAssetsCallable =
callableFactory.createUnaryCallable(
listAssetsTransportSettings, settings.listAssetsSettings(), clientContext);
this.listAssetsPagedCallable =
callableFactory.createPagedCallable(
listAssetsTransportSettings, settings.listAssetsSettings(), clientContext);
this.batchGetAssetsHistoryCallable =
callableFactory.createUnaryCallable(
batchGetAssetsHistoryTransportSettings,
@@ -477,6 +510,16 @@ public UnaryCallable<ExportAssetsRequest, Operation> exportAssetsCallable() {
return exportAssetsOperationCallable;
}

@Override
public UnaryCallable<ListAssetsRequest, ListAssetsResponse> listAssetsCallable() {
return listAssetsCallable;
}

@Override
public UnaryCallable<ListAssetsRequest, ListAssetsPagedResponse> listAssetsPagedCallable() {
return listAssetsPagedCallable;
}

@Override
public UnaryCallable<BatchGetAssetsHistoryRequest, BatchGetAssetsHistoryResponse>
batchGetAssetsHistoryCallable() {

0 comments on commit b1e7d4a

Please sign in to comment.