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

Commit 7ca4c0e

Browse files
feat: Add client library support for AssetService v1 BatchGetEffectiveIamPolicies API (#1300)
- [ ] Regenerate this pull request now. Committer: haochunzhang@ PiperOrigin-RevId: 468010360 Source-Link: googleapis/googleapis@4bda299 Source-Link: https://github.com/googleapis/googleapis-gen/commit/8ed040614d04743f16cf4e4844b716fed998f94c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGVkMDQwNjE0ZDA0NzQzZjE2Y2Y0ZTQ4NDRiNzE2ZmVkOTk4Zjk0YyJ9 feat: Release of query system Committer: lvv@ PiperOrigin-RevId: 466748663 Source-Link: googleapis/googleapis@80d630f Source-Link: https://github.com/googleapis/googleapis-gen/commit/252f5ade18a31a72f12810bbfd1d83d56a8e72e1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjUyZjVhZGUxOGEzMWE3MmYxMjgxMGJiZmQxZDgzZDU2YThlNzJlMSJ9 feat: Add client library support for AssetService v1 BatchGetEffectiveIamPolicies API Committer: haochunzhang@ PiperOrigin-RevId: 466134014 Source-Link: googleapis/googleapis@63c73fb Source-Link: https://github.com/googleapis/googleapis-gen/commit/2350945f7a70ecaaecf9a1fdd7d6e70ac50e862d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjM1MDk0NWY3YTcwZWNhYWVjZjlhMWZkZDdkNmU3MGFjNTBlODYyZCJ9
1 parent a7155d0 commit 7ca4c0e

35 files changed

+13325
-388
lines changed

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

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,13 @@ public final UnaryCallable<DeleteFeedRequest, Empty> deleteFeedCallable() {
10201020
* <li>`labels.env:&#42;` to find Cloud resources that have a label "env".
10211021
* <li>`kmsKey:key` to find Cloud resources encrypted with a customer-managed encryption key
10221022
* whose name contains the word "key".
1023+
* <li>`relationships:instance-group-1` to find Cloud resources that have relationships with
1024+
* "instance-group-1" in the related resource name.
1025+
* <li>`relationships:INSTANCE_TO_INSTANCEGROUP` to find compute instances that have
1026+
* relationships of type "INSTANCE_TO_INSTANCEGROUP".
1027+
* <li>`relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1` to find compute instances
1028+
* that have relationships with "instance-group-1" in the compute instance group
1029+
* resource name, for relationship type "INSTANCE_TO_INSTANCEGROUP".
10231030
* <li>`state:ACTIVE` to find Cloud resources whose state contains "ACTIVE" as a word.
10241031
* <li>`NOT state:ACTIVE` to find Cloud resources whose state doesn't contain "ACTIVE" as a
10251032
* word.
@@ -1219,8 +1226,8 @@ public final SearchAllResourcesPagedResponse searchAllResources(
12191226
* the specified `scope`. Note that the query string is compared against each Cloud IAM policy
12201227
* binding, including its principals, roles, and Cloud IAM conditions. The returned Cloud IAM
12211228
* policies will only contain the bindings that match your query. To learn more about the IAM
1222-
* policy structure, see [IAM policy
1223-
* doc](https://cloud.google.com/iam/docs/policies#structure).
1229+
* policy structure, see the [IAM policy
1230+
* documentation](https://cloud.google.com/iam/help/allow-policies/structure).
12241231
* <p>Examples:
12251232
* <ul>
12261233
* <li>`policy:amy{@literal @}gmail.com` to find IAM policy bindings that specify user
@@ -1596,6 +1603,86 @@ public final UnaryCallable<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveC
15961603
return stub.analyzeMoveCallable();
15971604
}
15981605

1606+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
1607+
/**
1608+
* Issue a job that queries assets using a SQL statement compatible with [BigQuery Standard
1609+
* SQL](http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql).
1610+
*
1611+
* <p>If the query execution finishes within timeout and there's no pagination, the full query
1612+
* results will be returned in the `QueryAssetsResponse`.
1613+
*
1614+
* <p>Otherwise, full query results can be obtained by issuing extra requests with the
1615+
* `job_reference` from the a previous `QueryAssets` call.
1616+
*
1617+
* <p>Note, the query result has approximately 10 GB limitation enforced by BigQuery
1618+
* https://cloud.google.com/bigquery/docs/best-practices-performance-output, queries return larger
1619+
* results will result in errors.
1620+
*
1621+
* <p>Sample code:
1622+
*
1623+
* <pre>{@code
1624+
* // This snippet has been automatically generated for illustrative purposes only.
1625+
* // It may require modifications to work in your environment.
1626+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
1627+
* QueryAssetsRequest request =
1628+
* QueryAssetsRequest.newBuilder()
1629+
* .setParent(FolderName.of("[FOLDER]").toString())
1630+
* .setPageSize(883849137)
1631+
* .setPageToken("pageToken873572522")
1632+
* .setTimeout(Duration.newBuilder().build())
1633+
* .setOutputConfig(QueryAssetsOutputConfig.newBuilder().build())
1634+
* .build();
1635+
* QueryAssetsResponse response = assetServiceClient.queryAssets(request);
1636+
* }
1637+
* }</pre>
1638+
*
1639+
* @param request The request object containing all of the parameters for the API call.
1640+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1641+
*/
1642+
public final QueryAssetsResponse queryAssets(QueryAssetsRequest request) {
1643+
return queryAssetsCallable().call(request);
1644+
}
1645+
1646+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
1647+
/**
1648+
* Issue a job that queries assets using a SQL statement compatible with [BigQuery Standard
1649+
* SQL](http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql).
1650+
*
1651+
* <p>If the query execution finishes within timeout and there's no pagination, the full query
1652+
* results will be returned in the `QueryAssetsResponse`.
1653+
*
1654+
* <p>Otherwise, full query results can be obtained by issuing extra requests with the
1655+
* `job_reference` from the a previous `QueryAssets` call.
1656+
*
1657+
* <p>Note, the query result has approximately 10 GB limitation enforced by BigQuery
1658+
* https://cloud.google.com/bigquery/docs/best-practices-performance-output, queries return larger
1659+
* results will result in errors.
1660+
*
1661+
* <p>Sample code:
1662+
*
1663+
* <pre>{@code
1664+
* // This snippet has been automatically generated for illustrative purposes only.
1665+
* // It may require modifications to work in your environment.
1666+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
1667+
* QueryAssetsRequest request =
1668+
* QueryAssetsRequest.newBuilder()
1669+
* .setParent(FolderName.of("[FOLDER]").toString())
1670+
* .setPageSize(883849137)
1671+
* .setPageToken("pageToken873572522")
1672+
* .setTimeout(Duration.newBuilder().build())
1673+
* .setOutputConfig(QueryAssetsOutputConfig.newBuilder().build())
1674+
* .build();
1675+
* ApiFuture<QueryAssetsResponse> future =
1676+
* assetServiceClient.queryAssetsCallable().futureCall(request);
1677+
* // Do something.
1678+
* QueryAssetsResponse response = future.get();
1679+
* }
1680+
* }</pre>
1681+
*/
1682+
public final UnaryCallable<QueryAssetsRequest, QueryAssetsResponse> queryAssetsCallable() {
1683+
return stub.queryAssetsCallable();
1684+
}
1685+
15991686
// AUTO-GENERATED DOCUMENTATION AND METHOD.
16001687
/**
16011688
* Creates a saved query in a parent project/folder/organization.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ public UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSet
168168
return ((AssetServiceStubSettings) getStubSettings()).analyzeMoveSettings();
169169
}
170170

171+
/** Returns the object with the settings used for calls to queryAssets. */
172+
public UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings() {
173+
return ((AssetServiceStubSettings) getStubSettings()).queryAssetsSettings();
174+
}
175+
171176
/** Returns the object with the settings used for calls to createSavedQuery. */
172177
public UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings() {
173178
return ((AssetServiceStubSettings) getStubSettings()).createSavedQuerySettings();
@@ -409,6 +414,12 @@ public UnaryCallSettings.Builder<DeleteFeedRequest, Empty> deleteFeedSettings()
409414
return getStubSettingsBuilder().analyzeMoveSettings();
410415
}
411416

417+
/** Returns the builder for the settings used for calls to queryAssets. */
418+
public UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
419+
queryAssetsSettings() {
420+
return getStubSettingsBuilder().queryAssetsSettings();
421+
}
422+
412423
/** Returns the builder for the settings used for calls to createSavedQuery. */
413424
public UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
414425
createSavedQuerySettings() {

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
@@ -55,6 +55,9 @@
5555
"ListSavedQueries": {
5656
"methods": ["listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueries", "listSavedQueriesPagedCallable", "listSavedQueriesCallable"]
5757
},
58+
"QueryAssets": {
59+
"methods": ["queryAssets", "queryAssetsCallable"]
60+
},
5861
"SearchAllIamPolicies": {
5962
"methods": ["searchAllIamPolicies", "searchAllIamPolicies", "searchAllIamPoliciesPagedCallable", "searchAllIamPoliciesCallable"]
6063
},

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import com.google.cloud.asset.v1.ListFeedsResponse;
5151
import com.google.cloud.asset.v1.ListSavedQueriesRequest;
5252
import com.google.cloud.asset.v1.ListSavedQueriesResponse;
53+
import com.google.cloud.asset.v1.QueryAssetsRequest;
54+
import com.google.cloud.asset.v1.QueryAssetsResponse;
5355
import com.google.cloud.asset.v1.SavedQuery;
5456
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
5557
import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse;
@@ -165,6 +167,10 @@ public UnaryCallable<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveCallabl
165167
throw new UnsupportedOperationException("Not implemented: analyzeMoveCallable()");
166168
}
167169

170+
public UnaryCallable<QueryAssetsRequest, QueryAssetsResponse> queryAssetsCallable() {
171+
throw new UnsupportedOperationException("Not implemented: queryAssetsCallable()");
172+
}
173+
168174
public UnaryCallable<CreateSavedQueryRequest, SavedQuery> createSavedQueryCallable() {
169175
throw new UnsupportedOperationException("Not implemented: createSavedQueryCallable()");
170176
}

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

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
import com.google.cloud.asset.v1.ListFeedsResponse;
7979
import com.google.cloud.asset.v1.ListSavedQueriesRequest;
8080
import com.google.cloud.asset.v1.ListSavedQueriesResponse;
81+
import com.google.cloud.asset.v1.QueryAssetsRequest;
82+
import com.google.cloud.asset.v1.QueryAssetsResponse;
8183
import com.google.cloud.asset.v1.ResourceSearchResult;
8284
import com.google.cloud.asset.v1.SavedQuery;
8385
import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest;
@@ -168,6 +170,7 @@ public class AssetServiceStubSettings extends StubSettings<AssetServiceStubSetti
168170
AnalyzeIamPolicyLongrunningMetadata>
169171
analyzeIamPolicyLongrunningOperationSettings;
170172
private final UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSettings;
173+
private final UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings;
171174
private final UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings;
172175
private final UnaryCallSettings<GetSavedQueryRequest, SavedQuery> getSavedQuerySettings;
173176
private final PagedCallSettings<
@@ -510,6 +513,11 @@ public UnaryCallSettings<AnalyzeMoveRequest, AnalyzeMoveResponse> analyzeMoveSet
510513
return analyzeMoveSettings;
511514
}
512515

516+
/** Returns the object with the settings used for calls to queryAssets. */
517+
public UnaryCallSettings<QueryAssetsRequest, QueryAssetsResponse> queryAssetsSettings() {
518+
return queryAssetsSettings;
519+
}
520+
513521
/** Returns the object with the settings used for calls to createSavedQuery. */
514522
public UnaryCallSettings<CreateSavedQueryRequest, SavedQuery> createSavedQuerySettings() {
515523
return createSavedQuerySettings;
@@ -667,6 +675,7 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException {
667675
analyzeIamPolicyLongrunningOperationSettings =
668676
settingsBuilder.analyzeIamPolicyLongrunningOperationSettings().build();
669677
analyzeMoveSettings = settingsBuilder.analyzeMoveSettings().build();
678+
queryAssetsSettings = settingsBuilder.queryAssetsSettings().build();
670679
createSavedQuerySettings = settingsBuilder.createSavedQuerySettings().build();
671680
getSavedQuerySettings = settingsBuilder.getSavedQuerySettings().build();
672681
listSavedQueriesSettings = settingsBuilder.listSavedQueriesSettings().build();
@@ -713,6 +722,8 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
713722
analyzeIamPolicyLongrunningOperationSettings;
714723
private final UnaryCallSettings.Builder<AnalyzeMoveRequest, AnalyzeMoveResponse>
715724
analyzeMoveSettings;
725+
private final UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
726+
queryAssetsSettings;
716727
private final UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
717728
createSavedQuerySettings;
718729
private final UnaryCallSettings.Builder<GetSavedQueryRequest, SavedQuery> getSavedQuerySettings;
@@ -746,6 +757,12 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
746757
"retry_policy_3_codes",
747758
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
748759
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
760+
definitions.put(
761+
"retry_policy_4_codes",
762+
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
763+
definitions.put(
764+
"retry_policy_6_codes",
765+
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
749766
RETRYABLE_CODE_DEFINITIONS = definitions.build();
750767
}
751768

@@ -797,6 +814,28 @@ public static class Builder extends StubSettings.Builder<AssetServiceStubSetting
797814
definitions.put("retry_policy_3_params", settings);
798815
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
799816
definitions.put("no_retry_params", settings);
817+
settings =
818+
RetrySettings.newBuilder()
819+
.setInitialRetryDelay(Duration.ofMillis(100L))
820+
.setRetryDelayMultiplier(1.3)
821+
.setMaxRetryDelay(Duration.ofMillis(60000L))
822+
.setInitialRpcTimeout(Duration.ofMillis(200000L))
823+
.setRpcTimeoutMultiplier(1.0)
824+
.setMaxRpcTimeout(Duration.ofMillis(200000L))
825+
.setTotalTimeout(Duration.ofMillis(200000L))
826+
.build();
827+
definitions.put("retry_policy_4_params", settings);
828+
settings =
829+
RetrySettings.newBuilder()
830+
.setInitialRetryDelay(Duration.ofMillis(100L))
831+
.setRetryDelayMultiplier(1.3)
832+
.setMaxRetryDelay(Duration.ofMillis(60000L))
833+
.setInitialRpcTimeout(Duration.ofMillis(300000L))
834+
.setRpcTimeoutMultiplier(1.0)
835+
.setMaxRpcTimeout(Duration.ofMillis(300000L))
836+
.setTotalTimeout(Duration.ofMillis(300000L))
837+
.build();
838+
definitions.put("retry_policy_6_params", settings);
800839
RETRY_PARAM_DEFINITIONS = definitions.build();
801840
}
802841

@@ -823,6 +862,7 @@ protected Builder(ClientContext clientContext) {
823862
analyzeIamPolicyLongrunningSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
824863
analyzeIamPolicyLongrunningOperationSettings = OperationCallSettings.newBuilder();
825864
analyzeMoveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
865+
queryAssetsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
826866
createSavedQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
827867
getSavedQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
828868
listSavedQueriesSettings = PagedCallSettings.newBuilder(LIST_SAVED_QUERIES_PAGE_STR_FACT);
@@ -845,6 +885,7 @@ protected Builder(ClientContext clientContext) {
845885
analyzeIamPolicySettings,
846886
analyzeIamPolicyLongrunningSettings,
847887
analyzeMoveSettings,
888+
queryAssetsSettings,
848889
createSavedQuerySettings,
849890
getSavedQuerySettings,
850891
listSavedQueriesSettings,
@@ -874,6 +915,7 @@ protected Builder(AssetServiceStubSettings settings) {
874915
analyzeIamPolicyLongrunningOperationSettings =
875916
settings.analyzeIamPolicyLongrunningOperationSettings.toBuilder();
876917
analyzeMoveSettings = settings.analyzeMoveSettings.toBuilder();
918+
queryAssetsSettings = settings.queryAssetsSettings.toBuilder();
877919
createSavedQuerySettings = settings.createSavedQuerySettings.toBuilder();
878920
getSavedQuerySettings = settings.getSavedQuerySettings.toBuilder();
879921
listSavedQueriesSettings = settings.listSavedQueriesSettings.toBuilder();
@@ -897,6 +939,7 @@ protected Builder(AssetServiceStubSettings settings) {
897939
analyzeIamPolicySettings,
898940
analyzeIamPolicyLongrunningSettings,
899941
analyzeMoveSettings,
942+
queryAssetsSettings,
900943
createSavedQuerySettings,
901944
getSavedQuerySettings,
902945
listSavedQueriesSettings,
@@ -997,6 +1040,11 @@ private static Builder initDefaults(Builder builder) {
9971040
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
9981041
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
9991042

1043+
builder
1044+
.queryAssetsSettings()
1045+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes"))
1046+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params"));
1047+
10001048
builder
10011049
.createSavedQuerySettings()
10021050
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
@@ -1024,8 +1072,8 @@ private static Builder initDefaults(Builder builder) {
10241072

10251073
builder
10261074
.batchGetEffectiveIamPoliciesSettings()
1027-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
1028-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
1075+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
1076+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));
10291077

10301078
builder
10311079
.exportAssetsOperationSettings()
@@ -1192,6 +1240,12 @@ public UnaryCallSettings.Builder<DeleteFeedRequest, Empty> deleteFeedSettings()
11921240
return analyzeMoveSettings;
11931241
}
11941242

1243+
/** Returns the builder for the settings used for calls to queryAssets. */
1244+
public UnaryCallSettings.Builder<QueryAssetsRequest, QueryAssetsResponse>
1245+
queryAssetsSettings() {
1246+
return queryAssetsSettings;
1247+
}
1248+
11951249
/** Returns the builder for the settings used for calls to createSavedQuery. */
11961250
public UnaryCallSettings.Builder<CreateSavedQueryRequest, SavedQuery>
11971251
createSavedQuerySettings() {

0 commit comments

Comments
 (0)