translation_service.proto 57 KB

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