xref: /aosp_15_r20/external/googleapis/google/cloud/translate/v3/translation_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.translation.v3;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/translate/v3/adaptive_mt.proto";
24import "google/longrunning/operations.proto";
25import "google/protobuf/empty.proto";
26import "google/protobuf/timestamp.proto";
27
28option cc_enable_arenas = true;
29option csharp_namespace = "Google.Cloud.Translate.V3";
30option go_package = "cloud.google.com/go/translate/apiv3/translatepb;translatepb";
31option java_multiple_files = true;
32option java_outer_classname = "TranslationServiceProto";
33option java_package = "com.google.cloud.translate.v3";
34option php_namespace = "Google\\Cloud\\Translate\\V3";
35option ruby_package = "Google::Cloud::Translate::V3";
36
37// Proto file for the Cloud Translation API (v3 GA).
38
39// Provides natural language translation operations.
40service TranslationService {
41  option (google.api.default_host) = "translate.googleapis.com";
42  option (google.api.oauth_scopes) =
43      "https://www.googleapis.com/auth/cloud-platform,"
44      "https://www.googleapis.com/auth/cloud-translation";
45
46  // Translates input text and returns translated text.
47  rpc TranslateText(TranslateTextRequest) returns (TranslateTextResponse) {
48    option (google.api.http) = {
49      post: "/v3/{parent=projects/*/locations/*}:translateText"
50      body: "*"
51      additional_bindings {
52        post: "/v3/{parent=projects/*}:translateText"
53        body: "*"
54      }
55    };
56    option (google.api.method_signature) =
57        "parent,target_language_code,contents";
58    option (google.api.method_signature) =
59        "parent,model,mime_type,source_language_code,target_language_code,contents";
60  }
61
62  // Detects the language of text within a request.
63  rpc DetectLanguage(DetectLanguageRequest) returns (DetectLanguageResponse) {
64    option (google.api.http) = {
65      post: "/v3/{parent=projects/*/locations/*}:detectLanguage"
66      body: "*"
67      additional_bindings {
68        post: "/v3/{parent=projects/*}:detectLanguage"
69        body: "*"
70      }
71    };
72    option (google.api.method_signature) = "parent,model,mime_type,content";
73  }
74
75  // Returns a list of supported languages for translation.
76  rpc GetSupportedLanguages(GetSupportedLanguagesRequest)
77      returns (SupportedLanguages) {
78    option (google.api.http) = {
79      get: "/v3/{parent=projects/*/locations/*}/supportedLanguages"
80      additional_bindings { get: "/v3/{parent=projects/*}/supportedLanguages" }
81    };
82    option (google.api.method_signature) = "parent,model,display_language_code";
83  }
84
85  // Translates documents in synchronous mode.
86  rpc TranslateDocument(TranslateDocumentRequest)
87      returns (TranslateDocumentResponse) {
88    option (google.api.http) = {
89      post: "/v3/{parent=projects/*/locations/*}:translateDocument"
90      body: "*"
91    };
92  }
93
94  // Translates a large volume of text in asynchronous batch mode.
95  // This function provides real-time output as the inputs are being processed.
96  // If caller cancels a request, the partial results (for an input file, it's
97  // all or nothing) may still be available on the specified output location.
98  //
99  // This call returns immediately and you can
100  // use google.longrunning.Operation.name to poll the status of the call.
101  rpc BatchTranslateText(BatchTranslateTextRequest)
102      returns (google.longrunning.Operation) {
103    option (google.api.http) = {
104      post: "/v3/{parent=projects/*/locations/*}:batchTranslateText"
105      body: "*"
106    };
107    option (google.longrunning.operation_info) = {
108      response_type: "BatchTranslateResponse"
109      metadata_type: "BatchTranslateMetadata"
110    };
111  }
112
113  // Translates a large volume of document in asynchronous batch mode.
114  // This function provides real-time output as the inputs are being processed.
115  // If caller cancels a request, the partial results (for an input file, it's
116  // all or nothing) may still be available on the specified output location.
117  //
118  // This call returns immediately and you can use
119  // google.longrunning.Operation.name to poll the status of the call.
120  rpc BatchTranslateDocument(BatchTranslateDocumentRequest)
121      returns (google.longrunning.Operation) {
122    option (google.api.http) = {
123      post: "/v3/{parent=projects/*/locations/*}:batchTranslateDocument"
124      body: "*"
125    };
126    option (google.api.method_signature) =
127        "parent,source_language_code,target_language_codes,input_configs,output_config";
128    option (google.longrunning.operation_info) = {
129      response_type: "BatchTranslateDocumentResponse"
130      metadata_type: "BatchTranslateDocumentMetadata"
131    };
132  }
133
134  // Creates a glossary and returns the long-running operation. Returns
135  // NOT_FOUND, if the project doesn't exist.
136  rpc CreateGlossary(CreateGlossaryRequest)
137      returns (google.longrunning.Operation) {
138    option (google.api.http) = {
139      post: "/v3/{parent=projects/*/locations/*}/glossaries"
140      body: "glossary"
141    };
142    option (google.api.method_signature) = "parent,glossary";
143    option (google.longrunning.operation_info) = {
144      response_type: "Glossary"
145      metadata_type: "CreateGlossaryMetadata"
146    };
147  }
148
149  // Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
150  // exist.
151  rpc ListGlossaries(ListGlossariesRequest) returns (ListGlossariesResponse) {
152    option (google.api.http) = {
153      get: "/v3/{parent=projects/*/locations/*}/glossaries"
154    };
155    option (google.api.method_signature) = "parent";
156  }
157
158  // Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
159  // exist.
160  rpc GetGlossary(GetGlossaryRequest) returns (Glossary) {
161    option (google.api.http) = {
162      get: "/v3/{name=projects/*/locations/*/glossaries/*}"
163    };
164    option (google.api.method_signature) = "name";
165  }
166
167  // Deletes a glossary, or cancels glossary construction
168  // if the glossary isn't created yet.
169  // Returns NOT_FOUND, if the glossary doesn't exist.
170  rpc DeleteGlossary(DeleteGlossaryRequest)
171      returns (google.longrunning.Operation) {
172    option (google.api.http) = {
173      delete: "/v3/{name=projects/*/locations/*/glossaries/*}"
174    };
175    option (google.api.method_signature) = "name";
176    option (google.longrunning.operation_info) = {
177      response_type: "DeleteGlossaryResponse"
178      metadata_type: "DeleteGlossaryMetadata"
179    };
180  }
181
182  // Creates an Adaptive MT dataset.
183  rpc CreateAdaptiveMtDataset(CreateAdaptiveMtDatasetRequest)
184      returns (AdaptiveMtDataset) {
185    option (google.api.http) = {
186      post: "/v3/{parent=projects/*/locations/*}/adaptiveMtDatasets"
187      body: "adaptive_mt_dataset"
188    };
189    option (google.api.method_signature) = "parent,adaptive_mt_dataset";
190  }
191
192  // Deletes an Adaptive MT dataset, including all its entries and associated
193  // metadata.
194  rpc DeleteAdaptiveMtDataset(DeleteAdaptiveMtDatasetRequest)
195      returns (google.protobuf.Empty) {
196    option (google.api.http) = {
197      delete: "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*}"
198    };
199    option (google.api.method_signature) = "name";
200  }
201
202  // Gets the Adaptive MT dataset.
203  rpc GetAdaptiveMtDataset(GetAdaptiveMtDatasetRequest)
204      returns (AdaptiveMtDataset) {
205    option (google.api.http) = {
206      get: "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*}"
207    };
208    option (google.api.method_signature) = "name";
209  }
210
211  // Lists all Adaptive MT datasets for which the caller has read permission.
212  rpc ListAdaptiveMtDatasets(ListAdaptiveMtDatasetsRequest)
213      returns (ListAdaptiveMtDatasetsResponse) {
214    option (google.api.http) = {
215      get: "/v3/{parent=projects/*/locations/*}/adaptiveMtDatasets"
216    };
217    option (google.api.method_signature) = "parent";
218  }
219
220  // Translate text using Adaptive MT.
221  rpc AdaptiveMtTranslate(AdaptiveMtTranslateRequest)
222      returns (AdaptiveMtTranslateResponse) {
223    option (google.api.http) = {
224      post: "/v3/{parent=projects/*/locations/*}:adaptiveMtTranslate"
225      body: "*"
226    };
227    option (google.api.method_signature) = "parent,content";
228  }
229
230  // Gets and AdaptiveMtFile
231  rpc GetAdaptiveMtFile(GetAdaptiveMtFileRequest) returns (AdaptiveMtFile) {
232    option (google.api.http) = {
233      get: "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}"
234    };
235    option (google.api.method_signature) = "name";
236  }
237
238  // Deletes an AdaptiveMtFile along with its sentences.
239  rpc DeleteAdaptiveMtFile(DeleteAdaptiveMtFileRequest)
240      returns (google.protobuf.Empty) {
241    option (google.api.http) = {
242      delete: "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}"
243    };
244    option (google.api.method_signature) = "name";
245  }
246
247  // Imports an AdaptiveMtFile and adds all of its sentences into the
248  // AdaptiveMtDataset.
249  rpc ImportAdaptiveMtFile(ImportAdaptiveMtFileRequest)
250      returns (ImportAdaptiveMtFileResponse) {
251    option (google.api.http) = {
252      post: "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}:importAdaptiveMtFile"
253      body: "*"
254    };
255    option (google.api.method_signature) = "parent";
256  }
257
258  // Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.
259  rpc ListAdaptiveMtFiles(ListAdaptiveMtFilesRequest)
260      returns (ListAdaptiveMtFilesResponse) {
261    option (google.api.http) = {
262      get: "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}/adaptiveMtFiles"
263    };
264    option (google.api.method_signature) = "parent";
265  }
266
267  // Lists all AdaptiveMtSentences under a given file/dataset.
268  rpc ListAdaptiveMtSentences(ListAdaptiveMtSentencesRequest)
269      returns (ListAdaptiveMtSentencesResponse) {
270    option (google.api.http) = {
271      get: "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}/adaptiveMtSentences"
272      additional_bindings {
273        get: "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}/adaptiveMtSentences"
274      }
275    };
276    option (google.api.method_signature) = "parent";
277  }
278}
279
280// Configures which glossary is used for a specific target language and defines
281// options for applying that glossary.
282message TranslateTextGlossaryConfig {
283  // Required. The `glossary` to be applied for this translation.
284  //
285  // The format depends on the glossary:
286  //
287  // - User-provided custom glossary:
288  //   `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
289  string glossary = 1 [(google.api.field_behavior) = REQUIRED];
290
291  // Optional. Indicates match is case insensitive. The default value is `false`
292  // if missing.
293  bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
294}
295
296// The request message for synchronous translation.
297message TranslateTextRequest {
298  // Required. The content of the input in string format.
299  // We recommend the total content be less than 30,000 codepoints. The max
300  // length of this field is 1024. Use BatchTranslateText for larger text.
301  repeated string contents = 1 [(google.api.field_behavior) = REQUIRED];
302
303  // Optional. The format of the source text, for example, "text/html",
304  //  "text/plain". If left blank, the MIME type defaults to "text/html".
305  string mime_type = 3 [(google.api.field_behavior) = OPTIONAL];
306
307  // Optional. The ISO-639 language code of the input text if
308  // known, for example, "en-US" or "sr-Latn". Supported language codes are
309  // listed in Language Support. If the source language isn't specified, the API
310  // attempts to identify the source language automatically and returns the
311  // source language within the response.
312  string source_language_code = 4 [(google.api.field_behavior) = OPTIONAL];
313
314  // Required. The ISO-639 language code to use for translation of the input
315  // text, set to one of the language codes listed in Language Support.
316  string target_language_code = 5 [(google.api.field_behavior) = REQUIRED];
317
318  // Required. Project or location to make a call. Must refer to a caller's
319  // project.
320  //
321  // Format: `projects/{project-number-or-id}` or
322  // `projects/{project-number-or-id}/locations/{location-id}`.
323  //
324  // For global calls, use `projects/{project-number-or-id}/locations/global` or
325  // `projects/{project-number-or-id}`.
326  //
327  // Non-global location is required for requests using AutoML models or
328  // custom glossaries.
329  //
330  // Models and glossaries must be within the same region (have same
331  // location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
332  string parent = 8 [
333    (google.api.field_behavior) = REQUIRED,
334    (google.api.resource_reference) = {
335      type: "locations.googleapis.com/Location"
336    }
337  ];
338
339  // Optional. The `model` type requested for this translation.
340  //
341  // The format depends on model type:
342  //
343  // - AutoML Translation models:
344  //   `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
345  //
346  // - General (built-in) models:
347  //   `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
348  //
349  //
350  // For global (non-regionalized) requests, use `location-id` `global`.
351  // For example,
352  // `projects/{project-number-or-id}/locations/global/models/general/nmt`.
353  //
354  // If not provided, the default Google model (NMT) will be used
355  string model = 6 [(google.api.field_behavior) = OPTIONAL];
356
357  // Optional. Glossary to be applied. The glossary must be
358  // within the same region (have the same location-id) as the model, otherwise
359  // an INVALID_ARGUMENT (400) error is returned.
360  TranslateTextGlossaryConfig glossary_config = 7
361      [(google.api.field_behavior) = OPTIONAL];
362
363  // Optional. The labels with user-defined metadata for the request.
364  //
365  // Label keys and values can be no longer than 63 characters
366  // (Unicode codepoints), can only contain lowercase letters, numeric
367  // characters, underscores and dashes. International characters are allowed.
368  // Label values are optional. Label keys must start with a letter.
369  //
370  // See https://cloud.google.com/translate/docs/advanced/labels for more
371  // information.
372  map<string, string> labels = 10 [(google.api.field_behavior) = OPTIONAL];
373}
374
375message TranslateTextResponse {
376  // Text translation responses with no glossary applied.
377  // This field has the same length as
378  // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
379  repeated Translation translations = 1;
380
381  // Text translation responses if a glossary is provided in the request.
382  // This can be the same as
383  // [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
384  // if no terms apply. This field has the same length as
385  // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
386  repeated Translation glossary_translations = 3;
387}
388
389// A single translation response.
390message Translation {
391  // Text translated into the target language.
392  // If an error occurs during translation, this field might be excluded from
393  // the response.
394  string translated_text = 1;
395
396  // Only present when `model` is present in the request.
397  // `model` here is normalized to have project number.
398  //
399  // For example:
400  // If the `model` requested in TranslationTextRequest is
401  // `projects/{project-id}/locations/{location-id}/models/general/nmt` then
402  // `model` here would be normalized to
403  // `projects/{project-number}/locations/{location-id}/models/general/nmt`.
404  string model = 2;
405
406  // The ISO-639 language code of source text in the initial request, detected
407  // automatically, if no source language was passed within the initial
408  // request. If the source language was passed, auto-detection of the language
409  // does not occur and this field is empty.
410  string detected_language_code = 4;
411
412  // The `glossary_config` used for this translation.
413  TranslateTextGlossaryConfig glossary_config = 3;
414}
415
416// The request message for language detection.
417message DetectLanguageRequest {
418  // Required. Project or location to make a call. Must refer to a caller's
419  // project.
420  //
421  // Format: `projects/{project-number-or-id}/locations/{location-id}` or
422  // `projects/{project-number-or-id}`.
423  //
424  // For global calls, use `projects/{project-number-or-id}/locations/global` or
425  // `projects/{project-number-or-id}`.
426  //
427  // Only models within the same region (has same location-id) can be used.
428  // Otherwise an INVALID_ARGUMENT (400) error is returned.
429  string parent = 5 [
430    (google.api.field_behavior) = REQUIRED,
431    (google.api.resource_reference) = {
432      type: "locations.googleapis.com/Location"
433    }
434  ];
435
436  // Optional. The language detection model to be used.
437  //
438  // Format:
439  // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}`
440  //
441  // Only one language detection model is currently supported:
442  // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
443  //
444  // If not specified, the default model is used.
445  string model = 4 [(google.api.field_behavior) = OPTIONAL];
446
447  // Required. The source of the document from which to detect the language.
448  oneof source {
449    // The content of the input stored as a string.
450    string content = 1;
451  }
452
453  // Optional. The format of the source text, for example, "text/html",
454  // "text/plain". If left blank, the MIME type defaults to "text/html".
455  string mime_type = 3 [(google.api.field_behavior) = OPTIONAL];
456
457  // Optional. The labels with user-defined metadata for the request.
458  //
459  // Label keys and values can be no longer than 63 characters
460  // (Unicode codepoints), can only contain lowercase letters, numeric
461  // characters, underscores and dashes. International characters are allowed.
462  // Label values are optional. Label keys must start with a letter.
463  //
464  // See https://cloud.google.com/translate/docs/advanced/labels for more
465  // information.
466  map<string, string> labels = 6 [(google.api.field_behavior) = OPTIONAL];
467}
468
469// The response message for language detection.
470message DetectedLanguage {
471  // The ISO-639 language code of the source content in the request, detected
472  // automatically.
473  string language_code = 1;
474
475  // The confidence of the detection result for this language.
476  float confidence = 2;
477}
478
479// The response message for language detection.
480message DetectLanguageResponse {
481  // The most probable language detected by the Translation API. For each
482  // request, the Translation API will always return only one result.
483  repeated DetectedLanguage languages = 1;
484}
485
486// The request message for discovering supported languages.
487message GetSupportedLanguagesRequest {
488  // Required. Project or location to make a call. Must refer to a caller's
489  // project.
490  //
491  // Format: `projects/{project-number-or-id}` or
492  // `projects/{project-number-or-id}/locations/{location-id}`.
493  //
494  // For global calls, use `projects/{project-number-or-id}/locations/global` or
495  // `projects/{project-number-or-id}`.
496  //
497  // Non-global location is required for AutoML models.
498  //
499  // Only models within the same region (have same location-id) can be used,
500  // otherwise an INVALID_ARGUMENT (400) error is returned.
501  string parent = 3 [
502    (google.api.field_behavior) = REQUIRED,
503    (google.api.resource_reference) = {
504      type: "locations.googleapis.com/Location"
505    }
506  ];
507
508  // Optional. The language to use to return localized, human readable names
509  // of supported languages. If missing, then display names are not returned
510  // in a response.
511  string display_language_code = 1 [(google.api.field_behavior) = OPTIONAL];
512
513  // Optional. Get supported languages of this model.
514  //
515  // The format depends on model type:
516  //
517  // - AutoML Translation models:
518  //   `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
519  //
520  // - General (built-in) models:
521  //   `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
522  //
523  //
524  // Returns languages supported by the specified model.
525  // If missing, we get supported languages of Google general NMT model.
526  string model = 2 [(google.api.field_behavior) = OPTIONAL];
527}
528
529// The response message for discovering supported languages.
530message SupportedLanguages {
531  // A list of supported language responses. This list contains an entry
532  // for each language the Translation API supports.
533  repeated SupportedLanguage languages = 1;
534}
535
536// A single supported language response corresponds to information related
537// to one supported language.
538message SupportedLanguage {
539  // Supported language code, generally consisting of its ISO 639-1
540  // identifier, for example, 'en', 'ja'. In certain cases, ISO-639 codes
541  // including language and region identifiers are returned (for example,
542  // 'zh-TW' and 'zh-CN').
543  string language_code = 1;
544
545  // Human-readable name of the language localized in the display language
546  // specified in the request.
547  string display_name = 2;
548
549  // Can be used as a source language.
550  bool support_source = 3;
551
552  // Can be used as a target language.
553  bool support_target = 4;
554}
555
556// The Google Cloud Storage location for the input content.
557message GcsSource {
558  // Required. Source data URI. For example, `gs://my_bucket/my_object`.
559  string input_uri = 1 [(google.api.field_behavior) = REQUIRED];
560}
561
562// Input configuration for BatchTranslateText request.
563message InputConfig {
564  // Optional. Can be "text/plain" or "text/html".
565  // For `.tsv`, "text/html" is used if mime_type is missing.
566  // For `.html`, this field must be "text/html" or empty.
567  // For `.txt`, this field must be "text/plain" or empty.
568  string mime_type = 1 [(google.api.field_behavior) = OPTIONAL];
569
570  // Required. Specify the input.
571  oneof source {
572    // Required. Google Cloud Storage location for the source input.
573    // This can be a single file (for example,
574    // `gs://translation-test/input.tsv`) or a wildcard (for example,
575    // `gs://translation-test/*`). If a file extension is `.tsv`, it can
576    // contain either one or two columns. The first column (optional) is the id
577    // of the text request. If the first column is missing, we use the row
578    // number (0-based) from the input file as the ID in the output file. The
579    // second column is the actual text to be
580    //  translated. We recommend each row be <= 10K Unicode codepoints,
581    // otherwise an error might be returned.
582    // Note that the input tsv must be RFC 4180 compliant.
583    //
584    // You could use https://github.com/Clever/csvlint to check potential
585    // formatting errors in your tsv file.
586    // csvlint --delimiter='\t' your_input_file.tsv
587    //
588    // The other supported file extensions are `.txt` or `.html`, which is
589    // treated as a single large chunk of text.
590    GcsSource gcs_source = 2;
591  }
592}
593
594// The Google Cloud Storage location for the output content.
595message GcsDestination {
596  // Required. The bucket used in 'output_uri_prefix' must exist and there must
597  // be no files under 'output_uri_prefix'. 'output_uri_prefix' must end with
598  // "/" and start with "gs://". One 'output_uri_prefix' can only be used by one
599  // batch translation job at a time. Otherwise an INVALID_ARGUMENT (400) error
600  // is returned.
601  string output_uri_prefix = 1 [(google.api.field_behavior) = REQUIRED];
602}
603
604// Output configuration for BatchTranslateText request.
605message OutputConfig {
606  // Required. The destination of output.
607  oneof destination {
608    // Google Cloud Storage destination for output content.
609    // For every single input file (for example, gs://a/b/c.[extension]), we
610    // generate at most 2 * n output files. (n is the # of target_language_codes
611    // in the BatchTranslateTextRequest).
612    //
613    // Output files (tsv) generated are compliant with RFC 4180 except that
614    // record delimiters are '\n' instead of '\r\n'. We don't provide any way to
615    // change record delimiters.
616    //
617    // While the input files are being processed, we write/update an index file
618    // 'index.csv'  under 'output_uri_prefix' (for example,
619    // gs://translation-test/index.csv) The index file is generated/updated as
620    // new files are being translated. The format is:
621    //
622    // input_file,target_language_code,translations_file,errors_file,
623    // glossary_translations_file,glossary_errors_file
624    //
625    // input_file is one file we matched using gcs_source.input_uri.
626    // target_language_code is provided in the request.
627    // translations_file contains the translations. (details provided below)
628    // errors_file contains the errors during processing of the file. (details
629    // below). Both translations_file and errors_file could be empty
630    // strings if we have no content to output.
631    // glossary_translations_file and glossary_errors_file are always empty
632    // strings if the input_file is tsv. They could also be empty if we have no
633    // content to output.
634    //
635    // Once a row is present in index.csv, the input/output matching never
636    // changes. Callers should also expect all the content in input_file are
637    // processed and ready to be consumed (that is, no partial output file is
638    // written).
639    //
640    // Since index.csv will be keeping updated during the process, please make
641    // sure there is no custom retention policy applied on the output bucket
642    // that may avoid file updating.
643    // (https://cloud.google.com/storage/docs/bucket-lock#retention-policy)
644    //
645    // The format of translations_file (for target language code 'trg') is:
646    // `gs://translation_test/a_b_c_'trg'_translations.[extension]`
647    //
648    // If the input file extension is tsv, the output has the following
649    // columns:
650    // Column 1: ID of the request provided in the input, if it's not
651    // provided in the input, then the input row number is used (0-based).
652    // Column 2: source sentence.
653    // Column 3: translation without applying a glossary. Empty string if there
654    // is an error.
655    // Column 4 (only present if a glossary is provided in the request):
656    // translation after applying the glossary. Empty string if there is an
657    // error applying the glossary. Could be same string as column 3 if there is
658    // no glossary applied.
659    //
660    // If input file extension is a txt or html, the translation is directly
661    // written to the output file. If glossary is requested, a separate
662    // glossary_translations_file has format of
663    // `gs://translation_test/a_b_c_'trg'_glossary_translations.[extension]`
664    //
665    // The format of errors file (for target language code 'trg') is:
666    // `gs://translation_test/a_b_c_'trg'_errors.[extension]`
667    //
668    // If the input file extension is tsv, errors_file contains the following:
669    // Column 1: ID of the request provided in the input, if it's not
670    // provided in the input, then the input row number is used (0-based).
671    // Column 2: source sentence.
672    // Column 3: Error detail for the translation. Could be empty.
673    // Column 4 (only present if a glossary is provided in the request):
674    // Error when applying the glossary.
675    //
676    // If the input file extension is txt or html, glossary_error_file will be
677    // generated that contains error details. glossary_error_file has format of
678    // `gs://translation_test/a_b_c_'trg'_glossary_errors.[extension]`
679    GcsDestination gcs_destination = 1;
680  }
681}
682
683// A document translation request input config.
684message DocumentInputConfig {
685  // Specifies the source for the document's content.
686  // The input file size should be <= 20MB for
687  // - application/vnd.openxmlformats-officedocument.wordprocessingml.document
688  // - application/vnd.openxmlformats-officedocument.presentationml.presentation
689  // - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
690  // The input file size should be <= 20MB and the maximum page limit is 20 for
691  // - application/pdf
692  oneof source {
693    // Document's content represented as a stream of bytes.
694    bytes content = 1;
695
696    // Google Cloud Storage location. This must be a single file.
697    // For example: gs://example_bucket/example_file.pdf
698    GcsSource gcs_source = 2;
699  }
700
701  // Specifies the input document's mime_type.
702  //
703  // If not specified it will be determined using the file extension for
704  // gcs_source provided files. For a file provided through bytes content the
705  // mime_type must be provided.
706  // Currently supported mime types are:
707  // - application/pdf
708  // - application/vnd.openxmlformats-officedocument.wordprocessingml.document
709  // - application/vnd.openxmlformats-officedocument.presentationml.presentation
710  // - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
711  string mime_type = 4;
712}
713
714// A document translation request output config.
715message DocumentOutputConfig {
716  // A URI destination for the translated document.
717  // It is optional to provide a destination. If provided the results from
718  // TranslateDocument will be stored in the destination.
719  // Whether a destination is provided or not, the translated documents will be
720  // returned within TranslateDocumentResponse.document_translation and
721  // TranslateDocumentResponse.glossary_document_translation.
722  oneof destination {
723    // Optional. Google Cloud Storage destination for the translation output,
724    // e.g., `gs://my_bucket/my_directory/`.
725    //
726    // The destination directory provided does not have to be empty, but the
727    // bucket must exist. If a file with the same name as the output file
728    // already exists in the destination an error will be returned.
729    //
730    // For a DocumentInputConfig.contents provided document, the output file
731    // will have the name "output_[trg]_translations.[ext]", where
732    // - [trg] corresponds to the translated file's language code,
733    // - [ext] corresponds to the translated file's extension according to its
734    // mime type.
735    //
736    //
737    // For a DocumentInputConfig.gcs_uri provided document, the output file will
738    // have a name according to its URI. For example: an input file with URI:
739    // `gs://a/b/c.[extension]` stored in a gcs_destination bucket with name
740    // "my_bucket" will have an output URI:
741    // `gs://my_bucket/a_b_c_[trg]_translations.[ext]`, where
742    // - [trg] corresponds to the translated file's language code,
743    // - [ext] corresponds to the translated file's extension according to its
744    // mime type.
745    //
746    //
747    // If the document was directly provided through the request, then the
748    // output document will have the format:
749    // `gs://my_bucket/translated_document_[trg]_translations.[ext]`, where
750    // - [trg] corresponds to the translated file's language code,
751    // - [ext] corresponds to the translated file's extension according to its
752    // mime type.
753    //
754    // If a glossary was provided, then the output URI for the glossary
755    // translation will be equal to the default output URI but have
756    // `glossary_translations` instead of `translations`. For the previous
757    // example, its glossary URI would be:
758    // `gs://my_bucket/a_b_c_[trg]_glossary_translations.[ext]`.
759    //
760    // Thus the max number of output files will be 2 (Translated document,
761    // Glossary translated document).
762    //
763    // Callers should expect no partial outputs. If there is any error during
764    // document translation, no output will be stored in the Cloud Storage
765    // bucket.
766    GcsDestination gcs_destination = 1 [(google.api.field_behavior) = OPTIONAL];
767  }
768
769  // Optional. Specifies the translated document's mime_type.
770  // If not specified, the translated file's mime type will be the same as the
771  // input file's mime type.
772  // Currently only support the output mime type to be the same as input mime
773  // type.
774  // - application/pdf
775  // - application/vnd.openxmlformats-officedocument.wordprocessingml.document
776  // - application/vnd.openxmlformats-officedocument.presentationml.presentation
777  // - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
778  string mime_type = 3 [(google.api.field_behavior) = OPTIONAL];
779}
780
781// A document translation request.
782message TranslateDocumentRequest {
783  // Required. Location to make a regional call.
784  //
785  // Format: `projects/{project-number-or-id}/locations/{location-id}`.
786  //
787  // For global calls, use `projects/{project-number-or-id}/locations/global` or
788  // `projects/{project-number-or-id}`.
789  //
790  // Non-global location is required for requests using AutoML models or custom
791  // glossaries.
792  //
793  // Models and glossaries must be within the same region (have the same
794  // location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
795  string parent = 1 [(google.api.field_behavior) = REQUIRED];
796
797  // Optional. The ISO-639 language code of the input document if known, for
798  // example, "en-US" or "sr-Latn". Supported language codes are listed in
799  // Language Support. If the source language isn't specified, the API attempts
800  // to identify the source language automatically and returns the source
801  // language within the response. Source language must be specified if the
802  // request contains a glossary or a custom model.
803  string source_language_code = 2 [(google.api.field_behavior) = OPTIONAL];
804
805  // Required. The ISO-639 language code to use for translation of the input
806  // document, set to one of the language codes listed in Language Support.
807  string target_language_code = 3 [(google.api.field_behavior) = REQUIRED];
808
809  // Required. Input configurations.
810  DocumentInputConfig document_input_config = 4
811      [(google.api.field_behavior) = REQUIRED];
812
813  // Optional. Output configurations.
814  // Defines if the output file should be stored within Cloud Storage as well
815  // as the desired output format. If not provided the translated file will
816  // only be returned through a byte-stream and its output mime type will be
817  // the same as the input file's mime type.
818  DocumentOutputConfig document_output_config = 5
819      [(google.api.field_behavior) = OPTIONAL];
820
821  // Optional. The `model` type requested for this translation.
822  //
823  // The format depends on model type:
824  //
825  // - AutoML Translation models:
826  //   `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
827  //
828  // - General (built-in) models:
829  //   `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
830  //
831  //
832  // If not provided, the default Google model (NMT) will be used for
833  // translation.
834  string model = 6 [(google.api.field_behavior) = OPTIONAL];
835
836  // Optional. Glossary to be applied. The glossary must be within the same
837  // region (have the same location-id) as the model, otherwise an
838  // INVALID_ARGUMENT (400) error is returned.
839  TranslateTextGlossaryConfig glossary_config = 7
840      [(google.api.field_behavior) = OPTIONAL];
841
842  // Optional. The labels with user-defined metadata for the request.
843  //
844  // Label keys and values can be no longer than 63 characters (Unicode
845  // codepoints), can only contain lowercase letters, numeric characters,
846  // underscores and dashes. International characters are allowed. Label values
847  // are optional. Label keys must start with a letter.
848  //
849  // See https://cloud.google.com/translate/docs/advanced/labels for more
850  // information.
851  map<string, string> labels = 8 [(google.api.field_behavior) = OPTIONAL];
852
853  // Optional. This flag is to support user customized attribution.
854  // If not provided, the default is `Machine Translated by Google`.
855  // Customized attribution should follow rules in
856  // https://cloud.google.com/translate/attribution#attribution_and_logos
857  string customized_attribution = 10 [(google.api.field_behavior) = OPTIONAL];
858
859  // Optional. is_translate_native_pdf_only field for external customers.
860  // If true, the page limit of online native pdf translation is 300 and only
861  // native pdf pages will be translated.
862  bool is_translate_native_pdf_only = 11
863      [(google.api.field_behavior) = OPTIONAL];
864
865  // Optional. If true, use the text removal server to remove the shadow text on
866  // background image for native pdf translation.
867  // Shadow removal feature can only be enabled when
868  // is_translate_native_pdf_only: false && pdf_native_only: false
869  bool enable_shadow_removal_native_pdf = 12
870      [(google.api.field_behavior) = OPTIONAL];
871
872  // Optional. If true, enable auto rotation correction in DVS.
873  bool enable_rotation_correction = 13 [(google.api.field_behavior) = OPTIONAL];
874}
875
876// A translated document message.
877message DocumentTranslation {
878  // The array of translated documents. It is expected to be size 1 for now. We
879  // may produce multiple translated documents in the future for other type of
880  // file formats.
881  repeated bytes byte_stream_outputs = 1;
882
883  // The translated document's mime type.
884  string mime_type = 2;
885
886  // The detected language for the input document.
887  // If the user did not provide the source language for the input document,
888  // this field will have the language code automatically detected. If the
889  // source language was passed, auto-detection of the language does not occur
890  // and this field is empty.
891  string detected_language_code = 3;
892}
893
894// A translated document response message.
895message TranslateDocumentResponse {
896  // Translated document.
897  DocumentTranslation document_translation = 1;
898
899  // The document's translation output if a glossary is provided in the request.
900  // This can be the same as [TranslateDocumentResponse.document_translation]
901  // if no glossary terms apply.
902  DocumentTranslation glossary_document_translation = 2;
903
904  // Only present when 'model' is present in the request.
905  // 'model' is normalized to have a project number.
906  //
907  // For example:
908  // If the 'model' field in TranslateDocumentRequest is:
909  // `projects/{project-id}/locations/{location-id}/models/general/nmt` then
910  // `model` here would be normalized to
911  // `projects/{project-number}/locations/{location-id}/models/general/nmt`.
912  string model = 3;
913
914  // The `glossary_config` used for this translation.
915  TranslateTextGlossaryConfig glossary_config = 4;
916}
917
918// The batch translation request.
919message BatchTranslateTextRequest {
920  // Required. Location to make a call. Must refer to a caller's project.
921  //
922  // Format: `projects/{project-number-or-id}/locations/{location-id}`.
923  //
924  // The `global` location is not supported for batch translation.
925  //
926  // Only AutoML Translation models or glossaries within the same region (have
927  // the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
928  // error is returned.
929  string parent = 1 [
930    (google.api.field_behavior) = REQUIRED,
931    (google.api.resource_reference) = {
932      type: "locations.googleapis.com/Location"
933    }
934  ];
935
936  // Required. Source language code.
937  string source_language_code = 2 [(google.api.field_behavior) = REQUIRED];
938
939  // Required. Specify up to 10 language codes here.
940  repeated string target_language_codes = 3
941      [(google.api.field_behavior) = REQUIRED];
942
943  // Optional. The models to use for translation. Map's key is target language
944  // code. Map's value is model name. Value can be a built-in general model,
945  // or an AutoML Translation model.
946  //
947  // The value format depends on model type:
948  //
949  // - AutoML Translation models:
950  //   `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
951  //
952  // - General (built-in) models:
953  //   `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
954  //
955  //
956  // If the map is empty or a specific model is
957  // not requested for a language pair, then default google model (nmt) is used.
958  map<string, string> models = 4 [(google.api.field_behavior) = OPTIONAL];
959
960  // Required. Input configurations.
961  // The total number of files matched should be <= 100.
962  // The total content size should be <= 100M Unicode codepoints.
963  // The files must use UTF-8 encoding.
964  repeated InputConfig input_configs = 5
965      [(google.api.field_behavior) = REQUIRED];
966
967  // Required. Output configuration.
968  // If 2 input configs match to the same file (that is, same input path),
969  // we don't generate output for duplicate inputs.
970  OutputConfig output_config = 6 [(google.api.field_behavior) = REQUIRED];
971
972  // Optional. Glossaries to be applied for translation.
973  // It's keyed by target language code.
974  map<string, TranslateTextGlossaryConfig> glossaries = 7
975      [(google.api.field_behavior) = OPTIONAL];
976
977  // Optional. The labels with user-defined metadata for the request.
978  //
979  // Label keys and values can be no longer than 63 characters
980  // (Unicode codepoints), can only contain lowercase letters, numeric
981  // characters, underscores and dashes. International characters are allowed.
982  // Label values are optional. Label keys must start with a letter.
983  //
984  // See https://cloud.google.com/translate/docs/advanced/labels for more
985  // information.
986  map<string, string> labels = 9 [(google.api.field_behavior) = OPTIONAL];
987}
988
989// State metadata for the batch translation operation.
990message BatchTranslateMetadata {
991  // State of the job.
992  enum State {
993    // Invalid.
994    STATE_UNSPECIFIED = 0;
995
996    // Request is being processed.
997    RUNNING = 1;
998
999    // The batch is processed, and at least one item was successfully
1000    // processed.
1001    SUCCEEDED = 2;
1002
1003    // The batch is done and no item was successfully processed.
1004    FAILED = 3;
1005
1006    // Request is in the process of being canceled after caller invoked
1007    // longrunning.Operations.CancelOperation on the request id.
1008    CANCELLING = 4;
1009
1010    // The batch is done after the user has called the
1011    // longrunning.Operations.CancelOperation. Any records processed before the
1012    // cancel command are output as specified in the request.
1013    CANCELLED = 5;
1014  }
1015
1016  // The state of the operation.
1017  State state = 1;
1018
1019  // Number of successfully translated characters so far (Unicode codepoints).
1020  int64 translated_characters = 2;
1021
1022  // Number of characters that have failed to process so far (Unicode
1023  // codepoints).
1024  int64 failed_characters = 3;
1025
1026  // Total number of characters (Unicode codepoints).
1027  // This is the total number of codepoints from input files times the number of
1028  // target languages and appears here shortly after the call is submitted.
1029  int64 total_characters = 4;
1030
1031  // Time when the operation was submitted.
1032  google.protobuf.Timestamp submit_time = 5;
1033}
1034
1035// Stored in the
1036// [google.longrunning.Operation.response][google.longrunning.Operation.response]
1037// field returned by BatchTranslateText if at least one sentence is translated
1038// successfully.
1039message BatchTranslateResponse {
1040  // Total number of characters (Unicode codepoints).
1041  int64 total_characters = 1;
1042
1043  // Number of successfully translated characters (Unicode codepoints).
1044  int64 translated_characters = 2;
1045
1046  // Number of characters that have failed to process (Unicode codepoints).
1047  int64 failed_characters = 3;
1048
1049  // Time when the operation was submitted.
1050  google.protobuf.Timestamp submit_time = 4;
1051
1052  // The time when the operation is finished and
1053  // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
1054  // set to true.
1055  google.protobuf.Timestamp end_time = 5;
1056}
1057
1058// Input configuration for glossaries.
1059message GlossaryInputConfig {
1060  // Required. Specify the input.
1061  oneof source {
1062    // Required. Google Cloud Storage location of glossary data.
1063    // File format is determined based on the filename extension. API returns
1064    // [google.rpc.Code.INVALID_ARGUMENT] for unsupported URI-s and file
1065    // formats. Wildcards are not allowed. This must be a single file in one of
1066    // the following formats:
1067    //
1068    // For unidirectional glossaries:
1069    //
1070    // - TSV/CSV (`.tsv`/`.csv`): Two column file, tab- or comma-separated.
1071    //   The first column is source text. The second column is target text.
1072    //   No headers in this file. The first row contains data and not column
1073    //   names.
1074    //
1075    // - TMX (`.tmx`): TMX file with parallel data defining source/target term
1076    // pairs.
1077    //
1078    // For equivalent term sets glossaries:
1079    //
1080    // - CSV (`.csv`): Multi-column CSV file defining equivalent glossary terms
1081    //   in multiple languages. See documentation for more information -
1082    //   [glossaries](https://cloud.google.com/translate/docs/advanced/glossary).
1083    GcsSource gcs_source = 1;
1084  }
1085}
1086
1087// Represents a glossary built from user-provided data.
1088message Glossary {
1089  option (google.api.resource) = {
1090    type: "translate.googleapis.com/Glossary"
1091    pattern: "projects/{project}/locations/{location}/glossaries/{glossary}"
1092  };
1093
1094  // Used with unidirectional glossaries.
1095  message LanguageCodePair {
1096    // Required. The ISO-639 language code of the input text, for example,
1097    // "en-US". Expected to be an exact match for GlossaryTerm.language_code.
1098    string source_language_code = 1;
1099
1100    // Required. The ISO-639 language code for translation output, for example,
1101    // "zh-CN". Expected to be an exact match for GlossaryTerm.language_code.
1102    string target_language_code = 2;
1103  }
1104
1105  // Used with equivalent term set glossaries.
1106  message LanguageCodesSet {
1107    // The ISO-639 language code(s) for terms defined in the glossary.
1108    // All entries are unique. The list contains at least two entries.
1109    // Expected to be an exact match for GlossaryTerm.language_code.
1110    repeated string language_codes = 1;
1111  }
1112
1113  // Required. The resource name of the glossary. Glossary names have the form
1114  // `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`.
1115  string name = 1 [(google.api.field_behavior) = REQUIRED];
1116
1117  // Languages supported by the glossary.
1118  oneof languages {
1119    // Used with unidirectional glossaries.
1120    LanguageCodePair language_pair = 3;
1121
1122    // Used with equivalent term set glossaries.
1123    LanguageCodesSet language_codes_set = 4;
1124  }
1125
1126  // Required. Provides examples to build the glossary from.
1127  // Total glossary must not exceed 10M Unicode codepoints.
1128  GlossaryInputConfig input_config = 5;
1129
1130  // Output only. The number of entries defined in the glossary.
1131  int32 entry_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
1132
1133  // Output only. When CreateGlossary was called.
1134  google.protobuf.Timestamp submit_time = 7
1135      [(google.api.field_behavior) = OUTPUT_ONLY];
1136
1137  // Output only. When the glossary creation was finished.
1138  google.protobuf.Timestamp end_time = 8
1139      [(google.api.field_behavior) = OUTPUT_ONLY];
1140
1141  // Optional. The display name of the glossary.
1142  string display_name = 9 [(google.api.field_behavior) = OPTIONAL];
1143}
1144
1145// Request message for CreateGlossary.
1146message CreateGlossaryRequest {
1147  // Required. The project name.
1148  string parent = 1 [
1149    (google.api.field_behavior) = REQUIRED,
1150    (google.api.resource_reference) = {
1151      type: "locations.googleapis.com/Location"
1152    }
1153  ];
1154
1155  // Required. The glossary to create.
1156  Glossary glossary = 2 [(google.api.field_behavior) = REQUIRED];
1157}
1158
1159// Request message for GetGlossary.
1160message GetGlossaryRequest {
1161  // Required. The name of the glossary to retrieve.
1162  string name = 1 [
1163    (google.api.field_behavior) = REQUIRED,
1164    (google.api.resource_reference) = {
1165      type: "translate.googleapis.com/Glossary"
1166    }
1167  ];
1168}
1169
1170// Request message for DeleteGlossary.
1171message DeleteGlossaryRequest {
1172  // Required. The name of the glossary to delete.
1173  string name = 1 [
1174    (google.api.field_behavior) = REQUIRED,
1175    (google.api.resource_reference) = {
1176      type: "translate.googleapis.com/Glossary"
1177    }
1178  ];
1179}
1180
1181// Request message for ListGlossaries.
1182message ListGlossariesRequest {
1183  // Required. The name of the project from which to list all of the glossaries.
1184  string parent = 1 [
1185    (google.api.field_behavior) = REQUIRED,
1186    (google.api.resource_reference) = {
1187      type: "locations.googleapis.com/Location"
1188    }
1189  ];
1190
1191  // Optional. Requested page size. The server may return fewer glossaries than
1192  // requested. If unspecified, the server picks an appropriate default.
1193  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
1194
1195  // Optional. A token identifying a page of results the server should return.
1196  // Typically, this is the value of [ListGlossariesResponse.next_page_token]
1197  // returned from the previous call to `ListGlossaries` method.
1198  // The first page is returned if `page_token`is empty or missing.
1199  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
1200
1201  // Optional. Filter specifying constraints of a list operation.
1202  // Specify the constraint by the format of "key=value", where key must be
1203  // "src" or "tgt", and the value must be a valid language code.
1204  // For multiple restrictions, concatenate them by "AND" (uppercase only),
1205  // such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used
1206  // here, which means using 'en-US' and 'en' can lead to different results,
1207  // which depends on the language code you used when you create the glossary.
1208  // For the unidirectional glossaries, the "src" and "tgt" add restrictions
1209  // on the source and target language code separately.
1210  // For the equivalent term set glossaries, the "src" and/or "tgt" add
1211  // restrictions on the term set.
1212  // For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional
1213  // glossaries which exactly match the source language code as "en-US" and the
1214  // target language code "zh-CN", but all equivalent term set glossaries which
1215  // contain "en-US" and "zh-CN" in their language set will be picked.
1216  // If missing, no filtering is performed.
1217  string filter = 4 [(google.api.field_behavior) = OPTIONAL];
1218}
1219
1220// Response message for ListGlossaries.
1221message ListGlossariesResponse {
1222  // The list of glossaries for a project.
1223  repeated Glossary glossaries = 1;
1224
1225  // A token to retrieve a page of results. Pass this value in the
1226  // [ListGlossariesRequest.page_token] field in the subsequent call to
1227  // `ListGlossaries` method to retrieve the next page of results.
1228  string next_page_token = 2;
1229}
1230
1231// Stored in the
1232// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
1233// field returned by CreateGlossary.
1234message CreateGlossaryMetadata {
1235  // Enumerates the possible states that the creation request can be in.
1236  enum State {
1237    // Invalid.
1238    STATE_UNSPECIFIED = 0;
1239
1240    // Request is being processed.
1241    RUNNING = 1;
1242
1243    // The glossary was successfully created.
1244    SUCCEEDED = 2;
1245
1246    // Failed to create the glossary.
1247    FAILED = 3;
1248
1249    // Request is in the process of being canceled after caller invoked
1250    // longrunning.Operations.CancelOperation on the request id.
1251    CANCELLING = 4;
1252
1253    // The glossary creation request was successfully canceled.
1254    CANCELLED = 5;
1255  }
1256
1257  // The name of the glossary that is being created.
1258  string name = 1;
1259
1260  // The current state of the glossary creation operation.
1261  State state = 2;
1262
1263  // The time when the operation was submitted to the server.
1264  google.protobuf.Timestamp submit_time = 3;
1265}
1266
1267// Stored in the
1268// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
1269// field returned by DeleteGlossary.
1270message DeleteGlossaryMetadata {
1271  // Enumerates the possible states that the creation request can be in.
1272  enum State {
1273    // Invalid.
1274    STATE_UNSPECIFIED = 0;
1275
1276    // Request is being processed.
1277    RUNNING = 1;
1278
1279    // The glossary was successfully deleted.
1280    SUCCEEDED = 2;
1281
1282    // Failed to delete the glossary.
1283    FAILED = 3;
1284
1285    // Request is in the process of being canceled after caller invoked
1286    // longrunning.Operations.CancelOperation on the request id.
1287    CANCELLING = 4;
1288
1289    // The glossary deletion request was successfully canceled.
1290    CANCELLED = 5;
1291  }
1292
1293  // The name of the glossary that is being deleted.
1294  string name = 1;
1295
1296  // The current state of the glossary deletion operation.
1297  State state = 2;
1298
1299  // The time when the operation was submitted to the server.
1300  google.protobuf.Timestamp submit_time = 3;
1301}
1302
1303// Stored in the
1304// [google.longrunning.Operation.response][google.longrunning.Operation.response]
1305// field returned by DeleteGlossary.
1306message DeleteGlossaryResponse {
1307  // The name of the deleted glossary.
1308  string name = 1;
1309
1310  // The time when the operation was submitted to the server.
1311  google.protobuf.Timestamp submit_time = 2;
1312
1313  // The time when the glossary deletion is finished and
1314  // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
1315  // set to true.
1316  google.protobuf.Timestamp end_time = 3;
1317}
1318
1319// The BatchTranslateDocument request.
1320message BatchTranslateDocumentRequest {
1321  // Required. Location to make a regional call.
1322  //
1323  // Format: `projects/{project-number-or-id}/locations/{location-id}`.
1324  //
1325  // The `global` location is not supported for batch translation.
1326  //
1327  // Only AutoML Translation models or glossaries within the same region (have
1328  // the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
1329  // error is returned.
1330  string parent = 1 [
1331    (google.api.field_behavior) = REQUIRED,
1332    (google.api.resource_reference) = {
1333      type: "locations.googleapis.com/Location"
1334    }
1335  ];
1336
1337  // Required. The ISO-639 language code of the input document if known, for
1338  // example, "en-US" or "sr-Latn". Supported language codes are listed in
1339  // [Language Support](https://cloud.google.com/translate/docs/languages).
1340  string source_language_code = 2 [(google.api.field_behavior) = REQUIRED];
1341
1342  // Required. The ISO-639 language code to use for translation of the input
1343  // document. Specify up to 10 language codes here.
1344  repeated string target_language_codes = 3
1345      [(google.api.field_behavior) = REQUIRED];
1346
1347  // Required. Input configurations.
1348  // The total number of files matched should be <= 100.
1349  // The total content size to translate should be <= 100M Unicode codepoints.
1350  // The files must use UTF-8 encoding.
1351  repeated BatchDocumentInputConfig input_configs = 4
1352      [(google.api.field_behavior) = REQUIRED];
1353
1354  // Required. Output configuration.
1355  // If 2 input configs match to the same file (that is, same input path),
1356  // we don't generate output for duplicate inputs.
1357  BatchDocumentOutputConfig output_config = 5
1358      [(google.api.field_behavior) = REQUIRED];
1359
1360  // Optional. The models to use for translation. Map's key is target language
1361  // code. Map's value is the model name. Value can be a built-in general model,
1362  // or an AutoML Translation model.
1363  //
1364  // The value format depends on model type:
1365  //
1366  // - AutoML Translation models:
1367  //   `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
1368  //
1369  // - General (built-in) models:
1370  //   `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
1371  //
1372  //
1373  // If the map is empty or a specific model is
1374  // not requested for a language pair, then default google model (nmt) is used.
1375  map<string, string> models = 6 [(google.api.field_behavior) = OPTIONAL];
1376
1377  // Optional. Glossaries to be applied. It's keyed by target language code.
1378  map<string, TranslateTextGlossaryConfig> glossaries = 7
1379      [(google.api.field_behavior) = OPTIONAL];
1380
1381  // Optional. The file format conversion map that is applied to all input
1382  // files. The map key is the original mime_type. The map value is the target
1383  // mime_type of translated documents.
1384  //
1385  // Supported file format conversion includes:
1386  // - `application/pdf` to
1387  //   `application/vnd.openxmlformats-officedocument.wordprocessingml.document`
1388  //
1389  // If nothing specified, output files will be in the same format as the
1390  // original file.
1391  map<string, string> format_conversions = 8
1392      [(google.api.field_behavior) = OPTIONAL];
1393
1394  // Optional. This flag is to support user customized attribution.
1395  // If not provided, the default is `Machine Translated by Google`.
1396  // Customized attribution should follow rules in
1397  // https://cloud.google.com/translate/attribution#attribution_and_logos
1398  string customized_attribution = 10 [(google.api.field_behavior) = OPTIONAL];
1399
1400  // Optional. If true, use the text removal server to remove the shadow text on
1401  // background image for native pdf translation.
1402  // Shadow removal feature can only be enabled when
1403  // is_translate_native_pdf_only: false && pdf_native_only: false
1404  bool enable_shadow_removal_native_pdf = 11
1405      [(google.api.field_behavior) = OPTIONAL];
1406
1407  // Optional. If true, enable auto rotation correction in DVS.
1408  bool enable_rotation_correction = 12 [(google.api.field_behavior) = OPTIONAL];
1409}
1410
1411// Input configuration for BatchTranslateDocument request.
1412message BatchDocumentInputConfig {
1413  // Specify the input.
1414  oneof source {
1415    // Google Cloud Storage location for the source input.
1416    // This can be a single file (for example,
1417    // `gs://translation-test/input.docx`) or a wildcard (for example,
1418    // `gs://translation-test/*`).
1419    //
1420    // File mime type is determined based on extension. Supported mime type
1421    // includes:
1422    // - `pdf`, application/pdf
1423    // - `docx`,
1424    // application/vnd.openxmlformats-officedocument.wordprocessingml.document
1425    // - `pptx`,
1426    // application/vnd.openxmlformats-officedocument.presentationml.presentation
1427    // - `xlsx`,
1428    // application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
1429    //
1430    // The max file size to support for `.docx`, `.pptx` and `.xlsx` is 100MB.
1431    // The max file size to support for `.pdf` is 1GB and the max page limit is
1432    // 1000 pages.
1433    // The max file size to support for all input documents is 1GB.
1434    GcsSource gcs_source = 1;
1435  }
1436}
1437
1438// Output configuration for BatchTranslateDocument request.
1439message BatchDocumentOutputConfig {
1440  // The destination of output. The destination directory provided must exist
1441  // and be empty.
1442  oneof destination {
1443    // Google Cloud Storage destination for output content.
1444    // For every single input document (for example, gs://a/b/c.[extension]), we
1445    // generate at most 2 * n output files. (n is the # of target_language_codes
1446    // in the BatchTranslateDocumentRequest).
1447    //
1448    // While the input documents are being processed, we write/update an index
1449    // file `index.csv` under `gcs_destination.output_uri_prefix` (for example,
1450    // gs://translation_output/index.csv) The index file is generated/updated as
1451    // new files are being translated. The format is:
1452    //
1453    // input_document,target_language_code,translation_output,error_output,
1454    // glossary_translation_output,glossary_error_output
1455    //
1456    // `input_document` is one file we matched using gcs_source.input_uri.
1457    // `target_language_code` is provided in the request.
1458    // `translation_output` contains the translations. (details provided below)
1459    // `error_output` contains the error message during processing of the file.
1460    // Both translations_file and errors_file could be empty strings if we have
1461    // no content to output.
1462    // `glossary_translation_output` and `glossary_error_output` are the
1463    // translated output/error when we apply glossaries. They could also be
1464    // empty if we have no content to output.
1465    //
1466    // Once a row is present in index.csv, the input/output matching never
1467    // changes. Callers should also expect all the content in input_file are
1468    // processed and ready to be consumed (that is, no partial output file is
1469    // written).
1470    //
1471    // Since index.csv will be keeping updated during the process, please make
1472    // sure there is no custom retention policy applied on the output bucket
1473    // that may avoid file updating.
1474    // (https://cloud.google.com/storage/docs/bucket-lock#retention-policy)
1475    //
1476    // The naming format of translation output files follows (for target
1477    // language code [trg]): `translation_output`:
1478    // `gs://translation_output/a_b_c_[trg]_translation.[extension]`
1479    // `glossary_translation_output`:
1480    // `gs://translation_test/a_b_c_[trg]_glossary_translation.[extension]`. The
1481    // output document will maintain the same file format as the input document.
1482    //
1483    // The naming format of error output files follows (for target language code
1484    // [trg]): `error_output`: `gs://translation_test/a_b_c_[trg]_errors.txt`
1485    // `glossary_error_output`:
1486    // `gs://translation_test/a_b_c_[trg]_glossary_translation.txt`. The error
1487    // output is a txt file containing error details.
1488    GcsDestination gcs_destination = 1;
1489  }
1490}
1491
1492// Stored in the
1493// [google.longrunning.Operation.response][google.longrunning.Operation.response]
1494// field returned by BatchTranslateDocument if at least one document is
1495// translated successfully.
1496message BatchTranslateDocumentResponse {
1497  // Total number of pages to translate in all documents. Documents without
1498  // clear page definition (such as XLSX) are not counted.
1499  int64 total_pages = 1;
1500
1501  // Number of successfully translated pages in all documents. Documents without
1502  // clear page definition (such as XLSX) are not counted.
1503  int64 translated_pages = 2;
1504
1505  // Number of pages that failed to process in all documents. Documents without
1506  // clear page definition (such as XLSX) are not counted.
1507  int64 failed_pages = 3;
1508
1509  // Number of billable pages in documents with clear page definition (such as
1510  // PDF, DOCX, PPTX)
1511  int64 total_billable_pages = 4;
1512
1513  // Total number of characters (Unicode codepoints) in all documents.
1514  int64 total_characters = 5;
1515
1516  // Number of successfully translated characters (Unicode codepoints) in all
1517  // documents.
1518  int64 translated_characters = 6;
1519
1520  // Number of characters that have failed to process (Unicode codepoints) in
1521  // all documents.
1522  int64 failed_characters = 7;
1523
1524  // Number of billable characters (Unicode codepoints) in documents without
1525  // clear page definition, such as XLSX.
1526  int64 total_billable_characters = 8;
1527
1528  // Time when the operation was submitted.
1529  google.protobuf.Timestamp submit_time = 9;
1530
1531  // The time when the operation is finished and
1532  // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
1533  // set to true.
1534  google.protobuf.Timestamp end_time = 10;
1535}
1536
1537// State metadata for the batch translation operation.
1538message BatchTranslateDocumentMetadata {
1539  // State of the job.
1540  enum State {
1541    // Invalid.
1542    STATE_UNSPECIFIED = 0;
1543
1544    // Request is being processed.
1545    RUNNING = 1;
1546
1547    // The batch is processed, and at least one item was successfully processed.
1548    SUCCEEDED = 2;
1549
1550    // The batch is done and no item was successfully processed.
1551    FAILED = 3;
1552
1553    // Request is in the process of being canceled after caller invoked
1554    // longrunning.Operations.CancelOperation on the request id.
1555    CANCELLING = 4;
1556
1557    // The batch is done after the user has called the
1558    // longrunning.Operations.CancelOperation. Any records processed before the
1559    // cancel command are output as specified in the request.
1560    CANCELLED = 5;
1561  }
1562
1563  // The state of the operation.
1564  State state = 1;
1565
1566  // Total number of pages to translate in all documents so far. Documents
1567  // without clear page definition (such as XLSX) are not counted.
1568  int64 total_pages = 2;
1569
1570  // Number of successfully translated pages in all documents so far. Documents
1571  // without clear page definition (such as XLSX) are not counted.
1572  int64 translated_pages = 3;
1573
1574  // Number of pages that failed to process in all documents so far. Documents
1575  // without clear page definition (such as XLSX) are not counted.
1576  int64 failed_pages = 4;
1577
1578  // Number of billable pages in documents with clear page definition (such as
1579  // PDF, DOCX, PPTX) so far.
1580  int64 total_billable_pages = 5;
1581
1582  // Total number of characters (Unicode codepoints) in all documents so far.
1583  int64 total_characters = 6;
1584
1585  // Number of successfully translated characters (Unicode codepoints) in all
1586  // documents so far.
1587  int64 translated_characters = 7;
1588
1589  // Number of characters that have failed to process (Unicode codepoints) in
1590  // all documents so far.
1591  int64 failed_characters = 8;
1592
1593  // Number of billable characters (Unicode codepoints) in documents without
1594  // clear page definition (such as XLSX) so far.
1595  int64 total_billable_characters = 9;
1596
1597  // Time when the operation was submitted.
1598  google.protobuf.Timestamp submit_time = 10;
1599}
1600