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.dialogflow.v2beta1; 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.dialogflow.v2beta1.stub.AnswerRecordsStub; 29 import com.google.cloud.dialogflow.v2beta1.stub.AnswerRecordsStubSettings; 30 import com.google.cloud.location.GetLocationRequest; 31 import com.google.cloud.location.ListLocationsRequest; 32 import com.google.cloud.location.ListLocationsResponse; 33 import com.google.cloud.location.Location; 34 import com.google.common.util.concurrent.MoreExecutors; 35 import com.google.protobuf.FieldMask; 36 import java.io.IOException; 37 import java.util.List; 38 import java.util.concurrent.TimeUnit; 39 import javax.annotation.Generated; 40 41 // AUTO-GENERATED DOCUMENTATION AND CLASS. 42 /** 43 * Service Description: Service for managing 44 * [AnswerRecords][google.cloud.dialogflow.v2beta1.AnswerRecord]. 45 * 46 * <p>This class provides the ability to make remote calls to the backing service through method 47 * calls that map to API methods. Sample code to get started: 48 * 49 * <pre>{@code 50 * // This snippet has been automatically generated and should be regarded as a code template only. 51 * // It will require modifications to work: 52 * // - It may require correct/in-range values for request initialization. 53 * // - It may require specifying regional endpoints when creating the service client as shown in 54 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 55 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 56 * GetAnswerRecordRequest request = 57 * GetAnswerRecordRequest.newBuilder().setName("name3373707").build(); 58 * AnswerRecord response = answerRecordsClient.getAnswerRecord(request); 59 * } 60 * }</pre> 61 * 62 * <p>Note: close() needs to be called on the AnswerRecordsClient object to clean up resources such 63 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 64 * 65 * <p>The surface of this class includes several types of Java methods for each of the API's 66 * methods: 67 * 68 * <ol> 69 * <li>A "flattened" method. With this type of method, the fields of the request type have been 70 * converted into function parameters. It may be the case that not all fields are available as 71 * parameters, and not every API method will have a flattened method entry point. 72 * <li>A "request object" method. This type of method only takes one parameter, a request object, 73 * which must be constructed before the call. Not every API method will have a request object 74 * method. 75 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 76 * callable object, which can be used to initiate calls to the service. 77 * </ol> 78 * 79 * <p>See the individual methods for example code. 80 * 81 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 82 * these names, this class includes a format method for each type of name, and additionally a parse 83 * method to extract the individual identifiers contained within names that are returned. 84 * 85 * <p>This class can be customized by passing in a custom instance of AnswerRecordsSettings to 86 * create(). For example: 87 * 88 * <p>To customize credentials: 89 * 90 * <pre>{@code 91 * // This snippet has been automatically generated and should be regarded as a code template only. 92 * // It will require modifications to work: 93 * // - It may require correct/in-range values for request initialization. 94 * // - It may require specifying regional endpoints when creating the service client as shown in 95 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 96 * AnswerRecordsSettings answerRecordsSettings = 97 * AnswerRecordsSettings.newBuilder() 98 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 99 * .build(); 100 * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); 101 * }</pre> 102 * 103 * <p>To customize the endpoint: 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 * AnswerRecordsSettings answerRecordsSettings = 112 * AnswerRecordsSettings.newBuilder().setEndpoint(myEndpoint).build(); 113 * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); 114 * }</pre> 115 * 116 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 117 * the wire: 118 * 119 * <pre>{@code 120 * // This snippet has been automatically generated and should be regarded as a code template only. 121 * // It will require modifications to work: 122 * // - It may require correct/in-range values for request initialization. 123 * // - It may require specifying regional endpoints when creating the service client as shown in 124 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 125 * AnswerRecordsSettings answerRecordsSettings = 126 * AnswerRecordsSettings.newHttpJsonBuilder().build(); 127 * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); 128 * }</pre> 129 * 130 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 131 */ 132 @BetaApi 133 @Generated("by gapic-generator-java") 134 public class AnswerRecordsClient implements BackgroundResource { 135 private final AnswerRecordsSettings settings; 136 private final AnswerRecordsStub stub; 137 138 /** Constructs an instance of AnswerRecordsClient with default settings. */ create()139 public static final AnswerRecordsClient create() throws IOException { 140 return create(AnswerRecordsSettings.newBuilder().build()); 141 } 142 143 /** 144 * Constructs an instance of AnswerRecordsClient, using the given settings. The channels are 145 * created based on the settings passed in, or defaults for any settings that are not set. 146 */ create(AnswerRecordsSettings settings)147 public static final AnswerRecordsClient create(AnswerRecordsSettings settings) 148 throws IOException { 149 return new AnswerRecordsClient(settings); 150 } 151 152 /** 153 * Constructs an instance of AnswerRecordsClient, using the given stub for making calls. This is 154 * for advanced usage - prefer using create(AnswerRecordsSettings). 155 */ create(AnswerRecordsStub stub)156 public static final AnswerRecordsClient create(AnswerRecordsStub stub) { 157 return new AnswerRecordsClient(stub); 158 } 159 160 /** 161 * Constructs an instance of AnswerRecordsClient, using the given settings. This is protected so 162 * that it is easy to make a subclass, but otherwise, the static factory methods should be 163 * preferred. 164 */ AnswerRecordsClient(AnswerRecordsSettings settings)165 protected AnswerRecordsClient(AnswerRecordsSettings settings) throws IOException { 166 this.settings = settings; 167 this.stub = ((AnswerRecordsStubSettings) settings.getStubSettings()).createStub(); 168 } 169 AnswerRecordsClient(AnswerRecordsStub stub)170 protected AnswerRecordsClient(AnswerRecordsStub stub) { 171 this.settings = null; 172 this.stub = stub; 173 } 174 getSettings()175 public final AnswerRecordsSettings getSettings() { 176 return settings; 177 } 178 getStub()179 public AnswerRecordsStub getStub() { 180 return stub; 181 } 182 183 // AUTO-GENERATED DOCUMENTATION AND METHOD. 184 /** 185 * Deprecated. Retrieves a specific answer record. 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 (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 196 * GetAnswerRecordRequest request = 197 * GetAnswerRecordRequest.newBuilder().setName("name3373707").build(); 198 * AnswerRecord response = answerRecordsClient.getAnswerRecord(request); 199 * } 200 * }</pre> 201 * 202 * @param request The request object containing all of the parameters for the API call. 203 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 204 * @deprecated This method is deprecated and will be removed in the next major version update. 205 */ 206 @Deprecated getAnswerRecord(GetAnswerRecordRequest request)207 public final AnswerRecord getAnswerRecord(GetAnswerRecordRequest request) { 208 return getAnswerRecordCallable().call(request); 209 } 210 211 // AUTO-GENERATED DOCUMENTATION AND METHOD. 212 /** 213 * Deprecated. Retrieves a specific answer record. 214 * 215 * <p>Sample code: 216 * 217 * <pre>{@code 218 * // This snippet has been automatically generated and should be regarded as a code template only. 219 * // It will require modifications to work: 220 * // - It may require correct/in-range values for request initialization. 221 * // - It may require specifying regional endpoints when creating the service client as shown in 222 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 223 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 224 * GetAnswerRecordRequest request = 225 * GetAnswerRecordRequest.newBuilder().setName("name3373707").build(); 226 * ApiFuture<AnswerRecord> future = 227 * answerRecordsClient.getAnswerRecordCallable().futureCall(request); 228 * // Do something. 229 * AnswerRecord response = future.get(); 230 * } 231 * }</pre> 232 * 233 * @deprecated This method is deprecated and will be removed in the next major version update. 234 */ 235 @Deprecated getAnswerRecordCallable()236 public final UnaryCallable<GetAnswerRecordRequest, AnswerRecord> getAnswerRecordCallable() { 237 return stub.getAnswerRecordCallable(); 238 } 239 240 // AUTO-GENERATED DOCUMENTATION AND METHOD. 241 /** 242 * Returns the list of all answer records in the specified project in reverse chronological order. 243 * 244 * <p>Sample code: 245 * 246 * <pre>{@code 247 * // This snippet has been automatically generated and should be regarded as a code template only. 248 * // It will require modifications to work: 249 * // - It may require correct/in-range values for request initialization. 250 * // - It may require specifying regional endpoints when creating the service client as shown in 251 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 252 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 253 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 254 * for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { 255 * // doThingsWith(element); 256 * } 257 * } 258 * }</pre> 259 * 260 * @param parent Required. The project to list all answer records for in reverse chronological 261 * order. Format: `projects/<Project ID>/locations/<Location ID>`. 262 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 263 */ listAnswerRecords(LocationName parent)264 public final ListAnswerRecordsPagedResponse listAnswerRecords(LocationName parent) { 265 ListAnswerRecordsRequest request = 266 ListAnswerRecordsRequest.newBuilder() 267 .setParent(parent == null ? null : parent.toString()) 268 .build(); 269 return listAnswerRecords(request); 270 } 271 272 // AUTO-GENERATED DOCUMENTATION AND METHOD. 273 /** 274 * Returns the list of all answer records in the specified project in reverse chronological order. 275 * 276 * <p>Sample code: 277 * 278 * <pre>{@code 279 * // This snippet has been automatically generated and should be regarded as a code template only. 280 * // It will require modifications to work: 281 * // - It may require correct/in-range values for request initialization. 282 * // - It may require specifying regional endpoints when creating the service client as shown in 283 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 284 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 285 * ProjectName parent = ProjectName.of("[PROJECT]"); 286 * for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { 287 * // doThingsWith(element); 288 * } 289 * } 290 * }</pre> 291 * 292 * @param parent Required. The project to list all answer records for in reverse chronological 293 * order. Format: `projects/<Project ID>/locations/<Location ID>`. 294 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 295 */ listAnswerRecords(ProjectName parent)296 public final ListAnswerRecordsPagedResponse listAnswerRecords(ProjectName parent) { 297 ListAnswerRecordsRequest request = 298 ListAnswerRecordsRequest.newBuilder() 299 .setParent(parent == null ? null : parent.toString()) 300 .build(); 301 return listAnswerRecords(request); 302 } 303 304 // AUTO-GENERATED DOCUMENTATION AND METHOD. 305 /** 306 * Returns the list of all answer records in the specified project in reverse chronological order. 307 * 308 * <p>Sample code: 309 * 310 * <pre>{@code 311 * // This snippet has been automatically generated and should be regarded as a code template only. 312 * // It will require modifications to work: 313 * // - It may require correct/in-range values for request initialization. 314 * // - It may require specifying regional endpoints when creating the service client as shown in 315 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 316 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 317 * String parent = ProjectName.of("[PROJECT]").toString(); 318 * for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { 319 * // doThingsWith(element); 320 * } 321 * } 322 * }</pre> 323 * 324 * @param parent Required. The project to list all answer records for in reverse chronological 325 * order. Format: `projects/<Project ID>/locations/<Location ID>`. 326 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 327 */ listAnswerRecords(String parent)328 public final ListAnswerRecordsPagedResponse listAnswerRecords(String parent) { 329 ListAnswerRecordsRequest request = 330 ListAnswerRecordsRequest.newBuilder().setParent(parent).build(); 331 return listAnswerRecords(request); 332 } 333 334 // AUTO-GENERATED DOCUMENTATION AND METHOD. 335 /** 336 * Returns the list of all answer records in the specified project in reverse chronological order. 337 * 338 * <p>Sample code: 339 * 340 * <pre>{@code 341 * // This snippet has been automatically generated and should be regarded as a code template only. 342 * // It will require modifications to work: 343 * // - It may require correct/in-range values for request initialization. 344 * // - It may require specifying regional endpoints when creating the service client as shown in 345 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 346 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 347 * ListAnswerRecordsRequest request = 348 * ListAnswerRecordsRequest.newBuilder() 349 * .setParent(ProjectName.of("[PROJECT]").toString()) 350 * .setFilter("filter-1274492040") 351 * .setPageSize(883849137) 352 * .setPageToken("pageToken873572522") 353 * .build(); 354 * for (AnswerRecord element : answerRecordsClient.listAnswerRecords(request).iterateAll()) { 355 * // doThingsWith(element); 356 * } 357 * } 358 * }</pre> 359 * 360 * @param request The request object containing all of the parameters for the API call. 361 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 362 */ listAnswerRecords(ListAnswerRecordsRequest request)363 public final ListAnswerRecordsPagedResponse listAnswerRecords(ListAnswerRecordsRequest request) { 364 return listAnswerRecordsPagedCallable().call(request); 365 } 366 367 // AUTO-GENERATED DOCUMENTATION AND METHOD. 368 /** 369 * Returns the list of all answer records in the specified project in reverse chronological order. 370 * 371 * <p>Sample code: 372 * 373 * <pre>{@code 374 * // This snippet has been automatically generated and should be regarded as a code template only. 375 * // It will require modifications to work: 376 * // - It may require correct/in-range values for request initialization. 377 * // - It may require specifying regional endpoints when creating the service client as shown in 378 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 379 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 380 * ListAnswerRecordsRequest request = 381 * ListAnswerRecordsRequest.newBuilder() 382 * .setParent(ProjectName.of("[PROJECT]").toString()) 383 * .setFilter("filter-1274492040") 384 * .setPageSize(883849137) 385 * .setPageToken("pageToken873572522") 386 * .build(); 387 * ApiFuture<AnswerRecord> future = 388 * answerRecordsClient.listAnswerRecordsPagedCallable().futureCall(request); 389 * // Do something. 390 * for (AnswerRecord element : future.get().iterateAll()) { 391 * // doThingsWith(element); 392 * } 393 * } 394 * }</pre> 395 */ 396 public final UnaryCallable<ListAnswerRecordsRequest, ListAnswerRecordsPagedResponse> listAnswerRecordsPagedCallable()397 listAnswerRecordsPagedCallable() { 398 return stub.listAnswerRecordsPagedCallable(); 399 } 400 401 // AUTO-GENERATED DOCUMENTATION AND METHOD. 402 /** 403 * Returns the list of all answer records in the specified project in reverse chronological order. 404 * 405 * <p>Sample code: 406 * 407 * <pre>{@code 408 * // This snippet has been automatically generated and should be regarded as a code template only. 409 * // It will require modifications to work: 410 * // - It may require correct/in-range values for request initialization. 411 * // - It may require specifying regional endpoints when creating the service client as shown in 412 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 413 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 414 * ListAnswerRecordsRequest request = 415 * ListAnswerRecordsRequest.newBuilder() 416 * .setParent(ProjectName.of("[PROJECT]").toString()) 417 * .setFilter("filter-1274492040") 418 * .setPageSize(883849137) 419 * .setPageToken("pageToken873572522") 420 * .build(); 421 * while (true) { 422 * ListAnswerRecordsResponse response = 423 * answerRecordsClient.listAnswerRecordsCallable().call(request); 424 * for (AnswerRecord element : response.getAnswerRecordsList()) { 425 * // doThingsWith(element); 426 * } 427 * String nextPageToken = response.getNextPageToken(); 428 * if (!Strings.isNullOrEmpty(nextPageToken)) { 429 * request = request.toBuilder().setPageToken(nextPageToken).build(); 430 * } else { 431 * break; 432 * } 433 * } 434 * } 435 * }</pre> 436 */ 437 public final UnaryCallable<ListAnswerRecordsRequest, ListAnswerRecordsResponse> listAnswerRecordsCallable()438 listAnswerRecordsCallable() { 439 return stub.listAnswerRecordsCallable(); 440 } 441 442 // AUTO-GENERATED DOCUMENTATION AND METHOD. 443 /** 444 * Updates the specified answer record. 445 * 446 * <p>Sample code: 447 * 448 * <pre>{@code 449 * // This snippet has been automatically generated and should be regarded as a code template only. 450 * // It will require modifications to work: 451 * // - It may require correct/in-range values for request initialization. 452 * // - It may require specifying regional endpoints when creating the service client as shown in 453 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 454 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 455 * AnswerRecord answerRecord = AnswerRecord.newBuilder().build(); 456 * FieldMask updateMask = FieldMask.newBuilder().build(); 457 * AnswerRecord response = answerRecordsClient.updateAnswerRecord(answerRecord, updateMask); 458 * } 459 * }</pre> 460 * 461 * @param answerRecord Required. Answer record to update. 462 * @param updateMask Required. The mask to control which fields get updated. 463 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 464 */ updateAnswerRecord(AnswerRecord answerRecord, FieldMask updateMask)465 public final AnswerRecord updateAnswerRecord(AnswerRecord answerRecord, FieldMask updateMask) { 466 UpdateAnswerRecordRequest request = 467 UpdateAnswerRecordRequest.newBuilder() 468 .setAnswerRecord(answerRecord) 469 .setUpdateMask(updateMask) 470 .build(); 471 return updateAnswerRecord(request); 472 } 473 474 // AUTO-GENERATED DOCUMENTATION AND METHOD. 475 /** 476 * Updates the specified answer record. 477 * 478 * <p>Sample code: 479 * 480 * <pre>{@code 481 * // This snippet has been automatically generated and should be regarded as a code template only. 482 * // It will require modifications to work: 483 * // - It may require correct/in-range values for request initialization. 484 * // - It may require specifying regional endpoints when creating the service client as shown in 485 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 486 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 487 * UpdateAnswerRecordRequest request = 488 * UpdateAnswerRecordRequest.newBuilder() 489 * .setAnswerRecord(AnswerRecord.newBuilder().build()) 490 * .setUpdateMask(FieldMask.newBuilder().build()) 491 * .build(); 492 * AnswerRecord response = answerRecordsClient.updateAnswerRecord(request); 493 * } 494 * }</pre> 495 * 496 * @param request The request object containing all of the parameters for the API call. 497 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 498 */ updateAnswerRecord(UpdateAnswerRecordRequest request)499 public final AnswerRecord updateAnswerRecord(UpdateAnswerRecordRequest request) { 500 return updateAnswerRecordCallable().call(request); 501 } 502 503 // AUTO-GENERATED DOCUMENTATION AND METHOD. 504 /** 505 * Updates the specified answer record. 506 * 507 * <p>Sample code: 508 * 509 * <pre>{@code 510 * // This snippet has been automatically generated and should be regarded as a code template only. 511 * // It will require modifications to work: 512 * // - It may require correct/in-range values for request initialization. 513 * // - It may require specifying regional endpoints when creating the service client as shown in 514 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 515 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 516 * UpdateAnswerRecordRequest request = 517 * UpdateAnswerRecordRequest.newBuilder() 518 * .setAnswerRecord(AnswerRecord.newBuilder().build()) 519 * .setUpdateMask(FieldMask.newBuilder().build()) 520 * .build(); 521 * ApiFuture<AnswerRecord> future = 522 * answerRecordsClient.updateAnswerRecordCallable().futureCall(request); 523 * // Do something. 524 * AnswerRecord response = future.get(); 525 * } 526 * }</pre> 527 */ updateAnswerRecordCallable()528 public final UnaryCallable<UpdateAnswerRecordRequest, AnswerRecord> updateAnswerRecordCallable() { 529 return stub.updateAnswerRecordCallable(); 530 } 531 532 // AUTO-GENERATED DOCUMENTATION AND METHOD. 533 /** 534 * Lists information about the supported locations for this service. 535 * 536 * <p>Sample code: 537 * 538 * <pre>{@code 539 * // This snippet has been automatically generated and should be regarded as a code template only. 540 * // It will require modifications to work: 541 * // - It may require correct/in-range values for request initialization. 542 * // - It may require specifying regional endpoints when creating the service client as shown in 543 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 544 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 545 * ListLocationsRequest request = 546 * ListLocationsRequest.newBuilder() 547 * .setName("name3373707") 548 * .setFilter("filter-1274492040") 549 * .setPageSize(883849137) 550 * .setPageToken("pageToken873572522") 551 * .build(); 552 * for (Location element : answerRecordsClient.listLocations(request).iterateAll()) { 553 * // doThingsWith(element); 554 * } 555 * } 556 * }</pre> 557 * 558 * @param request The request object containing all of the parameters for the API call. 559 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 560 */ listLocations(ListLocationsRequest request)561 public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { 562 return listLocationsPagedCallable().call(request); 563 } 564 565 // AUTO-GENERATED DOCUMENTATION AND METHOD. 566 /** 567 * Lists information about the supported locations for this service. 568 * 569 * <p>Sample code: 570 * 571 * <pre>{@code 572 * // This snippet has been automatically generated and should be regarded as a code template only. 573 * // It will require modifications to work: 574 * // - It may require correct/in-range values for request initialization. 575 * // - It may require specifying regional endpoints when creating the service client as shown in 576 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 577 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 578 * ListLocationsRequest request = 579 * ListLocationsRequest.newBuilder() 580 * .setName("name3373707") 581 * .setFilter("filter-1274492040") 582 * .setPageSize(883849137) 583 * .setPageToken("pageToken873572522") 584 * .build(); 585 * ApiFuture<Location> future = 586 * answerRecordsClient.listLocationsPagedCallable().futureCall(request); 587 * // Do something. 588 * for (Location element : future.get().iterateAll()) { 589 * // doThingsWith(element); 590 * } 591 * } 592 * }</pre> 593 */ 594 public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> listLocationsPagedCallable()595 listLocationsPagedCallable() { 596 return stub.listLocationsPagedCallable(); 597 } 598 599 // AUTO-GENERATED DOCUMENTATION AND METHOD. 600 /** 601 * Lists information about the supported locations for this service. 602 * 603 * <p>Sample code: 604 * 605 * <pre>{@code 606 * // This snippet has been automatically generated and should be regarded as a code template only. 607 * // It will require modifications to work: 608 * // - It may require correct/in-range values for request initialization. 609 * // - It may require specifying regional endpoints when creating the service client as shown in 610 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 611 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 612 * ListLocationsRequest request = 613 * ListLocationsRequest.newBuilder() 614 * .setName("name3373707") 615 * .setFilter("filter-1274492040") 616 * .setPageSize(883849137) 617 * .setPageToken("pageToken873572522") 618 * .build(); 619 * while (true) { 620 * ListLocationsResponse response = answerRecordsClient.listLocationsCallable().call(request); 621 * for (Location element : response.getLocationsList()) { 622 * // doThingsWith(element); 623 * } 624 * String nextPageToken = response.getNextPageToken(); 625 * if (!Strings.isNullOrEmpty(nextPageToken)) { 626 * request = request.toBuilder().setPageToken(nextPageToken).build(); 627 * } else { 628 * break; 629 * } 630 * } 631 * } 632 * }</pre> 633 */ listLocationsCallable()634 public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { 635 return stub.listLocationsCallable(); 636 } 637 638 // AUTO-GENERATED DOCUMENTATION AND METHOD. 639 /** 640 * Gets information about a location. 641 * 642 * <p>Sample code: 643 * 644 * <pre>{@code 645 * // This snippet has been automatically generated and should be regarded as a code template only. 646 * // It will require modifications to work: 647 * // - It may require correct/in-range values for request initialization. 648 * // - It may require specifying regional endpoints when creating the service client as shown in 649 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 650 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 651 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 652 * Location response = answerRecordsClient.getLocation(request); 653 * } 654 * }</pre> 655 * 656 * @param request The request object containing all of the parameters for the API call. 657 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 658 */ getLocation(GetLocationRequest request)659 public final Location getLocation(GetLocationRequest request) { 660 return getLocationCallable().call(request); 661 } 662 663 // AUTO-GENERATED DOCUMENTATION AND METHOD. 664 /** 665 * Gets information about a location. 666 * 667 * <p>Sample code: 668 * 669 * <pre>{@code 670 * // This snippet has been automatically generated and should be regarded as a code template only. 671 * // It will require modifications to work: 672 * // - It may require correct/in-range values for request initialization. 673 * // - It may require specifying regional endpoints when creating the service client as shown in 674 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 675 * try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { 676 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 677 * ApiFuture<Location> future = answerRecordsClient.getLocationCallable().futureCall(request); 678 * // Do something. 679 * Location response = future.get(); 680 * } 681 * }</pre> 682 */ getLocationCallable()683 public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { 684 return stub.getLocationCallable(); 685 } 686 687 @Override close()688 public final void close() { 689 stub.close(); 690 } 691 692 @Override shutdown()693 public void shutdown() { 694 stub.shutdown(); 695 } 696 697 @Override isShutdown()698 public boolean isShutdown() { 699 return stub.isShutdown(); 700 } 701 702 @Override isTerminated()703 public boolean isTerminated() { 704 return stub.isTerminated(); 705 } 706 707 @Override shutdownNow()708 public void shutdownNow() { 709 stub.shutdownNow(); 710 } 711 712 @Override awaitTermination(long duration, TimeUnit unit)713 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 714 return stub.awaitTermination(duration, unit); 715 } 716 717 public static class ListAnswerRecordsPagedResponse 718 extends AbstractPagedListResponse< 719 ListAnswerRecordsRequest, 720 ListAnswerRecordsResponse, 721 AnswerRecord, 722 ListAnswerRecordsPage, 723 ListAnswerRecordsFixedSizeCollection> { 724 createAsync( PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, ApiFuture<ListAnswerRecordsResponse> futureResponse)725 public static ApiFuture<ListAnswerRecordsPagedResponse> createAsync( 726 PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, 727 ApiFuture<ListAnswerRecordsResponse> futureResponse) { 728 ApiFuture<ListAnswerRecordsPage> futurePage = 729 ListAnswerRecordsPage.createEmptyPage().createPageAsync(context, futureResponse); 730 return ApiFutures.transform( 731 futurePage, 732 input -> new ListAnswerRecordsPagedResponse(input), 733 MoreExecutors.directExecutor()); 734 } 735 ListAnswerRecordsPagedResponse(ListAnswerRecordsPage page)736 private ListAnswerRecordsPagedResponse(ListAnswerRecordsPage page) { 737 super(page, ListAnswerRecordsFixedSizeCollection.createEmptyCollection()); 738 } 739 } 740 741 public static class ListAnswerRecordsPage 742 extends AbstractPage< 743 ListAnswerRecordsRequest, 744 ListAnswerRecordsResponse, 745 AnswerRecord, 746 ListAnswerRecordsPage> { 747 ListAnswerRecordsPage( PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, ListAnswerRecordsResponse response)748 private ListAnswerRecordsPage( 749 PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, 750 ListAnswerRecordsResponse response) { 751 super(context, response); 752 } 753 createEmptyPage()754 private static ListAnswerRecordsPage createEmptyPage() { 755 return new ListAnswerRecordsPage(null, null); 756 } 757 758 @Override createPage( PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, ListAnswerRecordsResponse response)759 protected ListAnswerRecordsPage createPage( 760 PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, 761 ListAnswerRecordsResponse response) { 762 return new ListAnswerRecordsPage(context, response); 763 } 764 765 @Override createPageAsync( PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, ApiFuture<ListAnswerRecordsResponse> futureResponse)766 public ApiFuture<ListAnswerRecordsPage> createPageAsync( 767 PageContext<ListAnswerRecordsRequest, ListAnswerRecordsResponse, AnswerRecord> context, 768 ApiFuture<ListAnswerRecordsResponse> futureResponse) { 769 return super.createPageAsync(context, futureResponse); 770 } 771 } 772 773 public static class ListAnswerRecordsFixedSizeCollection 774 extends AbstractFixedSizeCollection< 775 ListAnswerRecordsRequest, 776 ListAnswerRecordsResponse, 777 AnswerRecord, 778 ListAnswerRecordsPage, 779 ListAnswerRecordsFixedSizeCollection> { 780 ListAnswerRecordsFixedSizeCollection( List<ListAnswerRecordsPage> pages, int collectionSize)781 private ListAnswerRecordsFixedSizeCollection( 782 List<ListAnswerRecordsPage> pages, int collectionSize) { 783 super(pages, collectionSize); 784 } 785 createEmptyCollection()786 private static ListAnswerRecordsFixedSizeCollection createEmptyCollection() { 787 return new ListAnswerRecordsFixedSizeCollection(null, 0); 788 } 789 790 @Override createCollection( List<ListAnswerRecordsPage> pages, int collectionSize)791 protected ListAnswerRecordsFixedSizeCollection createCollection( 792 List<ListAnswerRecordsPage> pages, int collectionSize) { 793 return new ListAnswerRecordsFixedSizeCollection(pages, collectionSize); 794 } 795 } 796 797 public static class ListLocationsPagedResponse 798 extends AbstractPagedListResponse< 799 ListLocationsRequest, 800 ListLocationsResponse, 801 Location, 802 ListLocationsPage, 803 ListLocationsFixedSizeCollection> { 804 createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)805 public static ApiFuture<ListLocationsPagedResponse> createAsync( 806 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 807 ApiFuture<ListLocationsResponse> futureResponse) { 808 ApiFuture<ListLocationsPage> futurePage = 809 ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); 810 return ApiFutures.transform( 811 futurePage, 812 input -> new ListLocationsPagedResponse(input), 813 MoreExecutors.directExecutor()); 814 } 815 ListLocationsPagedResponse(ListLocationsPage page)816 private ListLocationsPagedResponse(ListLocationsPage page) { 817 super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); 818 } 819 } 820 821 public static class ListLocationsPage 822 extends AbstractPage< 823 ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { 824 ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)825 private ListLocationsPage( 826 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 827 ListLocationsResponse response) { 828 super(context, response); 829 } 830 createEmptyPage()831 private static ListLocationsPage createEmptyPage() { 832 return new ListLocationsPage(null, null); 833 } 834 835 @Override createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)836 protected ListLocationsPage createPage( 837 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 838 ListLocationsResponse response) { 839 return new ListLocationsPage(context, response); 840 } 841 842 @Override createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)843 public ApiFuture<ListLocationsPage> createPageAsync( 844 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 845 ApiFuture<ListLocationsResponse> futureResponse) { 846 return super.createPageAsync(context, futureResponse); 847 } 848 } 849 850 public static class ListLocationsFixedSizeCollection 851 extends AbstractFixedSizeCollection< 852 ListLocationsRequest, 853 ListLocationsResponse, 854 Location, 855 ListLocationsPage, 856 ListLocationsFixedSizeCollection> { 857 ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)858 private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { 859 super(pages, collectionSize); 860 } 861 createEmptyCollection()862 private static ListLocationsFixedSizeCollection createEmptyCollection() { 863 return new ListLocationsFixedSizeCollection(null, 0); 864 } 865 866 @Override createCollection( List<ListLocationsPage> pages, int collectionSize)867 protected ListLocationsFixedSizeCollection createCollection( 868 List<ListLocationsPage> pages, int collectionSize) { 869 return new ListLocationsFixedSizeCollection(pages, collectionSize); 870 } 871 } 872 } 873