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

Commit 4dbc2e9

Browse files
docs: generate sample code in the Java microgenerator (#540)
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
1 parent c4f7672 commit 4dbc2e9

File tree

11 files changed

+1046
-10
lines changed

11 files changed

+1046
-10
lines changed

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

Lines changed: 482 additions & 0 deletions
Large diffs are not rendered by default.

google-cloud-asset/src/main/java/com/google/cloud/asset/v1/package-info.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
* <p>Service Description: Asset service definition.
2323
*
2424
* <p>Sample for AssetServiceClient:
25+
*
26+
* <pre>{@code
27+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
28+
* BatchGetAssetsHistoryRequest request =
29+
* BatchGetAssetsHistoryRequest.newBuilder()
30+
* .setParent(ProjectName.of("[PROJECT]").toString())
31+
* .addAllAssetNames(new ArrayList<String>())
32+
* .setReadTimeWindow(TimeWindow.newBuilder().build())
33+
* .build();
34+
* BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
35+
* }
36+
* }</pre>
2537
*/
2638
@Generated("by gapic-generator-java")
2739
package com.google.cloud.asset.v1;

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

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
* <p>This class provides the ability to make remote calls to the backing service through method
4242
* calls that map to API methods. Sample code to get started:
4343
*
44+
* <pre>{@code
45+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
46+
* String scope = "scope109264468";
47+
* String query = "query107944136";
48+
* List<String> assetTypes = new ArrayList<>();
49+
* for (StandardResourceMetadata element :
50+
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
51+
* // doThingsWith(element);
52+
* }
53+
* }
54+
* }</pre>
55+
*
4456
* <p>Note: close() needs to be called on the AssetServiceClient object to clean up resources such
4557
* as threads. In the example above, try-with-resources is used, which automatically calls close().
4658
*
@@ -148,6 +160,20 @@ public AssetServiceStub getStub() {
148160
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
149161
* rejected.
150162
*
163+
* <p>Sample code:
164+
*
165+
* <pre>{@code
166+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
167+
* String scope = "scope109264468";
168+
* String query = "query107944136";
169+
* List<String> assetTypes = new ArrayList<>();
170+
* for (StandardResourceMetadata element :
171+
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
172+
* // doThingsWith(element);
173+
* }
174+
* }
175+
* }</pre>
176+
*
151177
* @param scope Required. The relative name of an asset. The search is limited to the resources
152178
* within the `scope`. The allowed value must be:
153179
* <ul>
@@ -181,6 +207,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
181207
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
182208
* rejected.
183209
*
210+
* <p>Sample code:
211+
*
212+
* <pre>{@code
213+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
214+
* SearchAllResourcesRequest request =
215+
* SearchAllResourcesRequest.newBuilder()
216+
* .setScope("scope109264468")
217+
* .setQuery("query107944136")
218+
* .addAllAssetTypes(new ArrayList<String>())
219+
* .setPageSize(883849137)
220+
* .setPageToken("pageToken873572522")
221+
* .setOrderBy("orderBy-1207110587")
222+
* .build();
223+
* for (StandardResourceMetadata element :
224+
* assetServiceClient.searchAllResources(request).iterateAll()) {
225+
* // doThingsWith(element);
226+
* }
227+
* }
228+
* }</pre>
229+
*
184230
* @param request The request object containing all of the parameters for the API call.
185231
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
186232
*/
@@ -198,6 +244,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
198244
* rejected.
199245
*
200246
* <p>Sample code:
247+
*
248+
* <pre>{@code
249+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
250+
* SearchAllResourcesRequest request =
251+
* SearchAllResourcesRequest.newBuilder()
252+
* .setScope("scope109264468")
253+
* .setQuery("query107944136")
254+
* .addAllAssetTypes(new ArrayList<String>())
255+
* .setPageSize(883849137)
256+
* .setPageToken("pageToken873572522")
257+
* .setOrderBy("orderBy-1207110587")
258+
* .build();
259+
* ApiFuture<StandardResourceMetadata> future =
260+
* assetServiceClient.searchAllResourcesPagedCallable().futureCall(request);
261+
* // Do something.
262+
* for (StandardResourceMetadata element : future.get().iterateAll()) {
263+
* // doThingsWith(element);
264+
* }
265+
* }
266+
* }</pre>
201267
*/
202268
public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesPagedResponse>
203269
searchAllResourcesPagedCallable() {
@@ -213,6 +279,24 @@ public final SearchAllResourcesPagedResponse searchAllResources(
213279
* rejected.
214280
*
215281
* <p>Sample code:
282+
*
283+
* <pre>{@code
284+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
285+
* while (true) {
286+
* SearchAllResourcesResponse response =
287+
* assetServiceClient.searchAllResourcesCallable().call(request);
288+
* for (StandardResourceMetadata element : response.getResponsesList()) {
289+
* // doThingsWith(element);
290+
* }
291+
* String nextPageToken = response.getNextPageToken();
292+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
293+
* request = request.toBuilder().setPageToken(nextPageToken).build();
294+
* } else {
295+
* break;
296+
* }
297+
* }
298+
* }
299+
* }</pre>
216300
*/
217301
public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesResponse>
218302
searchAllResourcesCallable() {
@@ -227,6 +311,19 @@ public final SearchAllResourcesPagedResponse searchAllResources(
227311
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
228312
* rejected.
229313
*
314+
* <p>Sample code:
315+
*
316+
* <pre>{@code
317+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
318+
* String scope = "scope109264468";
319+
* String query = "query107944136";
320+
* for (IamPolicySearchResult element :
321+
* assetServiceClient.searchAllIamPolicies(scope, query).iterateAll()) {
322+
* // doThingsWith(element);
323+
* }
324+
* }
325+
* }</pre>
326+
*
230327
* @param scope Required. The relative name of an asset. The search is limited to the resources
231328
* within the `scope`. The allowed value must be:
232329
* <ul>
@@ -258,6 +355,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope
258355
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
259356
* rejected.
260357
*
358+
* <p>Sample code:
359+
*
360+
* <pre>{@code
361+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
362+
* SearchAllIamPoliciesRequest request =
363+
* SearchAllIamPoliciesRequest.newBuilder()
364+
* .setScope("scope109264468")
365+
* .setQuery("query107944136")
366+
* .setPageSize(883849137)
367+
* .setPageToken("pageToken873572522")
368+
* .build();
369+
* for (IamPolicySearchResult element :
370+
* assetServiceClient.searchAllIamPolicies(request).iterateAll()) {
371+
* // doThingsWith(element);
372+
* }
373+
* }
374+
* }</pre>
375+
*
261376
* @param request The request object containing all of the parameters for the API call.
262377
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
263378
*/
@@ -275,6 +390,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
275390
* rejected.
276391
*
277392
* <p>Sample code:
393+
*
394+
* <pre>{@code
395+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
396+
* SearchAllIamPoliciesRequest request =
397+
* SearchAllIamPoliciesRequest.newBuilder()
398+
* .setScope("scope109264468")
399+
* .setQuery("query107944136")
400+
* .setPageSize(883849137)
401+
* .setPageToken("pageToken873572522")
402+
* .build();
403+
* ApiFuture<IamPolicySearchResult> future =
404+
* assetServiceClient.searchAllIamPoliciesPagedCallable().futureCall(request);
405+
* // Do something.
406+
* for (IamPolicySearchResult element : future.get().iterateAll()) {
407+
* // doThingsWith(element);
408+
* }
409+
* }
410+
* }</pre>
278411
*/
279412
public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesPagedResponse>
280413
searchAllIamPoliciesPagedCallable() {
@@ -290,6 +423,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
290423
* rejected.
291424
*
292425
* <p>Sample code:
426+
*
427+
* <pre>{@code
428+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
429+
* while (true) {
430+
* SearchAllIamPoliciesResponse response =
431+
* assetServiceClient.searchAllIamPoliciesCallable().call(request);
432+
* for (IamPolicySearchResult element : response.getResponsesList()) {
433+
* // doThingsWith(element);
434+
* }
435+
* String nextPageToken = response.getNextPageToken();
436+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
437+
* request = request.toBuilder().setPageToken(nextPageToken).build();
438+
* } else {
439+
* break;
440+
* }
441+
* }
442+
* }
443+
* }</pre>
293444
*/
294445
public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse>
295446
searchAllIamPoliciesCallable() {

google-cloud-asset/src/main/java/com/google/cloud/asset/v1p1beta1/package-info.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
* <p>Service Description: Asset service definition.
2323
*
2424
* <p>Sample for AssetServiceClient:
25+
*
26+
* <pre>{@code
27+
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
28+
* String scope = "scope109264468";
29+
* String query = "query107944136";
30+
* List<String> assetTypes = new ArrayList<>();
31+
* for (StandardResourceMetadata element :
32+
* assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) {
33+
* // doThingsWith(element);
34+
* }
35+
* }
36+
* }</pre>
2537
*/
2638
@Generated("by gapic-generator-java")
2739
package com.google.cloud.asset.v1p1beta1;

0 commit comments

Comments
 (0)