translation_service.proto 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. // Copyright 2019 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. //
  15. syntax = "proto3";
  16. package google.cloud.translation.v3;
  17. import "google/api/annotations.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/api/resource.proto";
  21. import "google/longrunning/operations.proto";
  22. import "google/protobuf/timestamp.proto";
  23. option cc_enable_arenas = true;
  24. option csharp_namespace = "Google.Cloud.Translate.V3";
  25. option go_package = "google.golang.org/genproto/googleapis/cloud/translate/v3;translate";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "TranslationServiceProto";
  28. option java_package = "com.google.cloud.translate.v3";
  29. option php_namespace = "Google\\Cloud\\Translate\\V3";
  30. option ruby_package = "Google::Cloud::Translate::V3";
  31. // Proto file for the Cloud Translation API (v3 GA).
  32. // Provides natural language translation operations.
  33. service TranslationService {
  34. option (google.api.default_host) = "translate.googleapis.com";
  35. option (google.api.oauth_scopes) =
  36. "https://www.googleapis.com/auth/cloud-platform,"
  37. "https://www.googleapis.com/auth/cloud-translation";
  38. // Translates input text and returns translated text.
  39. rpc TranslateText(TranslateTextRequest) returns (TranslateTextResponse) {
  40. option (google.api.http) = {
  41. post: "/v3/{parent=projects/*/locations/*}:translateText"
  42. body: "*"
  43. additional_bindings {
  44. post: "/v3/{parent=projects/*}:translateText"
  45. body: "*"
  46. }
  47. };
  48. option (google.api.method_signature) =
  49. "parent,target_language_code,contents";
  50. option (google.api.method_signature) =
  51. "parent,model,mime_type,source_language_code,target_language_code,contents";
  52. }
  53. // Detects the language of text within a request.
  54. rpc DetectLanguage(DetectLanguageRequest) returns (DetectLanguageResponse) {
  55. option (google.api.http) = {
  56. post: "/v3/{parent=projects/*/locations/*}:detectLanguage"
  57. body: "*"
  58. additional_bindings {
  59. post: "/v3/{parent=projects/*}:detectLanguage"
  60. body: "*"
  61. }
  62. };
  63. option (google.api.method_signature) = "parent,model,mime_type,content";
  64. }
  65. // Returns a list of supported languages for translation.
  66. rpc GetSupportedLanguages(GetSupportedLanguagesRequest)
  67. returns (SupportedLanguages) {
  68. option (google.api.http) = {
  69. get: "/v3/{parent=projects/*/locations/*}/supportedLanguages"
  70. additional_bindings { get: "/v3/{parent=projects/*}/supportedLanguages" }
  71. };
  72. option (google.api.method_signature) = "parent,model,display_language_code";
  73. }
  74. // Translates a large volume of text in asynchronous batch mode.
  75. // This function provides real-time output as the inputs are being processed.
  76. // If caller cancels a request, the partial results (for an input file, it's
  77. // all or nothing) may still be available on the specified output location.
  78. //
  79. // This call returns immediately and you can
  80. // use google.longrunning.Operation.name to poll the status of the call.
  81. rpc BatchTranslateText(BatchTranslateTextRequest)
  82. returns (google.longrunning.Operation) {
  83. option (google.api.http) = {
  84. post: "/v3/{parent=projects/*/locations/*}:batchTranslateText"
  85. body: "*"
  86. };
  87. option (google.longrunning.operation_info) = {
  88. response_type: "BatchTranslateResponse"
  89. metadata_type: "BatchTranslateMetadata"
  90. };
  91. }
  92. // Creates a glossary and returns the long-running operation. Returns
  93. // NOT_FOUND, if the project doesn't exist.
  94. rpc CreateGlossary(CreateGlossaryRequest)
  95. returns (google.longrunning.Operation) {
  96. option (google.api.http) = {
  97. post: "/v3/{parent=projects/*/locations/*}/glossaries"
  98. body: "glossary"
  99. };
  100. option (google.api.method_signature) = "parent,glossary";
  101. option (google.longrunning.operation_info) = {
  102. response_type: "Glossary"
  103. metadata_type: "CreateGlossaryMetadata"
  104. };
  105. }
  106. // Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
  107. // exist.
  108. rpc ListGlossaries(ListGlossariesRequest) returns (ListGlossariesResponse) {
  109. option (google.api.http) = {
  110. get: "/v3/{parent=projects/*/locations/*}/glossaries"
  111. };
  112. option (google.api.method_signature) = "parent";
  113. }
  114. // Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
  115. // exist.
  116. rpc GetGlossary(GetGlossaryRequest) returns (Glossary) {
  117. option (google.api.http) = {
  118. get: "/v3/{name=projects/*/locations/*/glossaries/*}"
  119. };
  120. option (google.api.method_signature) = "name";
  121. }
  122. // Deletes a glossary, or cancels glossary construction
  123. // if the glossary isn't created yet.
  124. // Returns NOT_FOUND, if the glossary doesn't exist.
  125. rpc DeleteGlossary(DeleteGlossaryRequest)
  126. returns (google.longrunning.Operation) {
  127. option (google.api.http) = {
  128. delete: "/v3/{name=projects/*/locations/*/glossaries/*}"
  129. };
  130. option (google.api.method_signature) = "name";
  131. option (google.longrunning.operation_info) = {
  132. response_type: "DeleteGlossaryResponse"
  133. metadata_type: "DeleteGlossaryMetadata"
  134. };
  135. }
  136. }
  137. // Configures which glossary should be used for a specific target language,
  138. // and defines options for applying that glossary.
  139. message TranslateTextGlossaryConfig {
  140. // Required. Specifies the glossary used for this translation. Use
  141. // this format: projects/*/locations/*/glossaries/*
  142. string glossary = 1 [(google.api.field_behavior) = REQUIRED];
  143. // Optional. Indicates match is case-insensitive.
  144. // Default value is false if missing.
  145. bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
  146. }
  147. // The request message for synchronous translation.
  148. message TranslateTextRequest {
  149. // Required. The content of the input in string format.
  150. // We recommend the total content be less than 30k codepoints.
  151. // Use BatchTranslateText for larger text.
  152. repeated string contents = 1 [(google.api.field_behavior) = REQUIRED];
  153. // Optional. The format of the source text, for example, "text/html",
  154. // "text/plain". If left blank, the MIME type defaults to "text/html".
  155. string mime_type = 3 [(google.api.field_behavior) = OPTIONAL];
  156. // Optional. The BCP-47 language code of the input text if
  157. // known, for example, "en-US" or "sr-Latn". Supported language codes are
  158. // listed in Language Support. If the source language isn't specified, the API
  159. // attempts to identify the source language automatically and returns the
  160. // source language within the response.
  161. string source_language_code = 4 [(google.api.field_behavior) = OPTIONAL];
  162. // Required. The BCP-47 language code to use for translation of the input
  163. // text, set to one of the language codes listed in Language Support.
  164. string target_language_code = 5 [(google.api.field_behavior) = REQUIRED];
  165. // Required. Project or location to make a call. Must refer to a caller's
  166. // project.
  167. //
  168. // Format: `projects/{project-number-or-id}` or
  169. // `projects/{project-number-or-id}/locations/{location-id}`.
  170. //
  171. // For global calls, use `projects/{project-number-or-id}/locations/global` or
  172. // `projects/{project-number-or-id}`.
  173. //
  174. // Non-global location is required for requests using AutoML models or
  175. // custom glossaries.
  176. //
  177. // Models and glossaries must be within the same region (have same
  178. // location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
  179. string parent = 8 [
  180. (google.api.field_behavior) = REQUIRED,
  181. (google.api.resource_reference) = {
  182. type: "locations.googleapis.com/Location"
  183. }
  184. ];
  185. // Optional. The `model` type requested for this translation.
  186. //
  187. // The format depends on model type:
  188. //
  189. // - AutoML Translation models:
  190. // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
  191. //
  192. // - General (built-in) models:
  193. // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
  194. // `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
  195. //
  196. //
  197. // For global (non-regionalized) requests, use `location-id` `global`.
  198. // For example,
  199. // `projects/{project-number-or-id}/locations/global/models/general/nmt`.
  200. //
  201. // If missing, the system decides which google base model to use.
  202. string model = 6 [(google.api.field_behavior) = OPTIONAL];
  203. // Optional. Glossary to be applied. The glossary must be
  204. // within the same region (have the same location-id) as the model, otherwise
  205. // an INVALID_ARGUMENT (400) error is returned.
  206. TranslateTextGlossaryConfig glossary_config = 7
  207. [(google.api.field_behavior) = OPTIONAL];
  208. // Optional. The labels with user-defined metadata for the request.
  209. //
  210. // Label keys and values can be no longer than 63 characters
  211. // (Unicode codepoints), can only contain lowercase letters, numeric
  212. // characters, underscores and dashes. International characters are allowed.
  213. // Label values are optional. Label keys must start with a letter.
  214. //
  215. // See https://cloud.google.com/translate/docs/labels for more information.
  216. map<string, string> labels = 10 [(google.api.field_behavior) = OPTIONAL];
  217. }
  218. message TranslateTextResponse {
  219. // Text translation responses with no glossary applied.
  220. // This field has the same length as
  221. // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
  222. repeated Translation translations = 1;
  223. // Text translation responses if a glossary is provided in the request.
  224. // This can be the same as
  225. // [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
  226. // if no terms apply. This field has the same length as
  227. // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
  228. repeated Translation glossary_translations = 3;
  229. }
  230. // A single translation response.
  231. message Translation {
  232. // Text translated into the target language.
  233. string translated_text = 1;
  234. // Only present when `model` is present in the request.
  235. // `model` here is normalized to have project number.
  236. //
  237. // For example:
  238. // If the `model` requested in TranslationTextRequest is
  239. // `projects/{project-id}/locations/{location-id}/models/general/nmt` then
  240. // `model` here would be normalized to
  241. // `projects/{project-number}/locations/{location-id}/models/general/nmt`.
  242. string model = 2;
  243. // The BCP-47 language code of source text in the initial request, detected
  244. // automatically, if no source language was passed within the initial
  245. // request. If the source language was passed, auto-detection of the language
  246. // does not occur and this field is empty.
  247. string detected_language_code = 4;
  248. // The `glossary_config` used for this translation.
  249. TranslateTextGlossaryConfig glossary_config = 3;
  250. }
  251. // The request message for language detection.
  252. message DetectLanguageRequest {
  253. // Required. Project or location to make a call. Must refer to a caller's
  254. // project.
  255. //
  256. // Format: `projects/{project-number-or-id}/locations/{location-id}` or
  257. // `projects/{project-number-or-id}`.
  258. //
  259. // For global calls, use `projects/{project-number-or-id}/locations/global` or
  260. // `projects/{project-number-or-id}`.
  261. //
  262. // Only models within the same region (has same location-id) can be used.
  263. // Otherwise an INVALID_ARGUMENT (400) error is returned.
  264. string parent = 5 [
  265. (google.api.field_behavior) = REQUIRED,
  266. (google.api.resource_reference) = {
  267. type: "locations.googleapis.com/Location"
  268. }
  269. ];
  270. // Optional. The language detection model to be used.
  271. //
  272. // Format:
  273. // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}`
  274. //
  275. // Only one language detection model is currently supported:
  276. // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
  277. //
  278. // If not specified, the default model is used.
  279. string model = 4 [(google.api.field_behavior) = OPTIONAL];
  280. // Required. The source of the document from which to detect the language.
  281. oneof source {
  282. // The content of the input stored as a string.
  283. string content = 1;
  284. }
  285. // Optional. The format of the source text, for example, "text/html",
  286. // "text/plain". If left blank, the MIME type defaults to "text/html".
  287. string mime_type = 3 [(google.api.field_behavior) = OPTIONAL];
  288. // Optional. The labels with user-defined metadata for the request.
  289. //
  290. // Label keys and values can be no longer than 63 characters
  291. // (Unicode codepoints), can only contain lowercase letters, numeric
  292. // characters, underscores and dashes. International characters are allowed.
  293. // Label values are optional. Label keys must start with a letter.
  294. //
  295. // See https://cloud.google.com/translate/docs/labels for more information.
  296. map<string, string> labels = 6 [(google.api.field_behavior) = OPTIONAL];
  297. }
  298. // The response message for language detection.
  299. message DetectedLanguage {
  300. // The BCP-47 language code of source content in the request, detected
  301. // automatically.
  302. string language_code = 1;
  303. // The confidence of the detection result for this language.
  304. float confidence = 2;
  305. }
  306. // The response message for language detection.
  307. message DetectLanguageResponse {
  308. // A list of detected languages sorted by detection confidence in descending
  309. // order. The most probable language first.
  310. repeated DetectedLanguage languages = 1;
  311. }
  312. // The request message for discovering supported languages.
  313. message GetSupportedLanguagesRequest {
  314. // Required. Project or location to make a call. Must refer to a caller's
  315. // project.
  316. //
  317. // Format: `projects/{project-number-or-id}` or
  318. // `projects/{project-number-or-id}/locations/{location-id}`.
  319. //
  320. // For global calls, use `projects/{project-number-or-id}/locations/global` or
  321. // `projects/{project-number-or-id}`.
  322. //
  323. // Non-global location is required for AutoML models.
  324. //
  325. // Only models within the same region (have same location-id) can be used,
  326. // otherwise an INVALID_ARGUMENT (400) error is returned.
  327. string parent = 3 [
  328. (google.api.field_behavior) = REQUIRED,
  329. (google.api.resource_reference) = {
  330. type: "locations.googleapis.com/Location"
  331. }
  332. ];
  333. // Optional. The language to use to return localized, human readable names
  334. // of supported languages. If missing, then display names are not returned
  335. // in a response.
  336. string display_language_code = 1 [(google.api.field_behavior) = OPTIONAL];
  337. // Optional. Get supported languages of this model.
  338. //
  339. // The format depends on model type:
  340. //
  341. // - AutoML Translation models:
  342. // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
  343. //
  344. // - General (built-in) models:
  345. // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
  346. // `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
  347. //
  348. //
  349. // Returns languages supported by the specified model.
  350. // If missing, we get supported languages of Google general base (PBMT) model.
  351. string model = 2 [(google.api.field_behavior) = OPTIONAL];
  352. }
  353. // The response message for discovering supported languages.
  354. message SupportedLanguages {
  355. // A list of supported language responses. This list contains an entry
  356. // for each language the Translation API supports.
  357. repeated SupportedLanguage languages = 1;
  358. }
  359. // A single supported language response corresponds to information related
  360. // to one supported language.
  361. message SupportedLanguage {
  362. // Supported language code, generally consisting of its ISO 639-1
  363. // identifier, for example, 'en', 'ja'. In certain cases, BCP-47 codes
  364. // including language and region identifiers are returned (for example,
  365. // 'zh-TW' and 'zh-CN')
  366. string language_code = 1;
  367. // Human readable name of the language localized in the display language
  368. // specified in the request.
  369. string display_name = 2;
  370. // Can be used as source language.
  371. bool support_source = 3;
  372. // Can be used as target language.
  373. bool support_target = 4;
  374. }
  375. // The Google Cloud Storage location for the input content.
  376. message GcsSource {
  377. // Required. Source data URI. For example, `gs://my_bucket/my_object`.
  378. string input_uri = 1;
  379. }
  380. // Input configuration for BatchTranslateText request.
  381. message InputConfig {
  382. // Optional. Can be "text/plain" or "text/html".
  383. // For `.tsv`, "text/html" is used if mime_type is missing.
  384. // For `.html`, this field must be "text/html" or empty.
  385. // For `.txt`, this field must be "text/plain" or empty.
  386. string mime_type = 1 [(google.api.field_behavior) = OPTIONAL];
  387. // Required. Specify the input.
  388. oneof source {
  389. // Required. Google Cloud Storage location for the source input.
  390. // This can be a single file (for example,
  391. // `gs://translation-test/input.tsv`) or a wildcard (for example,
  392. // `gs://translation-test/*`). If a file extension is `.tsv`, it can
  393. // contain either one or two columns. The first column (optional) is the id
  394. // of the text request. If the first column is missing, we use the row
  395. // number (0-based) from the input file as the ID in the output file. The
  396. // second column is the actual text to be
  397. // translated. We recommend each row be <= 10K Unicode codepoints,
  398. // otherwise an error might be returned.
  399. // Note that the input tsv must be RFC 4180 compliant.
  400. //
  401. // You could use https://github.com/Clever/csvlint to check potential
  402. // formatting errors in your tsv file.
  403. // csvlint --delimiter='\t' your_input_file.tsv
  404. //
  405. // The other supported file extensions are `.txt` or `.html`, which is
  406. // treated as a single large chunk of text.
  407. GcsSource gcs_source = 2;
  408. }
  409. }
  410. // The Google Cloud Storage location for the output content.
  411. message GcsDestination {
  412. // Required. There must be no files under 'output_uri_prefix'.
  413. // 'output_uri_prefix' must end with "/" and start with "gs://", otherwise an
  414. // INVALID_ARGUMENT (400) error is returned.
  415. string output_uri_prefix = 1;
  416. }
  417. // Output configuration for BatchTranslateText request.
  418. message OutputConfig {
  419. // Required. The destination of output.
  420. oneof destination {
  421. // Google Cloud Storage destination for output content.
  422. // For every single input file (for example, gs://a/b/c.[extension]), we
  423. // generate at most 2 * n output files. (n is the # of target_language_codes
  424. // in the BatchTranslateTextRequest).
  425. //
  426. // Output files (tsv) generated are compliant with RFC 4180 except that
  427. // record delimiters are '\n' instead of '\r\n'. We don't provide any way to
  428. // change record delimiters.
  429. //
  430. // While the input files are being processed, we write/update an index file
  431. // 'index.csv' under 'output_uri_prefix' (for example,
  432. // gs://translation-test/index.csv) The index file is generated/updated as
  433. // new files are being translated. The format is:
  434. //
  435. // input_file,target_language_code,translations_file,errors_file,
  436. // glossary_translations_file,glossary_errors_file
  437. //
  438. // input_file is one file we matched using gcs_source.input_uri.
  439. // target_language_code is provided in the request.
  440. // translations_file contains the translations. (details provided below)
  441. // errors_file contains the errors during processing of the file. (details
  442. // below). Both translations_file and errors_file could be empty
  443. // strings if we have no content to output.
  444. // glossary_translations_file and glossary_errors_file are always empty
  445. // strings if the input_file is tsv. They could also be empty if we have no
  446. // content to output.
  447. //
  448. // Once a row is present in index.csv, the input/output matching never
  449. // changes. Callers should also expect all the content in input_file are
  450. // processed and ready to be consumed (that is, no partial output file is
  451. // written).
  452. //
  453. // The format of translations_file (for target language code 'trg') is:
  454. // `gs://translation_test/a_b_c_'trg'_translations.[extension]`
  455. //
  456. // If the input file extension is tsv, the output has the following
  457. // columns:
  458. // Column 1: ID of the request provided in the input, if it's not
  459. // provided in the input, then the input row number is used (0-based).
  460. // Column 2: source sentence.
  461. // Column 3: translation without applying a glossary. Empty string if there
  462. // is an error.
  463. // Column 4 (only present if a glossary is provided in the request):
  464. // translation after applying the glossary. Empty string if there is an
  465. // error applying the glossary. Could be same string as column 3 if there is
  466. // no glossary applied.
  467. //
  468. // If input file extension is a txt or html, the translation is directly
  469. // written to the output file. If glossary is requested, a separate
  470. // glossary_translations_file has format of
  471. // `gs://translation_test/a_b_c_'trg'_glossary_translations.[extension]`
  472. //
  473. // The format of errors file (for target language code 'trg') is:
  474. // `gs://translation_test/a_b_c_'trg'_errors.[extension]`
  475. //
  476. // If the input file extension is tsv, errors_file contains the following:
  477. // Column 1: ID of the request provided in the input, if it's not
  478. // provided in the input, then the input row number is used (0-based).
  479. // Column 2: source sentence.
  480. // Column 3: Error detail for the translation. Could be empty.
  481. // Column 4 (only present if a glossary is provided in the request):
  482. // Error when applying the glossary.
  483. //
  484. // If the input file extension is txt or html, glossary_error_file will be
  485. // generated that contains error details. glossary_error_file has format of
  486. // `gs://translation_test/a_b_c_'trg'_glossary_errors.[extension]`
  487. GcsDestination gcs_destination = 1;
  488. }
  489. }
  490. // The batch translation request.
  491. message BatchTranslateTextRequest {
  492. // Required. Location to make a call. Must refer to a caller's project.
  493. //
  494. // Format: `projects/{project-number-or-id}/locations/{location-id}`.
  495. //
  496. // The `global` location is not supported for batch translation.
  497. //
  498. // Only AutoML Translation models or glossaries within the same region (have
  499. // the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
  500. // error is returned.
  501. string parent = 1 [
  502. (google.api.field_behavior) = REQUIRED,
  503. (google.api.resource_reference) = {
  504. type: "locations.googleapis.com/Location"
  505. }
  506. ];
  507. // Required. Source language code.
  508. string source_language_code = 2 [(google.api.field_behavior) = REQUIRED];
  509. // Required. Specify up to 10 language codes here.
  510. repeated string target_language_codes = 3
  511. [(google.api.field_behavior) = REQUIRED];
  512. // Optional. The models to use for translation. Map's key is target language
  513. // code. Map's value is model name. Value can be a built-in general model,
  514. // or an AutoML Translation model.
  515. //
  516. // The value format depends on model type:
  517. //
  518. // - AutoML Translation models:
  519. // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
  520. //
  521. // - General (built-in) models:
  522. // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
  523. // `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
  524. //
  525. //
  526. // If the map is empty or a specific model is
  527. // not requested for a language pair, then default google model (nmt) is used.
  528. map<string, string> models = 4 [(google.api.field_behavior) = OPTIONAL];
  529. // Required. Input configurations.
  530. // The total number of files matched should be <= 1000.
  531. // The total content size should be <= 100M Unicode codepoints.
  532. // The files must use UTF-8 encoding.
  533. repeated InputConfig input_configs = 5
  534. [(google.api.field_behavior) = REQUIRED];
  535. // Required. Output configuration.
  536. // If 2 input configs match to the same file (that is, same input path),
  537. // we don't generate output for duplicate inputs.
  538. OutputConfig output_config = 6 [(google.api.field_behavior) = REQUIRED];
  539. // Optional. Glossaries to be applied for translation.
  540. // It's keyed by target language code.
  541. map<string, TranslateTextGlossaryConfig> glossaries = 7
  542. [(google.api.field_behavior) = OPTIONAL];
  543. // Optional. The labels with user-defined metadata for the request.
  544. //
  545. // Label keys and values can be no longer than 63 characters
  546. // (Unicode codepoints), can only contain lowercase letters, numeric
  547. // characters, underscores and dashes. International characters are allowed.
  548. // Label values are optional. Label keys must start with a letter.
  549. //
  550. // See https://cloud.google.com/translate/docs/labels for more information.
  551. map<string, string> labels = 9 [(google.api.field_behavior) = OPTIONAL];
  552. }
  553. // State metadata for the batch translation operation.
  554. message BatchTranslateMetadata {
  555. // State of the job.
  556. enum State {
  557. // Invalid.
  558. STATE_UNSPECIFIED = 0;
  559. // Request is being processed.
  560. RUNNING = 1;
  561. // The batch is processed, and at least one item was successfully
  562. // processed.
  563. SUCCEEDED = 2;
  564. // The batch is done and no item was successfully processed.
  565. FAILED = 3;
  566. // Request is in the process of being canceled after caller invoked
  567. // longrunning.Operations.CancelOperation on the request id.
  568. CANCELLING = 4;
  569. // The batch is done after the user has called the
  570. // longrunning.Operations.CancelOperation. Any records processed before the
  571. // cancel command are output as specified in the request.
  572. CANCELLED = 5;
  573. }
  574. // The state of the operation.
  575. State state = 1;
  576. // Number of successfully translated characters so far (Unicode codepoints).
  577. int64 translated_characters = 2;
  578. // Number of characters that have failed to process so far (Unicode
  579. // codepoints).
  580. int64 failed_characters = 3;
  581. // Total number of characters (Unicode codepoints).
  582. // This is the total number of codepoints from input files times the number of
  583. // target languages and appears here shortly after the call is submitted.
  584. int64 total_characters = 4;
  585. // Time when the operation was submitted.
  586. google.protobuf.Timestamp submit_time = 5;
  587. }
  588. // Stored in the
  589. // [google.longrunning.Operation.response][google.longrunning.Operation.response]
  590. // field returned by BatchTranslateText if at least one sentence is translated
  591. // successfully.
  592. message BatchTranslateResponse {
  593. // Total number of characters (Unicode codepoints).
  594. int64 total_characters = 1;
  595. // Number of successfully translated characters (Unicode codepoints).
  596. int64 translated_characters = 2;
  597. // Number of characters that have failed to process (Unicode codepoints).
  598. int64 failed_characters = 3;
  599. // Time when the operation was submitted.
  600. google.protobuf.Timestamp submit_time = 4;
  601. // The time when the operation is finished and
  602. // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
  603. // set to true.
  604. google.protobuf.Timestamp end_time = 5;
  605. }
  606. // Input configuration for glossaries.
  607. message GlossaryInputConfig {
  608. // Required. Specify the input.
  609. oneof source {
  610. // Required. Google Cloud Storage location of glossary data.
  611. // File format is determined based on the filename extension. API returns
  612. // [google.rpc.Code.INVALID_ARGUMENT] for unsupported URI-s and file
  613. // formats. Wildcards are not allowed. This must be a single file in one of
  614. // the following formats:
  615. //
  616. // For unidirectional glossaries:
  617. //
  618. // - TSV/CSV (`.tsv`/`.csv`): 2 column file, tab- or comma-separated.
  619. // The first column is source text. The second column is target text.
  620. // The file must not contain headers. That is, the first row is data, not
  621. // column names.
  622. //
  623. // - TMX (`.tmx`): TMX file with parallel data defining source/target term
  624. // pairs.
  625. //
  626. // For equivalent term sets glossaries:
  627. //
  628. // - CSV (`.csv`): Multi-column CSV file defining equivalent glossary terms
  629. // in multiple languages. The format is defined for Google Translation
  630. // Toolkit and documented in [Use a
  631. // glossary](https://support.google.com/translatortoolkit/answer/6306379?hl=en).
  632. GcsSource gcs_source = 1;
  633. }
  634. }
  635. // Represents a glossary built from user provided data.
  636. message Glossary {
  637. option (google.api.resource) = {
  638. type: "translate.googleapis.com/Glossary"
  639. pattern: "projects/{project}/locations/{location}/glossaries/{glossary}"
  640. };
  641. // Used with unidirectional glossaries.
  642. message LanguageCodePair {
  643. // Required. The BCP-47 language code of the input text, for example,
  644. // "en-US". Expected to be an exact match for GlossaryTerm.language_code.
  645. string source_language_code = 1;
  646. // Required. The BCP-47 language code for translation output, for example,
  647. // "zh-CN". Expected to be an exact match for GlossaryTerm.language_code.
  648. string target_language_code = 2;
  649. }
  650. // Used with equivalent term set glossaries.
  651. message LanguageCodesSet {
  652. // The BCP-47 language code(s) for terms defined in the glossary.
  653. // All entries are unique. The list contains at least two entries.
  654. // Expected to be an exact match for GlossaryTerm.language_code.
  655. repeated string language_codes = 1;
  656. }
  657. // Required. The resource name of the glossary. Glossary names have the form
  658. // `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`.
  659. string name = 1;
  660. // Languages supported by the glossary.
  661. oneof languages {
  662. // Used with unidirectional glossaries.
  663. LanguageCodePair language_pair = 3;
  664. // Used with equivalent term set glossaries.
  665. LanguageCodesSet language_codes_set = 4;
  666. }
  667. // Required. Provides examples to build the glossary from.
  668. // Total glossary must not exceed 10M Unicode codepoints.
  669. GlossaryInputConfig input_config = 5;
  670. // Output only. The number of entries defined in the glossary.
  671. int32 entry_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  672. // Output only. When CreateGlossary was called.
  673. google.protobuf.Timestamp submit_time = 7
  674. [(google.api.field_behavior) = OUTPUT_ONLY];
  675. // Output only. When the glossary creation was finished.
  676. google.protobuf.Timestamp end_time = 8
  677. [(google.api.field_behavior) = OUTPUT_ONLY];
  678. }
  679. // Request message for CreateGlossary.
  680. message CreateGlossaryRequest {
  681. // Required. The project name.
  682. string parent = 1 [
  683. (google.api.field_behavior) = REQUIRED,
  684. (google.api.resource_reference) = {
  685. type: "locations.googleapis.com/Location"
  686. }
  687. ];
  688. // Required. The glossary to create.
  689. Glossary glossary = 2 [(google.api.field_behavior) = REQUIRED];
  690. }
  691. // Request message for GetGlossary.
  692. message GetGlossaryRequest {
  693. // Required. The name of the glossary to retrieve.
  694. string name = 1 [
  695. (google.api.field_behavior) = REQUIRED,
  696. (google.api.resource_reference) = {
  697. type: "translate.googleapis.com/Glossary"
  698. }
  699. ];
  700. }
  701. // Request message for DeleteGlossary.
  702. message DeleteGlossaryRequest {
  703. // Required. The name of the glossary to delete.
  704. string name = 1 [
  705. (google.api.field_behavior) = REQUIRED,
  706. (google.api.resource_reference) = {
  707. type: "translate.googleapis.com/Glossary"
  708. }
  709. ];
  710. }
  711. // Request message for ListGlossaries.
  712. message ListGlossariesRequest {
  713. // Required. The name of the project from which to list all of the glossaries.
  714. string parent = 1 [
  715. (google.api.field_behavior) = REQUIRED,
  716. (google.api.resource_reference) = {
  717. type: "locations.googleapis.com/Location"
  718. }
  719. ];
  720. // Optional. Requested page size. The server may return fewer glossaries than
  721. // requested. If unspecified, the server picks an appropriate default.
  722. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  723. // Optional. A token identifying a page of results the server should return.
  724. // Typically, this is the value of [ListGlossariesResponse.next_page_token]
  725. // returned from the previous call to `ListGlossaries` method.
  726. // The first page is returned if `page_token`is empty or missing.
  727. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  728. // Optional. Filter specifying constraints of a list operation.
  729. // Filtering is not supported yet, and the parameter currently has no effect.
  730. // If missing, no filtering is performed.
  731. string filter = 4 [(google.api.field_behavior) = OPTIONAL];
  732. }
  733. // Response message for ListGlossaries.
  734. message ListGlossariesResponse {
  735. // The list of glossaries for a project.
  736. repeated Glossary glossaries = 1;
  737. // A token to retrieve a page of results. Pass this value in the
  738. // [ListGlossariesRequest.page_token] field in the subsequent call to
  739. // `ListGlossaries` method to retrieve the next page of results.
  740. string next_page_token = 2;
  741. }
  742. // Stored in the
  743. // [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
  744. // field returned by CreateGlossary.
  745. message CreateGlossaryMetadata {
  746. // Enumerates the possible states that the creation request can be in.
  747. enum State {
  748. // Invalid.
  749. STATE_UNSPECIFIED = 0;
  750. // Request is being processed.
  751. RUNNING = 1;
  752. // The glossary was successfully created.
  753. SUCCEEDED = 2;
  754. // Failed to create the glossary.
  755. FAILED = 3;
  756. // Request is in the process of being canceled after caller invoked
  757. // longrunning.Operations.CancelOperation on the request id.
  758. CANCELLING = 4;
  759. // The glossary creation request was successfully canceled.
  760. CANCELLED = 5;
  761. }
  762. // The name of the glossary that is being created.
  763. string name = 1;
  764. // The current state of the glossary creation operation.
  765. State state = 2;
  766. // The time when the operation was submitted to the server.
  767. google.protobuf.Timestamp submit_time = 3;
  768. }
  769. // Stored in the
  770. // [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
  771. // field returned by DeleteGlossary.
  772. message DeleteGlossaryMetadata {
  773. // Enumerates the possible states that the creation request can be in.
  774. enum State {
  775. // Invalid.
  776. STATE_UNSPECIFIED = 0;
  777. // Request is being processed.
  778. RUNNING = 1;
  779. // The glossary was successfully deleted.
  780. SUCCEEDED = 2;
  781. // Failed to delete the glossary.
  782. FAILED = 3;
  783. // Request is in the process of being canceled after caller invoked
  784. // longrunning.Operations.CancelOperation on the request id.
  785. CANCELLING = 4;
  786. // The glossary deletion request was successfully canceled.
  787. CANCELLED = 5;
  788. }
  789. // The name of the glossary that is being deleted.
  790. string name = 1;
  791. // The current state of the glossary deletion operation.
  792. State state = 2;
  793. // The time when the operation was submitted to the server.
  794. google.protobuf.Timestamp submit_time = 3;
  795. }
  796. // Stored in the
  797. // [google.longrunning.Operation.response][google.longrunning.Operation.response]
  798. // field returned by DeleteGlossary.
  799. message DeleteGlossaryResponse {
  800. // The name of the deleted glossary.
  801. string name = 1;
  802. // The time when the operation was submitted to the server.
  803. google.protobuf.Timestamp submit_time = 2;
  804. // The time when the glossary deletion is finished and
  805. // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
  806. // set to true.
  807. google.protobuf.Timestamp end_time = 3;
  808. }