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.speech.v1p1beta1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.paging.AbstractFixedSizeCollection; 24 import com.google.api.gax.paging.AbstractPage; 25 import com.google.api.gax.paging.AbstractPagedListResponse; 26 import com.google.api.gax.rpc.PageContext; 27 import com.google.api.gax.rpc.UnaryCallable; 28 import com.google.cloud.speech.v1p1beta1.stub.AdaptationStub; 29 import com.google.cloud.speech.v1p1beta1.stub.AdaptationStubSettings; 30 import com.google.common.util.concurrent.MoreExecutors; 31 import com.google.protobuf.Empty; 32 import com.google.protobuf.FieldMask; 33 import java.io.IOException; 34 import java.util.List; 35 import java.util.concurrent.TimeUnit; 36 import javax.annotation.Generated; 37 38 // AUTO-GENERATED DOCUMENTATION AND CLASS. 39 /** 40 * Service Description: Service that implements Google Cloud Speech Adaptation API. 41 * 42 * <p>This class provides the ability to make remote calls to the backing service through method 43 * calls that map to API methods. Sample code to get started: 44 * 45 * <pre>{@code 46 * // This snippet has been automatically generated and should be regarded as a code template only. 47 * // It will require modifications to work: 48 * // - It may require correct/in-range values for request initialization. 49 * // - It may require specifying regional endpoints when creating the service client as shown in 50 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 51 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 52 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 53 * PhraseSet phraseSet = PhraseSet.newBuilder().build(); 54 * String phraseSetId = "phraseSetId959902180"; 55 * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); 56 * } 57 * }</pre> 58 * 59 * <p>Note: close() needs to be called on the AdaptationClient object to clean up resources such as 60 * threads. In the example above, try-with-resources is used, which automatically calls close(). 61 * 62 * <p>The surface of this class includes several types of Java methods for each of the API's 63 * methods: 64 * 65 * <ol> 66 * <li>A "flattened" method. With this type of method, the fields of the request type have been 67 * converted into function parameters. It may be the case that not all fields are available as 68 * parameters, and not every API method will have a flattened method entry point. 69 * <li>A "request object" method. This type of method only takes one parameter, a request object, 70 * which must be constructed before the call. Not every API method will have a request object 71 * method. 72 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 73 * callable object, which can be used to initiate calls to the service. 74 * </ol> 75 * 76 * <p>See the individual methods for example code. 77 * 78 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 79 * these names, this class includes a format method for each type of name, and additionally a parse 80 * method to extract the individual identifiers contained within names that are returned. 81 * 82 * <p>This class can be customized by passing in a custom instance of AdaptationSettings to 83 * create(). For example: 84 * 85 * <p>To customize credentials: 86 * 87 * <pre>{@code 88 * // This snippet has been automatically generated and should be regarded as a code template only. 89 * // It will require modifications to work: 90 * // - It may require correct/in-range values for request initialization. 91 * // - It may require specifying regional endpoints when creating the service client as shown in 92 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 93 * AdaptationSettings adaptationSettings = 94 * AdaptationSettings.newBuilder() 95 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 96 * .build(); 97 * AdaptationClient adaptationClient = AdaptationClient.create(adaptationSettings); 98 * }</pre> 99 * 100 * <p>To customize the endpoint: 101 * 102 * <pre>{@code 103 * // This snippet has been automatically generated and should be regarded as a code template only. 104 * // It will require modifications to work: 105 * // - It may require correct/in-range values for request initialization. 106 * // - It may require specifying regional endpoints when creating the service client as shown in 107 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 108 * AdaptationSettings adaptationSettings = 109 * AdaptationSettings.newBuilder().setEndpoint(myEndpoint).build(); 110 * AdaptationClient adaptationClient = AdaptationClient.create(adaptationSettings); 111 * }</pre> 112 * 113 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 114 * the wire: 115 * 116 * <pre>{@code 117 * // This snippet has been automatically generated and should be regarded as a code template only. 118 * // It will require modifications to work: 119 * // - It may require correct/in-range values for request initialization. 120 * // - It may require specifying regional endpoints when creating the service client as shown in 121 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 122 * AdaptationSettings adaptationSettings = AdaptationSettings.newHttpJsonBuilder().build(); 123 * AdaptationClient adaptationClient = AdaptationClient.create(adaptationSettings); 124 * }</pre> 125 * 126 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 127 */ 128 @BetaApi 129 @Generated("by gapic-generator-java") 130 public class AdaptationClient implements BackgroundResource { 131 private final AdaptationSettings settings; 132 private final AdaptationStub stub; 133 134 /** Constructs an instance of AdaptationClient with default settings. */ create()135 public static final AdaptationClient create() throws IOException { 136 return create(AdaptationSettings.newBuilder().build()); 137 } 138 139 /** 140 * Constructs an instance of AdaptationClient, using the given settings. The channels are created 141 * based on the settings passed in, or defaults for any settings that are not set. 142 */ create(AdaptationSettings settings)143 public static final AdaptationClient create(AdaptationSettings settings) throws IOException { 144 return new AdaptationClient(settings); 145 } 146 147 /** 148 * Constructs an instance of AdaptationClient, using the given stub for making calls. This is for 149 * advanced usage - prefer using create(AdaptationSettings). 150 */ create(AdaptationStub stub)151 public static final AdaptationClient create(AdaptationStub stub) { 152 return new AdaptationClient(stub); 153 } 154 155 /** 156 * Constructs an instance of AdaptationClient, using the given settings. This is protected so that 157 * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. 158 */ AdaptationClient(AdaptationSettings settings)159 protected AdaptationClient(AdaptationSettings settings) throws IOException { 160 this.settings = settings; 161 this.stub = ((AdaptationStubSettings) settings.getStubSettings()).createStub(); 162 } 163 AdaptationClient(AdaptationStub stub)164 protected AdaptationClient(AdaptationStub stub) { 165 this.settings = null; 166 this.stub = stub; 167 } 168 getSettings()169 public final AdaptationSettings getSettings() { 170 return settings; 171 } 172 getStub()173 public AdaptationStub getStub() { 174 return stub; 175 } 176 177 // AUTO-GENERATED DOCUMENTATION AND METHOD. 178 /** 179 * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. 180 * The items in the PhraseSet are favored by the recognition model when you send a call that 181 * includes the PhraseSet. 182 * 183 * <p>Sample code: 184 * 185 * <pre>{@code 186 * // This snippet has been automatically generated and should be regarded as a code template only. 187 * // It will require modifications to work: 188 * // - It may require correct/in-range values for request initialization. 189 * // - It may require specifying regional endpoints when creating the service client as shown in 190 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 191 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 192 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 193 * PhraseSet phraseSet = PhraseSet.newBuilder().build(); 194 * String phraseSetId = "phraseSetId959902180"; 195 * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); 196 * } 197 * }</pre> 198 * 199 * @param parent Required. The parent resource where this phrase set will be created. Format: 200 * <p>`projects/{project}/locations/{location}` 201 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 202 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 203 * location. To specify a region, use a [regional 204 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 205 * `eu` location value. 206 * @param phraseSet Required. The phrase set to create. 207 * @param phraseSetId Required. The ID to use for the phrase set, which will become the final 208 * component of the phrase set's resource name. 209 * <p>This value should restrict to letters, numbers, and hyphens, with the first character a 210 * letter, the last a letter or a number, and be 4-63 characters. 211 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 212 */ createPhraseSet( LocationName parent, PhraseSet phraseSet, String phraseSetId)213 public final PhraseSet createPhraseSet( 214 LocationName parent, PhraseSet phraseSet, String phraseSetId) { 215 CreatePhraseSetRequest request = 216 CreatePhraseSetRequest.newBuilder() 217 .setParent(parent == null ? null : parent.toString()) 218 .setPhraseSet(phraseSet) 219 .setPhraseSetId(phraseSetId) 220 .build(); 221 return createPhraseSet(request); 222 } 223 224 // AUTO-GENERATED DOCUMENTATION AND METHOD. 225 /** 226 * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. 227 * The items in the PhraseSet are favored by the recognition model when you send a call that 228 * includes the PhraseSet. 229 * 230 * <p>Sample code: 231 * 232 * <pre>{@code 233 * // This snippet has been automatically generated and should be regarded as a code template only. 234 * // It will require modifications to work: 235 * // - It may require correct/in-range values for request initialization. 236 * // - It may require specifying regional endpoints when creating the service client as shown in 237 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 238 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 239 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 240 * PhraseSet phraseSet = PhraseSet.newBuilder().build(); 241 * String phraseSetId = "phraseSetId959902180"; 242 * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); 243 * } 244 * }</pre> 245 * 246 * @param parent Required. The parent resource where this phrase set will be created. Format: 247 * <p>`projects/{project}/locations/{location}` 248 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 249 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 250 * location. To specify a region, use a [regional 251 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 252 * `eu` location value. 253 * @param phraseSet Required. The phrase set to create. 254 * @param phraseSetId Required. The ID to use for the phrase set, which will become the final 255 * component of the phrase set's resource name. 256 * <p>This value should restrict to letters, numbers, and hyphens, with the first character a 257 * letter, the last a letter or a number, and be 4-63 characters. 258 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 259 */ createPhraseSet(String parent, PhraseSet phraseSet, String phraseSetId)260 public final PhraseSet createPhraseSet(String parent, PhraseSet phraseSet, String phraseSetId) { 261 CreatePhraseSetRequest request = 262 CreatePhraseSetRequest.newBuilder() 263 .setParent(parent) 264 .setPhraseSet(phraseSet) 265 .setPhraseSetId(phraseSetId) 266 .build(); 267 return createPhraseSet(request); 268 } 269 270 // AUTO-GENERATED DOCUMENTATION AND METHOD. 271 /** 272 * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. 273 * The items in the PhraseSet are favored by the recognition model when you send a call that 274 * includes the PhraseSet. 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 (AdaptationClient adaptationClient = AdaptationClient.create()) { 285 * CreatePhraseSetRequest request = 286 * CreatePhraseSetRequest.newBuilder() 287 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 288 * .setPhraseSetId("phraseSetId959902180") 289 * .setPhraseSet(PhraseSet.newBuilder().build()) 290 * .build(); 291 * PhraseSet response = adaptationClient.createPhraseSet(request); 292 * } 293 * }</pre> 294 * 295 * @param request The request object containing all of the parameters for the API call. 296 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 297 */ createPhraseSet(CreatePhraseSetRequest request)298 public final PhraseSet createPhraseSet(CreatePhraseSetRequest request) { 299 return createPhraseSetCallable().call(request); 300 } 301 302 // AUTO-GENERATED DOCUMENTATION AND METHOD. 303 /** 304 * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. 305 * The items in the PhraseSet are favored by the recognition model when you send a call that 306 * includes the PhraseSet. 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 (AdaptationClient adaptationClient = AdaptationClient.create()) { 317 * CreatePhraseSetRequest request = 318 * CreatePhraseSetRequest.newBuilder() 319 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 320 * .setPhraseSetId("phraseSetId959902180") 321 * .setPhraseSet(PhraseSet.newBuilder().build()) 322 * .build(); 323 * ApiFuture<PhraseSet> future = adaptationClient.createPhraseSetCallable().futureCall(request); 324 * // Do something. 325 * PhraseSet response = future.get(); 326 * } 327 * }</pre> 328 */ createPhraseSetCallable()329 public final UnaryCallable<CreatePhraseSetRequest, PhraseSet> createPhraseSetCallable() { 330 return stub.createPhraseSetCallable(); 331 } 332 333 // AUTO-GENERATED DOCUMENTATION AND METHOD. 334 /** 335 * Get a phrase set. 336 * 337 * <p>Sample code: 338 * 339 * <pre>{@code 340 * // This snippet has been automatically generated and should be regarded as a code template only. 341 * // It will require modifications to work: 342 * // - It may require correct/in-range values for request initialization. 343 * // - It may require specifying regional endpoints when creating the service client as shown in 344 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 345 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 346 * PhraseSetName name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]"); 347 * PhraseSet response = adaptationClient.getPhraseSet(name); 348 * } 349 * }</pre> 350 * 351 * @param name Required. The name of the phrase set to retrieve. Format: 352 * <p>`projects/{project}/locations/{location}/phraseSets/{phrase_set}` 353 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 354 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 355 * location. To specify a region, use a [regional 356 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 357 * `eu` location value. 358 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 359 */ getPhraseSet(PhraseSetName name)360 public final PhraseSet getPhraseSet(PhraseSetName name) { 361 GetPhraseSetRequest request = 362 GetPhraseSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 363 return getPhraseSet(request); 364 } 365 366 // AUTO-GENERATED DOCUMENTATION AND METHOD. 367 /** 368 * Get a phrase set. 369 * 370 * <p>Sample code: 371 * 372 * <pre>{@code 373 * // This snippet has been automatically generated and should be regarded as a code template only. 374 * // It will require modifications to work: 375 * // - It may require correct/in-range values for request initialization. 376 * // - It may require specifying regional endpoints when creating the service client as shown in 377 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 378 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 379 * String name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); 380 * PhraseSet response = adaptationClient.getPhraseSet(name); 381 * } 382 * }</pre> 383 * 384 * @param name Required. The name of the phrase set to retrieve. Format: 385 * <p>`projects/{project}/locations/{location}/phraseSets/{phrase_set}` 386 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 387 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 388 * location. To specify a region, use a [regional 389 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 390 * `eu` location value. 391 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 392 */ getPhraseSet(String name)393 public final PhraseSet getPhraseSet(String name) { 394 GetPhraseSetRequest request = GetPhraseSetRequest.newBuilder().setName(name).build(); 395 return getPhraseSet(request); 396 } 397 398 // AUTO-GENERATED DOCUMENTATION AND METHOD. 399 /** 400 * Get a phrase set. 401 * 402 * <p>Sample code: 403 * 404 * <pre>{@code 405 * // This snippet has been automatically generated and should be regarded as a code template only. 406 * // It will require modifications to work: 407 * // - It may require correct/in-range values for request initialization. 408 * // - It may require specifying regional endpoints when creating the service client as shown in 409 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 410 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 411 * GetPhraseSetRequest request = 412 * GetPhraseSetRequest.newBuilder() 413 * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) 414 * .build(); 415 * PhraseSet response = adaptationClient.getPhraseSet(request); 416 * } 417 * }</pre> 418 * 419 * @param request The request object containing all of the parameters for the API call. 420 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 421 */ getPhraseSet(GetPhraseSetRequest request)422 public final PhraseSet getPhraseSet(GetPhraseSetRequest request) { 423 return getPhraseSetCallable().call(request); 424 } 425 426 // AUTO-GENERATED DOCUMENTATION AND METHOD. 427 /** 428 * Get a phrase set. 429 * 430 * <p>Sample code: 431 * 432 * <pre>{@code 433 * // This snippet has been automatically generated and should be regarded as a code template only. 434 * // It will require modifications to work: 435 * // - It may require correct/in-range values for request initialization. 436 * // - It may require specifying regional endpoints when creating the service client as shown in 437 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 438 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 439 * GetPhraseSetRequest request = 440 * GetPhraseSetRequest.newBuilder() 441 * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) 442 * .build(); 443 * ApiFuture<PhraseSet> future = adaptationClient.getPhraseSetCallable().futureCall(request); 444 * // Do something. 445 * PhraseSet response = future.get(); 446 * } 447 * }</pre> 448 */ getPhraseSetCallable()449 public final UnaryCallable<GetPhraseSetRequest, PhraseSet> getPhraseSetCallable() { 450 return stub.getPhraseSetCallable(); 451 } 452 453 // AUTO-GENERATED DOCUMENTATION AND METHOD. 454 /** 455 * List phrase sets. 456 * 457 * <p>Sample code: 458 * 459 * <pre>{@code 460 * // This snippet has been automatically generated and should be regarded as a code template only. 461 * // It will require modifications to work: 462 * // - It may require correct/in-range values for request initialization. 463 * // - It may require specifying regional endpoints when creating the service client as shown in 464 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 465 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 466 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 467 * for (PhraseSet element : adaptationClient.listPhraseSet(parent).iterateAll()) { 468 * // doThingsWith(element); 469 * } 470 * } 471 * }</pre> 472 * 473 * @param parent Required. The parent, which owns this collection of phrase set. Format: 474 * <p>`projects/{project}/locations/{location}` 475 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 476 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 477 * location. To specify a region, use a [regional 478 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 479 * `eu` location value. 480 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 481 */ listPhraseSet(LocationName parent)482 public final ListPhraseSetPagedResponse listPhraseSet(LocationName parent) { 483 ListPhraseSetRequest request = 484 ListPhraseSetRequest.newBuilder() 485 .setParent(parent == null ? null : parent.toString()) 486 .build(); 487 return listPhraseSet(request); 488 } 489 490 // AUTO-GENERATED DOCUMENTATION AND METHOD. 491 /** 492 * List phrase sets. 493 * 494 * <p>Sample code: 495 * 496 * <pre>{@code 497 * // This snippet has been automatically generated and should be regarded as a code template only. 498 * // It will require modifications to work: 499 * // - It may require correct/in-range values for request initialization. 500 * // - It may require specifying regional endpoints when creating the service client as shown in 501 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 502 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 503 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 504 * for (PhraseSet element : adaptationClient.listPhraseSet(parent).iterateAll()) { 505 * // doThingsWith(element); 506 * } 507 * } 508 * }</pre> 509 * 510 * @param parent Required. The parent, which owns this collection of phrase set. Format: 511 * <p>`projects/{project}/locations/{location}` 512 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 513 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 514 * location. To specify a region, use a [regional 515 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 516 * `eu` location value. 517 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 518 */ listPhraseSet(String parent)519 public final ListPhraseSetPagedResponse listPhraseSet(String parent) { 520 ListPhraseSetRequest request = ListPhraseSetRequest.newBuilder().setParent(parent).build(); 521 return listPhraseSet(request); 522 } 523 524 // AUTO-GENERATED DOCUMENTATION AND METHOD. 525 /** 526 * List phrase sets. 527 * 528 * <p>Sample code: 529 * 530 * <pre>{@code 531 * // This snippet has been automatically generated and should be regarded as a code template only. 532 * // It will require modifications to work: 533 * // - It may require correct/in-range values for request initialization. 534 * // - It may require specifying regional endpoints when creating the service client as shown in 535 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 536 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 537 * ListPhraseSetRequest request = 538 * ListPhraseSetRequest.newBuilder() 539 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 540 * .setPageSize(883849137) 541 * .setPageToken("pageToken873572522") 542 * .build(); 543 * for (PhraseSet element : adaptationClient.listPhraseSet(request).iterateAll()) { 544 * // doThingsWith(element); 545 * } 546 * } 547 * }</pre> 548 * 549 * @param request The request object containing all of the parameters for the API call. 550 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 551 */ listPhraseSet(ListPhraseSetRequest request)552 public final ListPhraseSetPagedResponse listPhraseSet(ListPhraseSetRequest request) { 553 return listPhraseSetPagedCallable().call(request); 554 } 555 556 // AUTO-GENERATED DOCUMENTATION AND METHOD. 557 /** 558 * List phrase sets. 559 * 560 * <p>Sample code: 561 * 562 * <pre>{@code 563 * // This snippet has been automatically generated and should be regarded as a code template only. 564 * // It will require modifications to work: 565 * // - It may require correct/in-range values for request initialization. 566 * // - It may require specifying regional endpoints when creating the service client as shown in 567 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 568 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 569 * ListPhraseSetRequest request = 570 * ListPhraseSetRequest.newBuilder() 571 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 572 * .setPageSize(883849137) 573 * .setPageToken("pageToken873572522") 574 * .build(); 575 * ApiFuture<PhraseSet> future = 576 * adaptationClient.listPhraseSetPagedCallable().futureCall(request); 577 * // Do something. 578 * for (PhraseSet element : future.get().iterateAll()) { 579 * // doThingsWith(element); 580 * } 581 * } 582 * }</pre> 583 */ 584 public final UnaryCallable<ListPhraseSetRequest, ListPhraseSetPagedResponse> listPhraseSetPagedCallable()585 listPhraseSetPagedCallable() { 586 return stub.listPhraseSetPagedCallable(); 587 } 588 589 // AUTO-GENERATED DOCUMENTATION AND METHOD. 590 /** 591 * List phrase sets. 592 * 593 * <p>Sample code: 594 * 595 * <pre>{@code 596 * // This snippet has been automatically generated and should be regarded as a code template only. 597 * // It will require modifications to work: 598 * // - It may require correct/in-range values for request initialization. 599 * // - It may require specifying regional endpoints when creating the service client as shown in 600 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 601 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 602 * ListPhraseSetRequest request = 603 * ListPhraseSetRequest.newBuilder() 604 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 605 * .setPageSize(883849137) 606 * .setPageToken("pageToken873572522") 607 * .build(); 608 * while (true) { 609 * ListPhraseSetResponse response = adaptationClient.listPhraseSetCallable().call(request); 610 * for (PhraseSet element : response.getPhraseSetsList()) { 611 * // doThingsWith(element); 612 * } 613 * String nextPageToken = response.getNextPageToken(); 614 * if (!Strings.isNullOrEmpty(nextPageToken)) { 615 * request = request.toBuilder().setPageToken(nextPageToken).build(); 616 * } else { 617 * break; 618 * } 619 * } 620 * } 621 * }</pre> 622 */ listPhraseSetCallable()623 public final UnaryCallable<ListPhraseSetRequest, ListPhraseSetResponse> listPhraseSetCallable() { 624 return stub.listPhraseSetCallable(); 625 } 626 627 // AUTO-GENERATED DOCUMENTATION AND METHOD. 628 /** 629 * Update a phrase set. 630 * 631 * <p>Sample code: 632 * 633 * <pre>{@code 634 * // This snippet has been automatically generated and should be regarded as a code template only. 635 * // It will require modifications to work: 636 * // - It may require correct/in-range values for request initialization. 637 * // - It may require specifying regional endpoints when creating the service client as shown in 638 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 639 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 640 * PhraseSet phraseSet = PhraseSet.newBuilder().build(); 641 * FieldMask updateMask = FieldMask.newBuilder().build(); 642 * PhraseSet response = adaptationClient.updatePhraseSet(phraseSet, updateMask); 643 * } 644 * }</pre> 645 * 646 * @param phraseSet Required. The phrase set to update. 647 * <p>The phrase set's `name` field is used to identify the set to be updated. Format: 648 * <p>`projects/{project}/locations/{location}/phraseSets/{phrase_set}` 649 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 650 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 651 * location. To specify a region, use a [regional 652 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 653 * `eu` location value. 654 * @param updateMask The list of fields to be updated. 655 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 656 */ updatePhraseSet(PhraseSet phraseSet, FieldMask updateMask)657 public final PhraseSet updatePhraseSet(PhraseSet phraseSet, FieldMask updateMask) { 658 UpdatePhraseSetRequest request = 659 UpdatePhraseSetRequest.newBuilder() 660 .setPhraseSet(phraseSet) 661 .setUpdateMask(updateMask) 662 .build(); 663 return updatePhraseSet(request); 664 } 665 666 // AUTO-GENERATED DOCUMENTATION AND METHOD. 667 /** 668 * Update a phrase set. 669 * 670 * <p>Sample code: 671 * 672 * <pre>{@code 673 * // This snippet has been automatically generated and should be regarded as a code template only. 674 * // It will require modifications to work: 675 * // - It may require correct/in-range values for request initialization. 676 * // - It may require specifying regional endpoints when creating the service client as shown in 677 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 678 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 679 * UpdatePhraseSetRequest request = 680 * UpdatePhraseSetRequest.newBuilder() 681 * .setPhraseSet(PhraseSet.newBuilder().build()) 682 * .setUpdateMask(FieldMask.newBuilder().build()) 683 * .build(); 684 * PhraseSet response = adaptationClient.updatePhraseSet(request); 685 * } 686 * }</pre> 687 * 688 * @param request The request object containing all of the parameters for the API call. 689 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 690 */ updatePhraseSet(UpdatePhraseSetRequest request)691 public final PhraseSet updatePhraseSet(UpdatePhraseSetRequest request) { 692 return updatePhraseSetCallable().call(request); 693 } 694 695 // AUTO-GENERATED DOCUMENTATION AND METHOD. 696 /** 697 * Update a phrase set. 698 * 699 * <p>Sample code: 700 * 701 * <pre>{@code 702 * // This snippet has been automatically generated and should be regarded as a code template only. 703 * // It will require modifications to work: 704 * // - It may require correct/in-range values for request initialization. 705 * // - It may require specifying regional endpoints when creating the service client as shown in 706 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 707 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 708 * UpdatePhraseSetRequest request = 709 * UpdatePhraseSetRequest.newBuilder() 710 * .setPhraseSet(PhraseSet.newBuilder().build()) 711 * .setUpdateMask(FieldMask.newBuilder().build()) 712 * .build(); 713 * ApiFuture<PhraseSet> future = adaptationClient.updatePhraseSetCallable().futureCall(request); 714 * // Do something. 715 * PhraseSet response = future.get(); 716 * } 717 * }</pre> 718 */ updatePhraseSetCallable()719 public final UnaryCallable<UpdatePhraseSetRequest, PhraseSet> updatePhraseSetCallable() { 720 return stub.updatePhraseSetCallable(); 721 } 722 723 // AUTO-GENERATED DOCUMENTATION AND METHOD. 724 /** 725 * Delete a phrase set. 726 * 727 * <p>Sample code: 728 * 729 * <pre>{@code 730 * // This snippet has been automatically generated and should be regarded as a code template only. 731 * // It will require modifications to work: 732 * // - It may require correct/in-range values for request initialization. 733 * // - It may require specifying regional endpoints when creating the service client as shown in 734 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 735 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 736 * PhraseSetName name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]"); 737 * adaptationClient.deletePhraseSet(name); 738 * } 739 * }</pre> 740 * 741 * @param name Required. The name of the phrase set to delete. Format: 742 * <p>`projects/{project}/locations/{location}/phraseSets/{phrase_set}` 743 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 744 */ deletePhraseSet(PhraseSetName name)745 public final void deletePhraseSet(PhraseSetName name) { 746 DeletePhraseSetRequest request = 747 DeletePhraseSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 748 deletePhraseSet(request); 749 } 750 751 // AUTO-GENERATED DOCUMENTATION AND METHOD. 752 /** 753 * Delete a phrase set. 754 * 755 * <p>Sample code: 756 * 757 * <pre>{@code 758 * // This snippet has been automatically generated and should be regarded as a code template only. 759 * // It will require modifications to work: 760 * // - It may require correct/in-range values for request initialization. 761 * // - It may require specifying regional endpoints when creating the service client as shown in 762 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 763 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 764 * String name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); 765 * adaptationClient.deletePhraseSet(name); 766 * } 767 * }</pre> 768 * 769 * @param name Required. The name of the phrase set to delete. Format: 770 * <p>`projects/{project}/locations/{location}/phraseSets/{phrase_set}` 771 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 772 */ deletePhraseSet(String name)773 public final void deletePhraseSet(String name) { 774 DeletePhraseSetRequest request = DeletePhraseSetRequest.newBuilder().setName(name).build(); 775 deletePhraseSet(request); 776 } 777 778 // AUTO-GENERATED DOCUMENTATION AND METHOD. 779 /** 780 * Delete a phrase set. 781 * 782 * <p>Sample code: 783 * 784 * <pre>{@code 785 * // This snippet has been automatically generated and should be regarded as a code template only. 786 * // It will require modifications to work: 787 * // - It may require correct/in-range values for request initialization. 788 * // - It may require specifying regional endpoints when creating the service client as shown in 789 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 790 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 791 * DeletePhraseSetRequest request = 792 * DeletePhraseSetRequest.newBuilder() 793 * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) 794 * .build(); 795 * adaptationClient.deletePhraseSet(request); 796 * } 797 * }</pre> 798 * 799 * @param request The request object containing all of the parameters for the API call. 800 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 801 */ deletePhraseSet(DeletePhraseSetRequest request)802 public final void deletePhraseSet(DeletePhraseSetRequest request) { 803 deletePhraseSetCallable().call(request); 804 } 805 806 // AUTO-GENERATED DOCUMENTATION AND METHOD. 807 /** 808 * Delete a phrase set. 809 * 810 * <p>Sample code: 811 * 812 * <pre>{@code 813 * // This snippet has been automatically generated and should be regarded as a code template only. 814 * // It will require modifications to work: 815 * // - It may require correct/in-range values for request initialization. 816 * // - It may require specifying regional endpoints when creating the service client as shown in 817 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 818 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 819 * DeletePhraseSetRequest request = 820 * DeletePhraseSetRequest.newBuilder() 821 * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) 822 * .build(); 823 * ApiFuture<Empty> future = adaptationClient.deletePhraseSetCallable().futureCall(request); 824 * // Do something. 825 * future.get(); 826 * } 827 * }</pre> 828 */ deletePhraseSetCallable()829 public final UnaryCallable<DeletePhraseSetRequest, Empty> deletePhraseSetCallable() { 830 return stub.deletePhraseSetCallable(); 831 } 832 833 // AUTO-GENERATED DOCUMENTATION AND METHOD. 834 /** 835 * Create a custom class. 836 * 837 * <p>Sample code: 838 * 839 * <pre>{@code 840 * // This snippet has been automatically generated and should be regarded as a code template only. 841 * // It will require modifications to work: 842 * // - It may require correct/in-range values for request initialization. 843 * // - It may require specifying regional endpoints when creating the service client as shown in 844 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 845 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 846 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 847 * CustomClass customClass = CustomClass.newBuilder().build(); 848 * String customClassId = "customClassId1871032322"; 849 * CustomClass response = adaptationClient.createCustomClass(parent, customClass, customClassId); 850 * } 851 * }</pre> 852 * 853 * @param parent Required. The parent resource where this custom class will be created. Format: 854 * <p>`projects/{project}/locations/{location}/customClasses` 855 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 856 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 857 * location. To specify a region, use a [regional 858 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 859 * `eu` location value. 860 * @param customClass Required. The custom class to create. 861 * @param customClassId Required. The ID to use for the custom class, which will become the final 862 * component of the custom class' resource name. 863 * <p>This value should restrict to letters, numbers, and hyphens, with the first character a 864 * letter, the last a letter or a number, and be 4-63 characters. 865 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 866 */ createCustomClass( LocationName parent, CustomClass customClass, String customClassId)867 public final CustomClass createCustomClass( 868 LocationName parent, CustomClass customClass, String customClassId) { 869 CreateCustomClassRequest request = 870 CreateCustomClassRequest.newBuilder() 871 .setParent(parent == null ? null : parent.toString()) 872 .setCustomClass(customClass) 873 .setCustomClassId(customClassId) 874 .build(); 875 return createCustomClass(request); 876 } 877 878 // AUTO-GENERATED DOCUMENTATION AND METHOD. 879 /** 880 * Create a custom class. 881 * 882 * <p>Sample code: 883 * 884 * <pre>{@code 885 * // This snippet has been automatically generated and should be regarded as a code template only. 886 * // It will require modifications to work: 887 * // - It may require correct/in-range values for request initialization. 888 * // - It may require specifying regional endpoints when creating the service client as shown in 889 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 890 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 891 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 892 * CustomClass customClass = CustomClass.newBuilder().build(); 893 * String customClassId = "customClassId1871032322"; 894 * CustomClass response = adaptationClient.createCustomClass(parent, customClass, customClassId); 895 * } 896 * }</pre> 897 * 898 * @param parent Required. The parent resource where this custom class will be created. Format: 899 * <p>`projects/{project}/locations/{location}/customClasses` 900 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 901 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 902 * location. To specify a region, use a [regional 903 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 904 * `eu` location value. 905 * @param customClass Required. The custom class to create. 906 * @param customClassId Required. The ID to use for the custom class, which will become the final 907 * component of the custom class' resource name. 908 * <p>This value should restrict to letters, numbers, and hyphens, with the first character a 909 * letter, the last a letter or a number, and be 4-63 characters. 910 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 911 */ createCustomClass( String parent, CustomClass customClass, String customClassId)912 public final CustomClass createCustomClass( 913 String parent, CustomClass customClass, String customClassId) { 914 CreateCustomClassRequest request = 915 CreateCustomClassRequest.newBuilder() 916 .setParent(parent) 917 .setCustomClass(customClass) 918 .setCustomClassId(customClassId) 919 .build(); 920 return createCustomClass(request); 921 } 922 923 // AUTO-GENERATED DOCUMENTATION AND METHOD. 924 /** 925 * Create a custom class. 926 * 927 * <p>Sample code: 928 * 929 * <pre>{@code 930 * // This snippet has been automatically generated and should be regarded as a code template only. 931 * // It will require modifications to work: 932 * // - It may require correct/in-range values for request initialization. 933 * // - It may require specifying regional endpoints when creating the service client as shown in 934 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 935 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 936 * CreateCustomClassRequest request = 937 * CreateCustomClassRequest.newBuilder() 938 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 939 * .setCustomClassId("customClassId1871032322") 940 * .setCustomClass(CustomClass.newBuilder().build()) 941 * .build(); 942 * CustomClass response = adaptationClient.createCustomClass(request); 943 * } 944 * }</pre> 945 * 946 * @param request The request object containing all of the parameters for the API call. 947 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 948 */ createCustomClass(CreateCustomClassRequest request)949 public final CustomClass createCustomClass(CreateCustomClassRequest request) { 950 return createCustomClassCallable().call(request); 951 } 952 953 // AUTO-GENERATED DOCUMENTATION AND METHOD. 954 /** 955 * Create a custom class. 956 * 957 * <p>Sample code: 958 * 959 * <pre>{@code 960 * // This snippet has been automatically generated and should be regarded as a code template only. 961 * // It will require modifications to work: 962 * // - It may require correct/in-range values for request initialization. 963 * // - It may require specifying regional endpoints when creating the service client as shown in 964 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 965 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 966 * CreateCustomClassRequest request = 967 * CreateCustomClassRequest.newBuilder() 968 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 969 * .setCustomClassId("customClassId1871032322") 970 * .setCustomClass(CustomClass.newBuilder().build()) 971 * .build(); 972 * ApiFuture<CustomClass> future = 973 * adaptationClient.createCustomClassCallable().futureCall(request); 974 * // Do something. 975 * CustomClass response = future.get(); 976 * } 977 * }</pre> 978 */ createCustomClassCallable()979 public final UnaryCallable<CreateCustomClassRequest, CustomClass> createCustomClassCallable() { 980 return stub.createCustomClassCallable(); 981 } 982 983 // AUTO-GENERATED DOCUMENTATION AND METHOD. 984 /** 985 * Get a custom class. 986 * 987 * <p>Sample code: 988 * 989 * <pre>{@code 990 * // This snippet has been automatically generated and should be regarded as a code template only. 991 * // It will require modifications to work: 992 * // - It may require correct/in-range values for request initialization. 993 * // - It may require specifying regional endpoints when creating the service client as shown in 994 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 995 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 996 * CustomClassName name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]"); 997 * CustomClass response = adaptationClient.getCustomClass(name); 998 * } 999 * }</pre> 1000 * 1001 * @param name Required. The name of the custom class to retrieve. Format: 1002 * <p>`projects/{project}/locations/{location}/customClasses/{custom_class}` 1003 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1004 */ getCustomClass(CustomClassName name)1005 public final CustomClass getCustomClass(CustomClassName name) { 1006 GetCustomClassRequest request = 1007 GetCustomClassRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1008 return getCustomClass(request); 1009 } 1010 1011 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1012 /** 1013 * Get a custom class. 1014 * 1015 * <p>Sample code: 1016 * 1017 * <pre>{@code 1018 * // This snippet has been automatically generated and should be regarded as a code template only. 1019 * // It will require modifications to work: 1020 * // - It may require correct/in-range values for request initialization. 1021 * // - It may require specifying regional endpoints when creating the service client as shown in 1022 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1023 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1024 * String name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); 1025 * CustomClass response = adaptationClient.getCustomClass(name); 1026 * } 1027 * }</pre> 1028 * 1029 * @param name Required. The name of the custom class to retrieve. Format: 1030 * <p>`projects/{project}/locations/{location}/customClasses/{custom_class}` 1031 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1032 */ getCustomClass(String name)1033 public final CustomClass getCustomClass(String name) { 1034 GetCustomClassRequest request = GetCustomClassRequest.newBuilder().setName(name).build(); 1035 return getCustomClass(request); 1036 } 1037 1038 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1039 /** 1040 * Get a custom class. 1041 * 1042 * <p>Sample code: 1043 * 1044 * <pre>{@code 1045 * // This snippet has been automatically generated and should be regarded as a code template only. 1046 * // It will require modifications to work: 1047 * // - It may require correct/in-range values for request initialization. 1048 * // - It may require specifying regional endpoints when creating the service client as shown in 1049 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1050 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1051 * GetCustomClassRequest request = 1052 * GetCustomClassRequest.newBuilder() 1053 * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) 1054 * .build(); 1055 * CustomClass response = adaptationClient.getCustomClass(request); 1056 * } 1057 * }</pre> 1058 * 1059 * @param request The request object containing all of the parameters for the API call. 1060 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1061 */ getCustomClass(GetCustomClassRequest request)1062 public final CustomClass getCustomClass(GetCustomClassRequest request) { 1063 return getCustomClassCallable().call(request); 1064 } 1065 1066 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1067 /** 1068 * Get a custom class. 1069 * 1070 * <p>Sample code: 1071 * 1072 * <pre>{@code 1073 * // This snippet has been automatically generated and should be regarded as a code template only. 1074 * // It will require modifications to work: 1075 * // - It may require correct/in-range values for request initialization. 1076 * // - It may require specifying regional endpoints when creating the service client as shown in 1077 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1078 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1079 * GetCustomClassRequest request = 1080 * GetCustomClassRequest.newBuilder() 1081 * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) 1082 * .build(); 1083 * ApiFuture<CustomClass> future = adaptationClient.getCustomClassCallable().futureCall(request); 1084 * // Do something. 1085 * CustomClass response = future.get(); 1086 * } 1087 * }</pre> 1088 */ getCustomClassCallable()1089 public final UnaryCallable<GetCustomClassRequest, CustomClass> getCustomClassCallable() { 1090 return stub.getCustomClassCallable(); 1091 } 1092 1093 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1094 /** 1095 * List custom classes. 1096 * 1097 * <p>Sample code: 1098 * 1099 * <pre>{@code 1100 * // This snippet has been automatically generated and should be regarded as a code template only. 1101 * // It will require modifications to work: 1102 * // - It may require correct/in-range values for request initialization. 1103 * // - It may require specifying regional endpoints when creating the service client as shown in 1104 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1105 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1106 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1107 * for (CustomClass element : adaptationClient.listCustomClasses(parent).iterateAll()) { 1108 * // doThingsWith(element); 1109 * } 1110 * } 1111 * }</pre> 1112 * 1113 * @param parent Required. The parent, which owns this collection of custom classes. Format: 1114 * <p>`projects/{project}/locations/{location}/customClasses` 1115 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 1116 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 1117 * location. To specify a region, use a [regional 1118 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 1119 * `eu` location value. 1120 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1121 */ listCustomClasses(LocationName parent)1122 public final ListCustomClassesPagedResponse listCustomClasses(LocationName parent) { 1123 ListCustomClassesRequest request = 1124 ListCustomClassesRequest.newBuilder() 1125 .setParent(parent == null ? null : parent.toString()) 1126 .build(); 1127 return listCustomClasses(request); 1128 } 1129 1130 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1131 /** 1132 * List custom classes. 1133 * 1134 * <p>Sample code: 1135 * 1136 * <pre>{@code 1137 * // This snippet has been automatically generated and should be regarded as a code template only. 1138 * // It will require modifications to work: 1139 * // - It may require correct/in-range values for request initialization. 1140 * // - It may require specifying regional endpoints when creating the service client as shown in 1141 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1142 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1143 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1144 * for (CustomClass element : adaptationClient.listCustomClasses(parent).iterateAll()) { 1145 * // doThingsWith(element); 1146 * } 1147 * } 1148 * }</pre> 1149 * 1150 * @param parent Required. The parent, which owns this collection of custom classes. Format: 1151 * <p>`projects/{project}/locations/{location}/customClasses` 1152 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 1153 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 1154 * location. To specify a region, use a [regional 1155 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 1156 * `eu` location value. 1157 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1158 */ listCustomClasses(String parent)1159 public final ListCustomClassesPagedResponse listCustomClasses(String parent) { 1160 ListCustomClassesRequest request = 1161 ListCustomClassesRequest.newBuilder().setParent(parent).build(); 1162 return listCustomClasses(request); 1163 } 1164 1165 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1166 /** 1167 * List custom classes. 1168 * 1169 * <p>Sample code: 1170 * 1171 * <pre>{@code 1172 * // This snippet has been automatically generated and should be regarded as a code template only. 1173 * // It will require modifications to work: 1174 * // - It may require correct/in-range values for request initialization. 1175 * // - It may require specifying regional endpoints when creating the service client as shown in 1176 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1177 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1178 * ListCustomClassesRequest request = 1179 * ListCustomClassesRequest.newBuilder() 1180 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1181 * .setPageSize(883849137) 1182 * .setPageToken("pageToken873572522") 1183 * .build(); 1184 * for (CustomClass element : adaptationClient.listCustomClasses(request).iterateAll()) { 1185 * // doThingsWith(element); 1186 * } 1187 * } 1188 * }</pre> 1189 * 1190 * @param request The request object containing all of the parameters for the API call. 1191 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1192 */ listCustomClasses(ListCustomClassesRequest request)1193 public final ListCustomClassesPagedResponse listCustomClasses(ListCustomClassesRequest request) { 1194 return listCustomClassesPagedCallable().call(request); 1195 } 1196 1197 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1198 /** 1199 * List custom classes. 1200 * 1201 * <p>Sample code: 1202 * 1203 * <pre>{@code 1204 * // This snippet has been automatically generated and should be regarded as a code template only. 1205 * // It will require modifications to work: 1206 * // - It may require correct/in-range values for request initialization. 1207 * // - It may require specifying regional endpoints when creating the service client as shown in 1208 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1209 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1210 * ListCustomClassesRequest request = 1211 * ListCustomClassesRequest.newBuilder() 1212 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1213 * .setPageSize(883849137) 1214 * .setPageToken("pageToken873572522") 1215 * .build(); 1216 * ApiFuture<CustomClass> future = 1217 * adaptationClient.listCustomClassesPagedCallable().futureCall(request); 1218 * // Do something. 1219 * for (CustomClass element : future.get().iterateAll()) { 1220 * // doThingsWith(element); 1221 * } 1222 * } 1223 * }</pre> 1224 */ 1225 public final UnaryCallable<ListCustomClassesRequest, ListCustomClassesPagedResponse> listCustomClassesPagedCallable()1226 listCustomClassesPagedCallable() { 1227 return stub.listCustomClassesPagedCallable(); 1228 } 1229 1230 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1231 /** 1232 * List custom classes. 1233 * 1234 * <p>Sample code: 1235 * 1236 * <pre>{@code 1237 * // This snippet has been automatically generated and should be regarded as a code template only. 1238 * // It will require modifications to work: 1239 * // - It may require correct/in-range values for request initialization. 1240 * // - It may require specifying regional endpoints when creating the service client as shown in 1241 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1242 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1243 * ListCustomClassesRequest request = 1244 * ListCustomClassesRequest.newBuilder() 1245 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1246 * .setPageSize(883849137) 1247 * .setPageToken("pageToken873572522") 1248 * .build(); 1249 * while (true) { 1250 * ListCustomClassesResponse response = 1251 * adaptationClient.listCustomClassesCallable().call(request); 1252 * for (CustomClass element : response.getCustomClassesList()) { 1253 * // doThingsWith(element); 1254 * } 1255 * String nextPageToken = response.getNextPageToken(); 1256 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1257 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1258 * } else { 1259 * break; 1260 * } 1261 * } 1262 * } 1263 * }</pre> 1264 */ 1265 public final UnaryCallable<ListCustomClassesRequest, ListCustomClassesResponse> listCustomClassesCallable()1266 listCustomClassesCallable() { 1267 return stub.listCustomClassesCallable(); 1268 } 1269 1270 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1271 /** 1272 * Update a custom class. 1273 * 1274 * <p>Sample code: 1275 * 1276 * <pre>{@code 1277 * // This snippet has been automatically generated and should be regarded as a code template only. 1278 * // It will require modifications to work: 1279 * // - It may require correct/in-range values for request initialization. 1280 * // - It may require specifying regional endpoints when creating the service client as shown in 1281 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1282 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1283 * CustomClass customClass = CustomClass.newBuilder().build(); 1284 * FieldMask updateMask = FieldMask.newBuilder().build(); 1285 * CustomClass response = adaptationClient.updateCustomClass(customClass, updateMask); 1286 * } 1287 * }</pre> 1288 * 1289 * @param customClass Required. The custom class to update. 1290 * <p>The custom class's `name` field is used to identify the custom class to be updated. 1291 * Format: 1292 * <p>`projects/{project}/locations/{location}/customClasses/{custom_class}` 1293 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 1294 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 1295 * location. To specify a region, use a [regional 1296 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 1297 * `eu` location value. 1298 * @param updateMask The list of fields to be updated. 1299 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1300 */ updateCustomClass(CustomClass customClass, FieldMask updateMask)1301 public final CustomClass updateCustomClass(CustomClass customClass, FieldMask updateMask) { 1302 UpdateCustomClassRequest request = 1303 UpdateCustomClassRequest.newBuilder() 1304 .setCustomClass(customClass) 1305 .setUpdateMask(updateMask) 1306 .build(); 1307 return updateCustomClass(request); 1308 } 1309 1310 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1311 /** 1312 * Update a custom class. 1313 * 1314 * <p>Sample code: 1315 * 1316 * <pre>{@code 1317 * // This snippet has been automatically generated and should be regarded as a code template only. 1318 * // It will require modifications to work: 1319 * // - It may require correct/in-range values for request initialization. 1320 * // - It may require specifying regional endpoints when creating the service client as shown in 1321 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1322 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1323 * UpdateCustomClassRequest request = 1324 * UpdateCustomClassRequest.newBuilder() 1325 * .setCustomClass(CustomClass.newBuilder().build()) 1326 * .setUpdateMask(FieldMask.newBuilder().build()) 1327 * .build(); 1328 * CustomClass response = adaptationClient.updateCustomClass(request); 1329 * } 1330 * }</pre> 1331 * 1332 * @param request The request object containing all of the parameters for the API call. 1333 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1334 */ updateCustomClass(UpdateCustomClassRequest request)1335 public final CustomClass updateCustomClass(UpdateCustomClassRequest request) { 1336 return updateCustomClassCallable().call(request); 1337 } 1338 1339 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1340 /** 1341 * Update a custom class. 1342 * 1343 * <p>Sample code: 1344 * 1345 * <pre>{@code 1346 * // This snippet has been automatically generated and should be regarded as a code template only. 1347 * // It will require modifications to work: 1348 * // - It may require correct/in-range values for request initialization. 1349 * // - It may require specifying regional endpoints when creating the service client as shown in 1350 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1351 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1352 * UpdateCustomClassRequest request = 1353 * UpdateCustomClassRequest.newBuilder() 1354 * .setCustomClass(CustomClass.newBuilder().build()) 1355 * .setUpdateMask(FieldMask.newBuilder().build()) 1356 * .build(); 1357 * ApiFuture<CustomClass> future = 1358 * adaptationClient.updateCustomClassCallable().futureCall(request); 1359 * // Do something. 1360 * CustomClass response = future.get(); 1361 * } 1362 * }</pre> 1363 */ updateCustomClassCallable()1364 public final UnaryCallable<UpdateCustomClassRequest, CustomClass> updateCustomClassCallable() { 1365 return stub.updateCustomClassCallable(); 1366 } 1367 1368 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1369 /** 1370 * Delete a custom class. 1371 * 1372 * <p>Sample code: 1373 * 1374 * <pre>{@code 1375 * // This snippet has been automatically generated and should be regarded as a code template only. 1376 * // It will require modifications to work: 1377 * // - It may require correct/in-range values for request initialization. 1378 * // - It may require specifying regional endpoints when creating the service client as shown in 1379 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1380 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1381 * CustomClassName name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]"); 1382 * adaptationClient.deleteCustomClass(name); 1383 * } 1384 * }</pre> 1385 * 1386 * @param name Required. The name of the custom class to delete. Format: 1387 * <p>`projects/{project}/locations/{location}/customClasses/{custom_class}` 1388 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 1389 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 1390 * location. To specify a region, use a [regional 1391 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 1392 * `eu` location value. 1393 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1394 */ deleteCustomClass(CustomClassName name)1395 public final void deleteCustomClass(CustomClassName name) { 1396 DeleteCustomClassRequest request = 1397 DeleteCustomClassRequest.newBuilder() 1398 .setName(name == null ? null : name.toString()) 1399 .build(); 1400 deleteCustomClass(request); 1401 } 1402 1403 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1404 /** 1405 * Delete a custom class. 1406 * 1407 * <p>Sample code: 1408 * 1409 * <pre>{@code 1410 * // This snippet has been automatically generated and should be regarded as a code template only. 1411 * // It will require modifications to work: 1412 * // - It may require correct/in-range values for request initialization. 1413 * // - It may require specifying regional endpoints when creating the service client as shown in 1414 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1415 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1416 * String name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); 1417 * adaptationClient.deleteCustomClass(name); 1418 * } 1419 * }</pre> 1420 * 1421 * @param name Required. The name of the custom class to delete. Format: 1422 * <p>`projects/{project}/locations/{location}/customClasses/{custom_class}` 1423 * <p>Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` 1424 * (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` 1425 * location. To specify a region, use a [regional 1426 * endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or 1427 * `eu` location value. 1428 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1429 */ deleteCustomClass(String name)1430 public final void deleteCustomClass(String name) { 1431 DeleteCustomClassRequest request = DeleteCustomClassRequest.newBuilder().setName(name).build(); 1432 deleteCustomClass(request); 1433 } 1434 1435 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1436 /** 1437 * Delete a custom class. 1438 * 1439 * <p>Sample code: 1440 * 1441 * <pre>{@code 1442 * // This snippet has been automatically generated and should be regarded as a code template only. 1443 * // It will require modifications to work: 1444 * // - It may require correct/in-range values for request initialization. 1445 * // - It may require specifying regional endpoints when creating the service client as shown in 1446 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1447 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1448 * DeleteCustomClassRequest request = 1449 * DeleteCustomClassRequest.newBuilder() 1450 * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) 1451 * .build(); 1452 * adaptationClient.deleteCustomClass(request); 1453 * } 1454 * }</pre> 1455 * 1456 * @param request The request object containing all of the parameters for the API call. 1457 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1458 */ deleteCustomClass(DeleteCustomClassRequest request)1459 public final void deleteCustomClass(DeleteCustomClassRequest request) { 1460 deleteCustomClassCallable().call(request); 1461 } 1462 1463 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1464 /** 1465 * Delete a custom class. 1466 * 1467 * <p>Sample code: 1468 * 1469 * <pre>{@code 1470 * // This snippet has been automatically generated and should be regarded as a code template only. 1471 * // It will require modifications to work: 1472 * // - It may require correct/in-range values for request initialization. 1473 * // - It may require specifying regional endpoints when creating the service client as shown in 1474 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1475 * try (AdaptationClient adaptationClient = AdaptationClient.create()) { 1476 * DeleteCustomClassRequest request = 1477 * DeleteCustomClassRequest.newBuilder() 1478 * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) 1479 * .build(); 1480 * ApiFuture<Empty> future = adaptationClient.deleteCustomClassCallable().futureCall(request); 1481 * // Do something. 1482 * future.get(); 1483 * } 1484 * }</pre> 1485 */ deleteCustomClassCallable()1486 public final UnaryCallable<DeleteCustomClassRequest, Empty> deleteCustomClassCallable() { 1487 return stub.deleteCustomClassCallable(); 1488 } 1489 1490 @Override close()1491 public final void close() { 1492 stub.close(); 1493 } 1494 1495 @Override shutdown()1496 public void shutdown() { 1497 stub.shutdown(); 1498 } 1499 1500 @Override isShutdown()1501 public boolean isShutdown() { 1502 return stub.isShutdown(); 1503 } 1504 1505 @Override isTerminated()1506 public boolean isTerminated() { 1507 return stub.isTerminated(); 1508 } 1509 1510 @Override shutdownNow()1511 public void shutdownNow() { 1512 stub.shutdownNow(); 1513 } 1514 1515 @Override awaitTermination(long duration, TimeUnit unit)1516 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1517 return stub.awaitTermination(duration, unit); 1518 } 1519 1520 public static class ListPhraseSetPagedResponse 1521 extends AbstractPagedListResponse< 1522 ListPhraseSetRequest, 1523 ListPhraseSetResponse, 1524 PhraseSet, 1525 ListPhraseSetPage, 1526 ListPhraseSetFixedSizeCollection> { 1527 createAsync( PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, ApiFuture<ListPhraseSetResponse> futureResponse)1528 public static ApiFuture<ListPhraseSetPagedResponse> createAsync( 1529 PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, 1530 ApiFuture<ListPhraseSetResponse> futureResponse) { 1531 ApiFuture<ListPhraseSetPage> futurePage = 1532 ListPhraseSetPage.createEmptyPage().createPageAsync(context, futureResponse); 1533 return ApiFutures.transform( 1534 futurePage, 1535 input -> new ListPhraseSetPagedResponse(input), 1536 MoreExecutors.directExecutor()); 1537 } 1538 ListPhraseSetPagedResponse(ListPhraseSetPage page)1539 private ListPhraseSetPagedResponse(ListPhraseSetPage page) { 1540 super(page, ListPhraseSetFixedSizeCollection.createEmptyCollection()); 1541 } 1542 } 1543 1544 public static class ListPhraseSetPage 1545 extends AbstractPage< 1546 ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet, ListPhraseSetPage> { 1547 ListPhraseSetPage( PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, ListPhraseSetResponse response)1548 private ListPhraseSetPage( 1549 PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, 1550 ListPhraseSetResponse response) { 1551 super(context, response); 1552 } 1553 createEmptyPage()1554 private static ListPhraseSetPage createEmptyPage() { 1555 return new ListPhraseSetPage(null, null); 1556 } 1557 1558 @Override createPage( PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, ListPhraseSetResponse response)1559 protected ListPhraseSetPage createPage( 1560 PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, 1561 ListPhraseSetResponse response) { 1562 return new ListPhraseSetPage(context, response); 1563 } 1564 1565 @Override createPageAsync( PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, ApiFuture<ListPhraseSetResponse> futureResponse)1566 public ApiFuture<ListPhraseSetPage> createPageAsync( 1567 PageContext<ListPhraseSetRequest, ListPhraseSetResponse, PhraseSet> context, 1568 ApiFuture<ListPhraseSetResponse> futureResponse) { 1569 return super.createPageAsync(context, futureResponse); 1570 } 1571 } 1572 1573 public static class ListPhraseSetFixedSizeCollection 1574 extends AbstractFixedSizeCollection< 1575 ListPhraseSetRequest, 1576 ListPhraseSetResponse, 1577 PhraseSet, 1578 ListPhraseSetPage, 1579 ListPhraseSetFixedSizeCollection> { 1580 ListPhraseSetFixedSizeCollection(List<ListPhraseSetPage> pages, int collectionSize)1581 private ListPhraseSetFixedSizeCollection(List<ListPhraseSetPage> pages, int collectionSize) { 1582 super(pages, collectionSize); 1583 } 1584 createEmptyCollection()1585 private static ListPhraseSetFixedSizeCollection createEmptyCollection() { 1586 return new ListPhraseSetFixedSizeCollection(null, 0); 1587 } 1588 1589 @Override createCollection( List<ListPhraseSetPage> pages, int collectionSize)1590 protected ListPhraseSetFixedSizeCollection createCollection( 1591 List<ListPhraseSetPage> pages, int collectionSize) { 1592 return new ListPhraseSetFixedSizeCollection(pages, collectionSize); 1593 } 1594 } 1595 1596 public static class ListCustomClassesPagedResponse 1597 extends AbstractPagedListResponse< 1598 ListCustomClassesRequest, 1599 ListCustomClassesResponse, 1600 CustomClass, 1601 ListCustomClassesPage, 1602 ListCustomClassesFixedSizeCollection> { 1603 createAsync( PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, ApiFuture<ListCustomClassesResponse> futureResponse)1604 public static ApiFuture<ListCustomClassesPagedResponse> createAsync( 1605 PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, 1606 ApiFuture<ListCustomClassesResponse> futureResponse) { 1607 ApiFuture<ListCustomClassesPage> futurePage = 1608 ListCustomClassesPage.createEmptyPage().createPageAsync(context, futureResponse); 1609 return ApiFutures.transform( 1610 futurePage, 1611 input -> new ListCustomClassesPagedResponse(input), 1612 MoreExecutors.directExecutor()); 1613 } 1614 ListCustomClassesPagedResponse(ListCustomClassesPage page)1615 private ListCustomClassesPagedResponse(ListCustomClassesPage page) { 1616 super(page, ListCustomClassesFixedSizeCollection.createEmptyCollection()); 1617 } 1618 } 1619 1620 public static class ListCustomClassesPage 1621 extends AbstractPage< 1622 ListCustomClassesRequest, ListCustomClassesResponse, CustomClass, ListCustomClassesPage> { 1623 ListCustomClassesPage( PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, ListCustomClassesResponse response)1624 private ListCustomClassesPage( 1625 PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, 1626 ListCustomClassesResponse response) { 1627 super(context, response); 1628 } 1629 createEmptyPage()1630 private static ListCustomClassesPage createEmptyPage() { 1631 return new ListCustomClassesPage(null, null); 1632 } 1633 1634 @Override createPage( PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, ListCustomClassesResponse response)1635 protected ListCustomClassesPage createPage( 1636 PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, 1637 ListCustomClassesResponse response) { 1638 return new ListCustomClassesPage(context, response); 1639 } 1640 1641 @Override createPageAsync( PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, ApiFuture<ListCustomClassesResponse> futureResponse)1642 public ApiFuture<ListCustomClassesPage> createPageAsync( 1643 PageContext<ListCustomClassesRequest, ListCustomClassesResponse, CustomClass> context, 1644 ApiFuture<ListCustomClassesResponse> futureResponse) { 1645 return super.createPageAsync(context, futureResponse); 1646 } 1647 } 1648 1649 public static class ListCustomClassesFixedSizeCollection 1650 extends AbstractFixedSizeCollection< 1651 ListCustomClassesRequest, 1652 ListCustomClassesResponse, 1653 CustomClass, 1654 ListCustomClassesPage, 1655 ListCustomClassesFixedSizeCollection> { 1656 ListCustomClassesFixedSizeCollection( List<ListCustomClassesPage> pages, int collectionSize)1657 private ListCustomClassesFixedSizeCollection( 1658 List<ListCustomClassesPage> pages, int collectionSize) { 1659 super(pages, collectionSize); 1660 } 1661 createEmptyCollection()1662 private static ListCustomClassesFixedSizeCollection createEmptyCollection() { 1663 return new ListCustomClassesFixedSizeCollection(null, 0); 1664 } 1665 1666 @Override createCollection( List<ListCustomClassesPage> pages, int collectionSize)1667 protected ListCustomClassesFixedSizeCollection createCollection( 1668 List<ListCustomClassesPage> pages, int collectionSize) { 1669 return new ListCustomClassesFixedSizeCollection(pages, collectionSize); 1670 } 1671 } 1672 } 1673