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

feat: Add client library support for AssetService v1 BatchGetEffectiveIamPolicies API #1300

Merged
merged 6 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ If you are using Maven without BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.0.0')
implementation platform('com.google.cloud:libraries-bom:26.1.0')

implementation 'com.google.cloud:google-cloud-asset'
```
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-asset:3.4.1'
implementation 'com.google.cloud:google-cloud-asset:3.5.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-asset" % "3.4.1"
libraryDependencies += "com.google.cloud" % "google-cloud-asset" % "3.5.0"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,13 @@ public final UnaryCallable<DeleteFeedRequest, Empty> deleteFeedCallable() {
* <li>`labels.env:&#42;` to find Cloud resources that have a label "env".
* <li>`kmsKey:key` to find Cloud resources encrypted with a customer-managed encryption key
* whose name contains the word "key".
* <li>`relationships:instance-group-1` to find Cloud resources that have relationships with
* "instance-group-1" in the related resource name.
* <li>`relationships:INSTANCE_TO_INSTANCEGROUP` to find compute instances that have
* relationships of type "INSTANCE_TO_INSTANCEGROUP".
* <li>`relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1` to find compute instances
* that have relationships with "instance-group-1" in the compute instance group
* resource name, for relationship type "INSTANCE_TO_INSTANCEGROUP".
* <li>`state:ACTIVE` to find Cloud resources whose state contains "ACTIVE" as a word.
* <li>`NOT state:ACTIVE` to find Cloud resources whose state doesn't contain "ACTIVE" as a
* word.
Expand Down Expand Up @@ -1219,8 +1226,8 @@ public final SearchAllResourcesPagedResponse searchAllResources(
* the specified `scope`. Note that the query string is compared against each Cloud IAM policy
* binding, including its principals, roles, and Cloud IAM conditions. The returned Cloud IAM
* policies will only contain the bindings that match your query. To learn more about the IAM
* policy structure, see [IAM policy
* doc](https://cloud.google.com/iam/docs/policies#structure).
* policy structure, see the [IAM policy
* documentation](https://cloud.google.com/iam/help/allow-policies/structure).
* <p>Examples:
* <ul>
* <li>`policy:amy{@literal @}gmail.com` to find IAM policy bindings that specify user
Expand Down Expand Up @@ -1596,6 +1603,86 @@ public final UnaryCallable<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveC
return stub.analyzeMoveCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Issue a job that queries assets using a SQL statement compatible with [BigQuery Standard
* SQL](http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql).
*
* <p>If the query execution finishes within timeout and there's no pagination, the full query
* results will be returned in the `QueryAssetsResponse`.
*
* <p>Otherwise, full query results can be obtained by issuing extra requests with the
* `job_reference` from the a previous `QueryAssets` call.
*
* <p>Note, the query result has approximately 10 GB limitation enforced by BigQuery
* https://cloud.google.com/bigquery/docs/best-practices-performance-output, queries return larger
* results will result in errors.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* QueryAssetsRequest request =
* QueryAssetsRequest.newBuilder()
* .setParent(FolderName.of("[FOLDER]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setTimeout(Duration.newBuilder().build())
* .setOutputConfig(QueryAssetsOutputConfig.newBuilder().build())
* .build();
* QueryAssetsResponse response = assetServiceClient.queryAssets(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final QueryAssetsResponse queryAssets(QueryAssetsRequest request) {
return queryAssetsCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Issue a job that queries assets using a SQL statement compatible with [BigQuery Standard
* SQL](http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql).
*
* <p>If the query execution finishes within timeout and there's no pagination, the full query
* results will be returned in the `QueryAssetsResponse`.
*
* <p>Otherwise, full query results can be obtained by issuing extra requests with the
* `job_reference` from the a previous `QueryAssets` call.
*
* <p>Note, the query result has approximately 10 GB limitation enforced by BigQuery
* https://cloud.google.com/bigquery/docs/best-practices-performance-output, queries return larger
* results will result in errors.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* QueryAssetsRequest request =
* QueryAssetsRequest.newBuilder()
* .setParent(FolderName.of("[FOLDER]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setTimeout(Duration.newBuilder().build())
* .setOutputConfig(QueryAssetsOutputConfig.newBuilder().build())
* .build();
* ApiFuture<QueryAssetsResponse> future =
* assetServiceClient.queryAssetsCallable().futureCall(request);
* // Do something.
* QueryAssetsResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<QueryAssetsRequest, QueryAssetsResponse> queryAssetsCallable() {
return stub.queryAssetsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a saved query in a parent project/folder/organization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ public UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSet
return ((AssetServiceStubSettings) getStubSettings()).analyzeMoveSettings();
}

/** Returns the object with the settings used for calls to queryAssets. */
public UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings() {
return ((AssetServiceStubSettings) getStubSettings()).queryAssetsSettings();
}

/** Returns the object with the settings used for calls to createSavedQuery. */
public UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings() {
return ((AssetServiceStubSettings) getStubSettings()).createSavedQuerySettings();
Expand Down Expand Up @@ -409,6 +414,12 @@ public UnaryCallSettings.Builder<DeleteFeedRequest, Empty> deleteFeedSettings()
return getStubSettingsBuilder().analyzeMoveSettings();
}

/** Returns the builder for the settings used for calls to queryAssets. */
public UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
queryAssetsSettings() {
return getStubSettingsBuilder().queryAssetsSettings();
}

/** Returns the builder for the settings used for calls to createSavedQuery. */
public UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
createSavedQuerySettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"ListSavedQueries": {
"methods": ["listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueriesPagedCallable", "listSavedQueriesCallable"]
},
"QueryAssets": {
"methods": ["queryAssets", "queryAssetsCallable"]
},
"SearchAllIamPolicies": {
"methods": ["searchAllIamPolicies", "searchAllIamPolicies", "searchAllIamPoliciesPagedCallable", "searchAllIamPoliciesCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import com.google.cloud.asset.v1.ListFeedsResponse;
import com.google.cloud.asset.v1.ListSavedQueriesRequest;
import com.google.cloud.asset.v1.ListSavedQueriesResponse;
import com.google.cloud.asset.v1.QueryAssetsRequest;
import com.google.cloud.asset.v1.QueryAssetsResponse;
import com.google.cloud.asset.v1.SavedQuery;
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse;
Expand Down Expand Up @@ -165,6 +167,10 @@ public UnaryCallable<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveCallabl
throw new UnsupportedOperationException("Not implemented: analyzeMoveCallable()");
}

public UnaryCallable<QueryAssetsRequest, QueryAssetsResponse> queryAssetsCallable() {
throw new UnsupportedOperationException("Not implemented: queryAssetsCallable()");
}

public UnaryCallable<CreateSavedQueryRequest, SavedQuery> createSavedQueryCallable() {
throw new UnsupportedOperationException("Not implemented: createSavedQueryCallable()");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
import com.google.cloud.asset.v1.ListFeedsResponse;
import com.google.cloud.asset.v1.ListSavedQueriesRequest;
import com.google.cloud.asset.v1.ListSavedQueriesResponse;
import com.google.cloud.asset.v1.QueryAssetsRequest;
import com.google.cloud.asset.v1.QueryAssetsResponse;
import com.google.cloud.asset.v1.ResourceSearchResult;
import com.google.cloud.asset.v1.SavedQuery;
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
Expand Down Expand Up @@ -168,6 +170,7 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
AnalyzeIamPolicyLongrunningMetadata>
analyzeIamPolicyLongrunningOperationSettings;
private final UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSettings;
private final UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings;
private final UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings;
private final UnaryCallSettings<GetSavedQueryRequest, SavedQuery> getSavedQuerySettings;
private final PagedCallSettings<
Expand Down Expand Up @@ -510,6 +513,11 @@ public UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSet
return analyzeMoveSettings;
}

/** Returns the object with the settings used for calls to queryAssets. */
public UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings() {
return queryAssetsSettings;
}

/** Returns the object with the settings used for calls to createSavedQuery. */
public UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings() {
return createSavedQuerySettings;
Expand Down Expand Up @@ -667,6 +675,7 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException {
analyzeIamPolicyLongrunningOperationSettings =
settingsBuilder.analyzeIamPolicyLongrunningOperationSettings().build();
analyzeMoveSettings = settingsBuilder.analyzeMoveSettings().build();
queryAssetsSettings = settingsBuilder.queryAssetsSettings().build();
createSavedQuerySettings = settingsBuilder.createSavedQuerySettings().build();
getSavedQuerySettings = settingsBuilder.getSavedQuerySettings().build();
listSavedQueriesSettings = settingsBuilder.listSavedQueriesSettings().build();
Expand Down Expand Up @@ -713,6 +722,8 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
analyzeIamPolicyLongrunningOperationSettings;
private final UnaryCallSettings.Builder<AnalyzeMoveRequest, AnalyzeMoveResponse>
analyzeMoveSettings;
private final UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
queryAssetsSettings;
private final UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
createSavedQuerySettings;
private final UnaryCallSettings.Builder<GetSavedQueryRequest, SavedQuery> getSavedQuerySettings;
Expand Down Expand Up @@ -746,6 +757,12 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
"retry_policy_3_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"retry_policy_4_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put(
"retry_policy_6_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -797,6 +814,28 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
definitions.put("retry_policy_3_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(200000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(200000L))
.setTotalTimeout(Duration.ofMillis(200000L))
.build();
definitions.put("retry_policy_4_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(300000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(300000L))
.setTotalTimeout(Duration.ofMillis(300000L))
.build();
definitions.put("retry_policy_6_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand All @@ -823,6 +862,7 @@ protected Builder(ClientContext clientContext) {
analyzeIamPolicyLongrunningSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
analyzeIamPolicyLongrunningOperationSettings = OperationCallSettings.newBuilder();
analyzeMoveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
queryAssetsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
createSavedQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
getSavedQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
listSavedQueriesSettings = PagedCallSettings.newBuilder(LIST_SAVED_QUERIES_PAGE_STR_FACT);
Expand All @@ -845,6 +885,7 @@ protected Builder(ClientContext clientContext) {
analyzeIamPolicySettings,
analyzeIamPolicyLongrunningSettings,
analyzeMoveSettings,
queryAssetsSettings,
createSavedQuerySettings,
getSavedQuerySettings,
listSavedQueriesSettings,
Expand Down Expand Up @@ -874,6 +915,7 @@ protected Builder(AssetServiceStubSettings settings) {
analyzeIamPolicyLongrunningOperationSettings =
settings.analyzeIamPolicyLongrunningOperationSettings.toBuilder();
analyzeMoveSettings = settings.analyzeMoveSettings.toBuilder();
queryAssetsSettings = settings.queryAssetsSettings.toBuilder();
createSavedQuerySettings = settings.createSavedQuerySettings.toBuilder();
getSavedQuerySettings = settings.getSavedQuerySettings.toBuilder();
listSavedQueriesSettings = settings.listSavedQueriesSettings.toBuilder();
Expand All @@ -897,6 +939,7 @@ protected Builder(AssetServiceStubSettings settings) {
analyzeIamPolicySettings,
analyzeIamPolicyLongrunningSettings,
analyzeMoveSettings,
queryAssetsSettings,
createSavedQuerySettings,
getSavedQuerySettings,
listSavedQueriesSettings,
Expand Down Expand Up @@ -997,6 +1040,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));

builder
.queryAssetsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params"));

builder
.createSavedQuerySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
Expand Down Expand Up @@ -1024,8 +1072,8 @@ private static Builder initDefaults(Builder builder) {

builder
.batchGetEffectiveIamPoliciesSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.exportAssetsOperationSettings()
Expand Down Expand Up @@ -1192,6 +1240,12 @@ public UnaryCallSettings.Builder<DeleteFeedRequest, Empty> deleteFeedSettings()
return analyzeMoveSettings;
}

/** Returns the builder for the settings used for calls to queryAssets. */
public UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
queryAssetsSettings() {
return queryAssetsSettings;
}

/** Returns the builder for the settings used for calls to createSavedQuery. */
public UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
createSavedQuerySettings() {
Expand Down
Loading