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

Commit

Permalink
docs: generate sample code in the Java microgenerator (#540)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/0ae55182-06f0-43ed-98b1-1c835bf4b2f1/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 356341083
Source-Link: googleapis/googleapis@8d8c008
  • Loading branch information
yoshi-automation committed Feb 16, 2021
1 parent c4f7672 commit 4dbc2e9
Show file tree
Hide file tree
Showing 11 changed files with 1,046 additions and 10 deletions.

Large diffs are not rendered by default.

Expand Up @@ -22,6 +22,18 @@
* <p>Service Description: Asset service definition.
*
* <p>Sample for AssetServiceClient:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* BatchGetAssetsHistoryRequest request =
* BatchGetAssetsHistoryRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .addAllAssetNames(new ArrayList<String>())
* .setReadTimeWindow(TimeWindow.newBuilder().build())
* .build();
* BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.asset.v1;
Expand Down
Expand Up @@ -41,6 +41,18 @@
* <p>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:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* String scope = "scope109264468";
* String query = "query107944136";
* List<String> assetTypes = new ArrayList<>();
* for (StandardResourceMetadata element :
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* <p>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().
*
Expand Down Expand Up @@ -148,6 +160,20 @@ public AssetServiceStub getStub() {
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
* rejected.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* String scope = "scope109264468";
* String query = "query107944136";
* List<String> assetTypes = new ArrayList<>();
* for (StandardResourceMetadata element :
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param scope Required. The relative name of an asset. The search is limited to the resources
* within the `scope`. The allowed value must be:
* <ul>
Expand Down Expand Up @@ -181,6 +207,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
* rejected.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* SearchAllResourcesRequest request =
* SearchAllResourcesRequest.newBuilder()
* .setScope("scope109264468")
* .setQuery("query107944136")
* .addAllAssetTypes(new ArrayList<String>())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setOrderBy("orderBy-1207110587")
* .build();
* for (StandardResourceMetadata element :
* assetServiceClient.searchAllResources(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</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
*/
Expand All @@ -198,6 +244,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
* rejected.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* SearchAllResourcesRequest request =
* SearchAllResourcesRequest.newBuilder()
* .setScope("scope109264468")
* .setQuery("query107944136")
* .addAllAssetTypes(new ArrayList<String>())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setOrderBy("orderBy-1207110587")
* .build();
* ApiFuture<StandardResourceMetadata> future =
* assetServiceClient.searchAllResourcesPagedCallable().futureCall(request);
* // Do something.
* for (StandardResourceMetadata element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesPagedResponse>
searchAllResourcesPagedCallable() {
Expand All @@ -213,6 +279,24 @@ public final SearchAllResourcesPagedResponse searchAllResources(
* rejected.
*
* <p>Sample code:
*
* <pre>{@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;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesResponse>
searchAllResourcesCallable() {
Expand All @@ -227,6 +311,19 @@ public final SearchAllResourcesPagedResponse searchAllResources(
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
* rejected.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* String scope = "scope109264468";
* String query = "query107944136";
* for (IamPolicySearchResult element :
* assetServiceClient.searchAllIamPolicies(scope, query).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param scope Required. The relative name of an asset. The search is limited to the resources
* within the `scope`. The allowed value must be:
* <ul>
Expand Down Expand Up @@ -258,6 +355,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
* rejected.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</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
*/
Expand All @@ -275,6 +390,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
* rejected.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* SearchAllIamPoliciesRequest request =
* SearchAllIamPoliciesRequest.newBuilder()
* .setScope("scope109264468")
* .setQuery("query107944136")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture<IamPolicySearchResult> future =
* assetServiceClient.searchAllIamPoliciesPagedCallable().futureCall(request);
* // Do something.
* for (IamPolicySearchResult element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesPagedResponse>
searchAllIamPoliciesPagedCallable() {
Expand All @@ -290,6 +423,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
* rejected.
*
* <p>Sample code:
*
* <pre>{@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;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse>
searchAllIamPoliciesCallable() {
Expand Down
Expand Up @@ -22,6 +22,18 @@
* <p>Service Description: Asset service definition.
*
* <p>Sample for AssetServiceClient:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* String scope = "scope109264468";
* String query = "query107944136";
* List<String> assetTypes = new ArrayList<>();
* for (StandardResourceMetadata element :
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.asset.v1p1beta1;
Expand Down

0 comments on commit 4dbc2e9

Please sign in to comment.