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

Commit

Permalink
feat: add Cloud Asset List API (#719)
Browse files Browse the repository at this point in the history
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 b1e7d4a
Show file tree
Hide file tree
Showing 35 changed files with 11,833 additions and 1,461 deletions.

Large diffs are not rendered by default.

Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -31,6 +31,9 @@
"GetFeed": {
"methods": ["getFeed", "getFeed", "getFeed", "getFeedCallable"]
},
"ListAssets": {
"methods": ["listAssets", "listAssets", "listAssets", "listAssetsPagedCallable", "listAssetsCallable"]
},
"ListFeeds": {
"methods": ["listFeeds", "listFeeds", "listFeedsCallable"]
},
Expand Down
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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()");
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -569,6 +639,7 @@ protected Builder(ClientContext clientContext) {
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
exportAssetsSettings,
listAssetsSettings,
batchGetAssetsHistorySettings,
createFeedSettings,
getFeedSettings,
Expand All @@ -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();
Expand All @@ -604,6 +676,7 @@ protected Builder(AssetServiceStubSettings settings) {
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
exportAssetsSettings,
listAssetsSettings,
batchGetAssetsHistorySettings,
createFeedSettings,
getFeedSettings,
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit b1e7d4a

Please sign in to comment.