translation_service.proto 57 KB

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