41
41
* <p>This class provides the ability to make remote calls to the backing service through method
42
42
* calls that map to API methods. Sample code to get started:
43
43
*
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
+ *
44
56
* <p>Note: close() needs to be called on the AssetServiceClient object to clean up resources such
45
57
* as threads. In the example above, try-with-resources is used, which automatically calls close().
46
58
*
@@ -148,6 +160,20 @@ public AssetServiceStub getStub() {
148
160
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
149
161
* rejected.
150
162
*
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
+ *
151
177
* @param scope Required. The relative name of an asset. The search is limited to the resources
152
178
* within the `scope`. The allowed value must be:
153
179
* <ul>
@@ -181,6 +207,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
181
207
* cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be
182
208
* rejected.
183
209
*
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
+ *
184
230
* @param request The request object containing all of the parameters for the API call.
185
231
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
186
232
*/
@@ -198,6 +244,26 @@ public final SearchAllResourcesPagedResponse searchAllResources(
198
244
* rejected.
199
245
*
200
246
* <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>
201
267
*/
202
268
public final UnaryCallable <SearchAllResourcesRequest , SearchAllResourcesPagedResponse >
203
269
searchAllResourcesPagedCallable () {
@@ -213,6 +279,24 @@ public final SearchAllResourcesPagedResponse searchAllResources(
213
279
* rejected.
214
280
*
215
281
* <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>
216
300
*/
217
301
public final UnaryCallable <SearchAllResourcesRequest , SearchAllResourcesResponse >
218
302
searchAllResourcesCallable () {
@@ -227,6 +311,19 @@ public final SearchAllResourcesPagedResponse searchAllResources(
227
311
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
228
312
* rejected.
229
313
*
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
+ *
230
327
* @param scope Required. The relative name of an asset. The search is limited to the resources
231
328
* within the `scope`. The allowed value must be:
232
329
* <ul>
@@ -258,6 +355,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope
258
355
* have cloud.assets.SearchAllIamPolicies permission on the requested scope, otherwise it will be
259
356
* rejected.
260
357
*
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
+ *
261
376
* @param request The request object containing all of the parameters for the API call.
262
377
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
263
378
*/
@@ -275,6 +390,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
275
390
* rejected.
276
391
*
277
392
* <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>
278
411
*/
279
412
public final UnaryCallable <SearchAllIamPoliciesRequest , SearchAllIamPoliciesPagedResponse >
280
413
searchAllIamPoliciesPagedCallable () {
@@ -290,6 +423,24 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
290
423
* rejected.
291
424
*
292
425
* <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>
293
444
*/
294
445
public final UnaryCallable <SearchAllIamPoliciesRequest , SearchAllIamPoliciesResponse >
295
446
searchAllIamPoliciesCallable () {
0 commit comments