1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.asset.v1p1beta1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.paging.AbstractFixedSizeCollection; 24 import com.google.api.gax.paging.AbstractPage; 25 import com.google.api.gax.paging.AbstractPagedListResponse; 26 import com.google.api.gax.rpc.PageContext; 27 import com.google.api.gax.rpc.UnaryCallable; 28 import com.google.cloud.asset.v1p1beta1.stub.AssetServiceStub; 29 import com.google.cloud.asset.v1p1beta1.stub.AssetServiceStubSettings; 30 import com.google.common.util.concurrent.MoreExecutors; 31 import java.io.IOException; 32 import java.util.List; 33 import java.util.concurrent.TimeUnit; 34 import javax.annotation.Generated; 35 36 // AUTO-GENERATED DOCUMENTATION AND CLASS. 37 /** 38 * Service Description: Asset service definition. 39 * 40 * <p>This class provides the ability to make remote calls to the backing service through method 41 * calls that map to API methods. Sample code to get started: 42 * 43 * <pre>{@code 44 * // This snippet has been automatically generated and should be regarded as a code template only. 45 * // It will require modifications to work: 46 * // - It may require correct/in-range values for request initialization. 47 * // - It may require specifying regional endpoints when creating the service client as shown in 48 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 49 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 50 * String scope = "scope109264468"; 51 * String query = "query107944136"; 52 * List<String> assetTypes = new ArrayList<>(); 53 * for (StandardResourceMetadata element : 54 * assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) { 55 * // doThingsWith(element); 56 * } 57 * } 58 * }</pre> 59 * 60 * <p>Note: close() needs to be called on the AssetServiceClient object to clean up resources such 61 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 62 * 63 * <p>The surface of this class includes several types of Java methods for each of the API's 64 * methods: 65 * 66 * <ol> 67 * <li>A "flattened" method. With this type of method, the fields of the request type have been 68 * converted into function parameters. It may be the case that not all fields are available as 69 * parameters, and not every API method will have a flattened method entry point. 70 * <li>A "request object" method. This type of method only takes one parameter, a request object, 71 * which must be constructed before the call. Not every API method will have a request object 72 * method. 73 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 74 * callable object, which can be used to initiate calls to the service. 75 * </ol> 76 * 77 * <p>See the individual methods for example code. 78 * 79 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 80 * these names, this class includes a format method for each type of name, and additionally a parse 81 * method to extract the individual identifiers contained within names that are returned. 82 * 83 * <p>This class can be customized by passing in a custom instance of AssetServiceSettings to 84 * create(). For example: 85 * 86 * <p>To customize credentials: 87 * 88 * <pre>{@code 89 * // This snippet has been automatically generated and should be regarded as a code template only. 90 * // It will require modifications to work: 91 * // - It may require correct/in-range values for request initialization. 92 * // - It may require specifying regional endpoints when creating the service client as shown in 93 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 94 * AssetServiceSettings assetServiceSettings = 95 * AssetServiceSettings.newBuilder() 96 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 97 * .build(); 98 * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings); 99 * }</pre> 100 * 101 * <p>To customize the endpoint: 102 * 103 * <pre>{@code 104 * // This snippet has been automatically generated and should be regarded as a code template only. 105 * // It will require modifications to work: 106 * // - It may require correct/in-range values for request initialization. 107 * // - It may require specifying regional endpoints when creating the service client as shown in 108 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 109 * AssetServiceSettings assetServiceSettings = 110 * AssetServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 111 * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings); 112 * }</pre> 113 * 114 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 115 * the wire: 116 * 117 * <pre>{@code 118 * // This snippet has been automatically generated and should be regarded as a code template only. 119 * // It will require modifications to work: 120 * // - It may require correct/in-range values for request initialization. 121 * // - It may require specifying regional endpoints when creating the service client as shown in 122 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 123 * AssetServiceSettings assetServiceSettings = AssetServiceSettings.newHttpJsonBuilder().build(); 124 * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings); 125 * }</pre> 126 * 127 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 128 */ 129 @BetaApi 130 @Generated("by gapic-generator-java") 131 public class AssetServiceClient implements BackgroundResource { 132 private final AssetServiceSettings settings; 133 private final AssetServiceStub stub; 134 135 /** Constructs an instance of AssetServiceClient with default settings. */ create()136 public static final AssetServiceClient create() throws IOException { 137 return create(AssetServiceSettings.newBuilder().build()); 138 } 139 140 /** 141 * Constructs an instance of AssetServiceClient, using the given settings. The channels are 142 * created based on the settings passed in, or defaults for any settings that are not set. 143 */ create(AssetServiceSettings settings)144 public static final AssetServiceClient create(AssetServiceSettings settings) throws IOException { 145 return new AssetServiceClient(settings); 146 } 147 148 /** 149 * Constructs an instance of AssetServiceClient, using the given stub for making calls. This is 150 * for advanced usage - prefer using create(AssetServiceSettings). 151 */ create(AssetServiceStub stub)152 public static final AssetServiceClient create(AssetServiceStub stub) { 153 return new AssetServiceClient(stub); 154 } 155 156 /** 157 * Constructs an instance of AssetServiceClient, using the given settings. This is protected so 158 * that it is easy to make a subclass, but otherwise, the static factory methods should be 159 * preferred. 160 */ AssetServiceClient(AssetServiceSettings settings)161 protected AssetServiceClient(AssetServiceSettings settings) throws IOException { 162 this.settings = settings; 163 this.stub = ((AssetServiceStubSettings) settings.getStubSettings()).createStub(); 164 } 165 AssetServiceClient(AssetServiceStub stub)166 protected AssetServiceClient(AssetServiceStub stub) { 167 this.settings = null; 168 this.stub = stub; 169 } 170 getSettings()171 public final AssetServiceSettings getSettings() { 172 return settings; 173 } 174 getStub()175 public AssetServiceStub getStub() { 176 return stub; 177 } 178 179 // AUTO-GENERATED DOCUMENTATION AND METHOD. 180 /** 181 * Searches all the resources within a given accessible Resource Manager scope 182 * (project/folder/organization). This RPC gives callers especially administrators the ability to 183 * search all the resources within a scope, even if they don't have `.get` permission of all the 184 * resources. Callers should have `cloud.assets.SearchAllResources` permission on the requested 185 * scope, otherwise the request will be rejected. 186 * 187 * <p>Sample code: 188 * 189 * <pre>{@code 190 * // This snippet has been automatically generated and should be regarded as a code template only. 191 * // It will require modifications to work: 192 * // - It may require correct/in-range values for request initialization. 193 * // - It may require specifying regional endpoints when creating the service client as shown in 194 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 195 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 196 * String scope = "scope109264468"; 197 * String query = "query107944136"; 198 * List<String> assetTypes = new ArrayList<>(); 199 * for (StandardResourceMetadata element : 200 * assetServiceClient.searchAllResources(scope, query, assetTypes).iterateAll()) { 201 * // doThingsWith(element); 202 * } 203 * } 204 * }</pre> 205 * 206 * @param scope Required. The relative name of an asset. The search is limited to the resources 207 * within the `scope`. The allowed value must be: 208 * <ul> 209 * <li>Organization number (such as "organizations/123") 210 * <li>Folder number (such as "folders/1234") 211 * <li>Project number (such as "projects/12345") 212 * <li>Project ID (such as "projects/abc") 213 * </ul> 214 * 215 * @param query Optional. The query statement. 216 * @param assetTypes Optional. A list of asset types that this request searches for. If empty, it 217 * will search all the supported asset types. 218 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 219 */ searchAllResources( String scope, String query, List<String> assetTypes)220 public final SearchAllResourcesPagedResponse searchAllResources( 221 String scope, String query, List<String> assetTypes) { 222 SearchAllResourcesRequest request = 223 SearchAllResourcesRequest.newBuilder() 224 .setScope(scope) 225 .setQuery(query) 226 .addAllAssetTypes(assetTypes) 227 .build(); 228 return searchAllResources(request); 229 } 230 231 // AUTO-GENERATED DOCUMENTATION AND METHOD. 232 /** 233 * Searches all the resources within a given accessible Resource Manager scope 234 * (project/folder/organization). This RPC gives callers especially administrators the ability to 235 * search all the resources within a scope, even if they don't have `.get` permission of all the 236 * resources. Callers should have `cloud.assets.SearchAllResources` permission on the requested 237 * scope, otherwise the request will be rejected. 238 * 239 * <p>Sample code: 240 * 241 * <pre>{@code 242 * // This snippet has been automatically generated and should be regarded as a code template only. 243 * // It will require modifications to work: 244 * // - It may require correct/in-range values for request initialization. 245 * // - It may require specifying regional endpoints when creating the service client as shown in 246 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 247 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 248 * SearchAllResourcesRequest request = 249 * SearchAllResourcesRequest.newBuilder() 250 * .setScope("scope109264468") 251 * .setQuery("query107944136") 252 * .addAllAssetTypes(new ArrayList<String>()) 253 * .setPageSize(883849137) 254 * .setPageToken("pageToken873572522") 255 * .setOrderBy("orderBy-1207110587") 256 * .build(); 257 * for (StandardResourceMetadata element : 258 * assetServiceClient.searchAllResources(request).iterateAll()) { 259 * // doThingsWith(element); 260 * } 261 * } 262 * }</pre> 263 * 264 * @param request The request object containing all of the parameters for the API call. 265 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 266 */ searchAllResources( SearchAllResourcesRequest request)267 public final SearchAllResourcesPagedResponse searchAllResources( 268 SearchAllResourcesRequest request) { 269 return searchAllResourcesPagedCallable().call(request); 270 } 271 272 // AUTO-GENERATED DOCUMENTATION AND METHOD. 273 /** 274 * Searches all the resources within a given accessible Resource Manager scope 275 * (project/folder/organization). This RPC gives callers especially administrators the ability to 276 * search all the resources within a scope, even if they don't have `.get` permission of all the 277 * resources. Callers should have `cloud.assets.SearchAllResources` permission on the requested 278 * scope, otherwise the request will be rejected. 279 * 280 * <p>Sample code: 281 * 282 * <pre>{@code 283 * // This snippet has been automatically generated and should be regarded as a code template only. 284 * // It will require modifications to work: 285 * // - It may require correct/in-range values for request initialization. 286 * // - It may require specifying regional endpoints when creating the service client as shown in 287 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 288 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 289 * SearchAllResourcesRequest request = 290 * SearchAllResourcesRequest.newBuilder() 291 * .setScope("scope109264468") 292 * .setQuery("query107944136") 293 * .addAllAssetTypes(new ArrayList<String>()) 294 * .setPageSize(883849137) 295 * .setPageToken("pageToken873572522") 296 * .setOrderBy("orderBy-1207110587") 297 * .build(); 298 * ApiFuture<StandardResourceMetadata> future = 299 * assetServiceClient.searchAllResourcesPagedCallable().futureCall(request); 300 * // Do something. 301 * for (StandardResourceMetadata element : future.get().iterateAll()) { 302 * // doThingsWith(element); 303 * } 304 * } 305 * }</pre> 306 */ 307 public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesPagedResponse> searchAllResourcesPagedCallable()308 searchAllResourcesPagedCallable() { 309 return stub.searchAllResourcesPagedCallable(); 310 } 311 312 // AUTO-GENERATED DOCUMENTATION AND METHOD. 313 /** 314 * Searches all the resources within a given accessible Resource Manager scope 315 * (project/folder/organization). This RPC gives callers especially administrators the ability to 316 * search all the resources within a scope, even if they don't have `.get` permission of all the 317 * resources. Callers should have `cloud.assets.SearchAllResources` permission on the requested 318 * scope, otherwise the request will be rejected. 319 * 320 * <p>Sample code: 321 * 322 * <pre>{@code 323 * // This snippet has been automatically generated and should be regarded as a code template only. 324 * // It will require modifications to work: 325 * // - It may require correct/in-range values for request initialization. 326 * // - It may require specifying regional endpoints when creating the service client as shown in 327 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 328 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 329 * SearchAllResourcesRequest request = 330 * SearchAllResourcesRequest.newBuilder() 331 * .setScope("scope109264468") 332 * .setQuery("query107944136") 333 * .addAllAssetTypes(new ArrayList<String>()) 334 * .setPageSize(883849137) 335 * .setPageToken("pageToken873572522") 336 * .setOrderBy("orderBy-1207110587") 337 * .build(); 338 * while (true) { 339 * SearchAllResourcesResponse response = 340 * assetServiceClient.searchAllResourcesCallable().call(request); 341 * for (StandardResourceMetadata element : response.getResultsList()) { 342 * // doThingsWith(element); 343 * } 344 * String nextPageToken = response.getNextPageToken(); 345 * if (!Strings.isNullOrEmpty(nextPageToken)) { 346 * request = request.toBuilder().setPageToken(nextPageToken).build(); 347 * } else { 348 * break; 349 * } 350 * } 351 * } 352 * }</pre> 353 */ 354 public final UnaryCallable<SearchAllResourcesRequest, SearchAllResourcesResponse> searchAllResourcesCallable()355 searchAllResourcesCallable() { 356 return stub.searchAllResourcesCallable(); 357 } 358 359 // AUTO-GENERATED DOCUMENTATION AND METHOD. 360 /** 361 * Searches all the IAM policies within a given accessible Resource Manager scope 362 * (project/folder/organization). This RPC gives callers especially administrators the ability to 363 * search all the IAM policies within a scope, even if they don't have `.getIamPolicy` permission 364 * of all the IAM policies. Callers should have `cloud.assets.SearchAllIamPolicies` permission on 365 * the requested scope, otherwise the request will be rejected. 366 * 367 * <p>Sample code: 368 * 369 * <pre>{@code 370 * // This snippet has been automatically generated and should be regarded as a code template only. 371 * // It will require modifications to work: 372 * // - It may require correct/in-range values for request initialization. 373 * // - It may require specifying regional endpoints when creating the service client as shown in 374 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 375 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 376 * String scope = "scope109264468"; 377 * String query = "query107944136"; 378 * for (IamPolicySearchResult element : 379 * assetServiceClient.searchAllIamPolicies(scope, query).iterateAll()) { 380 * // doThingsWith(element); 381 * } 382 * } 383 * }</pre> 384 * 385 * @param scope Required. The relative name of an asset. The search is limited to the resources 386 * within the `scope`. The allowed value must be: 387 * <ul> 388 * <li>Organization number (such as "organizations/123") 389 * <li>Folder number (such as "folders/1234") 390 * <li>Project number (such as "projects/12345") 391 * <li>Project ID (such as "projects/abc") 392 * </ul> 393 * 394 * @param query Optional. The query statement. Examples: 395 * <ul> 396 * <li>"policy:myuser{@literal @}mydomain.com" 397 * <li>"policy:(myuser{@literal @}mydomain.com viewer)" 398 * </ul> 399 * 400 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 401 */ searchAllIamPolicies(String scope, String query)402 public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope, String query) { 403 SearchAllIamPoliciesRequest request = 404 SearchAllIamPoliciesRequest.newBuilder().setScope(scope).setQuery(query).build(); 405 return searchAllIamPolicies(request); 406 } 407 408 // AUTO-GENERATED DOCUMENTATION AND METHOD. 409 /** 410 * Searches all the IAM policies within a given accessible Resource Manager scope 411 * (project/folder/organization). This RPC gives callers especially administrators the ability to 412 * search all the IAM policies within a scope, even if they don't have `.getIamPolicy` permission 413 * of all the IAM policies. Callers should have `cloud.assets.SearchAllIamPolicies` permission on 414 * the requested scope, otherwise the request will be rejected. 415 * 416 * <p>Sample code: 417 * 418 * <pre>{@code 419 * // This snippet has been automatically generated and should be regarded as a code template only. 420 * // It will require modifications to work: 421 * // - It may require correct/in-range values for request initialization. 422 * // - It may require specifying regional endpoints when creating the service client as shown in 423 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 424 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 425 * SearchAllIamPoliciesRequest request = 426 * SearchAllIamPoliciesRequest.newBuilder() 427 * .setScope("scope109264468") 428 * .setQuery("query107944136") 429 * .setPageSize(883849137) 430 * .setPageToken("pageToken873572522") 431 * .build(); 432 * for (IamPolicySearchResult element : 433 * assetServiceClient.searchAllIamPolicies(request).iterateAll()) { 434 * // doThingsWith(element); 435 * } 436 * } 437 * }</pre> 438 * 439 * @param request The request object containing all of the parameters for the API call. 440 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 441 */ searchAllIamPolicies( SearchAllIamPoliciesRequest request)442 public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( 443 SearchAllIamPoliciesRequest request) { 444 return searchAllIamPoliciesPagedCallable().call(request); 445 } 446 447 // AUTO-GENERATED DOCUMENTATION AND METHOD. 448 /** 449 * Searches all the IAM policies within a given accessible Resource Manager scope 450 * (project/folder/organization). This RPC gives callers especially administrators the ability to 451 * search all the IAM policies within a scope, even if they don't have `.getIamPolicy` permission 452 * of all the IAM policies. Callers should have `cloud.assets.SearchAllIamPolicies` permission on 453 * the requested scope, otherwise the request will be rejected. 454 * 455 * <p>Sample code: 456 * 457 * <pre>{@code 458 * // This snippet has been automatically generated and should be regarded as a code template only. 459 * // It will require modifications to work: 460 * // - It may require correct/in-range values for request initialization. 461 * // - It may require specifying regional endpoints when creating the service client as shown in 462 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 463 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 464 * SearchAllIamPoliciesRequest request = 465 * SearchAllIamPoliciesRequest.newBuilder() 466 * .setScope("scope109264468") 467 * .setQuery("query107944136") 468 * .setPageSize(883849137) 469 * .setPageToken("pageToken873572522") 470 * .build(); 471 * ApiFuture<IamPolicySearchResult> future = 472 * assetServiceClient.searchAllIamPoliciesPagedCallable().futureCall(request); 473 * // Do something. 474 * for (IamPolicySearchResult element : future.get().iterateAll()) { 475 * // doThingsWith(element); 476 * } 477 * } 478 * }</pre> 479 */ 480 public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesPagedResponse> searchAllIamPoliciesPagedCallable()481 searchAllIamPoliciesPagedCallable() { 482 return stub.searchAllIamPoliciesPagedCallable(); 483 } 484 485 // AUTO-GENERATED DOCUMENTATION AND METHOD. 486 /** 487 * Searches all the IAM policies within a given accessible Resource Manager scope 488 * (project/folder/organization). This RPC gives callers especially administrators the ability to 489 * search all the IAM policies within a scope, even if they don't have `.getIamPolicy` permission 490 * of all the IAM policies. Callers should have `cloud.assets.SearchAllIamPolicies` permission on 491 * the requested scope, otherwise the request will be rejected. 492 * 493 * <p>Sample code: 494 * 495 * <pre>{@code 496 * // This snippet has been automatically generated and should be regarded as a code template only. 497 * // It will require modifications to work: 498 * // - It may require correct/in-range values for request initialization. 499 * // - It may require specifying regional endpoints when creating the service client as shown in 500 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 501 * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) { 502 * SearchAllIamPoliciesRequest request = 503 * SearchAllIamPoliciesRequest.newBuilder() 504 * .setScope("scope109264468") 505 * .setQuery("query107944136") 506 * .setPageSize(883849137) 507 * .setPageToken("pageToken873572522") 508 * .build(); 509 * while (true) { 510 * SearchAllIamPoliciesResponse response = 511 * assetServiceClient.searchAllIamPoliciesCallable().call(request); 512 * for (IamPolicySearchResult element : response.getResultsList()) { 513 * // doThingsWith(element); 514 * } 515 * String nextPageToken = response.getNextPageToken(); 516 * if (!Strings.isNullOrEmpty(nextPageToken)) { 517 * request = request.toBuilder().setPageToken(nextPageToken).build(); 518 * } else { 519 * break; 520 * } 521 * } 522 * } 523 * }</pre> 524 */ 525 public final UnaryCallable<SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse> searchAllIamPoliciesCallable()526 searchAllIamPoliciesCallable() { 527 return stub.searchAllIamPoliciesCallable(); 528 } 529 530 @Override close()531 public final void close() { 532 stub.close(); 533 } 534 535 @Override shutdown()536 public void shutdown() { 537 stub.shutdown(); 538 } 539 540 @Override isShutdown()541 public boolean isShutdown() { 542 return stub.isShutdown(); 543 } 544 545 @Override isTerminated()546 public boolean isTerminated() { 547 return stub.isTerminated(); 548 } 549 550 @Override shutdownNow()551 public void shutdownNow() { 552 stub.shutdownNow(); 553 } 554 555 @Override awaitTermination(long duration, TimeUnit unit)556 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 557 return stub.awaitTermination(duration, unit); 558 } 559 560 public static class SearchAllResourcesPagedResponse 561 extends AbstractPagedListResponse< 562 SearchAllResourcesRequest, 563 SearchAllResourcesResponse, 564 StandardResourceMetadata, 565 SearchAllResourcesPage, 566 SearchAllResourcesFixedSizeCollection> { 567 createAsync( PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> context, ApiFuture<SearchAllResourcesResponse> futureResponse)568 public static ApiFuture<SearchAllResourcesPagedResponse> createAsync( 569 PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> 570 context, 571 ApiFuture<SearchAllResourcesResponse> futureResponse) { 572 ApiFuture<SearchAllResourcesPage> futurePage = 573 SearchAllResourcesPage.createEmptyPage().createPageAsync(context, futureResponse); 574 return ApiFutures.transform( 575 futurePage, 576 input -> new SearchAllResourcesPagedResponse(input), 577 MoreExecutors.directExecutor()); 578 } 579 SearchAllResourcesPagedResponse(SearchAllResourcesPage page)580 private SearchAllResourcesPagedResponse(SearchAllResourcesPage page) { 581 super(page, SearchAllResourcesFixedSizeCollection.createEmptyCollection()); 582 } 583 } 584 585 public static class SearchAllResourcesPage 586 extends AbstractPage< 587 SearchAllResourcesRequest, 588 SearchAllResourcesResponse, 589 StandardResourceMetadata, 590 SearchAllResourcesPage> { 591 SearchAllResourcesPage( PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> context, SearchAllResourcesResponse response)592 private SearchAllResourcesPage( 593 PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> 594 context, 595 SearchAllResourcesResponse response) { 596 super(context, response); 597 } 598 createEmptyPage()599 private static SearchAllResourcesPage createEmptyPage() { 600 return new SearchAllResourcesPage(null, null); 601 } 602 603 @Override createPage( PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> context, SearchAllResourcesResponse response)604 protected SearchAllResourcesPage createPage( 605 PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> 606 context, 607 SearchAllResourcesResponse response) { 608 return new SearchAllResourcesPage(context, response); 609 } 610 611 @Override createPageAsync( PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> context, ApiFuture<SearchAllResourcesResponse> futureResponse)612 public ApiFuture<SearchAllResourcesPage> createPageAsync( 613 PageContext<SearchAllResourcesRequest, SearchAllResourcesResponse, StandardResourceMetadata> 614 context, 615 ApiFuture<SearchAllResourcesResponse> futureResponse) { 616 return super.createPageAsync(context, futureResponse); 617 } 618 } 619 620 public static class SearchAllResourcesFixedSizeCollection 621 extends AbstractFixedSizeCollection< 622 SearchAllResourcesRequest, 623 SearchAllResourcesResponse, 624 StandardResourceMetadata, 625 SearchAllResourcesPage, 626 SearchAllResourcesFixedSizeCollection> { 627 SearchAllResourcesFixedSizeCollection( List<SearchAllResourcesPage> pages, int collectionSize)628 private SearchAllResourcesFixedSizeCollection( 629 List<SearchAllResourcesPage> pages, int collectionSize) { 630 super(pages, collectionSize); 631 } 632 createEmptyCollection()633 private static SearchAllResourcesFixedSizeCollection createEmptyCollection() { 634 return new SearchAllResourcesFixedSizeCollection(null, 0); 635 } 636 637 @Override createCollection( List<SearchAllResourcesPage> pages, int collectionSize)638 protected SearchAllResourcesFixedSizeCollection createCollection( 639 List<SearchAllResourcesPage> pages, int collectionSize) { 640 return new SearchAllResourcesFixedSizeCollection(pages, collectionSize); 641 } 642 } 643 644 public static class SearchAllIamPoliciesPagedResponse 645 extends AbstractPagedListResponse< 646 SearchAllIamPoliciesRequest, 647 SearchAllIamPoliciesResponse, 648 IamPolicySearchResult, 649 SearchAllIamPoliciesPage, 650 SearchAllIamPoliciesFixedSizeCollection> { 651 createAsync( PageContext< SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> context, ApiFuture<SearchAllIamPoliciesResponse> futureResponse)652 public static ApiFuture<SearchAllIamPoliciesPagedResponse> createAsync( 653 PageContext< 654 SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> 655 context, 656 ApiFuture<SearchAllIamPoliciesResponse> futureResponse) { 657 ApiFuture<SearchAllIamPoliciesPage> futurePage = 658 SearchAllIamPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); 659 return ApiFutures.transform( 660 futurePage, 661 input -> new SearchAllIamPoliciesPagedResponse(input), 662 MoreExecutors.directExecutor()); 663 } 664 SearchAllIamPoliciesPagedResponse(SearchAllIamPoliciesPage page)665 private SearchAllIamPoliciesPagedResponse(SearchAllIamPoliciesPage page) { 666 super(page, SearchAllIamPoliciesFixedSizeCollection.createEmptyCollection()); 667 } 668 } 669 670 public static class SearchAllIamPoliciesPage 671 extends AbstractPage< 672 SearchAllIamPoliciesRequest, 673 SearchAllIamPoliciesResponse, 674 IamPolicySearchResult, 675 SearchAllIamPoliciesPage> { 676 SearchAllIamPoliciesPage( PageContext< SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> context, SearchAllIamPoliciesResponse response)677 private SearchAllIamPoliciesPage( 678 PageContext< 679 SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> 680 context, 681 SearchAllIamPoliciesResponse response) { 682 super(context, response); 683 } 684 createEmptyPage()685 private static SearchAllIamPoliciesPage createEmptyPage() { 686 return new SearchAllIamPoliciesPage(null, null); 687 } 688 689 @Override createPage( PageContext< SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> context, SearchAllIamPoliciesResponse response)690 protected SearchAllIamPoliciesPage createPage( 691 PageContext< 692 SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> 693 context, 694 SearchAllIamPoliciesResponse response) { 695 return new SearchAllIamPoliciesPage(context, response); 696 } 697 698 @Override createPageAsync( PageContext< SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> context, ApiFuture<SearchAllIamPoliciesResponse> futureResponse)699 public ApiFuture<SearchAllIamPoliciesPage> createPageAsync( 700 PageContext< 701 SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> 702 context, 703 ApiFuture<SearchAllIamPoliciesResponse> futureResponse) { 704 return super.createPageAsync(context, futureResponse); 705 } 706 } 707 708 public static class SearchAllIamPoliciesFixedSizeCollection 709 extends AbstractFixedSizeCollection< 710 SearchAllIamPoliciesRequest, 711 SearchAllIamPoliciesResponse, 712 IamPolicySearchResult, 713 SearchAllIamPoliciesPage, 714 SearchAllIamPoliciesFixedSizeCollection> { 715 SearchAllIamPoliciesFixedSizeCollection( List<SearchAllIamPoliciesPage> pages, int collectionSize)716 private SearchAllIamPoliciesFixedSizeCollection( 717 List<SearchAllIamPoliciesPage> pages, int collectionSize) { 718 super(pages, collectionSize); 719 } 720 createEmptyCollection()721 private static SearchAllIamPoliciesFixedSizeCollection createEmptyCollection() { 722 return new SearchAllIamPoliciesFixedSizeCollection(null, 0); 723 } 724 725 @Override createCollection( List<SearchAllIamPoliciesPage> pages, int collectionSize)726 protected SearchAllIamPoliciesFixedSizeCollection createCollection( 727 List<SearchAllIamPoliciesPage> pages, int collectionSize) { 728 return new SearchAllIamPoliciesFixedSizeCollection(pages, collectionSize); 729 } 730 } 731 } 732