feat: Adds AdaptiveMt HTML/Glossary support

feat: Adds protos for Custom Translation API (AutoML)
feat: Adds protos for Transliteration in V3 Advanced translate text
feat: Adds protos for Romanization APIs
docs: Fixes typos in docs

PiperOrigin-RevId: 659659171
This commit is contained in:
Google APIs 2024-08-05 13:18:02 -07:00 committed by Copybara-Service
parent ae593946b7
commit db79b1a514
6 changed files with 1036 additions and 112 deletions

View file

@ -9,19 +9,21 @@
# * extra_protoc_file_parameters
# The complete list of preserved parameters can be found in the source code.
# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])
load("@com_google_googleapis_imports//:imports.bzl", "cc_grpc_library", "cc_proto_library", "csharp_gapic_assembly_pkg", "csharp_gapic_library", "csharp_grpc_library", "csharp_proto_library", "go_gapic_assembly_pkg", "go_gapic_library", "go_proto_library", "java_gapic_assembly_gradle_pkg", "java_gapic_library", "java_gapic_test", "java_grpc_library", "java_proto_library", "nodejs_gapic_assembly_pkg", "nodejs_gapic_library", "php_gapic_assembly_pkg", "php_gapic_library", "php_proto_library", "proto_library_with_info", "py_gapic_assembly_pkg", "py_gapic_library", "py_test", "ruby_cloud_gapic_library", "ruby_gapic_assembly_pkg", "ruby_grpc_library", "ruby_proto_library")
##############################################################################
# Common
##############################################################################
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])
proto_library(
name = "translation_proto",
srcs = [
"adaptive_mt.proto",
"automl_translation.proto",
"common.proto",
"translation_service.proto",
],
@ -30,7 +32,9 @@ proto_library(
"//google/api:client_proto",
"//google/api:field_behavior_proto",
"//google/api:resource_proto",
"//google/iam/v1:policy_proto",
"//google/longrunning:operations_proto",
"//google/rpc:status_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:timestamp_proto",
@ -45,18 +49,6 @@ proto_library_with_info(
],
)
##############################################################################
# Java
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_gapic_test",
"java_grpc_library",
"java_proto_library",
)
java_proto_library(
name = "translation_java_proto",
deps = [":translation_proto"],
@ -83,6 +75,7 @@ java_gapic_library(
deps = [
":translation_java_proto",
"//google/api:api_java_proto",
"//google/iam/v1:iam_java_proto",
],
)
@ -108,16 +101,6 @@ java_gapic_assembly_gradle_pkg(
],
)
##############################################################################
# Go
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"go_gapic_assembly_pkg",
"go_gapic_library",
"go_proto_library",
)
go_proto_library(
name = "translation_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
@ -161,16 +144,6 @@ go_gapic_assembly_pkg(
],
)
##############################################################################
# Python
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"py_gapic_assembly_pkg",
"py_gapic_library",
"py_test",
)
py_gapic_library(
name = "translation_py_gapic",
srcs = [":translation_proto"],
@ -180,6 +153,7 @@ py_gapic_library(
service_yaml = "translate_v3.yaml",
transport = "grpc+rest",
deps = [
"//google/iam/v1:iam_policy_py_proto",
],
)
@ -201,16 +175,6 @@ py_gapic_assembly_pkg(
],
)
##############################################################################
# PHP
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"php_gapic_assembly_pkg",
"php_gapic_library",
"php_proto_library",
)
php_proto_library(
name = "translation_php_proto",
deps = [":translation_proto"],
@ -238,15 +202,6 @@ php_gapic_assembly_pkg(
],
)
##############################################################################
# Node.js
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"nodejs_gapic_assembly_pkg",
"nodejs_gapic_library",
)
nodejs_gapic_library(
name = "translation_nodejs_gapic",
package_name = "@google-cloud/translate",
@ -268,17 +223,6 @@ nodejs_gapic_assembly_pkg(
],
)
##############################################################################
# Ruby
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"ruby_cloud_gapic_library",
"ruby_gapic_assembly_pkg",
"ruby_grpc_library",
"ruby_proto_library",
)
ruby_proto_library(
name = "translation_ruby_proto",
deps = [":translation_proto"],
@ -322,17 +266,6 @@ ruby_gapic_assembly_pkg(
],
)
##############################################################################
# C#
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"csharp_gapic_assembly_pkg",
"csharp_gapic_library",
"csharp_grpc_library",
"csharp_proto_library",
)
csharp_proto_library(
name = "translation_csharp_proto",
extra_opts = [],
@ -369,15 +302,6 @@ csharp_gapic_assembly_pkg(
],
)
##############################################################################
# C++
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_grpc_library",
"cc_proto_library",
)
cc_proto_library(
name = "translation_cc_proto",
deps = [":translation_proto"],

View file

@ -151,6 +151,58 @@ message ListAdaptiveMtDatasetsResponse {
// The request for sending an AdaptiveMt translation query.
message AdaptiveMtTranslateRequest {
// A pair of sentences used as reference in source and target languages.
message ReferenceSentencePair {
// Source sentence in the sentence pair.
string source_sentence = 1;
// Target sentence in the sentence pair.
string target_sentence = 2;
}
// A list of reference sentence pairs.
message ReferenceSentencePairList {
// Reference sentence pairs.
repeated ReferenceSentencePair reference_sentence_pairs = 1;
}
// Message of caller-provided reference configuration.
message ReferenceSentenceConfig {
// Reference sentences pair lists. Each list will be used as the references
// to translate the sentence under "content" field at the corresponding
// index. Length of the list is required to be equal to the length of
// "content" field.
repeated ReferenceSentencePairList reference_sentence_pair_lists = 1;
// Source language code.
string source_language_code = 2;
// Target language code.
string target_language_code = 3;
}
// Configures which glossary is used for a specific target language and
// defines
// options for applying that glossary.
message GlossaryConfig {
// Required. The `glossary` to be applied for this translation.
//
// The format depends on the glossary:
//
// - User-provided custom glossary:
// `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
string glossary = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Glossary"
}
];
// Optional. Indicates match is case insensitive. The default value is
// `false` if missing.
bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
}
// Required. Location to make a regional call.
//
// Format: `projects/{project-number-or-id}/locations/{location-id}`.
@ -171,8 +223,16 @@ message AdaptiveMtTranslateRequest {
];
// Required. The content of the input in string format.
// For now only one sentence per request is supported.
repeated string content = 3 [(google.api.field_behavior) = REQUIRED];
// Configuration for caller provided reference sentences.
optional ReferenceSentenceConfig reference_sentence_config = 6;
// Optional. Glossary to be applied. The glossary must be
// within the same region (have the same location-id) as the model, otherwise
// an INVALID_ARGUMENT (400) error is returned.
optional GlossaryConfig glossary_config = 7
[(google.api.field_behavior) = OPTIONAL];
}
// An AdaptiveMt translation.
@ -189,6 +249,10 @@ message AdaptiveMtTranslateResponse {
// Output only. The translation's language code.
string language_code = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// Text translation response if a glossary is provided in the request. This
// could be the same as 'translation' above if no terms apply.
repeated AdaptiveMtTranslation glossary_translations = 4;
}
// An AdaptiveMtFile.
@ -196,6 +260,8 @@ message AdaptiveMtFile {
option (google.api.resource) = {
type: "translate.googleapis.com/AdaptiveMtFile"
pattern: "projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}"
plural: "adaptiveMtFiles"
singular: "adaptiveMtFile"
};
// Required. The resource name of the file, in form of
@ -314,6 +380,8 @@ message AdaptiveMtSentence {
option (google.api.resource) = {
type: "translate.googleapis.com/AdaptiveMtSentence"
pattern: "projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}/adaptiveMtSentences/{sentence}"
plural: "adaptiveMtSentences"
singular: "adaptiveMtSentence"
};
// Required. The resource name of the file, in form of

View file

@ -0,0 +1,478 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.cloud.translation.v3;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/translate/v3/common.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";
option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Translate.V3";
option go_package = "cloud.google.com/go/translate/apiv3/translatepb;translatepb";
option java_multiple_files = true;
option java_outer_classname = "AutoMLTranslationProto";
option java_package = "com.google.cloud.translate.v3";
option php_namespace = "Google\\Cloud\\Translate\\V3";
option ruby_package = "Google::Cloud::Translate::V3";
// Request message for ImportData.
message ImportDataRequest {
// Required. Name of the dataset. In form of
// `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
string dataset = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The config for the input content.
DatasetInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED];
}
// Input configuration for datasets.
message DatasetInputConfig {
// An input file.
message InputFile {
// Optional. Usage of the file contents. Options are TRAIN|VALIDATION|TEST,
// or UNASSIGNED (by default) for auto split.
string usage = 2 [(google.api.field_behavior) = OPTIONAL];
// Source of the file containing sentence pairs.
// Supported formats are tab-separated values (.tsv) and Translation Memory
// eXchange (.tmx) .
oneof source {
// Google Cloud Storage file source.
GcsInputSource gcs_source = 3;
}
}
// Files containing the sentence pairs to be imported to the dataset.
repeated InputFile input_files = 1;
}
// Metadata of import data operation.
message ImportDataMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// Request message for ExportData.
message ExportDataRequest {
// Required. Name of the dataset. In form of
// `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
string dataset = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The config for the output content.
DatasetOutputConfig output_config = 2
[(google.api.field_behavior) = REQUIRED];
}
// Output configuration for datasets.
message DatasetOutputConfig {
// Required. Specify the output.
oneof destination {
// Google Cloud Storage destination to write the output.
GcsOutputDestination gcs_destination = 1;
}
}
// Metadata of export data operation.
message ExportDataMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// Request message for DeleteDataset.
message DeleteDatasetRequest {
// Required. The name of the dataset to delete.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Dataset"
}
];
}
// Metadata of delete dataset operation.
message DeleteDatasetMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// Request message for GetDataset.
message GetDatasetRequest {
// Required. The resource name of the dataset to retrieve.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Dataset"
}
];
}
// Request message for ListDatasets.
message ListDatasetsRequest {
// Required. Name of the parent project. In form of
// `projects/{project-number-or-id}/locations/{location-id}`
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Optional. Requested page size. The server can return fewer results than
// requested.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. A token identifying a page of results for the server to return.
// Typically obtained from next_page_token field in the response of a
// ListDatasets call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}
// Response message for ListDatasets.
message ListDatasetsResponse {
// The datasets read.
repeated Dataset datasets = 1;
// A token to retrieve next page of results.
// Pass this token to the page_token field in the ListDatasetsRequest to
// obtain the corresponding page.
string next_page_token = 2;
}
// Request message for CreateDataset.
message CreateDatasetRequest {
// Required. The project name.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Required. The Dataset to create.
Dataset dataset = 2 [(google.api.field_behavior) = REQUIRED];
}
// Metadata of create dataset operation.
message CreateDatasetMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// Request message for ListExamples.
message ListExamplesRequest {
// Required. Name of the parent dataset. In form of
// `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Dataset"
}
];
// Optional. An expression for filtering the examples that will be returned.
// Example filter:
// * `usage=TRAIN`
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. Requested page size. The server can return fewer results than
// requested.
int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL];
// Optional. A token identifying a page of results for the server to return.
// Typically obtained from next_page_token field in the response of a
// ListExamples call.
string page_token = 4 [(google.api.field_behavior) = OPTIONAL];
}
// Response message for ListExamples.
message ListExamplesResponse {
// The sentence pairs.
repeated Example examples = 1;
// A token to retrieve next page of results.
// Pass this token to the page_token field in the ListExamplesRequest to
// obtain the corresponding page.
string next_page_token = 2;
}
// A sentence pair.
message Example {
option (google.api.resource) = {
type: "translate.googleapis.com/Example"
pattern: "projects/{project}/locations/{location}/datasets/{dataset}/examples/{example}"
};
// Output only. The resource name of the example, in form of
// `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}/examples/{example_id}'
string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// Sentence in source language.
string source_text = 2;
// Sentence in target language.
string target_text = 3;
// Output only. Usage of the sentence pair. Options are TRAIN|VALIDATION|TEST.
string usage = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}
// Response message for BatchTransferResources.
message BatchTransferResourcesResponse {
// Transfer response for a single resource.
message TransferResourceResponse {
// Full name of the resource to transfer as specified in the request.
string source = 1;
// Full name of the new resource successfully transferred from the source
// hosted by Translation API. Target will be empty if the transfer failed.
string target = 2;
// The error result in case of failure.
google.rpc.Status error = 3;
}
// Responses of the transfer for individual resources.
repeated TransferResourceResponse responses = 1;
}
// A dataset that hosts the examples (sentence pairs) used for translation
// models.
message Dataset {
option (google.api.resource) = {
type: "translate.googleapis.com/Dataset"
pattern: "projects/{project}/locations/{location}/datasets/{dataset}"
};
// The resource name of the dataset, in form of
// `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}`
string name = 1;
// The name of the dataset to show in the interface. The name can be
// up to 32 characters long and can consist only of ASCII Latin letters A-Z
// and a-z, underscores (_), and ASCII digits 0-9.
string display_name = 2;
// The BCP-47 language code of the source language.
string source_language_code = 3;
// The BCP-47 language code of the target language.
string target_language_code = 4;
// Output only. The number of examples in the dataset.
int32 example_count = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of training examples (sentence pairs).
int32 train_example_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of validation examples (sentence pairs).
int32 validate_example_count = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of test examples (sentence pairs).
int32 test_example_count = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Timestamp when this dataset was created.
google.protobuf.Timestamp create_time = 9
[(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Timestamp when this dataset was last updated.
google.protobuf.Timestamp update_time = 10
[(google.api.field_behavior) = OUTPUT_ONLY];
}
// Request message for CreateModel.
message CreateModelRequest {
// Required. The project name, in form of
// `projects/{project}/locations/{location}`
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Required. The Model to create.
Model model = 2 [(google.api.field_behavior) = REQUIRED];
}
// Metadata of create model operation.
message CreateModelMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// Request message for ListModels.
message ListModelsRequest {
// Required. Name of the parent project. In form of
// `projects/{project-number-or-id}/locations/{location-id}`
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Optional. An expression for filtering the models that will be returned.
// Supported filter:
// `dataset_id=${dataset_id}`
string filter = 4 [(google.api.field_behavior) = OPTIONAL];
// Optional. Requested page size. The server can return fewer results than
// requested.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. A token identifying a page of results for the server to return.
// Typically obtained from next_page_token field in the response of a
// ListModels call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}
// Response message for ListModels.
message ListModelsResponse {
// The models read.
repeated Model models = 1;
// A token to retrieve next page of results.
// Pass this token to the page_token field in the ListModelsRequest to
// obtain the corresponding page.
string next_page_token = 2;
}
// Request message for GetModel.
message GetModelRequest {
// Required. The resource name of the model to retrieve.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = { type: "translate.googleapis.com/Model" }
];
}
// Request message for DeleteModel.
message DeleteModelRequest {
// Required. The name of the model to delete.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = { type: "translate.googleapis.com/Model" }
];
}
// Metadata of delete model operation.
message DeleteModelMetadata {
// The current state of the operation.
OperationState state = 1;
// The creation time of the operation.
google.protobuf.Timestamp create_time = 2;
// The last update time of the operation.
google.protobuf.Timestamp update_time = 3;
// Only populated when operation doesn't succeed.
google.rpc.Status error = 4;
}
// A trained translation model.
message Model {
option (google.api.resource) = {
type: "translate.googleapis.com/Model"
pattern: "projects/{project}/locations/{location}/models/{model}"
};
// The resource name of the model, in form of
// `projects/{project-number-or-id}/locations/{location_id}/models/{model_id}`
string name = 1;
// The name of the model to show in the interface. The name can be
// up to 32 characters long and can consist only of ASCII Latin letters A-Z
// and a-z, underscores (_), and ASCII digits 0-9.
string display_name = 2;
// The dataset from which the model is trained, in form of
// `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}`
string dataset = 3;
// Output only. The BCP-47 language code of the source language.
string source_language_code = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. The BCP-47 language code of the target language.
string target_language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of examples (sentence pairs) used to train the model.
int32 train_example_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of examples (sentence pairs) used to validate the
// model.
int32 validate_example_count = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Number of examples (sentence pairs) used to test the model.
int32 test_example_count = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Timestamp when the model resource was created, which is also
// when the training started.
google.protobuf.Timestamp create_time = 8
[(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Timestamp when this model was last updated.
google.protobuf.Timestamp update_time = 10
[(google.api.field_behavior) = OUTPUT_ONLY];
}

View file

@ -17,6 +17,7 @@ syntax = "proto3";
package google.cloud.translation.v3;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Translate.V3";
@ -52,3 +53,80 @@ message GcsOutputDestination {
// the bucket. The directory will be created if it doesn't exist.
string output_uri_prefix = 1 [(google.api.field_behavior) = REQUIRED];
}
// Possible states of long running operations.
enum OperationState {
// Invalid.
OPERATION_STATE_UNSPECIFIED = 0;
// Request is being processed.
OPERATION_STATE_RUNNING = 1;
// The operation was successful.
OPERATION_STATE_SUCCEEDED = 2;
// Failed to process operation.
OPERATION_STATE_FAILED = 3;
// Request is in the process of being canceled after caller invoked
// longrunning.Operations.CancelOperation on the request id.
OPERATION_STATE_CANCELLING = 4;
// The operation request was successfully canceled.
OPERATION_STATE_CANCELLED = 5;
}
// Represents a single entry in a glossary.
message GlossaryEntry {
option (google.api.resource) = {
type: "translate.googleapis.com/GlossaryEntry"
pattern: "projects/{project}/locations/{location}/glossaries/{glossary}/glossaryEntries/{glossary_entry}"
plural: "glossaryEntries"
singular: "glossaryEntry"
};
// Represents a single entry for an unidirectional glossary.
message GlossaryTermsPair {
// The source term is the term that will get match in the text,
GlossaryTerm source_term = 1;
// The term that will replace the match source term.
GlossaryTerm target_term = 2;
}
// Represents a single entry for an equivalent term set glossary. This is used
// for equivalent term sets where each term can be replaced by the other terms
// in the set.
message GlossaryTermsSet {
// Each term in the set represents a term that can be replaced by the other
// terms.
repeated GlossaryTerm terms = 1;
}
// Identifier. The resource name of the entry.
// Format:
// `projects/*/locations/*/glossaries/*/glossaryEntries/*`
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
// The different data for the glossary types (Unidirectional, Equivalent term
// sets).
oneof data {
// Used for an unidirectional glossary.
GlossaryTermsPair terms_pair = 2;
// Used for an equivalent term sets glossary.
GlossaryTermsSet terms_set = 3;
}
// Describes the glossary entry.
string description = 4;
}
// Represents a single glossary term
message GlossaryTerm {
// The language for this glossary term.
string language_code = 1;
// The text for the glossary term.
string text = 2;
}

View file

@ -4,7 +4,10 @@ name: translate.googleapis.com
title: Cloud Translation API
apis:
- name: google.cloud.location.Locations
- name: google.cloud.translation.v3.TranslationService
- name: google.iam.v1.IAMPolicy
- name: google.longrunning.Operations
documentation:
summary: Integrates text translation into your website or application.
@ -15,17 +18,6 @@ documentation:
- selector: google.cloud.location.Locations.ListLocations
description: Lists information about the supported locations for this service.
backend:
rules:
- selector: google.cloud.location.Locations.GetLocation
deadline: 30.0
- selector: google.cloud.location.Locations.ListLocations
deadline: 30.0
- selector: 'google.longrunning.Operations.*'
deadline: 60.0
- selector: google.longrunning.Operations.WaitOperation
deadline: 120.0
http:
rules:
- selector: google.cloud.location.Locations.GetLocation

View file

@ -16,13 +16,17 @@ syntax = "proto3";
package google.cloud.translation.v3;
import public "google/cloud/translate/v3/adaptive_mt.proto";
import public "google/cloud/translate/v3/automl_translation.proto";
import public "google/cloud/translate/v3/common.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/translate/v3/adaptive_mt.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
option cc_enable_arenas = true;
@ -31,6 +35,7 @@ option go_package = "cloud.google.com/go/translate/apiv3/translatepb;translatepb
option java_multiple_files = true;
option java_outer_classname = "TranslationServiceProto";
option java_package = "com.google.cloud.translate.v3";
option objc_class_prefix = "CTRL3";
option php_namespace = "Google\\Cloud\\Translate\\V3";
option ruby_package = "Google::Cloud::Translate::V3";
@ -59,6 +64,19 @@ service TranslationService {
"parent,model,mime_type,source_language_code,target_language_code,contents";
}
// Romanize input text written in non-Latin scripts to Latin text.
rpc RomanizeText(RomanizeTextRequest) returns (RomanizeTextResponse) {
option (google.api.http) = {
post: "/v3/{parent=projects/*/locations/*}:romanizeText"
body: "*"
additional_bindings {
post: "/v3/{parent=projects/*}:romanizeText"
body: "*"
}
};
option (google.api.method_signature) = "parent,contents";
}
// Detects the language of text within a request.
rpc DetectLanguage(DetectLanguageRequest) returns (DetectLanguageResponse) {
option (google.api.http) = {
@ -146,6 +164,21 @@ service TranslationService {
};
}
// Updates a glossary. A LRO is used since the update can be async if the
// glossary's entry file is updated.
rpc UpdateGlossary(UpdateGlossaryRequest)
returns (google.longrunning.Operation) {
option (google.api.http) = {
patch: "/v3/{glossary.name=projects/*/locations/*/glossaries/*}"
body: "glossary"
};
option (google.api.method_signature) = "glossary,update_mask";
option (google.longrunning.operation_info) = {
response_type: "Glossary"
metadata_type: "UpdateGlossaryMetadata"
};
}
// Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
// exist.
rpc ListGlossaries(ListGlossariesRequest) returns (ListGlossariesResponse) {
@ -179,6 +212,93 @@ service TranslationService {
};
}
// Gets a single glossary entry by the given id.
rpc GetGlossaryEntry(GetGlossaryEntryRequest) returns (GlossaryEntry) {
option (google.api.http) = {
get: "/v3/{name=projects/*/locations/*/glossaries/*/glossaryEntries/*}"
};
option (google.api.method_signature) = "name";
}
// List the entries for the glossary.
rpc ListGlossaryEntries(ListGlossaryEntriesRequest)
returns (ListGlossaryEntriesResponse) {
option (google.api.http) = {
get: "/v3/{parent=projects/*/locations/*/glossaries/*}/glossaryEntries"
};
option (google.api.method_signature) = "parent";
}
// Creates a glossary entry.
rpc CreateGlossaryEntry(CreateGlossaryEntryRequest) returns (GlossaryEntry) {
option (google.api.http) = {
post: "/v3/{parent=projects/*/locations/*/glossaries/*}/glossaryEntries"
body: "glossary_entry"
};
option (google.api.method_signature) = "parent,glossary_entry";
}
// Updates a glossary entry.
rpc UpdateGlossaryEntry(UpdateGlossaryEntryRequest) returns (GlossaryEntry) {
option (google.api.http) = {
patch: "/v3/{glossary_entry.name=projects/*/locations/*/glossaries/*/glossaryEntries/*}"
body: "glossary_entry"
};
option (google.api.method_signature) = "glossary_entry";
}
// Deletes a single entry from the glossary
rpc DeleteGlossaryEntry(DeleteGlossaryEntryRequest)
returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v3/{name=projects/*/locations/*/glossaries/*/glossaryEntries/*}"
};
option (google.api.method_signature) = "name";
}
// Creates a Dataset.
rpc CreateDataset(CreateDatasetRequest)
returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v3/{parent=projects/*/locations/*}/datasets"
body: "dataset"
};
option (google.api.method_signature) = "parent,dataset";
option (google.longrunning.operation_info) = {
response_type: "Dataset"
metadata_type: "CreateDatasetMetadata"
};
}
// Gets a Dataset.
rpc GetDataset(GetDatasetRequest) returns (Dataset) {
option (google.api.http) = {
get: "/v3/{name=projects/*/locations/*/datasets/*}"
};
option (google.api.method_signature) = "name";
}
// Lists datasets.
rpc ListDatasets(ListDatasetsRequest) returns (ListDatasetsResponse) {
option (google.api.http) = {
get: "/v3/{parent=projects/*/locations/*}/datasets"
};
option (google.api.method_signature) = "parent";
}
// Deletes a dataset and all of its contents.
rpc DeleteDataset(DeleteDatasetRequest)
returns (google.longrunning.Operation) {
option (google.api.http) = {
delete: "/v3/{name=projects/*/locations/*/datasets/*}"
};
option (google.api.method_signature) = "name";
option (google.longrunning.operation_info) = {
response_type: "google.protobuf.Empty"
metadata_type: "DeleteDatasetMetadata"
};
}
// Creates an Adaptive MT dataset.
rpc CreateAdaptiveMtDataset(CreateAdaptiveMtDatasetRequest)
returns (AdaptiveMtDataset) {
@ -275,22 +395,88 @@ service TranslationService {
};
option (google.api.method_signature) = "parent";
}
// Import sentence pairs into translation Dataset.
rpc ImportData(ImportDataRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v3/{dataset=projects/*/locations/*/datasets/*}:importData"
body: "*"
};
option (google.api.method_signature) = "dataset,input_config";
option (google.longrunning.operation_info) = {
response_type: "google.protobuf.Empty"
metadata_type: "ImportDataMetadata"
};
}
// Exports dataset's data to the provided output location.
rpc ExportData(ExportDataRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v3/{dataset=projects/*/locations/*/datasets/*}:exportData"
body: "*"
};
option (google.api.method_signature) = "dataset,output_config";
option (google.longrunning.operation_info) = {
response_type: "google.protobuf.Empty"
metadata_type: "ExportDataMetadata"
};
}
// Lists sentence pairs in the dataset.
rpc ListExamples(ListExamplesRequest) returns (ListExamplesResponse) {
option (google.api.http) = {
get: "/v3/{parent=projects/*/locations/*/datasets/*}/examples"
};
option (google.api.method_signature) = "parent";
}
// Creates a Model.
rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v3/{parent=projects/*/locations/*}/models"
body: "model"
};
option (google.api.method_signature) = "parent,model";
option (google.longrunning.operation_info) = {
response_type: "Model"
metadata_type: "CreateModelMetadata"
};
}
// Lists models.
rpc ListModels(ListModelsRequest) returns (ListModelsResponse) {
option (google.api.http) = {
get: "/v3/{parent=projects/*/locations/*}/models"
};
option (google.api.method_signature) = "parent";
}
// Gets a model.
rpc GetModel(GetModelRequest) returns (Model) {
option (google.api.http) = {
get: "/v3/{name=projects/*/locations/*/models/*}"
};
option (google.api.method_signature) = "name";
}
// Deletes a model.
rpc DeleteModel(DeleteModelRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
delete: "/v3/{name=projects/*/locations/*/models/*}"
};
option (google.api.method_signature) = "name";
option (google.longrunning.operation_info) = {
response_type: "google.protobuf.Empty"
metadata_type: "DeleteModelMetadata"
};
}
}
// Configures which glossary is used for a specific target language and defines
// options for applying that glossary.
message TranslateTextGlossaryConfig {
// Required. The `glossary` to be applied for this translation.
//
// The format depends on the glossary:
//
// - User-provided custom glossary:
// `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
string glossary = 1 [(google.api.field_behavior) = REQUIRED];
// Optional. Indicates match is case insensitive. The default value is `false`
// if missing.
bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
// Configures transliteration feature on top of translation.
message TransliterationConfig {
// If true, source text in romanized form can be translated to the target
// language.
bool enable_transliteration = 1;
}
// The request message for synchronous translation.
@ -346,6 +532,8 @@ message TranslateTextRequest {
// - General (built-in) models:
// `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
//
// - Translation LLM models:
// `projects/{project-number-or-id}/locations/{location-id}/models/general/translation-llm`,
//
// For global (non-regionalized) requests, use `location-id` `global`.
// For example,
@ -360,6 +548,10 @@ message TranslateTextRequest {
TranslateTextGlossaryConfig glossary_config = 7
[(google.api.field_behavior) = OPTIONAL];
// Optional. Transliteration to be applied.
TransliterationConfig transliteration_config = 13
[(google.api.field_behavior) = OPTIONAL];
// Optional. The labels with user-defined metadata for the request.
//
// Label keys and values can be no longer than 63 characters
@ -413,6 +605,55 @@ message Translation {
TranslateTextGlossaryConfig glossary_config = 3;
}
// The request message for synchronous romanization.
message RomanizeTextRequest {
// Required. Project or location to make a call. Must refer to a caller's
// project.
//
// Format: `projects/{project-number-or-id}/locations/{location-id}` or
// `projects/{project-number-or-id}`.
//
// For global calls, use `projects/{project-number-or-id}/locations/global` or
// `projects/{project-number-or-id}`.
string parent = 4 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Required. The content of the input in string format.
repeated string contents = 1 [(google.api.field_behavior) = REQUIRED];
// Optional. The ISO-639 language code of the input text if
// known, for example, "hi" or "zh". If the source language isn't specified,
// the API attempts to identify the source language automatically and returns
// the source language for each content in the response.
string source_language_code = 2 [(google.api.field_behavior) = OPTIONAL];
}
// A single romanization response.
message Romanization {
// Romanized text.
// If an error occurs during romanization, this field might be excluded from
// the response.
string romanized_text = 1;
// The ISO-639 language code of source text in the initial request, detected
// automatically, if no source language was passed within the initial
// request. If the source language was passed, auto-detection of the language
// does not occur and this field is empty.
string detected_language_code = 2;
}
// The response message for synchronous romanization.
message RomanizeTextResponse {
// Text romanization responses.
// This field has the same length as
// [`contents`][google.cloud.translation.v3.RomanizeTextRequest.contents].
repeated Romanization romanizations = 1;
}
// The request message for language detection.
message DetectLanguageRequest {
// Required. Project or location to make a call. Must refer to a caller's
@ -1156,6 +1397,16 @@ message CreateGlossaryRequest {
Glossary glossary = 2 [(google.api.field_behavior) = REQUIRED];
}
// Request message for the update glossary flow
message UpdateGlossaryRequest {
// Required. The glossary entry to update.
Glossary glossary = 1 [(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated. Currently only `display_name` and
// 'input_config'
google.protobuf.FieldMask update_mask = 2;
}
// Request message for GetGlossary.
message GetGlossaryRequest {
// Required. The name of the glossary to retrieve.
@ -1228,6 +1479,81 @@ message ListGlossariesResponse {
string next_page_token = 2;
}
// Request message for the Get Glossary Entry Api
message GetGlossaryEntryRequest {
// Required. The resource name of the glossary entry to get
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/GlossaryEntry"
}
];
}
// Request message for Delete Glossary Entry
message DeleteGlossaryEntryRequest {
// Required. The resource name of the glossary entry to delete
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/GlossaryEntry"
}
];
}
// Request message for ListGlossaryEntries
message ListGlossaryEntriesRequest {
// Required. The parent glossary resource name for listing the glossary's
// entries.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Glossary"
}
];
// Optional. Requested page size. The server may return fewer glossary entries
// than requested. If unspecified, the server picks an appropriate default.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListGlossaryEntriesResponse.next_page_token] returned from the previous
// call. The first page is returned if `page_token`is empty or missing.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}
// Response message for ListGlossaryEntries
message ListGlossaryEntriesResponse {
// Optional. The Glossary Entries
repeated GlossaryEntry glossary_entries = 1
[(google.api.field_behavior) = OPTIONAL];
// Optional. A token to retrieve a page of results. Pass this value in the
// [ListGLossaryEntriesRequest.page_token] field in the subsequent calls.
string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
}
// Request message for CreateGlossaryEntry
message CreateGlossaryEntryRequest {
// Required. The resource name of the glossary to create the entry under.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Glossary"
}
];
// Required. The glossary entry to create
GlossaryEntry glossary_entry = 2 [(google.api.field_behavior) = REQUIRED];
}
// Request message for UpdateGlossaryEntry
message UpdateGlossaryEntryRequest {
// Required. The glossary entry to update.
GlossaryEntry glossary_entry = 1 [(google.api.field_behavior) = REQUIRED];
}
// Stored in the
// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
// field returned by CreateGlossary.
@ -1264,6 +1590,43 @@ message CreateGlossaryMetadata {
google.protobuf.Timestamp submit_time = 3;
}
// Stored in the
// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
// field returned by UpdateGlossary.
message UpdateGlossaryMetadata {
// Enumerates the possible states that the update request can be in.
enum State {
// Invalid.
STATE_UNSPECIFIED = 0;
// Request is being processed.
RUNNING = 1;
// The glossary was successfully updated.
SUCCEEDED = 2;
// Failed to update the glossary.
FAILED = 3;
// Request is in the process of being canceled after caller invoked
// longrunning.Operations.CancelOperation on the request id.
CANCELLING = 4;
// The glossary update request was successfully canceled.
CANCELLED = 5;
}
// The updated glossary object.
Glossary glossary = 1;
// The current state of the glossary update operation. If the glossary input
// file was not updated this will be completed immediately
State state = 2;
// The time when the operation was submitted to the server.
google.protobuf.Timestamp submit_time = 3;
}
// Stored in the
// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]
// field returned by DeleteGlossary.
@ -1597,3 +1960,24 @@ message BatchTranslateDocumentMetadata {
// Time when the operation was submitted.
google.protobuf.Timestamp submit_time = 10;
}
// Configures which glossary is used for a specific target language and defines
// options for applying that glossary.
message TranslateTextGlossaryConfig {
// Required. The `glossary` to be applied for this translation.
//
// The format depends on the glossary:
//
// - User-provided custom glossary:
// `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
string glossary = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "translate.googleapis.com/Glossary"
}
];
// Optional. Indicates match is case insensitive. The default value is `false`
// if missing.
bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
}