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.translate.v3; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.httpjson.longrunning.OperationsClient; 24 import com.google.api.gax.longrunning.OperationFuture; 25 import com.google.api.gax.paging.AbstractFixedSizeCollection; 26 import com.google.api.gax.paging.AbstractPage; 27 import com.google.api.gax.paging.AbstractPagedListResponse; 28 import com.google.api.gax.rpc.OperationCallable; 29 import com.google.api.gax.rpc.PageContext; 30 import com.google.api.gax.rpc.UnaryCallable; 31 import com.google.cloud.translate.v3.stub.TranslationServiceStub; 32 import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings; 33 import com.google.common.util.concurrent.MoreExecutors; 34 import com.google.longrunning.Operation; 35 import java.io.IOException; 36 import java.util.List; 37 import java.util.concurrent.TimeUnit; 38 import javax.annotation.Generated; 39 40 // AUTO-GENERATED DOCUMENTATION AND CLASS. 41 /** 42 * Service Description: Provides natural language translation operations. 43 * 44 * <p>This class provides the ability to make remote calls to the backing service through method 45 * calls that map to API methods. Sample code to get started: 46 * 47 * <pre>{@code 48 * // This snippet has been automatically generated and should be regarded as a code template only. 49 * // It will require modifications to work: 50 * // - It may require correct/in-range values for request initialization. 51 * // - It may require specifying regional endpoints when creating the service client as shown in 52 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 53 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 54 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 55 * String targetLanguageCode = "targetLanguageCode-106414698"; 56 * List<String> contents = new ArrayList<>(); 57 * TranslateTextResponse response = 58 * translationServiceClient.translateText(parent, targetLanguageCode, contents); 59 * } 60 * }</pre> 61 * 62 * <p>Note: close() needs to be called on the TranslationServiceClient object to clean up resources 63 * such as threads. In the example above, try-with-resources is used, which automatically calls 64 * close(). 65 * 66 * <p>The surface of this class includes several types of Java methods for each of the API's 67 * methods: 68 * 69 * <ol> 70 * <li>A "flattened" method. With this type of method, the fields of the request type have been 71 * converted into function parameters. It may be the case that not all fields are available as 72 * parameters, and not every API method will have a flattened method entry point. 73 * <li>A "request object" method. This type of method only takes one parameter, a request object, 74 * which must be constructed before the call. Not every API method will have a request object 75 * method. 76 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 77 * callable object, which can be used to initiate calls to the service. 78 * </ol> 79 * 80 * <p>See the individual methods for example code. 81 * 82 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 83 * these names, this class includes a format method for each type of name, and additionally a parse 84 * method to extract the individual identifiers contained within names that are returned. 85 * 86 * <p>This class can be customized by passing in a custom instance of TranslationServiceSettings to 87 * create(). For example: 88 * 89 * <p>To customize credentials: 90 * 91 * <pre>{@code 92 * // This snippet has been automatically generated and should be regarded as a code template only. 93 * // It will require modifications to work: 94 * // - It may require correct/in-range values for request initialization. 95 * // - It may require specifying regional endpoints when creating the service client as shown in 96 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 97 * TranslationServiceSettings translationServiceSettings = 98 * TranslationServiceSettings.newBuilder() 99 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 100 * .build(); 101 * TranslationServiceClient translationServiceClient = 102 * TranslationServiceClient.create(translationServiceSettings); 103 * }</pre> 104 * 105 * <p>To customize the endpoint: 106 * 107 * <pre>{@code 108 * // This snippet has been automatically generated and should be regarded as a code template only. 109 * // It will require modifications to work: 110 * // - It may require correct/in-range values for request initialization. 111 * // - It may require specifying regional endpoints when creating the service client as shown in 112 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 113 * TranslationServiceSettings translationServiceSettings = 114 * TranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 115 * TranslationServiceClient translationServiceClient = 116 * TranslationServiceClient.create(translationServiceSettings); 117 * }</pre> 118 * 119 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 120 * the wire: 121 * 122 * <pre>{@code 123 * // This snippet has been automatically generated and should be regarded as a code template only. 124 * // It will require modifications to work: 125 * // - It may require correct/in-range values for request initialization. 126 * // - It may require specifying regional endpoints when creating the service client as shown in 127 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 128 * TranslationServiceSettings translationServiceSettings = 129 * TranslationServiceSettings.newHttpJsonBuilder().build(); 130 * TranslationServiceClient translationServiceClient = 131 * TranslationServiceClient.create(translationServiceSettings); 132 * }</pre> 133 * 134 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 135 */ 136 @Generated("by gapic-generator-java") 137 public class TranslationServiceClient implements BackgroundResource { 138 private final TranslationServiceSettings settings; 139 private final TranslationServiceStub stub; 140 private final OperationsClient httpJsonOperationsClient; 141 private final com.google.longrunning.OperationsClient operationsClient; 142 143 /** Constructs an instance of TranslationServiceClient with default settings. */ create()144 public static final TranslationServiceClient create() throws IOException { 145 return create(TranslationServiceSettings.newBuilder().build()); 146 } 147 148 /** 149 * Constructs an instance of TranslationServiceClient, using the given settings. The channels are 150 * created based on the settings passed in, or defaults for any settings that are not set. 151 */ create(TranslationServiceSettings settings)152 public static final TranslationServiceClient create(TranslationServiceSettings settings) 153 throws IOException { 154 return new TranslationServiceClient(settings); 155 } 156 157 /** 158 * Constructs an instance of TranslationServiceClient, using the given stub for making calls. This 159 * is for advanced usage - prefer using create(TranslationServiceSettings). 160 */ create(TranslationServiceStub stub)161 public static final TranslationServiceClient create(TranslationServiceStub stub) { 162 return new TranslationServiceClient(stub); 163 } 164 165 /** 166 * Constructs an instance of TranslationServiceClient, using the given settings. This is protected 167 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 168 * preferred. 169 */ TranslationServiceClient(TranslationServiceSettings settings)170 protected TranslationServiceClient(TranslationServiceSettings settings) throws IOException { 171 this.settings = settings; 172 this.stub = ((TranslationServiceStubSettings) settings.getStubSettings()).createStub(); 173 this.operationsClient = 174 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 175 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 176 } 177 TranslationServiceClient(TranslationServiceStub stub)178 protected TranslationServiceClient(TranslationServiceStub stub) { 179 this.settings = null; 180 this.stub = stub; 181 this.operationsClient = 182 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 183 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 184 } 185 getSettings()186 public final TranslationServiceSettings getSettings() { 187 return settings; 188 } 189 getStub()190 public TranslationServiceStub getStub() { 191 return stub; 192 } 193 194 /** 195 * Returns the OperationsClient that can be used to query the status of a long-running operation 196 * returned by another API method call. 197 */ getOperationsClient()198 public final com.google.longrunning.OperationsClient getOperationsClient() { 199 return operationsClient; 200 } 201 202 /** 203 * Returns the OperationsClient that can be used to query the status of a long-running operation 204 * returned by another API method call. 205 */ 206 @BetaApi getHttpJsonOperationsClient()207 public final OperationsClient getHttpJsonOperationsClient() { 208 return httpJsonOperationsClient; 209 } 210 211 // AUTO-GENERATED DOCUMENTATION AND METHOD. 212 /** 213 * Translates input text and returns translated text. 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 (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 224 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 225 * String targetLanguageCode = "targetLanguageCode-106414698"; 226 * List<String> contents = new ArrayList<>(); 227 * TranslateTextResponse response = 228 * translationServiceClient.translateText(parent, targetLanguageCode, contents); 229 * } 230 * }</pre> 231 * 232 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 233 * <p>Format: `projects/{project-number-or-id}` or 234 * `projects/{project-number-or-id}/locations/{location-id}`. 235 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 236 * `projects/{project-number-or-id}`. 237 * <p>Non-global location is required for requests using AutoML models or custom glossaries. 238 * <p>Models and glossaries must be within the same region (have same location-id), otherwise 239 * an INVALID_ARGUMENT (400) error is returned. 240 * @param targetLanguageCode Required. The ISO-639 language code to use for translation of the 241 * input text, set to one of the language codes listed in Language Support. 242 * @param contents Required. The content of the input in string format. We recommend the total 243 * content be less than 30,000 codepoints. The max length of this field is 1024. Use 244 * BatchTranslateText for larger text. 245 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 246 */ translateText( LocationName parent, String targetLanguageCode, List<String> contents)247 public final TranslateTextResponse translateText( 248 LocationName parent, String targetLanguageCode, List<String> contents) { 249 TranslateTextRequest request = 250 TranslateTextRequest.newBuilder() 251 .setParent(parent == null ? null : parent.toString()) 252 .setTargetLanguageCode(targetLanguageCode) 253 .addAllContents(contents) 254 .build(); 255 return translateText(request); 256 } 257 258 // AUTO-GENERATED DOCUMENTATION AND METHOD. 259 /** 260 * Translates input text and returns translated text. 261 * 262 * <p>Sample code: 263 * 264 * <pre>{@code 265 * // This snippet has been automatically generated and should be regarded as a code template only. 266 * // It will require modifications to work: 267 * // - It may require correct/in-range values for request initialization. 268 * // - It may require specifying regional endpoints when creating the service client as shown in 269 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 270 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 271 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 272 * String targetLanguageCode = "targetLanguageCode-106414698"; 273 * List<String> contents = new ArrayList<>(); 274 * TranslateTextResponse response = 275 * translationServiceClient.translateText(parent, targetLanguageCode, contents); 276 * } 277 * }</pre> 278 * 279 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 280 * <p>Format: `projects/{project-number-or-id}` or 281 * `projects/{project-number-or-id}/locations/{location-id}`. 282 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 283 * `projects/{project-number-or-id}`. 284 * <p>Non-global location is required for requests using AutoML models or custom glossaries. 285 * <p>Models and glossaries must be within the same region (have same location-id), otherwise 286 * an INVALID_ARGUMENT (400) error is returned. 287 * @param targetLanguageCode Required. The ISO-639 language code to use for translation of the 288 * input text, set to one of the language codes listed in Language Support. 289 * @param contents Required. The content of the input in string format. We recommend the total 290 * content be less than 30,000 codepoints. The max length of this field is 1024. Use 291 * BatchTranslateText for larger text. 292 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 293 */ translateText( String parent, String targetLanguageCode, List<String> contents)294 public final TranslateTextResponse translateText( 295 String parent, String targetLanguageCode, List<String> contents) { 296 TranslateTextRequest request = 297 TranslateTextRequest.newBuilder() 298 .setParent(parent) 299 .setTargetLanguageCode(targetLanguageCode) 300 .addAllContents(contents) 301 .build(); 302 return translateText(request); 303 } 304 305 // AUTO-GENERATED DOCUMENTATION AND METHOD. 306 /** 307 * Translates input text and returns translated text. 308 * 309 * <p>Sample code: 310 * 311 * <pre>{@code 312 * // This snippet has been automatically generated and should be regarded as a code template only. 313 * // It will require modifications to work: 314 * // - It may require correct/in-range values for request initialization. 315 * // - It may require specifying regional endpoints when creating the service client as shown in 316 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 317 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 318 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 319 * String model = "model104069929"; 320 * String mimeType = "mimeType-1392120434"; 321 * String sourceLanguageCode = "sourceLanguageCode1645917472"; 322 * String targetLanguageCode = "targetLanguageCode-106414698"; 323 * List<String> contents = new ArrayList<>(); 324 * TranslateTextResponse response = 325 * translationServiceClient.translateText( 326 * parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); 327 * } 328 * }</pre> 329 * 330 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 331 * <p>Format: `projects/{project-number-or-id}` or 332 * `projects/{project-number-or-id}/locations/{location-id}`. 333 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 334 * `projects/{project-number-or-id}`. 335 * <p>Non-global location is required for requests using AutoML models or custom glossaries. 336 * <p>Models and glossaries must be within the same region (have same location-id), otherwise 337 * an INVALID_ARGUMENT (400) error is returned. 338 * @param model Optional. The `model` type requested for this translation. 339 * <p>The format depends on model type: 340 * <p>- AutoML Translation models: 341 * `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` 342 * <p>- General (built-in) models: 343 * `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, 344 * <p>For global (non-regionalized) requests, use `location-id` `global`. For example, 345 * `projects/{project-number-or-id}/locations/global/models/general/nmt`. 346 * <p>If not provided, the default Google model (NMT) will be used. 347 * @param mimeType Optional. The format of the source text, for example, "text/html", 348 * "text/plain". If left blank, the MIME type defaults to "text/html". 349 * @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for 350 * example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If 351 * the source language isn't specified, the API attempts to identify the source language 352 * automatically and returns the source language within the response. 353 * @param targetLanguageCode Required. The ISO-639 language code to use for translation of the 354 * input text, set to one of the language codes listed in Language Support. 355 * @param contents Required. The content of the input in string format. We recommend the total 356 * content be less than 30,000 codepoints. The max length of this field is 1024. Use 357 * BatchTranslateText for larger text. 358 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 359 */ translateText( LocationName parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)360 public final TranslateTextResponse translateText( 361 LocationName parent, 362 String model, 363 String mimeType, 364 String sourceLanguageCode, 365 String targetLanguageCode, 366 List<String> contents) { 367 TranslateTextRequest request = 368 TranslateTextRequest.newBuilder() 369 .setParent(parent == null ? null : parent.toString()) 370 .setModel(model) 371 .setMimeType(mimeType) 372 .setSourceLanguageCode(sourceLanguageCode) 373 .setTargetLanguageCode(targetLanguageCode) 374 .addAllContents(contents) 375 .build(); 376 return translateText(request); 377 } 378 379 // AUTO-GENERATED DOCUMENTATION AND METHOD. 380 /** 381 * Translates input text and returns translated text. 382 * 383 * <p>Sample code: 384 * 385 * <pre>{@code 386 * // This snippet has been automatically generated and should be regarded as a code template only. 387 * // It will require modifications to work: 388 * // - It may require correct/in-range values for request initialization. 389 * // - It may require specifying regional endpoints when creating the service client as shown in 390 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 391 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 392 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 393 * String model = "model104069929"; 394 * String mimeType = "mimeType-1392120434"; 395 * String sourceLanguageCode = "sourceLanguageCode1645917472"; 396 * String targetLanguageCode = "targetLanguageCode-106414698"; 397 * List<String> contents = new ArrayList<>(); 398 * TranslateTextResponse response = 399 * translationServiceClient.translateText( 400 * parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); 401 * } 402 * }</pre> 403 * 404 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 405 * <p>Format: `projects/{project-number-or-id}` or 406 * `projects/{project-number-or-id}/locations/{location-id}`. 407 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 408 * `projects/{project-number-or-id}`. 409 * <p>Non-global location is required for requests using AutoML models or custom glossaries. 410 * <p>Models and glossaries must be within the same region (have same location-id), otherwise 411 * an INVALID_ARGUMENT (400) error is returned. 412 * @param model Optional. The `model` type requested for this translation. 413 * <p>The format depends on model type: 414 * <p>- AutoML Translation models: 415 * `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` 416 * <p>- General (built-in) models: 417 * `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, 418 * <p>For global (non-regionalized) requests, use `location-id` `global`. For example, 419 * `projects/{project-number-or-id}/locations/global/models/general/nmt`. 420 * <p>If not provided, the default Google model (NMT) will be used. 421 * @param mimeType Optional. The format of the source text, for example, "text/html", 422 * "text/plain". If left blank, the MIME type defaults to "text/html". 423 * @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for 424 * example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If 425 * the source language isn't specified, the API attempts to identify the source language 426 * automatically and returns the source language within the response. 427 * @param targetLanguageCode Required. The ISO-639 language code to use for translation of the 428 * input text, set to one of the language codes listed in Language Support. 429 * @param contents Required. The content of the input in string format. We recommend the total 430 * content be less than 30,000 codepoints. The max length of this field is 1024. Use 431 * BatchTranslateText for larger text. 432 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 433 */ translateText( String parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)434 public final TranslateTextResponse translateText( 435 String parent, 436 String model, 437 String mimeType, 438 String sourceLanguageCode, 439 String targetLanguageCode, 440 List<String> contents) { 441 TranslateTextRequest request = 442 TranslateTextRequest.newBuilder() 443 .setParent(parent) 444 .setModel(model) 445 .setMimeType(mimeType) 446 .setSourceLanguageCode(sourceLanguageCode) 447 .setTargetLanguageCode(targetLanguageCode) 448 .addAllContents(contents) 449 .build(); 450 return translateText(request); 451 } 452 453 // AUTO-GENERATED DOCUMENTATION AND METHOD. 454 /** 455 * Translates input text and returns translated text. 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 (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 466 * TranslateTextRequest request = 467 * TranslateTextRequest.newBuilder() 468 * .addAllContents(new ArrayList<String>()) 469 * .setMimeType("mimeType-1392120434") 470 * .setSourceLanguageCode("sourceLanguageCode1645917472") 471 * .setTargetLanguageCode("targetLanguageCode-106414698") 472 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 473 * .setModel("model104069929") 474 * .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) 475 * .putAllLabels(new HashMap<String, String>()) 476 * .build(); 477 * TranslateTextResponse response = translationServiceClient.translateText(request); 478 * } 479 * }</pre> 480 * 481 * @param request The request object containing all of the parameters for the API call. 482 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 483 */ translateText(TranslateTextRequest request)484 public final TranslateTextResponse translateText(TranslateTextRequest request) { 485 return translateTextCallable().call(request); 486 } 487 488 // AUTO-GENERATED DOCUMENTATION AND METHOD. 489 /** 490 * Translates input text and returns translated text. 491 * 492 * <p>Sample code: 493 * 494 * <pre>{@code 495 * // This snippet has been automatically generated and should be regarded as a code template only. 496 * // It will require modifications to work: 497 * // - It may require correct/in-range values for request initialization. 498 * // - It may require specifying regional endpoints when creating the service client as shown in 499 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 500 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 501 * TranslateTextRequest request = 502 * TranslateTextRequest.newBuilder() 503 * .addAllContents(new ArrayList<String>()) 504 * .setMimeType("mimeType-1392120434") 505 * .setSourceLanguageCode("sourceLanguageCode1645917472") 506 * .setTargetLanguageCode("targetLanguageCode-106414698") 507 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 508 * .setModel("model104069929") 509 * .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) 510 * .putAllLabels(new HashMap<String, String>()) 511 * .build(); 512 * ApiFuture<TranslateTextResponse> future = 513 * translationServiceClient.translateTextCallable().futureCall(request); 514 * // Do something. 515 * TranslateTextResponse response = future.get(); 516 * } 517 * }</pre> 518 */ translateTextCallable()519 public final UnaryCallable<TranslateTextRequest, TranslateTextResponse> translateTextCallable() { 520 return stub.translateTextCallable(); 521 } 522 523 // AUTO-GENERATED DOCUMENTATION AND METHOD. 524 /** 525 * Detects the language of text within a request. 526 * 527 * <p>Sample code: 528 * 529 * <pre>{@code 530 * // This snippet has been automatically generated and should be regarded as a code template only. 531 * // It will require modifications to work: 532 * // - It may require correct/in-range values for request initialization. 533 * // - It may require specifying regional endpoints when creating the service client as shown in 534 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 535 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 536 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 537 * String model = "model104069929"; 538 * String mimeType = "mimeType-1392120434"; 539 * String content = "content951530617"; 540 * DetectLanguageResponse response = 541 * translationServiceClient.detectLanguage(parent, model, mimeType, content); 542 * } 543 * }</pre> 544 * 545 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 546 * <p>Format: `projects/{project-number-or-id}/locations/{location-id}` or 547 * `projects/{project-number-or-id}`. 548 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 549 * `projects/{project-number-or-id}`. 550 * <p>Only models within the same region (has same location-id) can be used. Otherwise an 551 * INVALID_ARGUMENT (400) error is returned. 552 * @param model Optional. The language detection model to be used. 553 * <p>Format: 554 * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}` 555 * <p>Only one language detection model is currently supported: 556 * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`. 557 * <p>If not specified, the default model is used. 558 * @param mimeType Optional. The format of the source text, for example, "text/html", 559 * "text/plain". If left blank, the MIME type defaults to "text/html". 560 * @param content The content of the input stored as a string. 561 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 562 */ detectLanguage( LocationName parent, String model, String mimeType, String content)563 public final DetectLanguageResponse detectLanguage( 564 LocationName parent, String model, String mimeType, String content) { 565 DetectLanguageRequest request = 566 DetectLanguageRequest.newBuilder() 567 .setParent(parent == null ? null : parent.toString()) 568 .setModel(model) 569 .setMimeType(mimeType) 570 .setContent(content) 571 .build(); 572 return detectLanguage(request); 573 } 574 575 // AUTO-GENERATED DOCUMENTATION AND METHOD. 576 /** 577 * Detects the language of text within a request. 578 * 579 * <p>Sample code: 580 * 581 * <pre>{@code 582 * // This snippet has been automatically generated and should be regarded as a code template only. 583 * // It will require modifications to work: 584 * // - It may require correct/in-range values for request initialization. 585 * // - It may require specifying regional endpoints when creating the service client as shown in 586 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 587 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 588 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 589 * String model = "model104069929"; 590 * String mimeType = "mimeType-1392120434"; 591 * String content = "content951530617"; 592 * DetectLanguageResponse response = 593 * translationServiceClient.detectLanguage(parent, model, mimeType, content); 594 * } 595 * }</pre> 596 * 597 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 598 * <p>Format: `projects/{project-number-or-id}/locations/{location-id}` or 599 * `projects/{project-number-or-id}`. 600 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 601 * `projects/{project-number-or-id}`. 602 * <p>Only models within the same region (has same location-id) can be used. Otherwise an 603 * INVALID_ARGUMENT (400) error is returned. 604 * @param model Optional. The language detection model to be used. 605 * <p>Format: 606 * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}` 607 * <p>Only one language detection model is currently supported: 608 * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`. 609 * <p>If not specified, the default model is used. 610 * @param mimeType Optional. The format of the source text, for example, "text/html", 611 * "text/plain". If left blank, the MIME type defaults to "text/html". 612 * @param content The content of the input stored as a string. 613 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 614 */ detectLanguage( String parent, String model, String mimeType, String content)615 public final DetectLanguageResponse detectLanguage( 616 String parent, String model, String mimeType, String content) { 617 DetectLanguageRequest request = 618 DetectLanguageRequest.newBuilder() 619 .setParent(parent) 620 .setModel(model) 621 .setMimeType(mimeType) 622 .setContent(content) 623 .build(); 624 return detectLanguage(request); 625 } 626 627 // AUTO-GENERATED DOCUMENTATION AND METHOD. 628 /** 629 * Detects the language of text within a request. 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 (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 640 * DetectLanguageRequest request = 641 * DetectLanguageRequest.newBuilder() 642 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 643 * .setModel("model104069929") 644 * .setMimeType("mimeType-1392120434") 645 * .putAllLabels(new HashMap<String, String>()) 646 * .build(); 647 * DetectLanguageResponse response = translationServiceClient.detectLanguage(request); 648 * } 649 * }</pre> 650 * 651 * @param request The request object containing all of the parameters for the API call. 652 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 653 */ detectLanguage(DetectLanguageRequest request)654 public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request) { 655 return detectLanguageCallable().call(request); 656 } 657 658 // AUTO-GENERATED DOCUMENTATION AND METHOD. 659 /** 660 * Detects the language of text within a request. 661 * 662 * <p>Sample code: 663 * 664 * <pre>{@code 665 * // This snippet has been automatically generated and should be regarded as a code template only. 666 * // It will require modifications to work: 667 * // - It may require correct/in-range values for request initialization. 668 * // - It may require specifying regional endpoints when creating the service client as shown in 669 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 670 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 671 * DetectLanguageRequest request = 672 * DetectLanguageRequest.newBuilder() 673 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 674 * .setModel("model104069929") 675 * .setMimeType("mimeType-1392120434") 676 * .putAllLabels(new HashMap<String, String>()) 677 * .build(); 678 * ApiFuture<DetectLanguageResponse> future = 679 * translationServiceClient.detectLanguageCallable().futureCall(request); 680 * // Do something. 681 * DetectLanguageResponse response = future.get(); 682 * } 683 * }</pre> 684 */ 685 public final UnaryCallable<DetectLanguageRequest, DetectLanguageResponse> detectLanguageCallable()686 detectLanguageCallable() { 687 return stub.detectLanguageCallable(); 688 } 689 690 // AUTO-GENERATED DOCUMENTATION AND METHOD. 691 /** 692 * Returns a list of supported languages for translation. 693 * 694 * <p>Sample code: 695 * 696 * <pre>{@code 697 * // This snippet has been automatically generated and should be regarded as a code template only. 698 * // It will require modifications to work: 699 * // - It may require correct/in-range values for request initialization. 700 * // - It may require specifying regional endpoints when creating the service client as shown in 701 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 702 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 703 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 704 * String model = "model104069929"; 705 * String displayLanguageCode = "displayLanguageCode-1457478841"; 706 * SupportedLanguages response = 707 * translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode); 708 * } 709 * }</pre> 710 * 711 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 712 * <p>Format: `projects/{project-number-or-id}` or 713 * `projects/{project-number-or-id}/locations/{location-id}`. 714 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 715 * `projects/{project-number-or-id}`. 716 * <p>Non-global location is required for AutoML models. 717 * <p>Only models within the same region (have same location-id) can be used, otherwise an 718 * INVALID_ARGUMENT (400) error is returned. 719 * @param model Optional. Get supported languages of this model. 720 * <p>The format depends on model type: 721 * <p>- AutoML Translation models: 722 * `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` 723 * <p>- General (built-in) models: 724 * `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, 725 * <p>Returns languages supported by the specified model. If missing, we get supported 726 * languages of Google general NMT model. 727 * @param displayLanguageCode Optional. The language to use to return localized, human readable 728 * names of supported languages. If missing, then display names are not returned in a 729 * response. 730 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 731 */ getSupportedLanguages( LocationName parent, String model, String displayLanguageCode)732 public final SupportedLanguages getSupportedLanguages( 733 LocationName parent, String model, String displayLanguageCode) { 734 GetSupportedLanguagesRequest request = 735 GetSupportedLanguagesRequest.newBuilder() 736 .setParent(parent == null ? null : parent.toString()) 737 .setModel(model) 738 .setDisplayLanguageCode(displayLanguageCode) 739 .build(); 740 return getSupportedLanguages(request); 741 } 742 743 // AUTO-GENERATED DOCUMENTATION AND METHOD. 744 /** 745 * Returns a list of supported languages for translation. 746 * 747 * <p>Sample code: 748 * 749 * <pre>{@code 750 * // This snippet has been automatically generated and should be regarded as a code template only. 751 * // It will require modifications to work: 752 * // - It may require correct/in-range values for request initialization. 753 * // - It may require specifying regional endpoints when creating the service client as shown in 754 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 755 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 756 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 757 * String model = "model104069929"; 758 * String displayLanguageCode = "displayLanguageCode-1457478841"; 759 * SupportedLanguages response = 760 * translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode); 761 * } 762 * }</pre> 763 * 764 * @param parent Required. Project or location to make a call. Must refer to a caller's project. 765 * <p>Format: `projects/{project-number-or-id}` or 766 * `projects/{project-number-or-id}/locations/{location-id}`. 767 * <p>For global calls, use `projects/{project-number-or-id}/locations/global` or 768 * `projects/{project-number-or-id}`. 769 * <p>Non-global location is required for AutoML models. 770 * <p>Only models within the same region (have same location-id) can be used, otherwise an 771 * INVALID_ARGUMENT (400) error is returned. 772 * @param model Optional. Get supported languages of this model. 773 * <p>The format depends on model type: 774 * <p>- AutoML Translation models: 775 * `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` 776 * <p>- General (built-in) models: 777 * `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, 778 * <p>Returns languages supported by the specified model. If missing, we get supported 779 * languages of Google general NMT model. 780 * @param displayLanguageCode Optional. The language to use to return localized, human readable 781 * names of supported languages. If missing, then display names are not returned in a 782 * response. 783 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 784 */ getSupportedLanguages( String parent, String model, String displayLanguageCode)785 public final SupportedLanguages getSupportedLanguages( 786 String parent, String model, String displayLanguageCode) { 787 GetSupportedLanguagesRequest request = 788 GetSupportedLanguagesRequest.newBuilder() 789 .setParent(parent) 790 .setModel(model) 791 .setDisplayLanguageCode(displayLanguageCode) 792 .build(); 793 return getSupportedLanguages(request); 794 } 795 796 // AUTO-GENERATED DOCUMENTATION AND METHOD. 797 /** 798 * Returns a list of supported languages for translation. 799 * 800 * <p>Sample code: 801 * 802 * <pre>{@code 803 * // This snippet has been automatically generated and should be regarded as a code template only. 804 * // It will require modifications to work: 805 * // - It may require correct/in-range values for request initialization. 806 * // - It may require specifying regional endpoints when creating the service client as shown in 807 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 808 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 809 * GetSupportedLanguagesRequest request = 810 * GetSupportedLanguagesRequest.newBuilder() 811 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 812 * .setDisplayLanguageCode("displayLanguageCode-1457478841") 813 * .setModel("model104069929") 814 * .build(); 815 * SupportedLanguages response = translationServiceClient.getSupportedLanguages(request); 816 * } 817 * }</pre> 818 * 819 * @param request The request object containing all of the parameters for the API call. 820 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 821 */ getSupportedLanguages(GetSupportedLanguagesRequest request)822 public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesRequest request) { 823 return getSupportedLanguagesCallable().call(request); 824 } 825 826 // AUTO-GENERATED DOCUMENTATION AND METHOD. 827 /** 828 * Returns a list of supported languages for translation. 829 * 830 * <p>Sample code: 831 * 832 * <pre>{@code 833 * // This snippet has been automatically generated and should be regarded as a code template only. 834 * // It will require modifications to work: 835 * // - It may require correct/in-range values for request initialization. 836 * // - It may require specifying regional endpoints when creating the service client as shown in 837 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 838 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 839 * GetSupportedLanguagesRequest request = 840 * GetSupportedLanguagesRequest.newBuilder() 841 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 842 * .setDisplayLanguageCode("displayLanguageCode-1457478841") 843 * .setModel("model104069929") 844 * .build(); 845 * ApiFuture<SupportedLanguages> future = 846 * translationServiceClient.getSupportedLanguagesCallable().futureCall(request); 847 * // Do something. 848 * SupportedLanguages response = future.get(); 849 * } 850 * }</pre> 851 */ 852 public final UnaryCallable<GetSupportedLanguagesRequest, SupportedLanguages> getSupportedLanguagesCallable()853 getSupportedLanguagesCallable() { 854 return stub.getSupportedLanguagesCallable(); 855 } 856 857 // AUTO-GENERATED DOCUMENTATION AND METHOD. 858 /** 859 * Translates documents in synchronous mode. 860 * 861 * <p>Sample code: 862 * 863 * <pre>{@code 864 * // This snippet has been automatically generated and should be regarded as a code template only. 865 * // It will require modifications to work: 866 * // - It may require correct/in-range values for request initialization. 867 * // - It may require specifying regional endpoints when creating the service client as shown in 868 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 869 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 870 * TranslateDocumentRequest request = 871 * TranslateDocumentRequest.newBuilder() 872 * .setParent("parent-995424086") 873 * .setSourceLanguageCode("sourceLanguageCode1645917472") 874 * .setTargetLanguageCode("targetLanguageCode-106414698") 875 * .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) 876 * .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) 877 * .setModel("model104069929") 878 * .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) 879 * .putAllLabels(new HashMap<String, String>()) 880 * .setCustomizedAttribution("customizedAttribution557650238") 881 * .setIsTranslateNativePdfOnly(true) 882 * .setEnableShadowRemovalNativePdf(true) 883 * .build(); 884 * TranslateDocumentResponse response = translationServiceClient.translateDocument(request); 885 * } 886 * }</pre> 887 * 888 * @param request The request object containing all of the parameters for the API call. 889 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 890 */ translateDocument(TranslateDocumentRequest request)891 public final TranslateDocumentResponse translateDocument(TranslateDocumentRequest request) { 892 return translateDocumentCallable().call(request); 893 } 894 895 // AUTO-GENERATED DOCUMENTATION AND METHOD. 896 /** 897 * Translates documents in synchronous mode. 898 * 899 * <p>Sample code: 900 * 901 * <pre>{@code 902 * // This snippet has been automatically generated and should be regarded as a code template only. 903 * // It will require modifications to work: 904 * // - It may require correct/in-range values for request initialization. 905 * // - It may require specifying regional endpoints when creating the service client as shown in 906 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 907 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 908 * TranslateDocumentRequest request = 909 * TranslateDocumentRequest.newBuilder() 910 * .setParent("parent-995424086") 911 * .setSourceLanguageCode("sourceLanguageCode1645917472") 912 * .setTargetLanguageCode("targetLanguageCode-106414698") 913 * .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) 914 * .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) 915 * .setModel("model104069929") 916 * .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) 917 * .putAllLabels(new HashMap<String, String>()) 918 * .setCustomizedAttribution("customizedAttribution557650238") 919 * .setIsTranslateNativePdfOnly(true) 920 * .setEnableShadowRemovalNativePdf(true) 921 * .build(); 922 * ApiFuture<TranslateDocumentResponse> future = 923 * translationServiceClient.translateDocumentCallable().futureCall(request); 924 * // Do something. 925 * TranslateDocumentResponse response = future.get(); 926 * } 927 * }</pre> 928 */ 929 public final UnaryCallable<TranslateDocumentRequest, TranslateDocumentResponse> translateDocumentCallable()930 translateDocumentCallable() { 931 return stub.translateDocumentCallable(); 932 } 933 934 // AUTO-GENERATED DOCUMENTATION AND METHOD. 935 /** 936 * Translates a large volume of text in asynchronous batch mode. This function provides real-time 937 * output as the inputs are being processed. If caller cancels a request, the partial results (for 938 * an input file, it's all or nothing) may still be available on the specified output location. 939 * 940 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 941 * status of the call. 942 * 943 * <p>Sample code: 944 * 945 * <pre>{@code 946 * // This snippet has been automatically generated and should be regarded as a code template only. 947 * // It will require modifications to work: 948 * // - It may require correct/in-range values for request initialization. 949 * // - It may require specifying regional endpoints when creating the service client as shown in 950 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 951 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 952 * BatchTranslateTextRequest request = 953 * BatchTranslateTextRequest.newBuilder() 954 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 955 * .setSourceLanguageCode("sourceLanguageCode1645917472") 956 * .addAllTargetLanguageCodes(new ArrayList<String>()) 957 * .putAllModels(new HashMap<String, String>()) 958 * .addAllInputConfigs(new ArrayList<InputConfig>()) 959 * .setOutputConfig(OutputConfig.newBuilder().build()) 960 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 961 * .putAllLabels(new HashMap<String, String>()) 962 * .build(); 963 * BatchTranslateResponse response = 964 * translationServiceClient.batchTranslateTextAsync(request).get(); 965 * } 966 * }</pre> 967 * 968 * @param request The request object containing all of the parameters for the API call. 969 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 970 */ 971 public final OperationFuture<BatchTranslateResponse, BatchTranslateMetadata> batchTranslateTextAsync(BatchTranslateTextRequest request)972 batchTranslateTextAsync(BatchTranslateTextRequest request) { 973 return batchTranslateTextOperationCallable().futureCall(request); 974 } 975 976 // AUTO-GENERATED DOCUMENTATION AND METHOD. 977 /** 978 * Translates a large volume of text in asynchronous batch mode. This function provides real-time 979 * output as the inputs are being processed. If caller cancels a request, the partial results (for 980 * an input file, it's all or nothing) may still be available on the specified output location. 981 * 982 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 983 * status of the call. 984 * 985 * <p>Sample code: 986 * 987 * <pre>{@code 988 * // This snippet has been automatically generated and should be regarded as a code template only. 989 * // It will require modifications to work: 990 * // - It may require correct/in-range values for request initialization. 991 * // - It may require specifying regional endpoints when creating the service client as shown in 992 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 993 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 994 * BatchTranslateTextRequest request = 995 * BatchTranslateTextRequest.newBuilder() 996 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 997 * .setSourceLanguageCode("sourceLanguageCode1645917472") 998 * .addAllTargetLanguageCodes(new ArrayList<String>()) 999 * .putAllModels(new HashMap<String, String>()) 1000 * .addAllInputConfigs(new ArrayList<InputConfig>()) 1001 * .setOutputConfig(OutputConfig.newBuilder().build()) 1002 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 1003 * .putAllLabels(new HashMap<String, String>()) 1004 * .build(); 1005 * OperationFuture<BatchTranslateResponse, BatchTranslateMetadata> future = 1006 * translationServiceClient.batchTranslateTextOperationCallable().futureCall(request); 1007 * // Do something. 1008 * BatchTranslateResponse response = future.get(); 1009 * } 1010 * }</pre> 1011 */ 1012 public final OperationCallable< 1013 BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> batchTranslateTextOperationCallable()1014 batchTranslateTextOperationCallable() { 1015 return stub.batchTranslateTextOperationCallable(); 1016 } 1017 1018 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1019 /** 1020 * Translates a large volume of text in asynchronous batch mode. This function provides real-time 1021 * output as the inputs are being processed. If caller cancels a request, the partial results (for 1022 * an input file, it's all or nothing) may still be available on the specified output location. 1023 * 1024 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1025 * status of the call. 1026 * 1027 * <p>Sample code: 1028 * 1029 * <pre>{@code 1030 * // This snippet has been automatically generated and should be regarded as a code template only. 1031 * // It will require modifications to work: 1032 * // - It may require correct/in-range values for request initialization. 1033 * // - It may require specifying regional endpoints when creating the service client as shown in 1034 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1035 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1036 * BatchTranslateTextRequest request = 1037 * BatchTranslateTextRequest.newBuilder() 1038 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1039 * .setSourceLanguageCode("sourceLanguageCode1645917472") 1040 * .addAllTargetLanguageCodes(new ArrayList<String>()) 1041 * .putAllModels(new HashMap<String, String>()) 1042 * .addAllInputConfigs(new ArrayList<InputConfig>()) 1043 * .setOutputConfig(OutputConfig.newBuilder().build()) 1044 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 1045 * .putAllLabels(new HashMap<String, String>()) 1046 * .build(); 1047 * ApiFuture<Operation> future = 1048 * translationServiceClient.batchTranslateTextCallable().futureCall(request); 1049 * // Do something. 1050 * Operation response = future.get(); 1051 * } 1052 * }</pre> 1053 */ batchTranslateTextCallable()1054 public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateTextCallable() { 1055 return stub.batchTranslateTextCallable(); 1056 } 1057 1058 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1059 /** 1060 * Translates a large volume of document in asynchronous batch mode. This function provides 1061 * real-time output as the inputs are being processed. If caller cancels a request, the partial 1062 * results (for an input file, it's all or nothing) may still be available on the specified output 1063 * location. 1064 * 1065 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1066 * status of the call. 1067 * 1068 * <p>Sample code: 1069 * 1070 * <pre>{@code 1071 * // This snippet has been automatically generated and should be regarded as a code template only. 1072 * // It will require modifications to work: 1073 * // - It may require correct/in-range values for request initialization. 1074 * // - It may require specifying regional endpoints when creating the service client as shown in 1075 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1076 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1077 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1078 * String sourceLanguageCode = "sourceLanguageCode1645917472"; 1079 * List<String> targetLanguageCodes = new ArrayList<>(); 1080 * List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>(); 1081 * BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); 1082 * BatchTranslateDocumentResponse response = 1083 * translationServiceClient 1084 * .batchTranslateDocumentAsync( 1085 * parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) 1086 * .get(); 1087 * } 1088 * }</pre> 1089 * 1090 * @param parent Required. Location to make a regional call. 1091 * <p>Format: `projects/{project-number-or-id}/locations/{location-id}`. 1092 * <p>The `global` location is not supported for batch translation. 1093 * <p>Only AutoML Translation models or glossaries within the same region (have the same 1094 * location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned. 1095 * @param sourceLanguageCode Required. The ISO-639 language code of the input document if known, 1096 * for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language 1097 * Support](https://cloud.google.com/translate/docs/languages). 1098 * @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the 1099 * input document. Specify up to 10 language codes here. 1100 * @param inputConfigs Required. Input configurations. The total number of files matched should be 1101 * <= 100. The total content size to translate should be <= 100M Unicode codepoints. The 1102 * files must use UTF-8 encoding. 1103 * @param outputConfig Required. Output configuration. If 2 input configs match to the same file 1104 * (that is, same input path), we don't generate output for duplicate inputs. 1105 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1106 */ 1107 public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> batchTranslateDocumentAsync( LocationName parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)1108 batchTranslateDocumentAsync( 1109 LocationName parent, 1110 String sourceLanguageCode, 1111 List<String> targetLanguageCodes, 1112 List<BatchDocumentInputConfig> inputConfigs, 1113 BatchDocumentOutputConfig outputConfig) { 1114 BatchTranslateDocumentRequest request = 1115 BatchTranslateDocumentRequest.newBuilder() 1116 .setParent(parent == null ? null : parent.toString()) 1117 .setSourceLanguageCode(sourceLanguageCode) 1118 .addAllTargetLanguageCodes(targetLanguageCodes) 1119 .addAllInputConfigs(inputConfigs) 1120 .setOutputConfig(outputConfig) 1121 .build(); 1122 return batchTranslateDocumentAsync(request); 1123 } 1124 1125 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1126 /** 1127 * Translates a large volume of document in asynchronous batch mode. This function provides 1128 * real-time output as the inputs are being processed. If caller cancels a request, the partial 1129 * results (for an input file, it's all or nothing) may still be available on the specified output 1130 * location. 1131 * 1132 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1133 * status of the call. 1134 * 1135 * <p>Sample code: 1136 * 1137 * <pre>{@code 1138 * // This snippet has been automatically generated and should be regarded as a code template only. 1139 * // It will require modifications to work: 1140 * // - It may require correct/in-range values for request initialization. 1141 * // - It may require specifying regional endpoints when creating the service client as shown in 1142 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1143 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1144 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1145 * String sourceLanguageCode = "sourceLanguageCode1645917472"; 1146 * List<String> targetLanguageCodes = new ArrayList<>(); 1147 * List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>(); 1148 * BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); 1149 * BatchTranslateDocumentResponse response = 1150 * translationServiceClient 1151 * .batchTranslateDocumentAsync( 1152 * parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) 1153 * .get(); 1154 * } 1155 * }</pre> 1156 * 1157 * @param parent Required. Location to make a regional call. 1158 * <p>Format: `projects/{project-number-or-id}/locations/{location-id}`. 1159 * <p>The `global` location is not supported for batch translation. 1160 * <p>Only AutoML Translation models or glossaries within the same region (have the same 1161 * location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned. 1162 * @param sourceLanguageCode Required. The ISO-639 language code of the input document if known, 1163 * for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language 1164 * Support](https://cloud.google.com/translate/docs/languages). 1165 * @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the 1166 * input document. Specify up to 10 language codes here. 1167 * @param inputConfigs Required. Input configurations. The total number of files matched should be 1168 * <= 100. The total content size to translate should be <= 100M Unicode codepoints. The 1169 * files must use UTF-8 encoding. 1170 * @param outputConfig Required. Output configuration. If 2 input configs match to the same file 1171 * (that is, same input path), we don't generate output for duplicate inputs. 1172 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1173 */ 1174 public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> batchTranslateDocumentAsync( String parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)1175 batchTranslateDocumentAsync( 1176 String parent, 1177 String sourceLanguageCode, 1178 List<String> targetLanguageCodes, 1179 List<BatchDocumentInputConfig> inputConfigs, 1180 BatchDocumentOutputConfig outputConfig) { 1181 BatchTranslateDocumentRequest request = 1182 BatchTranslateDocumentRequest.newBuilder() 1183 .setParent(parent) 1184 .setSourceLanguageCode(sourceLanguageCode) 1185 .addAllTargetLanguageCodes(targetLanguageCodes) 1186 .addAllInputConfigs(inputConfigs) 1187 .setOutputConfig(outputConfig) 1188 .build(); 1189 return batchTranslateDocumentAsync(request); 1190 } 1191 1192 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1193 /** 1194 * Translates a large volume of document in asynchronous batch mode. This function provides 1195 * real-time output as the inputs are being processed. If caller cancels a request, the partial 1196 * results (for an input file, it's all or nothing) may still be available on the specified output 1197 * location. 1198 * 1199 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1200 * status of the call. 1201 * 1202 * <p>Sample code: 1203 * 1204 * <pre>{@code 1205 * // This snippet has been automatically generated and should be regarded as a code template only. 1206 * // It will require modifications to work: 1207 * // - It may require correct/in-range values for request initialization. 1208 * // - It may require specifying regional endpoints when creating the service client as shown in 1209 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1210 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1211 * BatchTranslateDocumentRequest request = 1212 * BatchTranslateDocumentRequest.newBuilder() 1213 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1214 * .setSourceLanguageCode("sourceLanguageCode1645917472") 1215 * .addAllTargetLanguageCodes(new ArrayList<String>()) 1216 * .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>()) 1217 * .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) 1218 * .putAllModels(new HashMap<String, String>()) 1219 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 1220 * .putAllFormatConversions(new HashMap<String, String>()) 1221 * .setCustomizedAttribution("customizedAttribution557650238") 1222 * .build(); 1223 * BatchTranslateDocumentResponse response = 1224 * translationServiceClient.batchTranslateDocumentAsync(request).get(); 1225 * } 1226 * }</pre> 1227 * 1228 * @param request The request object containing all of the parameters for the API call. 1229 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1230 */ 1231 public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> batchTranslateDocumentAsync(BatchTranslateDocumentRequest request)1232 batchTranslateDocumentAsync(BatchTranslateDocumentRequest request) { 1233 return batchTranslateDocumentOperationCallable().futureCall(request); 1234 } 1235 1236 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1237 /** 1238 * Translates a large volume of document in asynchronous batch mode. This function provides 1239 * real-time output as the inputs are being processed. If caller cancels a request, the partial 1240 * results (for an input file, it's all or nothing) may still be available on the specified output 1241 * location. 1242 * 1243 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1244 * status of the call. 1245 * 1246 * <p>Sample code: 1247 * 1248 * <pre>{@code 1249 * // This snippet has been automatically generated and should be regarded as a code template only. 1250 * // It will require modifications to work: 1251 * // - It may require correct/in-range values for request initialization. 1252 * // - It may require specifying regional endpoints when creating the service client as shown in 1253 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1254 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1255 * BatchTranslateDocumentRequest request = 1256 * BatchTranslateDocumentRequest.newBuilder() 1257 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1258 * .setSourceLanguageCode("sourceLanguageCode1645917472") 1259 * .addAllTargetLanguageCodes(new ArrayList<String>()) 1260 * .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>()) 1261 * .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) 1262 * .putAllModels(new HashMap<String, String>()) 1263 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 1264 * .putAllFormatConversions(new HashMap<String, String>()) 1265 * .setCustomizedAttribution("customizedAttribution557650238") 1266 * .build(); 1267 * OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future = 1268 * translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request); 1269 * // Do something. 1270 * BatchTranslateDocumentResponse response = future.get(); 1271 * } 1272 * }</pre> 1273 */ 1274 public final OperationCallable< 1275 BatchTranslateDocumentRequest, 1276 BatchTranslateDocumentResponse, 1277 BatchTranslateDocumentMetadata> batchTranslateDocumentOperationCallable()1278 batchTranslateDocumentOperationCallable() { 1279 return stub.batchTranslateDocumentOperationCallable(); 1280 } 1281 1282 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1283 /** 1284 * Translates a large volume of document in asynchronous batch mode. This function provides 1285 * real-time output as the inputs are being processed. If caller cancels a request, the partial 1286 * results (for an input file, it's all or nothing) may still be available on the specified output 1287 * location. 1288 * 1289 * <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the 1290 * status of the call. 1291 * 1292 * <p>Sample code: 1293 * 1294 * <pre>{@code 1295 * // This snippet has been automatically generated and should be regarded as a code template only. 1296 * // It will require modifications to work: 1297 * // - It may require correct/in-range values for request initialization. 1298 * // - It may require specifying regional endpoints when creating the service client as shown in 1299 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1300 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1301 * BatchTranslateDocumentRequest request = 1302 * BatchTranslateDocumentRequest.newBuilder() 1303 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1304 * .setSourceLanguageCode("sourceLanguageCode1645917472") 1305 * .addAllTargetLanguageCodes(new ArrayList<String>()) 1306 * .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>()) 1307 * .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) 1308 * .putAllModels(new HashMap<String, String>()) 1309 * .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>()) 1310 * .putAllFormatConversions(new HashMap<String, String>()) 1311 * .setCustomizedAttribution("customizedAttribution557650238") 1312 * .build(); 1313 * ApiFuture<Operation> future = 1314 * translationServiceClient.batchTranslateDocumentCallable().futureCall(request); 1315 * // Do something. 1316 * Operation response = future.get(); 1317 * } 1318 * }</pre> 1319 */ 1320 public final UnaryCallable<BatchTranslateDocumentRequest, Operation> batchTranslateDocumentCallable()1321 batchTranslateDocumentCallable() { 1322 return stub.batchTranslateDocumentCallable(); 1323 } 1324 1325 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1326 /** 1327 * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project 1328 * doesn't exist. 1329 * 1330 * <p>Sample code: 1331 * 1332 * <pre>{@code 1333 * // This snippet has been automatically generated and should be regarded as a code template only. 1334 * // It will require modifications to work: 1335 * // - It may require correct/in-range values for request initialization. 1336 * // - It may require specifying regional endpoints when creating the service client as shown in 1337 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1338 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1339 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1340 * Glossary glossary = Glossary.newBuilder().build(); 1341 * Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); 1342 * } 1343 * }</pre> 1344 * 1345 * @param parent Required. The project name. 1346 * @param glossary Required. The glossary to create. 1347 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1348 */ createGlossaryAsync( LocationName parent, Glossary glossary)1349 public final OperationFuture<Glossary, CreateGlossaryMetadata> createGlossaryAsync( 1350 LocationName parent, Glossary glossary) { 1351 CreateGlossaryRequest request = 1352 CreateGlossaryRequest.newBuilder() 1353 .setParent(parent == null ? null : parent.toString()) 1354 .setGlossary(glossary) 1355 .build(); 1356 return createGlossaryAsync(request); 1357 } 1358 1359 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1360 /** 1361 * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project 1362 * doesn't exist. 1363 * 1364 * <p>Sample code: 1365 * 1366 * <pre>{@code 1367 * // This snippet has been automatically generated and should be regarded as a code template only. 1368 * // It will require modifications to work: 1369 * // - It may require correct/in-range values for request initialization. 1370 * // - It may require specifying regional endpoints when creating the service client as shown in 1371 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1372 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1373 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1374 * Glossary glossary = Glossary.newBuilder().build(); 1375 * Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); 1376 * } 1377 * }</pre> 1378 * 1379 * @param parent Required. The project name. 1380 * @param glossary Required. The glossary to create. 1381 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1382 */ createGlossaryAsync( String parent, Glossary glossary)1383 public final OperationFuture<Glossary, CreateGlossaryMetadata> createGlossaryAsync( 1384 String parent, Glossary glossary) { 1385 CreateGlossaryRequest request = 1386 CreateGlossaryRequest.newBuilder().setParent(parent).setGlossary(glossary).build(); 1387 return createGlossaryAsync(request); 1388 } 1389 1390 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1391 /** 1392 * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project 1393 * doesn't exist. 1394 * 1395 * <p>Sample code: 1396 * 1397 * <pre>{@code 1398 * // This snippet has been automatically generated and should be regarded as a code template only. 1399 * // It will require modifications to work: 1400 * // - It may require correct/in-range values for request initialization. 1401 * // - It may require specifying regional endpoints when creating the service client as shown in 1402 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1403 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1404 * CreateGlossaryRequest request = 1405 * CreateGlossaryRequest.newBuilder() 1406 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1407 * .setGlossary(Glossary.newBuilder().build()) 1408 * .build(); 1409 * Glossary response = translationServiceClient.createGlossaryAsync(request).get(); 1410 * } 1411 * }</pre> 1412 * 1413 * @param request The request object containing all of the parameters for the API call. 1414 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1415 */ createGlossaryAsync( CreateGlossaryRequest request)1416 public final OperationFuture<Glossary, CreateGlossaryMetadata> createGlossaryAsync( 1417 CreateGlossaryRequest request) { 1418 return createGlossaryOperationCallable().futureCall(request); 1419 } 1420 1421 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1422 /** 1423 * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project 1424 * doesn't exist. 1425 * 1426 * <p>Sample code: 1427 * 1428 * <pre>{@code 1429 * // This snippet has been automatically generated and should be regarded as a code template only. 1430 * // It will require modifications to work: 1431 * // - It may require correct/in-range values for request initialization. 1432 * // - It may require specifying regional endpoints when creating the service client as shown in 1433 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1434 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1435 * CreateGlossaryRequest request = 1436 * CreateGlossaryRequest.newBuilder() 1437 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1438 * .setGlossary(Glossary.newBuilder().build()) 1439 * .build(); 1440 * OperationFuture<Glossary, CreateGlossaryMetadata> future = 1441 * translationServiceClient.createGlossaryOperationCallable().futureCall(request); 1442 * // Do something. 1443 * Glossary response = future.get(); 1444 * } 1445 * }</pre> 1446 */ 1447 public final OperationCallable<CreateGlossaryRequest, Glossary, CreateGlossaryMetadata> createGlossaryOperationCallable()1448 createGlossaryOperationCallable() { 1449 return stub.createGlossaryOperationCallable(); 1450 } 1451 1452 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1453 /** 1454 * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project 1455 * doesn't exist. 1456 * 1457 * <p>Sample code: 1458 * 1459 * <pre>{@code 1460 * // This snippet has been automatically generated and should be regarded as a code template only. 1461 * // It will require modifications to work: 1462 * // - It may require correct/in-range values for request initialization. 1463 * // - It may require specifying regional endpoints when creating the service client as shown in 1464 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1465 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1466 * CreateGlossaryRequest request = 1467 * CreateGlossaryRequest.newBuilder() 1468 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1469 * .setGlossary(Glossary.newBuilder().build()) 1470 * .build(); 1471 * ApiFuture<Operation> future = 1472 * translationServiceClient.createGlossaryCallable().futureCall(request); 1473 * // Do something. 1474 * Operation response = future.get(); 1475 * } 1476 * }</pre> 1477 */ createGlossaryCallable()1478 public final UnaryCallable<CreateGlossaryRequest, Operation> createGlossaryCallable() { 1479 return stub.createGlossaryCallable(); 1480 } 1481 1482 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1483 /** 1484 * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. 1485 * 1486 * <p>Sample code: 1487 * 1488 * <pre>{@code 1489 * // This snippet has been automatically generated and should be regarded as a code template only. 1490 * // It will require modifications to work: 1491 * // - It may require correct/in-range values for request initialization. 1492 * // - It may require specifying regional endpoints when creating the service client as shown in 1493 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1494 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1495 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1496 * for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) { 1497 * // doThingsWith(element); 1498 * } 1499 * } 1500 * }</pre> 1501 * 1502 * @param parent Required. The name of the project from which to list all of the glossaries. 1503 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1504 */ listGlossaries(LocationName parent)1505 public final ListGlossariesPagedResponse listGlossaries(LocationName parent) { 1506 ListGlossariesRequest request = 1507 ListGlossariesRequest.newBuilder() 1508 .setParent(parent == null ? null : parent.toString()) 1509 .build(); 1510 return listGlossaries(request); 1511 } 1512 1513 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1514 /** 1515 * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. 1516 * 1517 * <p>Sample code: 1518 * 1519 * <pre>{@code 1520 * // This snippet has been automatically generated and should be regarded as a code template only. 1521 * // It will require modifications to work: 1522 * // - It may require correct/in-range values for request initialization. 1523 * // - It may require specifying regional endpoints when creating the service client as shown in 1524 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1525 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1526 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1527 * for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) { 1528 * // doThingsWith(element); 1529 * } 1530 * } 1531 * }</pre> 1532 * 1533 * @param parent Required. The name of the project from which to list all of the glossaries. 1534 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1535 */ listGlossaries(String parent)1536 public final ListGlossariesPagedResponse listGlossaries(String parent) { 1537 ListGlossariesRequest request = ListGlossariesRequest.newBuilder().setParent(parent).build(); 1538 return listGlossaries(request); 1539 } 1540 1541 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1542 /** 1543 * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. 1544 * 1545 * <p>Sample code: 1546 * 1547 * <pre>{@code 1548 * // This snippet has been automatically generated and should be regarded as a code template only. 1549 * // It will require modifications to work: 1550 * // - It may require correct/in-range values for request initialization. 1551 * // - It may require specifying regional endpoints when creating the service client as shown in 1552 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1553 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1554 * ListGlossariesRequest request = 1555 * ListGlossariesRequest.newBuilder() 1556 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1557 * .setPageSize(883849137) 1558 * .setPageToken("pageToken873572522") 1559 * .setFilter("filter-1274492040") 1560 * .build(); 1561 * for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) { 1562 * // doThingsWith(element); 1563 * } 1564 * } 1565 * }</pre> 1566 * 1567 * @param request The request object containing all of the parameters for the API call. 1568 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1569 */ listGlossaries(ListGlossariesRequest request)1570 public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest request) { 1571 return listGlossariesPagedCallable().call(request); 1572 } 1573 1574 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1575 /** 1576 * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. 1577 * 1578 * <p>Sample code: 1579 * 1580 * <pre>{@code 1581 * // This snippet has been automatically generated and should be regarded as a code template only. 1582 * // It will require modifications to work: 1583 * // - It may require correct/in-range values for request initialization. 1584 * // - It may require specifying regional endpoints when creating the service client as shown in 1585 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1586 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1587 * ListGlossariesRequest request = 1588 * ListGlossariesRequest.newBuilder() 1589 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1590 * .setPageSize(883849137) 1591 * .setPageToken("pageToken873572522") 1592 * .setFilter("filter-1274492040") 1593 * .build(); 1594 * ApiFuture<Glossary> future = 1595 * translationServiceClient.listGlossariesPagedCallable().futureCall(request); 1596 * // Do something. 1597 * for (Glossary element : future.get().iterateAll()) { 1598 * // doThingsWith(element); 1599 * } 1600 * } 1601 * }</pre> 1602 */ 1603 public final UnaryCallable<ListGlossariesRequest, ListGlossariesPagedResponse> listGlossariesPagedCallable()1604 listGlossariesPagedCallable() { 1605 return stub.listGlossariesPagedCallable(); 1606 } 1607 1608 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1609 /** 1610 * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. 1611 * 1612 * <p>Sample code: 1613 * 1614 * <pre>{@code 1615 * // This snippet has been automatically generated and should be regarded as a code template only. 1616 * // It will require modifications to work: 1617 * // - It may require correct/in-range values for request initialization. 1618 * // - It may require specifying regional endpoints when creating the service client as shown in 1619 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1620 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1621 * ListGlossariesRequest request = 1622 * ListGlossariesRequest.newBuilder() 1623 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1624 * .setPageSize(883849137) 1625 * .setPageToken("pageToken873572522") 1626 * .setFilter("filter-1274492040") 1627 * .build(); 1628 * while (true) { 1629 * ListGlossariesResponse response = 1630 * translationServiceClient.listGlossariesCallable().call(request); 1631 * for (Glossary element : response.getGlossariesList()) { 1632 * // doThingsWith(element); 1633 * } 1634 * String nextPageToken = response.getNextPageToken(); 1635 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1636 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1637 * } else { 1638 * break; 1639 * } 1640 * } 1641 * } 1642 * }</pre> 1643 */ 1644 public final UnaryCallable<ListGlossariesRequest, ListGlossariesResponse> listGlossariesCallable()1645 listGlossariesCallable() { 1646 return stub.listGlossariesCallable(); 1647 } 1648 1649 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1650 /** 1651 * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. 1652 * 1653 * <p>Sample code: 1654 * 1655 * <pre>{@code 1656 * // This snippet has been automatically generated and should be regarded as a code template only. 1657 * // It will require modifications to work: 1658 * // - It may require correct/in-range values for request initialization. 1659 * // - It may require specifying regional endpoints when creating the service client as shown in 1660 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1661 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1662 * GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); 1663 * Glossary response = translationServiceClient.getGlossary(name); 1664 * } 1665 * }</pre> 1666 * 1667 * @param name Required. The name of the glossary to retrieve. 1668 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1669 */ getGlossary(GlossaryName name)1670 public final Glossary getGlossary(GlossaryName name) { 1671 GetGlossaryRequest request = 1672 GetGlossaryRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1673 return getGlossary(request); 1674 } 1675 1676 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1677 /** 1678 * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. 1679 * 1680 * <p>Sample code: 1681 * 1682 * <pre>{@code 1683 * // This snippet has been automatically generated and should be regarded as a code template only. 1684 * // It will require modifications to work: 1685 * // - It may require correct/in-range values for request initialization. 1686 * // - It may require specifying regional endpoints when creating the service client as shown in 1687 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1688 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1689 * String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); 1690 * Glossary response = translationServiceClient.getGlossary(name); 1691 * } 1692 * }</pre> 1693 * 1694 * @param name Required. The name of the glossary to retrieve. 1695 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1696 */ getGlossary(String name)1697 public final Glossary getGlossary(String name) { 1698 GetGlossaryRequest request = GetGlossaryRequest.newBuilder().setName(name).build(); 1699 return getGlossary(request); 1700 } 1701 1702 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1703 /** 1704 * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. 1705 * 1706 * <p>Sample code: 1707 * 1708 * <pre>{@code 1709 * // This snippet has been automatically generated and should be regarded as a code template only. 1710 * // It will require modifications to work: 1711 * // - It may require correct/in-range values for request initialization. 1712 * // - It may require specifying regional endpoints when creating the service client as shown in 1713 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1714 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1715 * GetGlossaryRequest request = 1716 * GetGlossaryRequest.newBuilder() 1717 * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) 1718 * .build(); 1719 * Glossary response = translationServiceClient.getGlossary(request); 1720 * } 1721 * }</pre> 1722 * 1723 * @param request The request object containing all of the parameters for the API call. 1724 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1725 */ getGlossary(GetGlossaryRequest request)1726 public final Glossary getGlossary(GetGlossaryRequest request) { 1727 return getGlossaryCallable().call(request); 1728 } 1729 1730 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1731 /** 1732 * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. 1733 * 1734 * <p>Sample code: 1735 * 1736 * <pre>{@code 1737 * // This snippet has been automatically generated and should be regarded as a code template only. 1738 * // It will require modifications to work: 1739 * // - It may require correct/in-range values for request initialization. 1740 * // - It may require specifying regional endpoints when creating the service client as shown in 1741 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1742 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1743 * GetGlossaryRequest request = 1744 * GetGlossaryRequest.newBuilder() 1745 * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) 1746 * .build(); 1747 * ApiFuture<Glossary> future = 1748 * translationServiceClient.getGlossaryCallable().futureCall(request); 1749 * // Do something. 1750 * Glossary response = future.get(); 1751 * } 1752 * }</pre> 1753 */ getGlossaryCallable()1754 public final UnaryCallable<GetGlossaryRequest, Glossary> getGlossaryCallable() { 1755 return stub.getGlossaryCallable(); 1756 } 1757 1758 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1759 /** 1760 * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns 1761 * NOT_FOUND, if the glossary doesn't exist. 1762 * 1763 * <p>Sample code: 1764 * 1765 * <pre>{@code 1766 * // This snippet has been automatically generated and should be regarded as a code template only. 1767 * // It will require modifications to work: 1768 * // - It may require correct/in-range values for request initialization. 1769 * // - It may require specifying regional endpoints when creating the service client as shown in 1770 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1771 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1772 * GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); 1773 * DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); 1774 * } 1775 * }</pre> 1776 * 1777 * @param name Required. The name of the glossary to delete. 1778 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1779 */ deleteGlossaryAsync( GlossaryName name)1780 public final OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> deleteGlossaryAsync( 1781 GlossaryName name) { 1782 DeleteGlossaryRequest request = 1783 DeleteGlossaryRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1784 return deleteGlossaryAsync(request); 1785 } 1786 1787 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1788 /** 1789 * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns 1790 * NOT_FOUND, if the glossary doesn't exist. 1791 * 1792 * <p>Sample code: 1793 * 1794 * <pre>{@code 1795 * // This snippet has been automatically generated and should be regarded as a code template only. 1796 * // It will require modifications to work: 1797 * // - It may require correct/in-range values for request initialization. 1798 * // - It may require specifying regional endpoints when creating the service client as shown in 1799 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1800 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1801 * String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); 1802 * DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); 1803 * } 1804 * }</pre> 1805 * 1806 * @param name Required. The name of the glossary to delete. 1807 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1808 */ deleteGlossaryAsync( String name)1809 public final OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> deleteGlossaryAsync( 1810 String name) { 1811 DeleteGlossaryRequest request = DeleteGlossaryRequest.newBuilder().setName(name).build(); 1812 return deleteGlossaryAsync(request); 1813 } 1814 1815 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1816 /** 1817 * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns 1818 * NOT_FOUND, if the glossary doesn't exist. 1819 * 1820 * <p>Sample code: 1821 * 1822 * <pre>{@code 1823 * // This snippet has been automatically generated and should be regarded as a code template only. 1824 * // It will require modifications to work: 1825 * // - It may require correct/in-range values for request initialization. 1826 * // - It may require specifying regional endpoints when creating the service client as shown in 1827 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1828 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1829 * DeleteGlossaryRequest request = 1830 * DeleteGlossaryRequest.newBuilder() 1831 * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) 1832 * .build(); 1833 * DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get(); 1834 * } 1835 * }</pre> 1836 * 1837 * @param request The request object containing all of the parameters for the API call. 1838 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1839 */ deleteGlossaryAsync( DeleteGlossaryRequest request)1840 public final OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> deleteGlossaryAsync( 1841 DeleteGlossaryRequest request) { 1842 return deleteGlossaryOperationCallable().futureCall(request); 1843 } 1844 1845 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1846 /** 1847 * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns 1848 * NOT_FOUND, if the glossary doesn't exist. 1849 * 1850 * <p>Sample code: 1851 * 1852 * <pre>{@code 1853 * // This snippet has been automatically generated and should be regarded as a code template only. 1854 * // It will require modifications to work: 1855 * // - It may require correct/in-range values for request initialization. 1856 * // - It may require specifying regional endpoints when creating the service client as shown in 1857 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1858 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1859 * DeleteGlossaryRequest request = 1860 * DeleteGlossaryRequest.newBuilder() 1861 * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) 1862 * .build(); 1863 * OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> future = 1864 * translationServiceClient.deleteGlossaryOperationCallable().futureCall(request); 1865 * // Do something. 1866 * DeleteGlossaryResponse response = future.get(); 1867 * } 1868 * }</pre> 1869 */ 1870 public final OperationCallable< 1871 DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> deleteGlossaryOperationCallable()1872 deleteGlossaryOperationCallable() { 1873 return stub.deleteGlossaryOperationCallable(); 1874 } 1875 1876 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1877 /** 1878 * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns 1879 * NOT_FOUND, if the glossary doesn't exist. 1880 * 1881 * <p>Sample code: 1882 * 1883 * <pre>{@code 1884 * // This snippet has been automatically generated and should be regarded as a code template only. 1885 * // It will require modifications to work: 1886 * // - It may require correct/in-range values for request initialization. 1887 * // - It may require specifying regional endpoints when creating the service client as shown in 1888 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1889 * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { 1890 * DeleteGlossaryRequest request = 1891 * DeleteGlossaryRequest.newBuilder() 1892 * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) 1893 * .build(); 1894 * ApiFuture<Operation> future = 1895 * translationServiceClient.deleteGlossaryCallable().futureCall(request); 1896 * // Do something. 1897 * Operation response = future.get(); 1898 * } 1899 * }</pre> 1900 */ deleteGlossaryCallable()1901 public final UnaryCallable<DeleteGlossaryRequest, Operation> deleteGlossaryCallable() { 1902 return stub.deleteGlossaryCallable(); 1903 } 1904 1905 @Override close()1906 public final void close() { 1907 stub.close(); 1908 } 1909 1910 @Override shutdown()1911 public void shutdown() { 1912 stub.shutdown(); 1913 } 1914 1915 @Override isShutdown()1916 public boolean isShutdown() { 1917 return stub.isShutdown(); 1918 } 1919 1920 @Override isTerminated()1921 public boolean isTerminated() { 1922 return stub.isTerminated(); 1923 } 1924 1925 @Override shutdownNow()1926 public void shutdownNow() { 1927 stub.shutdownNow(); 1928 } 1929 1930 @Override awaitTermination(long duration, TimeUnit unit)1931 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1932 return stub.awaitTermination(duration, unit); 1933 } 1934 1935 public static class ListGlossariesPagedResponse 1936 extends AbstractPagedListResponse< 1937 ListGlossariesRequest, 1938 ListGlossariesResponse, 1939 Glossary, 1940 ListGlossariesPage, 1941 ListGlossariesFixedSizeCollection> { 1942 createAsync( PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, ApiFuture<ListGlossariesResponse> futureResponse)1943 public static ApiFuture<ListGlossariesPagedResponse> createAsync( 1944 PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, 1945 ApiFuture<ListGlossariesResponse> futureResponse) { 1946 ApiFuture<ListGlossariesPage> futurePage = 1947 ListGlossariesPage.createEmptyPage().createPageAsync(context, futureResponse); 1948 return ApiFutures.transform( 1949 futurePage, 1950 input -> new ListGlossariesPagedResponse(input), 1951 MoreExecutors.directExecutor()); 1952 } 1953 ListGlossariesPagedResponse(ListGlossariesPage page)1954 private ListGlossariesPagedResponse(ListGlossariesPage page) { 1955 super(page, ListGlossariesFixedSizeCollection.createEmptyCollection()); 1956 } 1957 } 1958 1959 public static class ListGlossariesPage 1960 extends AbstractPage< 1961 ListGlossariesRequest, ListGlossariesResponse, Glossary, ListGlossariesPage> { 1962 ListGlossariesPage( PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, ListGlossariesResponse response)1963 private ListGlossariesPage( 1964 PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, 1965 ListGlossariesResponse response) { 1966 super(context, response); 1967 } 1968 createEmptyPage()1969 private static ListGlossariesPage createEmptyPage() { 1970 return new ListGlossariesPage(null, null); 1971 } 1972 1973 @Override createPage( PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, ListGlossariesResponse response)1974 protected ListGlossariesPage createPage( 1975 PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, 1976 ListGlossariesResponse response) { 1977 return new ListGlossariesPage(context, response); 1978 } 1979 1980 @Override createPageAsync( PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, ApiFuture<ListGlossariesResponse> futureResponse)1981 public ApiFuture<ListGlossariesPage> createPageAsync( 1982 PageContext<ListGlossariesRequest, ListGlossariesResponse, Glossary> context, 1983 ApiFuture<ListGlossariesResponse> futureResponse) { 1984 return super.createPageAsync(context, futureResponse); 1985 } 1986 } 1987 1988 public static class ListGlossariesFixedSizeCollection 1989 extends AbstractFixedSizeCollection< 1990 ListGlossariesRequest, 1991 ListGlossariesResponse, 1992 Glossary, 1993 ListGlossariesPage, 1994 ListGlossariesFixedSizeCollection> { 1995 ListGlossariesFixedSizeCollection(List<ListGlossariesPage> pages, int collectionSize)1996 private ListGlossariesFixedSizeCollection(List<ListGlossariesPage> pages, int collectionSize) { 1997 super(pages, collectionSize); 1998 } 1999 createEmptyCollection()2000 private static ListGlossariesFixedSizeCollection createEmptyCollection() { 2001 return new ListGlossariesFixedSizeCollection(null, 0); 2002 } 2003 2004 @Override createCollection( List<ListGlossariesPage> pages, int collectionSize)2005 protected ListGlossariesFixedSizeCollection createCollection( 2006 List<ListGlossariesPage> pages, int collectionSize) { 2007 return new ListGlossariesFixedSizeCollection(pages, collectionSize); 2008 } 2009 } 2010 } 2011