translation_service.proto 57 KB

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