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.showcase.v1beta1; 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.httpjson.longrunning.OperationsClient; 24 import com.google.api.gax.longrunning.OperationFuture; 25 import com.google.api.gax.paging.AbstractFixedSizeCollection; 26 import com.google.api.gax.paging.AbstractPage; 27 import com.google.api.gax.paging.AbstractPagedListResponse; 28 import com.google.api.gax.rpc.BidiStreamingCallable; 29 import com.google.api.gax.rpc.ClientStreamingCallable; 30 import com.google.api.gax.rpc.OperationCallable; 31 import com.google.api.gax.rpc.PageContext; 32 import com.google.api.gax.rpc.ServerStreamingCallable; 33 import com.google.api.gax.rpc.UnaryCallable; 34 import com.google.cloud.location.GetLocationRequest; 35 import com.google.cloud.location.ListLocationsRequest; 36 import com.google.cloud.location.ListLocationsResponse; 37 import com.google.cloud.location.Location; 38 import com.google.common.util.concurrent.MoreExecutors; 39 import com.google.longrunning.Operation; 40 import com.google.showcase.v1beta1.stub.EchoStub; 41 import com.google.showcase.v1beta1.stub.EchoStubSettings; 42 import java.io.IOException; 43 import java.util.List; 44 import java.util.Map; 45 import java.util.concurrent.TimeUnit; 46 import javax.annotation.Generated; 47 48 // AUTO-GENERATED DOCUMENTATION AND CLASS. 49 /** 50 * Service Description: This service is used showcase the four main types of rpcs - unary, server 51 * side streaming, client side streaming, and bidirectional streaming. This service also exposes 52 * methods that explicitly implement server delay, and paginated calls. Set the 'showcase-trailer' 53 * metadata key on any method to have the values echoed in the response trailers. Set the 54 * 'x-goog-request-params' metadata key on any method to have the values echoed in the response 55 * headers. 56 * 57 * <p>This class provides the ability to make remote calls to the backing service through method 58 * calls that map to API methods. Sample code to get started: 59 * 60 * <pre>{@code 61 * // This snippet has been automatically generated and should be regarded as a code template only. 62 * // It will require modifications to work: 63 * // - It may require correct/in-range values for request initialization. 64 * // - It may require specifying regional endpoints when creating the service client as shown in 65 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 66 * try (EchoClient echoClient = EchoClient.create()) { 67 * EchoRequest request = 68 * EchoRequest.newBuilder() 69 * .setSeverity(Severity.forNumber(0)) 70 * .setHeader("header-1221270899") 71 * .setOtherHeader("otherHeader-2026585667") 72 * .build(); 73 * EchoResponse response = echoClient.echo(request); 74 * } 75 * }</pre> 76 * 77 * <p>Note: close() needs to be called on the EchoClient object to clean up resources such as 78 * threads. In the example above, try-with-resources is used, which automatically calls close(). 79 * 80 * <p>The surface of this class includes several types of Java methods for each of the API's 81 * methods: 82 * 83 * <ol> 84 * <li>A "flattened" method. With this type of method, the fields of the request type have been 85 * converted into function parameters. It may be the case that not all fields are available as 86 * parameters, and not every API method will have a flattened method entry point. 87 * <li>A "request object" method. This type of method only takes one parameter, a request object, 88 * which must be constructed before the call. Not every API method will have a request object 89 * method. 90 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 91 * callable object, which can be used to initiate calls to the service. 92 * </ol> 93 * 94 * <p>See the individual methods for example code. 95 * 96 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 97 * these names, this class includes a format method for each type of name, and additionally a parse 98 * method to extract the individual identifiers contained within names that are returned. 99 * 100 * <p>This class can be customized by passing in a custom instance of EchoSettings to create(). For 101 * example: 102 * 103 * <p>To customize credentials: 104 * 105 * <pre>{@code 106 * // This snippet has been automatically generated and should be regarded as a code template only. 107 * // It will require modifications to work: 108 * // - It may require correct/in-range values for request initialization. 109 * // - It may require specifying regional endpoints when creating the service client as shown in 110 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 111 * EchoSettings echoSettings = 112 * EchoSettings.newBuilder() 113 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 114 * .build(); 115 * EchoClient echoClient = EchoClient.create(echoSettings); 116 * }</pre> 117 * 118 * <p>To customize the endpoint: 119 * 120 * <pre>{@code 121 * // This snippet has been automatically generated and should be regarded as a code template only. 122 * // It will require modifications to work: 123 * // - It may require correct/in-range values for request initialization. 124 * // - It may require specifying regional endpoints when creating the service client as shown in 125 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 126 * EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint(myEndpoint).build(); 127 * EchoClient echoClient = EchoClient.create(echoSettings); 128 * }</pre> 129 * 130 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 131 * the wire: 132 * 133 * <pre>{@code 134 * // This snippet has been automatically generated and should be regarded as a code template only. 135 * // It will require modifications to work: 136 * // - It may require correct/in-range values for request initialization. 137 * // - It may require specifying regional endpoints when creating the service client as shown in 138 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 139 * EchoSettings echoSettings = EchoSettings.newHttpJsonBuilder().build(); 140 * EchoClient echoClient = EchoClient.create(echoSettings); 141 * }</pre> 142 * 143 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 144 */ 145 @BetaApi 146 @Generated("by gapic-generator-java") 147 public class EchoClient implements BackgroundResource { 148 private final EchoSettings settings; 149 private final EchoStub stub; 150 private final OperationsClient httpJsonOperationsClient; 151 private final com.google.longrunning.OperationsClient operationsClient; 152 153 /** Constructs an instance of EchoClient with default settings. */ create()154 public static final EchoClient create() throws IOException { 155 return create(EchoSettings.newBuilder().build()); 156 } 157 158 /** 159 * Constructs an instance of EchoClient, using the given settings. The channels are created based 160 * on the settings passed in, or defaults for any settings that are not set. 161 */ create(EchoSettings settings)162 public static final EchoClient create(EchoSettings settings) throws IOException { 163 return new EchoClient(settings); 164 } 165 166 /** 167 * Constructs an instance of EchoClient, using the given stub for making calls. This is for 168 * advanced usage - prefer using create(EchoSettings). 169 */ create(EchoStub stub)170 public static final EchoClient create(EchoStub stub) { 171 return new EchoClient(stub); 172 } 173 174 /** 175 * Constructs an instance of EchoClient, using the given settings. This is protected so that it is 176 * easy to make a subclass, but otherwise, the static factory methods should be preferred. 177 */ EchoClient(EchoSettings settings)178 protected EchoClient(EchoSettings settings) throws IOException { 179 this.settings = settings; 180 this.stub = ((EchoStubSettings) settings.getStubSettings()).createStub(); 181 this.operationsClient = 182 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 183 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 184 } 185 EchoClient(EchoStub stub)186 protected EchoClient(EchoStub stub) { 187 this.settings = null; 188 this.stub = stub; 189 this.operationsClient = 190 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 191 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 192 } 193 getSettings()194 public final EchoSettings getSettings() { 195 return settings; 196 } 197 getStub()198 public EchoStub getStub() { 199 return stub; 200 } 201 202 /** 203 * Returns the OperationsClient that can be used to query the status of a long-running operation 204 * returned by another API method call. 205 */ getOperationsClient()206 public final com.google.longrunning.OperationsClient getOperationsClient() { 207 return operationsClient; 208 } 209 210 /** 211 * Returns the OperationsClient that can be used to query the status of a long-running operation 212 * returned by another API method call. 213 */ 214 @BetaApi getHttpJsonOperationsClient()215 public final OperationsClient getHttpJsonOperationsClient() { 216 return httpJsonOperationsClient; 217 } 218 219 // AUTO-GENERATED DOCUMENTATION AND METHOD. 220 /** 221 * This method simply echoes the request. This method showcases unary RPCs. 222 * 223 * <p>Sample code: 224 * 225 * <pre>{@code 226 * // This snippet has been automatically generated and should be regarded as a code template only. 227 * // It will require modifications to work: 228 * // - It may require correct/in-range values for request initialization. 229 * // - It may require specifying regional endpoints when creating the service client as shown in 230 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 231 * try (EchoClient echoClient = EchoClient.create()) { 232 * EchoRequest request = 233 * EchoRequest.newBuilder() 234 * .setSeverity(Severity.forNumber(0)) 235 * .setHeader("header-1221270899") 236 * .setOtherHeader("otherHeader-2026585667") 237 * .build(); 238 * EchoResponse response = echoClient.echo(request); 239 * } 240 * }</pre> 241 * 242 * @param request The request object containing all of the parameters for the API call. 243 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 244 */ echo(EchoRequest request)245 public final EchoResponse echo(EchoRequest request) { 246 return echoCallable().call(request); 247 } 248 249 // AUTO-GENERATED DOCUMENTATION AND METHOD. 250 /** 251 * This method simply echoes the request. This method showcases unary RPCs. 252 * 253 * <p>Sample code: 254 * 255 * <pre>{@code 256 * // This snippet has been automatically generated and should be regarded as a code template only. 257 * // It will require modifications to work: 258 * // - It may require correct/in-range values for request initialization. 259 * // - It may require specifying regional endpoints when creating the service client as shown in 260 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 261 * try (EchoClient echoClient = EchoClient.create()) { 262 * EchoRequest request = 263 * EchoRequest.newBuilder() 264 * .setSeverity(Severity.forNumber(0)) 265 * .setHeader("header-1221270899") 266 * .setOtherHeader("otherHeader-2026585667") 267 * .build(); 268 * ApiFuture<EchoResponse> future = echoClient.echoCallable().futureCall(request); 269 * // Do something. 270 * EchoResponse response = future.get(); 271 * } 272 * }</pre> 273 */ echoCallable()274 public final UnaryCallable<EchoRequest, EchoResponse> echoCallable() { 275 return stub.echoCallable(); 276 } 277 278 // AUTO-GENERATED DOCUMENTATION AND METHOD. 279 /** 280 * This method splits the given content into words and will pass each word back through the 281 * stream. This method showcases server-side streaming RPCs. 282 * 283 * <p>Sample code: 284 * 285 * <pre>{@code 286 * // This snippet has been automatically generated and should be regarded as a code template only. 287 * // It will require modifications to work: 288 * // - It may require correct/in-range values for request initialization. 289 * // - It may require specifying regional endpoints when creating the service client as shown in 290 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 291 * try (EchoClient echoClient = EchoClient.create()) { 292 * ExpandRequest request = 293 * ExpandRequest.newBuilder() 294 * .setContent("content951530617") 295 * .setError(Status.newBuilder().build()) 296 * .build(); 297 * ServerStream<EchoResponse> stream = echoClient.expandCallable().call(request); 298 * for (EchoResponse response : stream) { 299 * // Do something when a response is received. 300 * } 301 * } 302 * }</pre> 303 */ expandCallable()304 public final ServerStreamingCallable<ExpandRequest, EchoResponse> expandCallable() { 305 return stub.expandCallable(); 306 } 307 308 // AUTO-GENERATED DOCUMENTATION AND METHOD. 309 /** 310 * This method will collect the words given to it. When the stream is closed by the client, this 311 * method will return the a concatenation of the strings passed to it. This method showcases 312 * client-side streaming RPCs. 313 * 314 * <p>Sample code: 315 * 316 * <pre>{@code 317 * // This snippet has been automatically generated and should be regarded as a code template only. 318 * // It will require modifications to work: 319 * // - It may require correct/in-range values for request initialization. 320 * // - It may require specifying regional endpoints when creating the service client as shown in 321 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 322 * try (EchoClient echoClient = EchoClient.create()) { 323 * ApiStreamObserver<EchoRequest> responseObserver = 324 * new ApiStreamObserver<EchoRequest>() { 325 * {@literal @}Override 326 * public void onNext(EchoResponse response) { 327 * // Do something when a response is received. 328 * } 329 * 330 * {@literal @}Override 331 * public void onError(Throwable t) { 332 * // Add error-handling 333 * } 334 * 335 * {@literal @}Override 336 * public void onCompleted() { 337 * // Do something when complete. 338 * } 339 * }; 340 * ApiStreamObserver<EchoRequest> requestObserver = 341 * echoClient.collect().clientStreamingCall(responseObserver); 342 * EchoRequest request = 343 * EchoRequest.newBuilder() 344 * .setSeverity(Severity.forNumber(0)) 345 * .setHeader("header-1221270899") 346 * .setOtherHeader("otherHeader-2026585667") 347 * .build(); 348 * requestObserver.onNext(request); 349 * } 350 * }</pre> 351 */ collectCallable()352 public final ClientStreamingCallable<EchoRequest, EchoResponse> collectCallable() { 353 return stub.collectCallable(); 354 } 355 356 // AUTO-GENERATED DOCUMENTATION AND METHOD. 357 /** 358 * This method, upon receiving a request on the stream, will pass the same content back on the 359 * stream. This method showcases bidirectional streaming RPCs. 360 * 361 * <p>Sample code: 362 * 363 * <pre>{@code 364 * // This snippet has been automatically generated and should be regarded as a code template only. 365 * // It will require modifications to work: 366 * // - It may require correct/in-range values for request initialization. 367 * // - It may require specifying regional endpoints when creating the service client as shown in 368 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 369 * try (EchoClient echoClient = EchoClient.create()) { 370 * BidiStream<EchoRequest, EchoResponse> bidiStream = echoClient.chatCallable().call(); 371 * EchoRequest request = 372 * EchoRequest.newBuilder() 373 * .setSeverity(Severity.forNumber(0)) 374 * .setHeader("header-1221270899") 375 * .setOtherHeader("otherHeader-2026585667") 376 * .build(); 377 * bidiStream.send(request); 378 * for (EchoResponse response : bidiStream) { 379 * // Do something when a response is received. 380 * } 381 * } 382 * }</pre> 383 */ chatCallable()384 public final BidiStreamingCallable<EchoRequest, EchoResponse> chatCallable() { 385 return stub.chatCallable(); 386 } 387 388 // AUTO-GENERATED DOCUMENTATION AND METHOD. 389 /** 390 * This is similar to the Expand method but instead of returning a stream of expanded words, this 391 * method returns a paged list of expanded words. 392 * 393 * <p>Sample code: 394 * 395 * <pre>{@code 396 * // This snippet has been automatically generated and should be regarded as a code template only. 397 * // It will require modifications to work: 398 * // - It may require correct/in-range values for request initialization. 399 * // - It may require specifying regional endpoints when creating the service client as shown in 400 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 401 * try (EchoClient echoClient = EchoClient.create()) { 402 * PagedExpandRequest request = 403 * PagedExpandRequest.newBuilder() 404 * .setContent("content951530617") 405 * .setPageSize(883849137) 406 * .setPageToken("pageToken873572522") 407 * .build(); 408 * for (EchoResponse element : echoClient.pagedExpand(request).iterateAll()) { 409 * // doThingsWith(element); 410 * } 411 * } 412 * }</pre> 413 * 414 * @param request The request object containing all of the parameters for the API call. 415 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 416 */ pagedExpand(PagedExpandRequest request)417 public final PagedExpandPagedResponse pagedExpand(PagedExpandRequest request) { 418 return pagedExpandPagedCallable().call(request); 419 } 420 421 // AUTO-GENERATED DOCUMENTATION AND METHOD. 422 /** 423 * This is similar to the Expand method but instead of returning a stream of expanded words, this 424 * method returns a paged list of expanded words. 425 * 426 * <p>Sample code: 427 * 428 * <pre>{@code 429 * // This snippet has been automatically generated and should be regarded as a code template only. 430 * // It will require modifications to work: 431 * // - It may require correct/in-range values for request initialization. 432 * // - It may require specifying regional endpoints when creating the service client as shown in 433 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 434 * try (EchoClient echoClient = EchoClient.create()) { 435 * PagedExpandRequest request = 436 * PagedExpandRequest.newBuilder() 437 * .setContent("content951530617") 438 * .setPageSize(883849137) 439 * .setPageToken("pageToken873572522") 440 * .build(); 441 * ApiFuture<EchoResponse> future = echoClient.pagedExpandPagedCallable().futureCall(request); 442 * // Do something. 443 * for (EchoResponse element : future.get().iterateAll()) { 444 * // doThingsWith(element); 445 * } 446 * } 447 * }</pre> 448 */ 449 public final UnaryCallable<PagedExpandRequest, PagedExpandPagedResponse> pagedExpandPagedCallable()450 pagedExpandPagedCallable() { 451 return stub.pagedExpandPagedCallable(); 452 } 453 454 // AUTO-GENERATED DOCUMENTATION AND METHOD. 455 /** 456 * This is similar to the Expand method but instead of returning a stream of expanded words, this 457 * method returns a paged list of expanded words. 458 * 459 * <p>Sample code: 460 * 461 * <pre>{@code 462 * // This snippet has been automatically generated and should be regarded as a code template only. 463 * // It will require modifications to work: 464 * // - It may require correct/in-range values for request initialization. 465 * // - It may require specifying regional endpoints when creating the service client as shown in 466 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 467 * try (EchoClient echoClient = EchoClient.create()) { 468 * PagedExpandRequest request = 469 * PagedExpandRequest.newBuilder() 470 * .setContent("content951530617") 471 * .setPageSize(883849137) 472 * .setPageToken("pageToken873572522") 473 * .build(); 474 * while (true) { 475 * PagedExpandResponse response = echoClient.pagedExpandCallable().call(request); 476 * for (EchoResponse element : response.getResponsesList()) { 477 * // doThingsWith(element); 478 * } 479 * String nextPageToken = response.getNextPageToken(); 480 * if (!Strings.isNullOrEmpty(nextPageToken)) { 481 * request = request.toBuilder().setPageToken(nextPageToken).build(); 482 * } else { 483 * break; 484 * } 485 * } 486 * } 487 * }</pre> 488 */ pagedExpandCallable()489 public final UnaryCallable<PagedExpandRequest, PagedExpandResponse> pagedExpandCallable() { 490 return stub.pagedExpandCallable(); 491 } 492 493 // AUTO-GENERATED DOCUMENTATION AND METHOD. 494 /** 495 * This is similar to the PagedExpand except that it uses max_results instead of page_size, as 496 * some legacy APIs still do. New APIs should NOT use this pattern. 497 * 498 * <p>Sample code: 499 * 500 * <pre>{@code 501 * // This snippet has been automatically generated and should be regarded as a code template only. 502 * // It will require modifications to work: 503 * // - It may require correct/in-range values for request initialization. 504 * // - It may require specifying regional endpoints when creating the service client as shown in 505 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 506 * try (EchoClient echoClient = EchoClient.create()) { 507 * PagedExpandLegacyRequest request = 508 * PagedExpandLegacyRequest.newBuilder() 509 * .setContent("content951530617") 510 * .setMaxResults(1128457243) 511 * .setPageToken("pageToken873572522") 512 * .build(); 513 * PagedExpandResponse response = echoClient.pagedExpandLegacy(request); 514 * } 515 * }</pre> 516 * 517 * @param request The request object containing all of the parameters for the API call. 518 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 519 */ pagedExpandLegacy(PagedExpandLegacyRequest request)520 public final PagedExpandResponse pagedExpandLegacy(PagedExpandLegacyRequest request) { 521 return pagedExpandLegacyCallable().call(request); 522 } 523 524 // AUTO-GENERATED DOCUMENTATION AND METHOD. 525 /** 526 * This is similar to the PagedExpand except that it uses max_results instead of page_size, as 527 * some legacy APIs still do. New APIs should NOT use this pattern. 528 * 529 * <p>Sample code: 530 * 531 * <pre>{@code 532 * // This snippet has been automatically generated and should be regarded as a code template only. 533 * // It will require modifications to work: 534 * // - It may require correct/in-range values for request initialization. 535 * // - It may require specifying regional endpoints when creating the service client as shown in 536 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 537 * try (EchoClient echoClient = EchoClient.create()) { 538 * PagedExpandLegacyRequest request = 539 * PagedExpandLegacyRequest.newBuilder() 540 * .setContent("content951530617") 541 * .setMaxResults(1128457243) 542 * .setPageToken("pageToken873572522") 543 * .build(); 544 * ApiFuture<PagedExpandResponse> future = 545 * echoClient.pagedExpandLegacyCallable().futureCall(request); 546 * // Do something. 547 * PagedExpandResponse response = future.get(); 548 * } 549 * }</pre> 550 */ 551 public final UnaryCallable<PagedExpandLegacyRequest, PagedExpandResponse> pagedExpandLegacyCallable()552 pagedExpandLegacyCallable() { 553 return stub.pagedExpandLegacyCallable(); 554 } 555 556 // AUTO-GENERATED DOCUMENTATION AND METHOD. 557 /** 558 * This method returns a map containing lists of words that appear in the input, keyed by their 559 * initial character. The only words returned are the ones included in the current page, as 560 * determined by page_token and page_size, which both refer to the word indices in the input. This 561 * paging result consisting of a map of lists is a pattern used by some legacy APIs. New APIs 562 * should NOT use this pattern. 563 * 564 * <p>Sample code: 565 * 566 * <pre>{@code 567 * // This snippet has been automatically generated and should be regarded as a code template only. 568 * // It will require modifications to work: 569 * // - It may require correct/in-range values for request initialization. 570 * // - It may require specifying regional endpoints when creating the service client as shown in 571 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 572 * try (EchoClient echoClient = EchoClient.create()) { 573 * PagedExpandRequest request = 574 * PagedExpandRequest.newBuilder() 575 * .setContent("content951530617") 576 * .setPageSize(883849137) 577 * .setPageToken("pageToken873572522") 578 * .build(); 579 * for (Map.Entry<String, PagedExpandResponseList> element : 580 * echoClient.pagedExpandLegacyMapped(request).iterateAll()) { 581 * // doThingsWith(element); 582 * } 583 * } 584 * }</pre> 585 * 586 * @param request The request object containing all of the parameters for the API call. 587 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 588 */ pagedExpandLegacyMapped( PagedExpandRequest request)589 public final PagedExpandLegacyMappedPagedResponse pagedExpandLegacyMapped( 590 PagedExpandRequest request) { 591 return pagedExpandLegacyMappedPagedCallable().call(request); 592 } 593 594 // AUTO-GENERATED DOCUMENTATION AND METHOD. 595 /** 596 * This method returns a map containing lists of words that appear in the input, keyed by their 597 * initial character. The only words returned are the ones included in the current page, as 598 * determined by page_token and page_size, which both refer to the word indices in the input. This 599 * paging result consisting of a map of lists is a pattern used by some legacy APIs. New APIs 600 * should NOT use this pattern. 601 * 602 * <p>Sample code: 603 * 604 * <pre>{@code 605 * // This snippet has been automatically generated and should be regarded as a code template only. 606 * // It will require modifications to work: 607 * // - It may require correct/in-range values for request initialization. 608 * // - It may require specifying regional endpoints when creating the service client as shown in 609 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 610 * try (EchoClient echoClient = EchoClient.create()) { 611 * PagedExpandRequest request = 612 * PagedExpandRequest.newBuilder() 613 * .setContent("content951530617") 614 * .setPageSize(883849137) 615 * .setPageToken("pageToken873572522") 616 * .build(); 617 * ApiFuture<Map.Entry<String, PagedExpandResponseList>> future = 618 * echoClient.pagedExpandLegacyMappedPagedCallable().futureCall(request); 619 * // Do something. 620 * for (Map.Entry<String, PagedExpandResponseList> element : future.get().iterateAll()) { 621 * // doThingsWith(element); 622 * } 623 * } 624 * }</pre> 625 */ 626 public final UnaryCallable<PagedExpandRequest, PagedExpandLegacyMappedPagedResponse> pagedExpandLegacyMappedPagedCallable()627 pagedExpandLegacyMappedPagedCallable() { 628 return stub.pagedExpandLegacyMappedPagedCallable(); 629 } 630 631 // AUTO-GENERATED DOCUMENTATION AND METHOD. 632 /** 633 * This method returns a map containing lists of words that appear in the input, keyed by their 634 * initial character. The only words returned are the ones included in the current page, as 635 * determined by page_token and page_size, which both refer to the word indices in the input. This 636 * paging result consisting of a map of lists is a pattern used by some legacy APIs. New APIs 637 * should NOT use this pattern. 638 * 639 * <p>Sample code: 640 * 641 * <pre>{@code 642 * // This snippet has been automatically generated and should be regarded as a code template only. 643 * // It will require modifications to work: 644 * // - It may require correct/in-range values for request initialization. 645 * // - It may require specifying regional endpoints when creating the service client as shown in 646 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 647 * try (EchoClient echoClient = EchoClient.create()) { 648 * PagedExpandRequest request = 649 * PagedExpandRequest.newBuilder() 650 * .setContent("content951530617") 651 * .setPageSize(883849137) 652 * .setPageToken("pageToken873572522") 653 * .build(); 654 * while (true) { 655 * PagedExpandLegacyMappedResponse response = 656 * echoClient.pagedExpandLegacyMappedCallable().call(request); 657 * for (Map.Entry<String, PagedExpandResponseList> element : response.getAlphabetizedList()) { 658 * // doThingsWith(element); 659 * } 660 * String nextPageToken = response.getNextPageToken(); 661 * if (!Strings.isNullOrEmpty(nextPageToken)) { 662 * request = request.toBuilder().setPageToken(nextPageToken).build(); 663 * } else { 664 * break; 665 * } 666 * } 667 * } 668 * }</pre> 669 */ 670 public final UnaryCallable<PagedExpandRequest, PagedExpandLegacyMappedResponse> pagedExpandLegacyMappedCallable()671 pagedExpandLegacyMappedCallable() { 672 return stub.pagedExpandLegacyMappedCallable(); 673 } 674 675 // AUTO-GENERATED DOCUMENTATION AND METHOD. 676 /** 677 * This method will wait for the requested amount of time and then return. This method showcases 678 * how a client handles a request timeout. 679 * 680 * <p>Sample code: 681 * 682 * <pre>{@code 683 * // This snippet has been automatically generated and should be regarded as a code template only. 684 * // It will require modifications to work: 685 * // - It may require correct/in-range values for request initialization. 686 * // - It may require specifying regional endpoints when creating the service client as shown in 687 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 688 * try (EchoClient echoClient = EchoClient.create()) { 689 * WaitRequest request = WaitRequest.newBuilder().build(); 690 * WaitResponse response = echoClient.waitAsync(request).get(); 691 * } 692 * }</pre> 693 * 694 * @param request The request object containing all of the parameters for the API call. 695 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 696 */ waitAsync(WaitRequest request)697 public final OperationFuture<WaitResponse, WaitMetadata> waitAsync(WaitRequest request) { 698 return waitOperationCallable().futureCall(request); 699 } 700 701 // AUTO-GENERATED DOCUMENTATION AND METHOD. 702 /** 703 * This method will wait for the requested amount of time and then return. This method showcases 704 * how a client handles a request timeout. 705 * 706 * <p>Sample code: 707 * 708 * <pre>{@code 709 * // This snippet has been automatically generated and should be regarded as a code template only. 710 * // It will require modifications to work: 711 * // - It may require correct/in-range values for request initialization. 712 * // - It may require specifying regional endpoints when creating the service client as shown in 713 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 714 * try (EchoClient echoClient = EchoClient.create()) { 715 * WaitRequest request = WaitRequest.newBuilder().build(); 716 * OperationFuture<WaitResponse, WaitMetadata> future = 717 * echoClient.waitOperationCallable().futureCall(request); 718 * // Do something. 719 * WaitResponse response = future.get(); 720 * } 721 * }</pre> 722 */ waitOperationCallable()723 public final OperationCallable<WaitRequest, WaitResponse, WaitMetadata> waitOperationCallable() { 724 return stub.waitOperationCallable(); 725 } 726 727 // AUTO-GENERATED DOCUMENTATION AND METHOD. 728 /** 729 * This method will wait for the requested amount of time and then return. This method showcases 730 * how a client handles a request timeout. 731 * 732 * <p>Sample code: 733 * 734 * <pre>{@code 735 * // This snippet has been automatically generated and should be regarded as a code template only. 736 * // It will require modifications to work: 737 * // - It may require correct/in-range values for request initialization. 738 * // - It may require specifying regional endpoints when creating the service client as shown in 739 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 740 * try (EchoClient echoClient = EchoClient.create()) { 741 * WaitRequest request = WaitRequest.newBuilder().build(); 742 * ApiFuture<Operation> future = echoClient.waitCallable().futureCall(request); 743 * // Do something. 744 * Operation response = future.get(); 745 * } 746 * }</pre> 747 */ waitCallable()748 public final UnaryCallable<WaitRequest, Operation> waitCallable() { 749 return stub.waitCallable(); 750 } 751 752 // AUTO-GENERATED DOCUMENTATION AND METHOD. 753 /** 754 * This method will block (wait) for the requested amount of time and then return the response or 755 * error. This method showcases how a client handles delays or retries. 756 * 757 * <p>Sample code: 758 * 759 * <pre>{@code 760 * // This snippet has been automatically generated and should be regarded as a code template only. 761 * // It will require modifications to work: 762 * // - It may require correct/in-range values for request initialization. 763 * // - It may require specifying regional endpoints when creating the service client as shown in 764 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 765 * try (EchoClient echoClient = EchoClient.create()) { 766 * BlockRequest request = 767 * BlockRequest.newBuilder().setResponseDelay(Duration.newBuilder().build()).build(); 768 * BlockResponse response = echoClient.block(request); 769 * } 770 * }</pre> 771 * 772 * @param request The request object containing all of the parameters for the API call. 773 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 774 */ block(BlockRequest request)775 public final BlockResponse block(BlockRequest request) { 776 return blockCallable().call(request); 777 } 778 779 // AUTO-GENERATED DOCUMENTATION AND METHOD. 780 /** 781 * This method will block (wait) for the requested amount of time and then return the response or 782 * error. This method showcases how a client handles delays or retries. 783 * 784 * <p>Sample code: 785 * 786 * <pre>{@code 787 * // This snippet has been automatically generated and should be regarded as a code template only. 788 * // It will require modifications to work: 789 * // - It may require correct/in-range values for request initialization. 790 * // - It may require specifying regional endpoints when creating the service client as shown in 791 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 792 * try (EchoClient echoClient = EchoClient.create()) { 793 * BlockRequest request = 794 * BlockRequest.newBuilder().setResponseDelay(Duration.newBuilder().build()).build(); 795 * ApiFuture<BlockResponse> future = echoClient.blockCallable().futureCall(request); 796 * // Do something. 797 * BlockResponse response = future.get(); 798 * } 799 * }</pre> 800 */ blockCallable()801 public final UnaryCallable<BlockRequest, BlockResponse> blockCallable() { 802 return stub.blockCallable(); 803 } 804 805 // AUTO-GENERATED DOCUMENTATION AND METHOD. 806 /** 807 * Lists information about the supported locations for this service. 808 * 809 * <p>Sample code: 810 * 811 * <pre>{@code 812 * // This snippet has been automatically generated and should be regarded as a code template only. 813 * // It will require modifications to work: 814 * // - It may require correct/in-range values for request initialization. 815 * // - It may require specifying regional endpoints when creating the service client as shown in 816 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 817 * try (EchoClient echoClient = EchoClient.create()) { 818 * ListLocationsRequest request = 819 * ListLocationsRequest.newBuilder() 820 * .setName("name3373707") 821 * .setFilter("filter-1274492040") 822 * .setPageSize(883849137) 823 * .setPageToken("pageToken873572522") 824 * .build(); 825 * for (Location element : echoClient.listLocations(request).iterateAll()) { 826 * // doThingsWith(element); 827 * } 828 * } 829 * }</pre> 830 * 831 * @param request The request object containing all of the parameters for the API call. 832 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 833 */ listLocations(ListLocationsRequest request)834 public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { 835 return listLocationsPagedCallable().call(request); 836 } 837 838 // AUTO-GENERATED DOCUMENTATION AND METHOD. 839 /** 840 * Lists information about the supported locations for this service. 841 * 842 * <p>Sample code: 843 * 844 * <pre>{@code 845 * // This snippet has been automatically generated and should be regarded as a code template only. 846 * // It will require modifications to work: 847 * // - It may require correct/in-range values for request initialization. 848 * // - It may require specifying regional endpoints when creating the service client as shown in 849 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 850 * try (EchoClient echoClient = EchoClient.create()) { 851 * ListLocationsRequest request = 852 * ListLocationsRequest.newBuilder() 853 * .setName("name3373707") 854 * .setFilter("filter-1274492040") 855 * .setPageSize(883849137) 856 * .setPageToken("pageToken873572522") 857 * .build(); 858 * ApiFuture<Location> future = echoClient.listLocationsPagedCallable().futureCall(request); 859 * // Do something. 860 * for (Location element : future.get().iterateAll()) { 861 * // doThingsWith(element); 862 * } 863 * } 864 * }</pre> 865 */ 866 public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> listLocationsPagedCallable()867 listLocationsPagedCallable() { 868 return stub.listLocationsPagedCallable(); 869 } 870 871 // AUTO-GENERATED DOCUMENTATION AND METHOD. 872 /** 873 * Lists information about the supported locations for this service. 874 * 875 * <p>Sample code: 876 * 877 * <pre>{@code 878 * // This snippet has been automatically generated and should be regarded as a code template only. 879 * // It will require modifications to work: 880 * // - It may require correct/in-range values for request initialization. 881 * // - It may require specifying regional endpoints when creating the service client as shown in 882 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 883 * try (EchoClient echoClient = EchoClient.create()) { 884 * ListLocationsRequest request = 885 * ListLocationsRequest.newBuilder() 886 * .setName("name3373707") 887 * .setFilter("filter-1274492040") 888 * .setPageSize(883849137) 889 * .setPageToken("pageToken873572522") 890 * .build(); 891 * while (true) { 892 * ListLocationsResponse response = echoClient.listLocationsCallable().call(request); 893 * for (Location element : response.getLocationsList()) { 894 * // doThingsWith(element); 895 * } 896 * String nextPageToken = response.getNextPageToken(); 897 * if (!Strings.isNullOrEmpty(nextPageToken)) { 898 * request = request.toBuilder().setPageToken(nextPageToken).build(); 899 * } else { 900 * break; 901 * } 902 * } 903 * } 904 * }</pre> 905 */ listLocationsCallable()906 public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { 907 return stub.listLocationsCallable(); 908 } 909 910 // AUTO-GENERATED DOCUMENTATION AND METHOD. 911 /** 912 * Gets information about a location. 913 * 914 * <p>Sample code: 915 * 916 * <pre>{@code 917 * // This snippet has been automatically generated and should be regarded as a code template only. 918 * // It will require modifications to work: 919 * // - It may require correct/in-range values for request initialization. 920 * // - It may require specifying regional endpoints when creating the service client as shown in 921 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 922 * try (EchoClient echoClient = EchoClient.create()) { 923 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 924 * Location response = echoClient.getLocation(request); 925 * } 926 * }</pre> 927 * 928 * @param request The request object containing all of the parameters for the API call. 929 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 930 */ getLocation(GetLocationRequest request)931 public final Location getLocation(GetLocationRequest request) { 932 return getLocationCallable().call(request); 933 } 934 935 // AUTO-GENERATED DOCUMENTATION AND METHOD. 936 /** 937 * Gets information about a location. 938 * 939 * <p>Sample code: 940 * 941 * <pre>{@code 942 * // This snippet has been automatically generated and should be regarded as a code template only. 943 * // It will require modifications to work: 944 * // - It may require correct/in-range values for request initialization. 945 * // - It may require specifying regional endpoints when creating the service client as shown in 946 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 947 * try (EchoClient echoClient = EchoClient.create()) { 948 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 949 * ApiFuture<Location> future = echoClient.getLocationCallable().futureCall(request); 950 * // Do something. 951 * Location response = future.get(); 952 * } 953 * }</pre> 954 */ getLocationCallable()955 public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { 956 return stub.getLocationCallable(); 957 } 958 959 @Override close()960 public final void close() { 961 stub.close(); 962 } 963 964 @Override shutdown()965 public void shutdown() { 966 stub.shutdown(); 967 } 968 969 @Override isShutdown()970 public boolean isShutdown() { 971 return stub.isShutdown(); 972 } 973 974 @Override isTerminated()975 public boolean isTerminated() { 976 return stub.isTerminated(); 977 } 978 979 @Override shutdownNow()980 public void shutdownNow() { 981 stub.shutdownNow(); 982 } 983 984 @Override awaitTermination(long duration, TimeUnit unit)985 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 986 return stub.awaitTermination(duration, unit); 987 } 988 989 public static class PagedExpandPagedResponse 990 extends AbstractPagedListResponse< 991 PagedExpandRequest, 992 PagedExpandResponse, 993 EchoResponse, 994 PagedExpandPage, 995 PagedExpandFixedSizeCollection> { 996 createAsync( PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, ApiFuture<PagedExpandResponse> futureResponse)997 public static ApiFuture<PagedExpandPagedResponse> createAsync( 998 PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, 999 ApiFuture<PagedExpandResponse> futureResponse) { 1000 ApiFuture<PagedExpandPage> futurePage = 1001 PagedExpandPage.createEmptyPage().createPageAsync(context, futureResponse); 1002 return ApiFutures.transform( 1003 futurePage, input -> new PagedExpandPagedResponse(input), MoreExecutors.directExecutor()); 1004 } 1005 PagedExpandPagedResponse(PagedExpandPage page)1006 private PagedExpandPagedResponse(PagedExpandPage page) { 1007 super(page, PagedExpandFixedSizeCollection.createEmptyCollection()); 1008 } 1009 } 1010 1011 public static class PagedExpandPage 1012 extends AbstractPage<PagedExpandRequest, PagedExpandResponse, EchoResponse, PagedExpandPage> { 1013 PagedExpandPage( PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, PagedExpandResponse response)1014 private PagedExpandPage( 1015 PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, 1016 PagedExpandResponse response) { 1017 super(context, response); 1018 } 1019 createEmptyPage()1020 private static PagedExpandPage createEmptyPage() { 1021 return new PagedExpandPage(null, null); 1022 } 1023 1024 @Override createPage( PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, PagedExpandResponse response)1025 protected PagedExpandPage createPage( 1026 PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, 1027 PagedExpandResponse response) { 1028 return new PagedExpandPage(context, response); 1029 } 1030 1031 @Override createPageAsync( PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, ApiFuture<PagedExpandResponse> futureResponse)1032 public ApiFuture<PagedExpandPage> createPageAsync( 1033 PageContext<PagedExpandRequest, PagedExpandResponse, EchoResponse> context, 1034 ApiFuture<PagedExpandResponse> futureResponse) { 1035 return super.createPageAsync(context, futureResponse); 1036 } 1037 } 1038 1039 public static class PagedExpandFixedSizeCollection 1040 extends AbstractFixedSizeCollection< 1041 PagedExpandRequest, 1042 PagedExpandResponse, 1043 EchoResponse, 1044 PagedExpandPage, 1045 PagedExpandFixedSizeCollection> { 1046 PagedExpandFixedSizeCollection(List<PagedExpandPage> pages, int collectionSize)1047 private PagedExpandFixedSizeCollection(List<PagedExpandPage> pages, int collectionSize) { 1048 super(pages, collectionSize); 1049 } 1050 createEmptyCollection()1051 private static PagedExpandFixedSizeCollection createEmptyCollection() { 1052 return new PagedExpandFixedSizeCollection(null, 0); 1053 } 1054 1055 @Override createCollection( List<PagedExpandPage> pages, int collectionSize)1056 protected PagedExpandFixedSizeCollection createCollection( 1057 List<PagedExpandPage> pages, int collectionSize) { 1058 return new PagedExpandFixedSizeCollection(pages, collectionSize); 1059 } 1060 } 1061 1062 public static class PagedExpandLegacyMappedPagedResponse 1063 extends AbstractPagedListResponse< 1064 PagedExpandRequest, 1065 PagedExpandLegacyMappedResponse, 1066 Map.Entry<String, PagedExpandResponseList>, 1067 PagedExpandLegacyMappedPage, 1068 PagedExpandLegacyMappedFixedSizeCollection> { 1069 createAsync( PageContext< PagedExpandRequest, PagedExpandLegacyMappedResponse, Map.Entry<String, PagedExpandResponseList>> context, ApiFuture<PagedExpandLegacyMappedResponse> futureResponse)1070 public static ApiFuture<PagedExpandLegacyMappedPagedResponse> createAsync( 1071 PageContext< 1072 PagedExpandRequest, 1073 PagedExpandLegacyMappedResponse, 1074 Map.Entry<String, PagedExpandResponseList>> 1075 context, 1076 ApiFuture<PagedExpandLegacyMappedResponse> futureResponse) { 1077 ApiFuture<PagedExpandLegacyMappedPage> futurePage = 1078 PagedExpandLegacyMappedPage.createEmptyPage().createPageAsync(context, futureResponse); 1079 return ApiFutures.transform( 1080 futurePage, 1081 input -> new PagedExpandLegacyMappedPagedResponse(input), 1082 MoreExecutors.directExecutor()); 1083 } 1084 PagedExpandLegacyMappedPagedResponse(PagedExpandLegacyMappedPage page)1085 private PagedExpandLegacyMappedPagedResponse(PagedExpandLegacyMappedPage page) { 1086 super(page, PagedExpandLegacyMappedFixedSizeCollection.createEmptyCollection()); 1087 } 1088 } 1089 1090 public static class PagedExpandLegacyMappedPage 1091 extends AbstractPage< 1092 PagedExpandRequest, 1093 PagedExpandLegacyMappedResponse, 1094 Map.Entry<String, PagedExpandResponseList>, 1095 PagedExpandLegacyMappedPage> { 1096 PagedExpandLegacyMappedPage( PageContext< PagedExpandRequest, PagedExpandLegacyMappedResponse, Map.Entry<String, PagedExpandResponseList>> context, PagedExpandLegacyMappedResponse response)1097 private PagedExpandLegacyMappedPage( 1098 PageContext< 1099 PagedExpandRequest, 1100 PagedExpandLegacyMappedResponse, 1101 Map.Entry<String, PagedExpandResponseList>> 1102 context, 1103 PagedExpandLegacyMappedResponse response) { 1104 super(context, response); 1105 } 1106 createEmptyPage()1107 private static PagedExpandLegacyMappedPage createEmptyPage() { 1108 return new PagedExpandLegacyMappedPage(null, null); 1109 } 1110 1111 @Override createPage( PageContext< PagedExpandRequest, PagedExpandLegacyMappedResponse, Map.Entry<String, PagedExpandResponseList>> context, PagedExpandLegacyMappedResponse response)1112 protected PagedExpandLegacyMappedPage createPage( 1113 PageContext< 1114 PagedExpandRequest, 1115 PagedExpandLegacyMappedResponse, 1116 Map.Entry<String, PagedExpandResponseList>> 1117 context, 1118 PagedExpandLegacyMappedResponse response) { 1119 return new PagedExpandLegacyMappedPage(context, response); 1120 } 1121 1122 @Override createPageAsync( PageContext< PagedExpandRequest, PagedExpandLegacyMappedResponse, Map.Entry<String, PagedExpandResponseList>> context, ApiFuture<PagedExpandLegacyMappedResponse> futureResponse)1123 public ApiFuture<PagedExpandLegacyMappedPage> createPageAsync( 1124 PageContext< 1125 PagedExpandRequest, 1126 PagedExpandLegacyMappedResponse, 1127 Map.Entry<String, PagedExpandResponseList>> 1128 context, 1129 ApiFuture<PagedExpandLegacyMappedResponse> futureResponse) { 1130 return super.createPageAsync(context, futureResponse); 1131 } 1132 } 1133 1134 public static class PagedExpandLegacyMappedFixedSizeCollection 1135 extends AbstractFixedSizeCollection< 1136 PagedExpandRequest, 1137 PagedExpandLegacyMappedResponse, 1138 Map.Entry<String, PagedExpandResponseList>, 1139 PagedExpandLegacyMappedPage, 1140 PagedExpandLegacyMappedFixedSizeCollection> { 1141 PagedExpandLegacyMappedFixedSizeCollection( List<PagedExpandLegacyMappedPage> pages, int collectionSize)1142 private PagedExpandLegacyMappedFixedSizeCollection( 1143 List<PagedExpandLegacyMappedPage> pages, int collectionSize) { 1144 super(pages, collectionSize); 1145 } 1146 createEmptyCollection()1147 private static PagedExpandLegacyMappedFixedSizeCollection createEmptyCollection() { 1148 return new PagedExpandLegacyMappedFixedSizeCollection(null, 0); 1149 } 1150 1151 @Override createCollection( List<PagedExpandLegacyMappedPage> pages, int collectionSize)1152 protected PagedExpandLegacyMappedFixedSizeCollection createCollection( 1153 List<PagedExpandLegacyMappedPage> pages, int collectionSize) { 1154 return new PagedExpandLegacyMappedFixedSizeCollection(pages, collectionSize); 1155 } 1156 } 1157 1158 public static class ListLocationsPagedResponse 1159 extends AbstractPagedListResponse< 1160 ListLocationsRequest, 1161 ListLocationsResponse, 1162 Location, 1163 ListLocationsPage, 1164 ListLocationsFixedSizeCollection> { 1165 createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1166 public static ApiFuture<ListLocationsPagedResponse> createAsync( 1167 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1168 ApiFuture<ListLocationsResponse> futureResponse) { 1169 ApiFuture<ListLocationsPage> futurePage = 1170 ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); 1171 return ApiFutures.transform( 1172 futurePage, 1173 input -> new ListLocationsPagedResponse(input), 1174 MoreExecutors.directExecutor()); 1175 } 1176 ListLocationsPagedResponse(ListLocationsPage page)1177 private ListLocationsPagedResponse(ListLocationsPage page) { 1178 super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); 1179 } 1180 } 1181 1182 public static class ListLocationsPage 1183 extends AbstractPage< 1184 ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { 1185 ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1186 private ListLocationsPage( 1187 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1188 ListLocationsResponse response) { 1189 super(context, response); 1190 } 1191 createEmptyPage()1192 private static ListLocationsPage createEmptyPage() { 1193 return new ListLocationsPage(null, null); 1194 } 1195 1196 @Override createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1197 protected ListLocationsPage createPage( 1198 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1199 ListLocationsResponse response) { 1200 return new ListLocationsPage(context, response); 1201 } 1202 1203 @Override createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1204 public ApiFuture<ListLocationsPage> createPageAsync( 1205 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1206 ApiFuture<ListLocationsResponse> futureResponse) { 1207 return super.createPageAsync(context, futureResponse); 1208 } 1209 } 1210 1211 public static class ListLocationsFixedSizeCollection 1212 extends AbstractFixedSizeCollection< 1213 ListLocationsRequest, 1214 ListLocationsResponse, 1215 Location, 1216 ListLocationsPage, 1217 ListLocationsFixedSizeCollection> { 1218 ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1219 private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { 1220 super(pages, collectionSize); 1221 } 1222 createEmptyCollection()1223 private static ListLocationsFixedSizeCollection createEmptyCollection() { 1224 return new ListLocationsFixedSizeCollection(null, 0); 1225 } 1226 1227 @Override createCollection( List<ListLocationsPage> pages, int collectionSize)1228 protected ListLocationsFixedSizeCollection createCollection( 1229 List<ListLocationsPage> pages, int collectionSize) { 1230 return new ListLocationsFixedSizeCollection(pages, collectionSize); 1231 } 1232 } 1233 } 1234