From 4dbc2e9ae7d23469686f4d0cc20f90530c8109a3 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 16 Feb 2021 09:46:05 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#540) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/0ae55182-06f0-43ed-98b1-1c835bf4b2f1/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../cloud/asset/v1/AssetServiceClient.java | 482 ++++++++++++++++++ .../google/cloud/asset/v1/package-info.java | 12 + .../asset/v1p1beta1/AssetServiceClient.java | 151 ++++++ .../cloud/asset/v1p1beta1/package-info.java | 12 + .../asset/v1p2beta1/AssetServiceClient.java | 193 +++++++ .../cloud/asset/v1p2beta1/package-info.java | 7 + .../asset/v1p4beta1/AssetServiceClient.java | 83 +++ .../cloud/asset/v1p4beta1/package-info.java | 11 + .../asset/v1p5beta1/AssetServiceClient.java | 69 +++ .../cloud/asset/v1p5beta1/package-info.java | 16 + synth.metadata | 20 +- 11 files changed, 1046 insertions(+), 10 deletions(-) diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java index 08abe777d..bc1752136 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/AssetServiceClient.java @@ -46,6 +46,18 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+ *   BatchGetAssetsHistoryRequest request =
+ *       BatchGetAssetsHistoryRequest.newBuilder()
+ *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+ *           .addAllAssetNames(new ArrayList())
+ *           .setReadTimeWindow(TimeWindow.newBuilder().build())
+ *           .build();
+ *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
+ * }
+ * }
+ * *

Note: close() needs to be called on the AssetServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -166,6 +178,21 @@ public final OperationsClient getOperationsClient() { * exponential retry to poll the export operation result. For regular-size resource parent, the * export operation usually finishes within 5 minutes. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ExportAssetsRequest request =
+   *       ExportAssetsRequest.newBuilder()
+   *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .setReadTime(Timestamp.newBuilder().build())
+   *           .addAllAssetTypes(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .build();
+   *   ExportAssetsResponse response = assetServiceClient.exportAssetsAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -186,6 +213,22 @@ public final OperationFuture exportAs * export operation usually finishes within 5 minutes. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ExportAssetsRequest request =
+   *       ExportAssetsRequest.newBuilder()
+   *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .setReadTime(Timestamp.newBuilder().build())
+   *           .addAllAssetTypes(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       assetServiceClient.exportAssetsOperationCallable().futureCall(request);
+   *   // Do something.
+   *   ExportAssetsResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable exportAssetsOperationCallable() { @@ -204,6 +247,21 @@ public final OperationFuture exportAs * export operation usually finishes within 5 minutes. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ExportAssetsRequest request =
+   *       ExportAssetsRequest.newBuilder()
+   *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .setReadTime(Timestamp.newBuilder().build())
+   *           .addAllAssetTypes(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = assetServiceClient.exportAssetsCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable exportAssetsCallable() { return stub.exportAssetsCallable(); @@ -217,6 +275,20 @@ public final UnaryCallable exportAssetsCallable( * or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT * error. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   BatchGetAssetsHistoryRequest request =
+   *       BatchGetAssetsHistoryRequest.newBuilder()
+   *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .addAllAssetNames(new ArrayList())
+   *           .setReadTimeWindow(TimeWindow.newBuilder().build())
+   *           .build();
+   *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
+   * }
+   * }
+ * * @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 */ @@ -234,6 +306,21 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( * error. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   BatchGetAssetsHistoryRequest request =
+   *       BatchGetAssetsHistoryRequest.newBuilder()
+   *           .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .addAllAssetNames(new ArrayList())
+   *           .setReadTimeWindow(TimeWindow.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       assetServiceClient.batchGetAssetsHistoryCallable().futureCall(request);
+   *   // Do something.
+   *   BatchGetAssetsHistoryResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable batchGetAssetsHistoryCallable() { @@ -244,6 +331,15 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( /** * Creates a feed in a parent project/folder/organization to listen to its asset updates. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   Feed response = assetServiceClient.createFeed(parent);
+   * }
+   * }
+ * * @param parent Required. The name of the project/folder/organization where this feed should be * created in. It can only be an organization number (such as "organizations/123"), a folder * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a @@ -259,6 +355,20 @@ public final Feed createFeed(String parent) { /** * Creates a feed in a parent project/folder/organization to listen to its asset updates. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   CreateFeedRequest request =
+   *       CreateFeedRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setFeedId("feedId-1278410919")
+   *           .setFeed(Feed.newBuilder().build())
+   *           .build();
+   *   Feed response = assetServiceClient.createFeed(request);
+   * }
+   * }
+ * * @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 */ @@ -271,6 +381,20 @@ public final Feed createFeed(CreateFeedRequest request) { * Creates a feed in a parent project/folder/organization to listen to its asset updates. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   CreateFeedRequest request =
+   *       CreateFeedRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setFeedId("feedId-1278410919")
+   *           .setFeed(Feed.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = assetServiceClient.createFeedCallable().futureCall(request);
+   *   // Do something.
+   *   Feed response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createFeedCallable() { return stub.createFeedCallable(); @@ -280,6 +404,15 @@ public final UnaryCallable createFeedCallable() { /** * Gets details about an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   Feed response = assetServiceClient.getFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -295,6 +428,15 @@ public final Feed getFeed(FeedName name) { /** * Gets details about an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString();
+   *   Feed response = assetServiceClient.getFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -309,6 +451,18 @@ public final Feed getFeed(String name) { /** * Gets details about an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   GetFeedRequest request =
+   *       GetFeedRequest.newBuilder()
+   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .build();
+   *   Feed response = assetServiceClient.getFeed(request);
+   * }
+   * }
+ * * @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 */ @@ -321,6 +475,18 @@ public final Feed getFeed(GetFeedRequest request) { * Gets details about an asset feed. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   GetFeedRequest request =
+   *       GetFeedRequest.newBuilder()
+   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .build();
+   *   ApiFuture future = assetServiceClient.getFeedCallable().futureCall(request);
+   *   // Do something.
+   *   Feed response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getFeedCallable() { return stub.getFeedCallable(); @@ -330,6 +496,15 @@ public final UnaryCallable getFeedCallable() { /** * Lists all asset feeds in a parent project/folder/organization. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   ListFeedsResponse response = assetServiceClient.listFeeds(parent);
+   * }
+   * }
+ * * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It * can only be using project/folder/organization number (such as "folders/12345")", or a * project ID (such as "projects/my-project-id"). @@ -344,6 +519,16 @@ public final ListFeedsResponse listFeeds(String parent) { /** * Lists all asset feeds in a parent project/folder/organization. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ListFeedsRequest request =
+   *       ListFeedsRequest.newBuilder().setParent("parent-995424086").build();
+   *   ListFeedsResponse response = assetServiceClient.listFeeds(request);
+   * }
+   * }
+ * * @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 */ @@ -356,6 +541,17 @@ public final ListFeedsResponse listFeeds(ListFeedsRequest request) { * Lists all asset feeds in a parent project/folder/organization. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ListFeedsRequest request =
+   *       ListFeedsRequest.newBuilder().setParent("parent-995424086").build();
+   *   ApiFuture future =
+   *       assetServiceClient.listFeedsCallable().futureCall(request);
+   *   // Do something.
+   *   ListFeedsResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable listFeedsCallable() { return stub.listFeedsCallable(); @@ -365,6 +561,15 @@ public final UnaryCallable listFeedsCallabl /** * Updates an asset feed configuration. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   Feed feed = Feed.newBuilder().build();
+   *   Feed response = assetServiceClient.updateFeed(feed);
+   * }
+   * }
+ * * @param feed Required. The new values of feed details. It must match an existing feed and the * field `name` must be in the format of: projects/project_number/feeds/feed_id or * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. @@ -379,6 +584,19 @@ public final Feed updateFeed(Feed feed) { /** * Updates an asset feed configuration. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   UpdateFeedRequest request =
+   *       UpdateFeedRequest.newBuilder()
+   *           .setFeed(Feed.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Feed response = assetServiceClient.updateFeed(request);
+   * }
+   * }
+ * * @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 */ @@ -391,6 +609,19 @@ public final Feed updateFeed(UpdateFeedRequest request) { * Updates an asset feed configuration. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   UpdateFeedRequest request =
+   *       UpdateFeedRequest.newBuilder()
+   *           .setFeed(Feed.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = assetServiceClient.updateFeedCallable().futureCall(request);
+   *   // Do something.
+   *   Feed response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateFeedCallable() { return stub.updateFeedCallable(); @@ -400,6 +631,15 @@ public final UnaryCallable updateFeedCallable() { /** * Deletes an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   assetServiceClient.deleteFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -415,6 +655,15 @@ public final void deleteFeed(FeedName name) { /** * Deletes an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString();
+   *   assetServiceClient.deleteFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -429,6 +678,18 @@ public final void deleteFeed(String name) { /** * Deletes an asset feed. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   DeleteFeedRequest request =
+   *       DeleteFeedRequest.newBuilder()
+   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .build();
+   *   assetServiceClient.deleteFeed(request);
+   * }
+   * }
+ * * @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 */ @@ -441,6 +702,18 @@ public final void deleteFeed(DeleteFeedRequest request) { * Deletes an asset feed. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   DeleteFeedRequest request =
+   *       DeleteFeedRequest.newBuilder()
+   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
+   *           .build();
+   *   ApiFuture future = assetServiceClient.deleteFeedCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteFeedCallable() { return stub.deleteFeedCallable(); @@ -452,6 +725,20 @@ public final UnaryCallable deleteFeedCallable() { * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission * on the desired scope, otherwise the request will be rejected. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List assetTypes = new ArrayList<>();
+   *   for (ResourceSearchResult element :
+   *       assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the resources within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -518,6 +805,26 @@ public final SearchAllResourcesPagedResponse searchAllResources( * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission * on the desired scope, otherwise the request will be rejected. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   SearchAllResourcesRequest request =
+   *       SearchAllResourcesRequest.newBuilder()
+   *           .setScope("scope109264468")
+   *           .setQuery("query107944136")
+   *           .addAllAssetTypes(new ArrayList())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .build();
+   *   for (ResourceSearchResult element :
+   *       assetServiceClient.searchAllResources(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -533,6 +840,26 @@ public final SearchAllResourcesPagedResponse searchAllResources( * on the desired scope, otherwise the request will be rejected. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   SearchAllResourcesRequest request =
+   *       SearchAllResourcesRequest.newBuilder()
+   *           .setScope("scope109264468")
+   *           .setQuery("query107944136")
+   *           .addAllAssetTypes(new ArrayList())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .build();
+   *   ApiFuture future =
+   *       assetServiceClient.searchAllResourcesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (ResourceSearchResult element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable searchAllResourcesPagedCallable() { @@ -546,6 +873,24 @@ public final SearchAllResourcesPagedResponse searchAllResources( * on the desired scope, otherwise the request will be rejected. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   while (true) {
+   *     SearchAllResourcesResponse response =
+   *         assetServiceClient.searchAllResourcesCallable().call(request);
+   *     for (ResourceSearchResult element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable searchAllResourcesCallable() { @@ -558,6 +903,19 @@ public final SearchAllResourcesPagedResponse searchAllResources( * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` * permission on the desired scope, otherwise the request will be rejected. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   for (IamPolicySearchResult element :
+   *       assetServiceClient.searchAllIamPolicies(scope, query).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the IAM policies within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -608,6 +966,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` * permission on the desired scope, otherwise the request will be rejected. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   SearchAllIamPoliciesRequest request =
+   *       SearchAllIamPoliciesRequest.newBuilder()
+   *           .setScope("scope109264468")
+   *           .setQuery("query107944136")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (IamPolicySearchResult element :
+   *       assetServiceClient.searchAllIamPolicies(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -623,6 +999,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( * permission on the desired scope, otherwise the request will be rejected. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   SearchAllIamPoliciesRequest request =
+   *       SearchAllIamPoliciesRequest.newBuilder()
+   *           .setScope("scope109264468")
+   *           .setQuery("query107944136")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       assetServiceClient.searchAllIamPoliciesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (IamPolicySearchResult element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable searchAllIamPoliciesPagedCallable() { @@ -636,6 +1030,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( * permission on the desired scope, otherwise the request will be rejected. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   while (true) {
+   *     SearchAllIamPoliciesResponse response =
+   *         assetServiceClient.searchAllIamPoliciesCallable().call(request);
+   *     for (IamPolicySearchResult element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable searchAllIamPoliciesCallable() { @@ -646,6 +1058,19 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( /** * Analyzes IAM policies to answer which identities have what accesses on which resources. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   AnalyzeIamPolicyRequest request =
+   *       AnalyzeIamPolicyRequest.newBuilder()
+   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
+   *           .setExecutionTimeout(Duration.newBuilder().build())
+   *           .build();
+   *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
+   * }
+   * }
+ * * @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 */ @@ -658,6 +1083,20 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * Analyzes IAM policies to answer which identities have what accesses on which resources. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   AnalyzeIamPolicyRequest request =
+   *       AnalyzeIamPolicyRequest.newBuilder()
+   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
+   *           .setExecutionTimeout(Duration.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeIamPolicyResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeIamPolicyCallable() { @@ -675,6 +1114,20 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * backoff retry to poll the operation result. The metadata contains the request to help callers * to map responses to requests. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   AnalyzeIamPolicyLongrunningRequest request =
+   *       AnalyzeIamPolicyLongrunningRequest.newBuilder()
+   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
+   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
+   *           .build();
+   *   AnalyzeIamPolicyLongrunningResponse response =
+   *       assetServiceClient.analyzeIamPolicyLongrunningAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -696,6 +1149,21 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * to map responses to requests. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   AnalyzeIamPolicyLongrunningRequest request =
+   *       AnalyzeIamPolicyLongrunningRequest.newBuilder()
+   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
+   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
+   *           .build();
+   *   OperationFuture
+   *       future =
+   *           assetServiceClient.analyzeIamPolicyLongrunningOperationCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeIamPolicyLongrunningResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< AnalyzeIamPolicyLongrunningRequest, @@ -717,6 +1185,20 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * to map responses to requests. * *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   AnalyzeIamPolicyLongrunningRequest request =
+   *       AnalyzeIamPolicyLongrunningRequest.newBuilder()
+   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
+   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       assetServiceClient.analyzeIamPolicyLongrunningCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeIamPolicyLongrunningCallable() { diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/package-info.java index e57f64180..1d38c8e91 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/package-info.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/package-info.java @@ -22,6 +22,18 @@ *

Service Description: Asset service definition. * *

Sample for AssetServiceClient: + * + *

{@code
+ * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+ *   BatchGetAssetsHistoryRequest request =
+ *       BatchGetAssetsHistoryRequest.newBuilder()
+ *           .setParent(ProjectName.of("[PROJECT]").toString())
+ *           .addAllAssetNames(new ArrayList())
+ *           .setReadTimeWindow(TimeWindow.newBuilder().build())
+ *           .build();
+ *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.asset.v1; diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/AssetServiceClient.java index b46ebfd01..d9c031a10 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/AssetServiceClient.java @@ -41,6 +41,18 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+ *   String scope = "scope109264468";
+ *   String query = "query107944136";
+ *   List assetTypes = new ArrayList<>();
+ *   for (StandardResourceMetadata element :
+ *       assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
+ *     // doThingsWith(element);
+ *   }
+ * }
+ * }
+ * *

Note: close() needs to be called on the AssetServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -148,6 +160,20 @@ public AssetServiceStub getStub() { * cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be * rejected. * + *

Sample code: + * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List assetTypes = new ArrayList<>();
+   *   for (StandardResourceMetadata element :
+   *       assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param scope Required. The relative name of an asset. The search is limited to the resources * within the `scope`. The allowed value must be: *
    @@ -181,6 +207,26 @@ public final SearchAllResourcesPagedResponse searchAllResources( * cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be * rejected. * + *

    Sample code: + * + *

    {@code
    +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
    +   *   SearchAllResourcesRequest request =
    +   *       SearchAllResourcesRequest.newBuilder()
    +   *           .setScope("scope109264468")
    +   *           .setQuery("query107944136")
    +   *           .addAllAssetTypes(new ArrayList())
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .setOrderBy("orderBy-1207110587")
    +   *           .build();
    +   *   for (StandardResourceMetadata element :
    +   *       assetServiceClient.searchAllResources(request).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @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 */ @@ -198,6 +244,26 @@ public final SearchAllResourcesPagedResponse searchAllResources( * rejected. * *

    Sample code: + * + *

    {@code
    +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
    +   *   SearchAllResourcesRequest request =
    +   *       SearchAllResourcesRequest.newBuilder()
    +   *           .setScope("scope109264468")
    +   *           .setQuery("query107944136")
    +   *           .addAllAssetTypes(new ArrayList())
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .setOrderBy("orderBy-1207110587")
    +   *           .build();
    +   *   ApiFuture future =
    +   *       assetServiceClient.searchAllResourcesPagedCallable().futureCall(request);
    +   *   // Do something.
    +   *   for (StandardResourceMetadata element : future.get().iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable searchAllResourcesPagedCallable() { @@ -213,6 +279,24 @@ public final SearchAllResourcesPagedResponse searchAllResources( * rejected. * *

    Sample code: + * + *

    {@code
    +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
    +   *   while (true) {
    +   *     SearchAllResourcesResponse response =
    +   *         assetServiceClient.searchAllResourcesCallable().call(request);
    +   *     for (StandardResourceMetadata element : response.getResponsesList()) {
    +   *       // doThingsWith(element);
    +   *     }
    +   *     String nextPageToken = response.getNextPageToken();
    +   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
    +   *       request = request.toBuilder().setPageToken(nextPageToken).build();
    +   *     } else {
    +   *       break;
    +   *     }
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable searchAllResourcesCallable() { @@ -227,6 +311,19 @@ public final SearchAllResourcesPagedResponse searchAllResources( * have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be * rejected. * + *

    Sample code: + * + *

    {@code
    +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
    +   *   String scope = "scope109264468";
    +   *   String query = "query107944136";
    +   *   for (IamPolicySearchResult element :
    +   *       assetServiceClient.searchAllIamPolicies(scope, query).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param scope Required. The relative name of an asset. The search is limited to the resources * within the `scope`. The allowed value must be: *
      @@ -258,6 +355,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope * have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be * rejected. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   SearchAllIamPoliciesRequest request =
      +   *       SearchAllIamPoliciesRequest.newBuilder()
      +   *           .setScope("scope109264468")
      +   *           .setQuery("query107944136")
      +   *           .setPageSize(883849137)
      +   *           .setPageToken("pageToken873572522")
      +   *           .build();
      +   *   for (IamPolicySearchResult element :
      +   *       assetServiceClient.searchAllIamPolicies(request).iterateAll()) {
      +   *     // doThingsWith(element);
      +   *   }
      +   * }
      +   * }
      + * * @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 */ @@ -275,6 +390,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( * rejected. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   SearchAllIamPoliciesRequest request =
      +   *       SearchAllIamPoliciesRequest.newBuilder()
      +   *           .setScope("scope109264468")
      +   *           .setQuery("query107944136")
      +   *           .setPageSize(883849137)
      +   *           .setPageToken("pageToken873572522")
      +   *           .build();
      +   *   ApiFuture future =
      +   *       assetServiceClient.searchAllIamPoliciesPagedCallable().futureCall(request);
      +   *   // Do something.
      +   *   for (IamPolicySearchResult element : future.get().iterateAll()) {
      +   *     // doThingsWith(element);
      +   *   }
      +   * }
      +   * }
      */ public final UnaryCallable searchAllIamPoliciesPagedCallable() { @@ -290,6 +423,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( * rejected. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   while (true) {
      +   *     SearchAllIamPoliciesResponse response =
      +   *         assetServiceClient.searchAllIamPoliciesCallable().call(request);
      +   *     for (IamPolicySearchResult element : response.getResponsesList()) {
      +   *       // doThingsWith(element);
      +   *     }
      +   *     String nextPageToken = response.getNextPageToken();
      +   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
      +   *       request = request.toBuilder().setPageToken(nextPageToken).build();
      +   *     } else {
      +   *       break;
      +   *     }
      +   *   }
      +   * }
      +   * }
      */ public final UnaryCallable searchAllIamPoliciesCallable() { diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/package-info.java index 429d478f7..2f0fd3989 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/package-info.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/package-info.java @@ -22,6 +22,18 @@ *

      Service Description: Asset service definition. * *

      Sample for AssetServiceClient: + * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   String scope = "scope109264468";
      + *   String query = "query107944136";
      + *   List assetTypes = new ArrayList<>();
      + *   for (StandardResourceMetadata element :
      + *       assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
      + *     // doThingsWith(element);
      + *   }
      + * }
      + * }
      */ @Generated("by gapic-generator-java") package com.google.cloud.asset.v1p1beta1; diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java index 20863a34f..d190cb945 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java @@ -33,6 +33,13 @@ *

      This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   String parent = "parent-995424086";
      + *   Feed response = assetServiceClient.createFeed(parent);
      + * }
      + * }
      + * *

      Note: close() needs to be called on the AssetServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -136,6 +143,15 @@ public AssetServiceStub getStub() { /** * Creates a feed in a parent project/folder/organization to listen to its asset updates. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   String parent = "parent-995424086";
      +   *   Feed response = assetServiceClient.createFeed(parent);
      +   * }
      +   * }
      + * * @param parent Required. The name of the project/folder/organization where this feed should be * created in. It can only be an organization number (such as "organizations/123"), a folder * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a @@ -151,6 +167,20 @@ public final Feed createFeed(String parent) { /** * Creates a feed in a parent project/folder/organization to listen to its asset updates. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   CreateFeedRequest request =
      +   *       CreateFeedRequest.newBuilder()
      +   *           .setParent("parent-995424086")
      +   *           .setFeedId("feedId-1278410919")
      +   *           .setFeed(Feed.newBuilder().build())
      +   *           .build();
      +   *   Feed response = assetServiceClient.createFeed(request);
      +   * }
      +   * }
      + * * @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 */ @@ -163,6 +193,20 @@ public final Feed createFeed(CreateFeedRequest request) { * Creates a feed in a parent project/folder/organization to listen to its asset updates. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   CreateFeedRequest request =
      +   *       CreateFeedRequest.newBuilder()
      +   *           .setParent("parent-995424086")
      +   *           .setFeedId("feedId-1278410919")
      +   *           .setFeed(Feed.newBuilder().build())
      +   *           .build();
      +   *   ApiFuture future = assetServiceClient.createFeedCallable().futureCall(request);
      +   *   // Do something.
      +   *   Feed response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable createFeedCallable() { return stub.createFeedCallable(); @@ -172,6 +216,15 @@ public final UnaryCallable createFeedCallable() { /** * Gets details about an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
      +   *   Feed response = assetServiceClient.getFeed(name);
      +   * }
      +   * }
      + * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -187,6 +240,15 @@ public final Feed getFeed(FeedName name) { /** * Gets details about an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   String name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString();
      +   *   Feed response = assetServiceClient.getFeed(name);
      +   * }
      +   * }
      + * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -201,6 +263,18 @@ public final Feed getFeed(String name) { /** * Gets details about an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   GetFeedRequest request =
      +   *       GetFeedRequest.newBuilder()
      +   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
      +   *           .build();
      +   *   Feed response = assetServiceClient.getFeed(request);
      +   * }
      +   * }
      + * * @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 */ @@ -213,6 +287,18 @@ public final Feed getFeed(GetFeedRequest request) { * Gets details about an asset feed. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   GetFeedRequest request =
      +   *       GetFeedRequest.newBuilder()
      +   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
      +   *           .build();
      +   *   ApiFuture future = assetServiceClient.getFeedCallable().futureCall(request);
      +   *   // Do something.
      +   *   Feed response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable getFeedCallable() { return stub.getFeedCallable(); @@ -222,6 +308,15 @@ public final UnaryCallable getFeedCallable() { /** * Lists all asset feeds in a parent project/folder/organization. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   String parent = "parent-995424086";
      +   *   ListFeedsResponse response = assetServiceClient.listFeeds(parent);
      +   * }
      +   * }
      + * * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It * can only be using project/folder/organization number (such as "folders/12345")", or a * project ID (such as "projects/my-project-id"). @@ -236,6 +331,16 @@ public final ListFeedsResponse listFeeds(String parent) { /** * Lists all asset feeds in a parent project/folder/organization. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ListFeedsRequest request =
      +   *       ListFeedsRequest.newBuilder().setParent("parent-995424086").build();
      +   *   ListFeedsResponse response = assetServiceClient.listFeeds(request);
      +   * }
      +   * }
      + * * @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 */ @@ -248,6 +353,17 @@ public final ListFeedsResponse listFeeds(ListFeedsRequest request) { * Lists all asset feeds in a parent project/folder/organization. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ListFeedsRequest request =
      +   *       ListFeedsRequest.newBuilder().setParent("parent-995424086").build();
      +   *   ApiFuture future =
      +   *       assetServiceClient.listFeedsCallable().futureCall(request);
      +   *   // Do something.
      +   *   ListFeedsResponse response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable listFeedsCallable() { return stub.listFeedsCallable(); @@ -257,6 +373,15 @@ public final UnaryCallable listFeedsCallabl /** * Updates an asset feed configuration. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   Feed feed = Feed.newBuilder().build();
      +   *   Feed response = assetServiceClient.updateFeed(feed);
      +   * }
      +   * }
      + * * @param feed Required. The new values of feed details. It must match an existing feed and the * field `name` must be in the format of: projects/project_number/feeds/feed_id or * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. @@ -271,6 +396,19 @@ public final Feed updateFeed(Feed feed) { /** * Updates an asset feed configuration. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   UpdateFeedRequest request =
      +   *       UpdateFeedRequest.newBuilder()
      +   *           .setFeed(Feed.newBuilder().build())
      +   *           .setUpdateMask(FieldMask.newBuilder().build())
      +   *           .build();
      +   *   Feed response = assetServiceClient.updateFeed(request);
      +   * }
      +   * }
      + * * @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 */ @@ -283,6 +421,19 @@ public final Feed updateFeed(UpdateFeedRequest request) { * Updates an asset feed configuration. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   UpdateFeedRequest request =
      +   *       UpdateFeedRequest.newBuilder()
      +   *           .setFeed(Feed.newBuilder().build())
      +   *           .setUpdateMask(FieldMask.newBuilder().build())
      +   *           .build();
      +   *   ApiFuture future = assetServiceClient.updateFeedCallable().futureCall(request);
      +   *   // Do something.
      +   *   Feed response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable updateFeedCallable() { return stub.updateFeedCallable(); @@ -292,6 +443,15 @@ public final UnaryCallable updateFeedCallable() { /** * Deletes an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
      +   *   assetServiceClient.deleteFeed(name);
      +   * }
      +   * }
      + * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -307,6 +467,15 @@ public final void deleteFeed(FeedName name) { /** * Deletes an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   String name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString();
      +   *   assetServiceClient.deleteFeed(name);
      +   * }
      +   * }
      + * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -321,6 +490,18 @@ public final void deleteFeed(String name) { /** * Deletes an asset feed. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   DeleteFeedRequest request =
      +   *       DeleteFeedRequest.newBuilder()
      +   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
      +   *           .build();
      +   *   assetServiceClient.deleteFeed(request);
      +   * }
      +   * }
      + * * @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 */ @@ -333,6 +514,18 @@ public final void deleteFeed(DeleteFeedRequest request) { * Deletes an asset feed. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   DeleteFeedRequest request =
      +   *       DeleteFeedRequest.newBuilder()
      +   *           .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString())
      +   *           .build();
      +   *   ApiFuture future = assetServiceClient.deleteFeedCallable().futureCall(request);
      +   *   // Do something.
      +   *   future.get();
      +   * }
      +   * }
      */ public final UnaryCallable deleteFeedCallable() { return stub.deleteFeedCallable(); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java index b09af0ea3..c69243663 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java @@ -22,6 +22,13 @@ *

      Service Description: Asset service definition. * *

      Sample for AssetServiceClient: + * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   String parent = "parent-995424086";
      + *   Feed response = assetServiceClient.createFeed(parent);
      + * }
      + * }
      */ @Generated("by gapic-generator-java") package com.google.cloud.asset.v1p2beta1; diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java index 94e4b7d12..8c08c5ebe 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java @@ -36,6 +36,17 @@ *

      This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   AnalyzeIamPolicyRequest request =
      + *       AnalyzeIamPolicyRequest.newBuilder()
      + *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      + *           .setOptions(AnalyzeIamPolicyRequest.Options.newBuilder().build())
      + *           .build();
      + *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
      + * }
      + * }
      + * *

      Note: close() needs to be called on the AssetServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -152,6 +163,19 @@ public final OperationsClient getOperationsClient() { * [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the * request. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   AnalyzeIamPolicyRequest request =
      +   *       AnalyzeIamPolicyRequest.newBuilder()
      +   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      +   *           .setOptions(AnalyzeIamPolicyRequest.Options.newBuilder().build())
      +   *           .build();
      +   *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
      +   * }
      +   * }
      + * * @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 */ @@ -166,6 +190,20 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * request. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   AnalyzeIamPolicyRequest request =
      +   *       AnalyzeIamPolicyRequest.newBuilder()
      +   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      +   *           .setOptions(AnalyzeIamPolicyRequest.Options.newBuilder().build())
      +   *           .build();
      +   *   ApiFuture future =
      +   *       assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
      +   *   // Do something.
      +   *   AnalyzeIamPolicyResponse response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable analyzeIamPolicyCallable() { @@ -178,6 +216,21 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of * the export. The metadata contains the request to help callers to map responses to requests. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ExportIamPolicyAnalysisRequest request =
      +   *       ExportIamPolicyAnalysisRequest.newBuilder()
      +   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      +   *           .setOptions(ExportIamPolicyAnalysisRequest.Options.newBuilder().build())
      +   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
      +   *           .build();
      +   *   ExportIamPolicyAnalysisResponse response =
      +   *       assetServiceClient.exportIamPolicyAnalysisAsync(request).get();
      +   * }
      +   * }
      + * * @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 */ @@ -193,6 +246,21 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * the export. The metadata contains the request to help callers to map responses to requests. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ExportIamPolicyAnalysisRequest request =
      +   *       ExportIamPolicyAnalysisRequest.newBuilder()
      +   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      +   *           .setOptions(ExportIamPolicyAnalysisRequest.Options.newBuilder().build())
      +   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
      +   *           .build();
      +   *   OperationFuture future =
      +   *       assetServiceClient.exportIamPolicyAnalysisOperationCallable().futureCall(request);
      +   *   // Do something.
      +   *   ExportIamPolicyAnalysisResponse response = future.get();
      +   * }
      +   * }
      */ public final OperationCallable< ExportIamPolicyAnalysisRequest, @@ -209,6 +277,21 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r * the export. The metadata contains the request to help callers to map responses to requests. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ExportIamPolicyAnalysisRequest request =
      +   *       ExportIamPolicyAnalysisRequest.newBuilder()
      +   *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      +   *           .setOptions(ExportIamPolicyAnalysisRequest.Options.newBuilder().build())
      +   *           .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
      +   *           .build();
      +   *   ApiFuture future =
      +   *       assetServiceClient.exportIamPolicyAnalysisCallable().futureCall(request);
      +   *   // Do something.
      +   *   Operation response = future.get();
      +   * }
      +   * }
      */ public final UnaryCallable exportIamPolicyAnalysisCallable() { diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/package-info.java index c5f6b23c4..e9d1e3891 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/package-info.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/package-info.java @@ -22,6 +22,17 @@ *

      Service Description: Asset service definition. * *

      Sample for AssetServiceClient: + * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   AnalyzeIamPolicyRequest request =
      + *       AnalyzeIamPolicyRequest.newBuilder()
      + *           .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
      + *           .setOptions(AnalyzeIamPolicyRequest.Options.newBuilder().build())
      + *           .build();
      + *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
      + * }
      + * }
      */ @Generated("by gapic-generator-java") package com.google.cloud.asset.v1p4beta1; diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/AssetServiceClient.java index 4195826b4..22aba80c9 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/AssetServiceClient.java @@ -41,6 +41,22 @@ *

      This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   ListAssetsRequest request =
      + *       ListAssetsRequest.newBuilder()
      + *           .setParent("parent-995424086")
      + *           .setReadTime(Timestamp.newBuilder().build())
      + *           .addAllAssetTypes(new ArrayList())
      + *           .setPageSize(883849137)
      + *           .setPageToken("pageToken873572522")
      + *           .build();
      + *   for (Asset element : assetServiceClient.listAssets(request).iterateAll()) {
      + *     // doThingsWith(element);
      + *   }
      + * }
      + * }
      + * *

      Note: close() needs to be called on the AssetServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -144,6 +160,24 @@ public AssetServiceStub getStub() { /** * Lists assets with time and resource types and returns paged results in response. * + *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ListAssetsRequest request =
      +   *       ListAssetsRequest.newBuilder()
      +   *           .setParent("parent-995424086")
      +   *           .setReadTime(Timestamp.newBuilder().build())
      +   *           .addAllAssetTypes(new ArrayList())
      +   *           .setPageSize(883849137)
      +   *           .setPageToken("pageToken873572522")
      +   *           .build();
      +   *   for (Asset element : assetServiceClient.listAssets(request).iterateAll()) {
      +   *     // doThingsWith(element);
      +   *   }
      +   * }
      +   * }
      + * * @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 */ @@ -156,6 +190,24 @@ public final ListAssetsPagedResponse listAssets(ListAssetsRequest request) { * Lists assets with time and resource types and returns paged results in response. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   ListAssetsRequest request =
      +   *       ListAssetsRequest.newBuilder()
      +   *           .setParent("parent-995424086")
      +   *           .setReadTime(Timestamp.newBuilder().build())
      +   *           .addAllAssetTypes(new ArrayList())
      +   *           .setPageSize(883849137)
      +   *           .setPageToken("pageToken873572522")
      +   *           .build();
      +   *   ApiFuture future = assetServiceClient.listAssetsPagedCallable().futureCall(request);
      +   *   // Do something.
      +   *   for (Asset element : future.get().iterateAll()) {
      +   *     // doThingsWith(element);
      +   *   }
      +   * }
      +   * }
      */ public final UnaryCallable listAssetsPagedCallable() { return stub.listAssetsPagedCallable(); @@ -166,6 +218,23 @@ public final UnaryCallable listAsset * Lists assets with time and resource types and returns paged results in response. * *

      Sample code: + * + *

      {@code
      +   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      +   *   while (true) {
      +   *     ListAssetsResponse response = assetServiceClient.listAssetsCallable().call(request);
      +   *     for (Asset element : response.getResponsesList()) {
      +   *       // doThingsWith(element);
      +   *     }
      +   *     String nextPageToken = response.getNextPageToken();
      +   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
      +   *       request = request.toBuilder().setPageToken(nextPageToken).build();
      +   *     } else {
      +   *       break;
      +   *     }
      +   *   }
      +   * }
      +   * }
      */ public final UnaryCallable listAssetsCallable() { return stub.listAssetsCallable(); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/package-info.java index 36080a7b8..41161ad88 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/package-info.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p5beta1/package-info.java @@ -22,6 +22,22 @@ *

      Service Description: Asset service definition. * *

      Sample for AssetServiceClient: + * + *

      {@code
      + * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
      + *   ListAssetsRequest request =
      + *       ListAssetsRequest.newBuilder()
      + *           .setParent("parent-995424086")
      + *           .setReadTime(Timestamp.newBuilder().build())
      + *           .addAllAssetTypes(new ArrayList())
      + *           .setPageSize(883849137)
      + *           .setPageToken("pageToken873572522")
      + *           .build();
      + *   for (Asset element : assetServiceClient.listAssets(request).iterateAll()) {
      + *     // doThingsWith(element);
      + *   }
      + * }
      + * }
      */ @Generated("by gapic-generator-java") package com.google.cloud.asset.v1p5beta1; diff --git a/synth.metadata b/synth.metadata index fdf3b2d3d..1498cf493 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,40 +11,40 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {