diff --git a/.bots/header-checker-lint.json b/.bots/header-checker-lint.json new file mode 100644 index 00000000..925a9db3 --- /dev/null +++ b/.bots/header-checker-lint.json @@ -0,0 +1,3 @@ +{ + "ignoreFiles": ["protos/*"] +} \ No newline at end of file diff --git a/package.json b/package.json index 00e16494..e065aa55 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "lint": "npm run check && eslint '**/*.js'", "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "system-test": "mocha build/system-test --timeout 600000", - "test": "nyc mocha build/test", + "test": "c8 mocha build/test", "check": "gts check", "clean": "gts clean", "compile": "tsc -p . && npm run copy-js", @@ -62,6 +62,7 @@ "@types/node": "^10.5.7", "@types/proxyquire": "^1.3.28", "@types/request": "^2.47.1", + "c8": "^6.0.0", "codecov": "^3.0.2", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", @@ -73,7 +74,6 @@ "jsdoc-fresh": "^1.0.1", "linkinator": "^1.5.0", "mocha": "^6.1.4", - "nyc": "^14.0.0", "power-assert": "^1.6.0", "prettier": "^1.13.5", "proxyquire": "^2.0.1", diff --git a/protos/google/cloud/translate/v3/translation_service.proto b/protos/google/cloud/translate/v3/translation_service.proto new file mode 100644 index 00000000..ad43831c --- /dev/null +++ b/protos/google/cloud/translate/v3/translation_service.proto @@ -0,0 +1,926 @@ +// Copyright 2019 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/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Translate.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/translate/v3;translate"; +option java_multiple_files = true; +option java_outer_classname = "TranslationServiceProto"; +option java_package = "com.google.cloud.translate.v3"; +option php_namespace = "Google\\Cloud\\Translate\\V3"; +option ruby_package = "Google::Cloud::Translate::V3"; + +// Proto file for the Cloud Translation API (v3 GA). + +// Provides natural language translation operations. +service TranslationService { + option (google.api.default_host) = "translate.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-translation"; + + // Translates input text and returns translated text. + rpc TranslateText(TranslateTextRequest) returns (TranslateTextResponse) { + option (google.api.http) = { + post: "/v3/{parent=projects/*/locations/*}:translateText" + body: "*" + additional_bindings { + post: "/v3/{parent=projects/*}:translateText" + body: "*" + } + }; + option (google.api.method_signature) = + "parent,target_language_code,contents"; + option (google.api.method_signature) = + "parent,model,mime_type,source_language_code,target_language_code,contents"; + } + + // Detects the language of text within a request. + rpc DetectLanguage(DetectLanguageRequest) returns (DetectLanguageResponse) { + option (google.api.http) = { + post: "/v3/{parent=projects/*/locations/*}:detectLanguage" + body: "*" + additional_bindings { + post: "/v3/{parent=projects/*}:detectLanguage" + body: "*" + } + }; + option (google.api.method_signature) = "parent,model,mime_type,content"; + } + + // Returns a list of supported languages for translation. + rpc GetSupportedLanguages(GetSupportedLanguagesRequest) + returns (SupportedLanguages) { + option (google.api.http) = { + get: "/v3/{parent=projects/*/locations/*}/supportedLanguages" + additional_bindings { get: "/v3/{parent=projects/*}/supportedLanguages" } + }; + option (google.api.method_signature) = "parent,model,display_language_code"; + } + + // Translates a large volume of text in asynchronous batch mode. + // This function provides real-time output as the inputs are being processed. + // If caller cancels a request, the partial results (for an input file, it's + // all or nothing) may still be available on the specified output location. + // + // This call returns immediately and you can + // use google.longrunning.Operation.name to poll the status of the call. + rpc BatchTranslateText(BatchTranslateTextRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{parent=projects/*/locations/*}:batchTranslateText" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "BatchTranslateResponse" + metadata_type: "BatchTranslateMetadata" + }; + } + + // Creates a glossary and returns the long-running operation. Returns + // NOT_FOUND, if the project doesn't exist. + rpc CreateGlossary(CreateGlossaryRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{parent=projects/*/locations/*}/glossaries" + body: "glossary" + }; + option (google.api.method_signature) = "parent,glossary"; + option (google.longrunning.operation_info) = { + response_type: "Glossary" + metadata_type: "CreateGlossaryMetadata" + }; + } + + // Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't + // exist. + rpc ListGlossaries(ListGlossariesRequest) returns (ListGlossariesResponse) { + option (google.api.http) = { + get: "/v3/{parent=projects/*/locations/*}/glossaries" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a glossary. Returns NOT_FOUND, if the glossary doesn't + // exist. + rpc GetGlossary(GetGlossaryRequest) returns (Glossary) { + option (google.api.http) = { + get: "/v3/{name=projects/*/locations/*/glossaries/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a glossary, or cancels glossary construction + // if the glossary isn't created yet. + // Returns NOT_FOUND, if the glossary doesn't exist. + rpc DeleteGlossary(DeleteGlossaryRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/locations/*/glossaries/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "DeleteGlossaryResponse" + metadata_type: "DeleteGlossaryMetadata" + }; + } +} + +// Configures which glossary should be used for a specific target language, +// and defines options for applying that glossary. +message TranslateTextGlossaryConfig { + // Required. Specifies the glossary used for this translation. Use + // this format: projects/*/locations/*/glossaries/* + string glossary = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates match is case-insensitive. + // Default value is false if missing. + bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message for synchronous translation. +message TranslateTextRequest { + // Required. The content of the input in string format. + // We recommend the total content be less than 30k codepoints. + // Use BatchTranslateText for larger text. + repeated string contents = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The format of the source text, for example, "text/html", + // "text/plain". If left blank, the MIME type defaults to "text/html". + string mime_type = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The BCP-47 language code of the input text if + // known, for example, "en-US" or "sr-Latn". Supported language codes are + // listed in Language Support. If the source language isn't specified, the API + // attempts to identify the source language automatically and returns the + // source language within the response. + string source_language_code = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The BCP-47 language code to use for translation of the input + // text, set to one of the language codes listed in Language Support. + string target_language_code = 5 [(google.api.field_behavior) = REQUIRED]; + + // Required. Project or location to make a call. Must refer to a caller's + // project. + // + // Format: `projects/{project-number-or-id}` or + // `projects/{project-number-or-id}/locations/{location-id}`. + // + // For global calls, use `projects/{project-number-or-id}/locations/global` or + // `projects/{project-number-or-id}`. + // + // Non-global location is required for requests using AutoML models or + // custom glossaries. + // + // Models and glossaries must be within the same region (have same + // location-id), otherwise an INVALID_ARGUMENT (400) error is returned. + string parent = 8 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Optional. The `model` type requested for this translation. + // + // The format depends on model type: + // + // - AutoML Translation models: + // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` + // + // - General (built-in) models: + // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, + // `projects/{project-number-or-id}/locations/{location-id}/models/general/base` + // + // + // For global (non-regionalized) requests, use `location-id` `global`. + // For example, + // `projects/{project-number-or-id}/locations/global/models/general/nmt`. + // + // If missing, the system decides which google base model to use. + string model = 6 [(google.api.field_behavior) = OPTIONAL]; + + // 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. + TranslateTextGlossaryConfig glossary_config = 7 + [(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 + // (Unicode codepoints), can only contain lowercase letters, numeric + // characters, underscores and dashes. International characters are allowed. + // Label values are optional. Label keys must start with a letter. + // + // See https://cloud.google.com/translate/docs/labels for more information. + map labels = 10 [(google.api.field_behavior) = OPTIONAL]; +} + +message TranslateTextResponse { + // Text translation responses with no glossary applied. + // This field has the same length as + // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents]. + repeated Translation translations = 1; + + // Text translation responses if a glossary is provided in the request. + // This can be the same as + // [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations] + // if no terms apply. This field has the same length as + // [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents]. + repeated Translation glossary_translations = 3; +} + +// A single translation response. +message Translation { + // Text translated into the target language. + string translated_text = 1; + + // Only present when `model` is present in the request. + // `model` here is normalized to have project number. + // + // For example: + // If the `model` requested in TranslationTextRequest is + // `projects/{project-id}/locations/{location-id}/models/general/nmt` then + // `model` here would be normalized to + // `projects/{project-number}/locations/{location-id}/models/general/nmt`. + string model = 2; + + // The BCP-47 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 = 4; + + // The `glossary_config` used for this translation. + TranslateTextGlossaryConfig glossary_config = 3; +} + +// The request message for language detection. +message DetectLanguageRequest { + // 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}`. + // + // Only models within the same region (has same location-id) can be used. + // Otherwise an INVALID_ARGUMENT (400) error is returned. + string parent = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Optional. The language detection model to be used. + // + // Format: + // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}` + // + // Only one language detection model is currently supported: + // `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`. + // + // If not specified, the default model is used. + string model = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The source of the document from which to detect the language. + oneof source { + // The content of the input stored as a string. + string content = 1; + } + + // Optional. The format of the source text, for example, "text/html", + // "text/plain". If left blank, the MIME type defaults to "text/html". + string mime_type = 3 [(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 + // (Unicode codepoints), can only contain lowercase letters, numeric + // characters, underscores and dashes. International characters are allowed. + // Label values are optional. Label keys must start with a letter. + // + // See https://cloud.google.com/translate/docs/labels for more information. + map labels = 6 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response message for language detection. +message DetectedLanguage { + // The BCP-47 language code of source content in the request, detected + // automatically. + string language_code = 1; + + // The confidence of the detection result for this language. + float confidence = 2; +} + +// The response message for language detection. +message DetectLanguageResponse { + // A list of detected languages sorted by detection confidence in descending + // order. The most probable language first. + repeated DetectedLanguage languages = 1; +} + +// The request message for discovering supported languages. +message GetSupportedLanguagesRequest { + // Required. Project or location to make a call. Must refer to a caller's + // project. + // + // Format: `projects/{project-number-or-id}` or + // `projects/{project-number-or-id}/locations/{location-id}`. + // + // For global calls, use `projects/{project-number-or-id}/locations/global` or + // `projects/{project-number-or-id}`. + // + // Non-global location is required for AutoML models. + // + // Only models within the same region (have same location-id) can be used, + // otherwise an INVALID_ARGUMENT (400) error is returned. + string parent = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Optional. The language to use to return localized, human readable names + // of supported languages. If missing, then display names are not returned + // in a response. + string display_language_code = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Get supported languages of this model. + // + // The format depends on model type: + // + // - AutoML Translation models: + // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` + // + // - General (built-in) models: + // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, + // `projects/{project-number-or-id}/locations/{location-id}/models/general/base` + // + // + // Returns languages supported by the specified model. + // If missing, we get supported languages of Google general base (PBMT) model. + string model = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response message for discovering supported languages. +message SupportedLanguages { + // A list of supported language responses. This list contains an entry + // for each language the Translation API supports. + repeated SupportedLanguage languages = 1; +} + +// A single supported language response corresponds to information related +// to one supported language. +message SupportedLanguage { + // Supported language code, generally consisting of its ISO 639-1 + // identifier, for example, 'en', 'ja'. In certain cases, BCP-47 codes + // including language and region identifiers are returned (for example, + // 'zh-TW' and 'zh-CN') + string language_code = 1; + + // Human readable name of the language localized in the display language + // specified in the request. + string display_name = 2; + + // Can be used as source language. + bool support_source = 3; + + // Can be used as target language. + bool support_target = 4; +} + +// The Google Cloud Storage location for the input content. +message GcsSource { + // Required. Source data URI. For example, `gs://my_bucket/my_object`. + string input_uri = 1; +} + +// Input configuration for BatchTranslateText request. +message InputConfig { + // Optional. Can be "text/plain" or "text/html". + // For `.tsv`, "text/html" is used if mime_type is missing. + // For `.html`, this field must be "text/html" or empty. + // For `.txt`, this field must be "text/plain" or empty. + string mime_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Specify the input. + oneof source { + // Required. Google Cloud Storage location for the source input. + // This can be a single file (for example, + // `gs://translation-test/input.tsv`) or a wildcard (for example, + // `gs://translation-test/*`). If a file extension is `.tsv`, it can + // contain either one or two columns. The first column (optional) is the id + // of the text request. If the first column is missing, we use the row + // number (0-based) from the input file as the ID in the output file. The + // second column is the actual text to be + // translated. We recommend each row be <= 10K Unicode codepoints, + // otherwise an error might be returned. + // Note that the input tsv must be RFC 4180 compliant. + // + // You could use https://github.com/Clever/csvlint to check potential + // formatting errors in your tsv file. + // csvlint --delimiter='\t' your_input_file.tsv + // + // The other supported file extensions are `.txt` or `.html`, which is + // treated as a single large chunk of text. + GcsSource gcs_source = 2; + } +} + +// The Google Cloud Storage location for the output content. +message GcsDestination { + // Required. There must be no files under 'output_uri_prefix'. + // 'output_uri_prefix' must end with "/" and start with "gs://", otherwise an + // INVALID_ARGUMENT (400) error is returned. + string output_uri_prefix = 1; +} + +// Output configuration for BatchTranslateText request. +message OutputConfig { + // Required. The destination of output. + oneof destination { + // Google Cloud Storage destination for output content. + // For every single input file (for example, gs://a/b/c.[extension]), we + // generate at most 2 * n output files. (n is the # of target_language_codes + // in the BatchTranslateTextRequest). + // + // Output files (tsv) generated are compliant with RFC 4180 except that + // record delimiters are '\n' instead of '\r\n'. We don't provide any way to + // change record delimiters. + // + // While the input files are being processed, we write/update an index file + // 'index.csv' under 'output_uri_prefix' (for example, + // gs://translation-test/index.csv) The index file is generated/updated as + // new files are being translated. The format is: + // + // input_file,target_language_code,translations_file,errors_file, + // glossary_translations_file,glossary_errors_file + // + // input_file is one file we matched using gcs_source.input_uri. + // target_language_code is provided in the request. + // translations_file contains the translations. (details provided below) + // errors_file contains the errors during processing of the file. (details + // below). Both translations_file and errors_file could be empty + // strings if we have no content to output. + // glossary_translations_file and glossary_errors_file are always empty + // strings if the input_file is tsv. They could also be empty if we have no + // content to output. + // + // Once a row is present in index.csv, the input/output matching never + // changes. Callers should also expect all the content in input_file are + // processed and ready to be consumed (that is, no partial output file is + // written). + // + // The format of translations_file (for target language code 'trg') is: + // gs://translation_test/a_b_c_'trg'_translations.[extension] + // + // If the input file extension is tsv, the output has the following + // columns: + // Column 1: ID of the request provided in the input, if it's not + // provided in the input, then the input row number is used (0-based). + // Column 2: source sentence. + // Column 3: translation without applying a glossary. Empty string if there + // is an error. + // Column 4 (only present if a glossary is provided in the request): + // translation after applying the glossary. Empty string if there is an + // error applying the glossary. Could be same string as column 3 if there is + // no glossary applied. + // + // If input file extension is a txt or html, the translation is directly + // written to the output file. If glossary is requested, a separate + // glossary_translations_file has format of + // gs://translation_test/a_b_c_'trg'_glossary_translations.[extension] + // + // The format of errors file (for target language code 'trg') is: + // gs://translation_test/a_b_c_'trg'_errors.[extension] + // + // If the input file extension is tsv, errors_file contains the following: + // Column 1: ID of the request provided in the input, if it's not + // provided in the input, then the input row number is used (0-based). + // Column 2: source sentence. + // Column 3: Error detail for the translation. Could be empty. + // Column 4 (only present if a glossary is provided in the request): + // Error when applying the glossary. + // + // If the input file extension is txt or html, glossary_error_file will be + // generated that contains error details. glossary_error_file has format of + // gs://translation_test/a_b_c_'trg'_glossary_errors.[extension] + GcsDestination gcs_destination = 1; + } +} + +// The batch translation request. +message BatchTranslateTextRequest { + // Required. Location to make a call. Must refer to a caller's project. + // + // Format: `projects/{project-number-or-id}/locations/{location-id}`. + // + // The `global` location is not supported for batch translation. + // + // Only AutoML Translation models or glossaries within the same region (have + // the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. Source language code. + string source_language_code = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specify up to 10 language codes here. + repeated string target_language_codes = 3 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. The models to use for translation. Map's key is target language + // code. Map's value is model name. Value can be a built-in general model, + // or an AutoML Translation model. + // + // The value format depends on model type: + // + // - AutoML Translation models: + // `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` + // + // - General (built-in) models: + // `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, + // `projects/{project-number-or-id}/locations/{location-id}/models/general/base` + // + // + // If the map is empty or a specific model is + // not requested for a language pair, then default google model (nmt) is used. + map models = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Input configurations. + // The total number of files matched should be <= 1000. + // The total content size should be <= 100M Unicode codepoints. + // The files must use UTF-8 encoding. + repeated InputConfig input_configs = 5 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Output configuration. + // If 2 input configs match to the same file (that is, same input path), + // we don't generate output for duplicate inputs. + OutputConfig output_config = 6 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Glossaries to be applied for translation. + // It's keyed by target language code. + map glossaries = 7 + [(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 + // (Unicode codepoints), can only contain lowercase letters, numeric + // characters, underscores and dashes. International characters are allowed. + // Label values are optional. Label keys must start with a letter. + // + // See https://cloud.google.com/translate/docs/labels for more information. + map labels = 9 [(google.api.field_behavior) = OPTIONAL]; +} + +// State metadata for the batch translation operation. +message BatchTranslateMetadata { + // State of the job. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is being processed. + RUNNING = 1; + + // The batch is processed, and at least one item was successfully + // processed. + SUCCEEDED = 2; + + // The batch is done and no item was successfully processed. + FAILED = 3; + + // Request is in the process of being canceled after caller invoked + // longrunning.Operations.CancelOperation on the request id. + CANCELLING = 4; + + // The batch is done after the user has called the + // longrunning.Operations.CancelOperation. Any records processed before the + // cancel command are output as specified in the request. + CANCELLED = 5; + } + + // The state of the operation. + State state = 1; + + // Number of successfully translated characters so far (Unicode codepoints). + int64 translated_characters = 2; + + // Number of characters that have failed to process so far (Unicode + // codepoints). + int64 failed_characters = 3; + + // Total number of characters (Unicode codepoints). + // This is the total number of codepoints from input files times the number of + // target languages and appears here shortly after the call is submitted. + int64 total_characters = 4; + + // Time when the operation was submitted. + google.protobuf.Timestamp submit_time = 5; +} + +// Stored in the +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field returned by BatchTranslateText if at least one sentence is translated +// successfully. +message BatchTranslateResponse { + // Total number of characters (Unicode codepoints). + int64 total_characters = 1; + + // Number of successfully translated characters (Unicode codepoints). + int64 translated_characters = 2; + + // Number of characters that have failed to process (Unicode codepoints). + int64 failed_characters = 3; + + // Time when the operation was submitted. + google.protobuf.Timestamp submit_time = 4; + + // The time when the operation is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 5; +} + +// Input configuration for glossaries. +message GlossaryInputConfig { + // Required. Specify the input. + oneof source { + // Required. Google Cloud Storage location of glossary data. + // File format is determined based on the filename extension. API returns + // [google.rpc.Code.INVALID_ARGUMENT] for unsupported URI-s and file + // formats. Wildcards are not allowed. This must be a single file in one of + // the following formats: + // + // For unidirectional glossaries: + // + // - TSV/CSV (`.tsv`/`.csv`): 2 column file, tab- or comma-separated. + // The first column is source text. The second column is target text. + // The file must not contain headers. That is, the first row is data, not + // column names. + // + // - TMX (`.tmx`): TMX file with parallel data defining source/target term + // pairs. + // + // For equivalent term sets glossaries: + // + // - CSV (`.csv`): Multi-column CSV file defining equivalent glossary terms + // in multiple languages. The format is defined for Google Translation + // Toolkit and documented in [Use a + // glossary](https://support.google.com/translatortoolkit/answer/6306379?hl=en). + GcsSource gcs_source = 1; + } +} + +// Represents a glossary built from user provided data. +message Glossary { + option (google.api.resource) = { + type: "translate.googleapis.com/Glossary" + pattern: "projects/{project}/locations/{location}/glossaries/{glossary}" + }; + + // Used with unidirectional glossaries. + message LanguageCodePair { + // Required. The BCP-47 language code of the input text, for example, + // "en-US". Expected to be an exact match for GlossaryTerm.language_code. + string source_language_code = 1; + + // Required. The BCP-47 language code for translation output, for example, + // "zh-CN". Expected to be an exact match for GlossaryTerm.language_code. + string target_language_code = 2; + } + + // Used with equivalent term set glossaries. + message LanguageCodesSet { + // The BCP-47 language code(s) for terms defined in the glossary. + // All entries are unique. The list contains at least two entries. + // Expected to be an exact match for GlossaryTerm.language_code. + repeated string language_codes = 1; + } + + // Required. The resource name of the glossary. Glossary names have the form + // `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`. + string name = 1; + + // Languages supported by the glossary. + oneof languages { + // Used with unidirectional glossaries. + LanguageCodePair language_pair = 3; + + // Used with equivalent term set glossaries. + LanguageCodesSet language_codes_set = 4; + } + + // Required. Provides examples to build the glossary from. + // Total glossary must not exceed 10M Unicode codepoints. + GlossaryInputConfig input_config = 5; + + // Output only. The number of entries defined in the glossary. + int32 entry_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. When CreateGlossary was called. + google.protobuf.Timestamp submit_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. When the glossary creation was finished. + google.protobuf.Timestamp end_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request message for CreateGlossary. +message CreateGlossaryRequest { + // Required. The project name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The glossary to create. + Glossary glossary = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for GetGlossary. +message GetGlossaryRequest { + // Required. The name of the glossary to retrieve. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "translate.googleapis.com/Glossary" + } + ]; +} + +// Request message for DeleteGlossary. +message DeleteGlossaryRequest { + // Required. The name of the glossary to delete. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "translate.googleapis.com/Glossary" + } + ]; +} + +// Request message for ListGlossaries. +message ListGlossariesRequest { + // Required. The name of the project from which to list all of the glossaries. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Optional. Requested page size. The server may return fewer glossaries 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 [ListGlossariesResponse.next_page_token] + // returned from the previous call to `ListGlossaries` method. + // The first page is returned if `page_token`is empty or missing. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Filter specifying constraints of a list operation. + // Filtering is not supported yet, and the parameter currently has no effect. + // If missing, no filtering is performed. + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message for ListGlossaries. +message ListGlossariesResponse { + // The list of glossaries for a project. + repeated Glossary glossaries = 1; + + // A token to retrieve a page of results. Pass this value in the + // [ListGlossariesRequest.page_token] field in the subsequent call to + // `ListGlossaries` method to retrieve the next page of results. + string next_page_token = 2; +} + +// Stored in the +// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata] +// field returned by CreateGlossary. +message CreateGlossaryMetadata { + // Enumerates the possible states that the creation request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is being processed. + RUNNING = 1; + + // The glossary was successfully created. + SUCCEEDED = 2; + + // Failed to create 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 creation request was successfully canceled. + CANCELLED = 5; + } + + // The name of the glossary that is being created. + string name = 1; + + // The current state of the glossary creation operation. + 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. +message DeleteGlossaryMetadata { + // Enumerates the possible states that the creation request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is being processed. + RUNNING = 1; + + // The glossary was successfully deleted. + SUCCEEDED = 2; + + // Failed to delete 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 deletion request was successfully canceled. + CANCELLED = 5; + } + + // The name of the glossary that is being deleted. + string name = 1; + + // The current state of the glossary deletion operation. + 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.response][google.longrunning.Operation.response] +// field returned by DeleteGlossary. +message DeleteGlossaryResponse { + // The name of the deleted glossary. + string name = 1; + + // The time when the operation was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the glossary deletion is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 979b9314..c9915730 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -8,6 +8,3205 @@ export namespace google { /** Namespace translation. */ namespace translation { + /** Namespace v3. */ + namespace v3 { + + /** Represents a TranslationService */ + class TranslationService extends $protobuf.rpc.Service { + + /** + * Constructs a new TranslationService service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new TranslationService service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): TranslationService; + + /** + * Calls TranslateText. + * @param request TranslateTextRequest message or plain object + * @param callback Node-style callback called with the error, if any, and TranslateTextResponse + */ + public translateText(request: google.cloud.translation.v3.ITranslateTextRequest, callback: google.cloud.translation.v3.TranslationService.TranslateTextCallback): void; + + /** + * Calls TranslateText. + * @param request TranslateTextRequest message or plain object + * @returns Promise + */ + public translateText(request: google.cloud.translation.v3.ITranslateTextRequest): Promise; + + /** + * Calls DetectLanguage. + * @param request DetectLanguageRequest message or plain object + * @param callback Node-style callback called with the error, if any, and DetectLanguageResponse + */ + public detectLanguage(request: google.cloud.translation.v3.IDetectLanguageRequest, callback: google.cloud.translation.v3.TranslationService.DetectLanguageCallback): void; + + /** + * Calls DetectLanguage. + * @param request DetectLanguageRequest message or plain object + * @returns Promise + */ + public detectLanguage(request: google.cloud.translation.v3.IDetectLanguageRequest): Promise; + + /** + * Calls GetSupportedLanguages. + * @param request GetSupportedLanguagesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SupportedLanguages + */ + public getSupportedLanguages(request: google.cloud.translation.v3.IGetSupportedLanguagesRequest, callback: google.cloud.translation.v3.TranslationService.GetSupportedLanguagesCallback): void; + + /** + * Calls GetSupportedLanguages. + * @param request GetSupportedLanguagesRequest message or plain object + * @returns Promise + */ + public getSupportedLanguages(request: google.cloud.translation.v3.IGetSupportedLanguagesRequest): Promise; + + /** + * Calls BatchTranslateText. + * @param request BatchTranslateTextRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public batchTranslateText(request: google.cloud.translation.v3.IBatchTranslateTextRequest, callback: google.cloud.translation.v3.TranslationService.BatchTranslateTextCallback): void; + + /** + * Calls BatchTranslateText. + * @param request BatchTranslateTextRequest message or plain object + * @returns Promise + */ + public batchTranslateText(request: google.cloud.translation.v3.IBatchTranslateTextRequest): Promise; + + /** + * Calls CreateGlossary. + * @param request CreateGlossaryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createGlossary(request: google.cloud.translation.v3.ICreateGlossaryRequest, callback: google.cloud.translation.v3.TranslationService.CreateGlossaryCallback): void; + + /** + * Calls CreateGlossary. + * @param request CreateGlossaryRequest message or plain object + * @returns Promise + */ + public createGlossary(request: google.cloud.translation.v3.ICreateGlossaryRequest): Promise; + + /** + * Calls ListGlossaries. + * @param request ListGlossariesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListGlossariesResponse + */ + public listGlossaries(request: google.cloud.translation.v3.IListGlossariesRequest, callback: google.cloud.translation.v3.TranslationService.ListGlossariesCallback): void; + + /** + * Calls ListGlossaries. + * @param request ListGlossariesRequest message or plain object + * @returns Promise + */ + public listGlossaries(request: google.cloud.translation.v3.IListGlossariesRequest): Promise; + + /** + * Calls GetGlossary. + * @param request GetGlossaryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Glossary + */ + public getGlossary(request: google.cloud.translation.v3.IGetGlossaryRequest, callback: google.cloud.translation.v3.TranslationService.GetGlossaryCallback): void; + + /** + * Calls GetGlossary. + * @param request GetGlossaryRequest message or plain object + * @returns Promise + */ + public getGlossary(request: google.cloud.translation.v3.IGetGlossaryRequest): Promise; + + /** + * Calls DeleteGlossary. + * @param request DeleteGlossaryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deleteGlossary(request: google.cloud.translation.v3.IDeleteGlossaryRequest, callback: google.cloud.translation.v3.TranslationService.DeleteGlossaryCallback): void; + + /** + * Calls DeleteGlossary. + * @param request DeleteGlossaryRequest message or plain object + * @returns Promise + */ + public deleteGlossary(request: google.cloud.translation.v3.IDeleteGlossaryRequest): Promise; + } + + namespace TranslationService { + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#translateText}. + * @param error Error, if any + * @param [response] TranslateTextResponse + */ + type TranslateTextCallback = (error: (Error|null), response?: google.cloud.translation.v3.TranslateTextResponse) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#detectLanguage}. + * @param error Error, if any + * @param [response] DetectLanguageResponse + */ + type DetectLanguageCallback = (error: (Error|null), response?: google.cloud.translation.v3.DetectLanguageResponse) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#getSupportedLanguages}. + * @param error Error, if any + * @param [response] SupportedLanguages + */ + type GetSupportedLanguagesCallback = (error: (Error|null), response?: google.cloud.translation.v3.SupportedLanguages) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#batchTranslateText}. + * @param error Error, if any + * @param [response] Operation + */ + type BatchTranslateTextCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#createGlossary}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateGlossaryCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#listGlossaries}. + * @param error Error, if any + * @param [response] ListGlossariesResponse + */ + type ListGlossariesCallback = (error: (Error|null), response?: google.cloud.translation.v3.ListGlossariesResponse) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#getGlossary}. + * @param error Error, if any + * @param [response] Glossary + */ + type GetGlossaryCallback = (error: (Error|null), response?: google.cloud.translation.v3.Glossary) => void; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#deleteGlossary}. + * @param error Error, if any + * @param [response] Operation + */ + type DeleteGlossaryCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a TranslateTextGlossaryConfig. */ + interface ITranslateTextGlossaryConfig { + + /** TranslateTextGlossaryConfig glossary */ + glossary?: (string|null); + + /** TranslateTextGlossaryConfig ignoreCase */ + ignoreCase?: (boolean|null); + } + + /** Represents a TranslateTextGlossaryConfig. */ + class TranslateTextGlossaryConfig implements ITranslateTextGlossaryConfig { + + /** + * Constructs a new TranslateTextGlossaryConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ITranslateTextGlossaryConfig); + + /** TranslateTextGlossaryConfig glossary. */ + public glossary: string; + + /** TranslateTextGlossaryConfig ignoreCase. */ + public ignoreCase: boolean; + + /** + * Creates a new TranslateTextGlossaryConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns TranslateTextGlossaryConfig instance + */ + public static create(properties?: google.cloud.translation.v3.ITranslateTextGlossaryConfig): google.cloud.translation.v3.TranslateTextGlossaryConfig; + + /** + * Encodes the specified TranslateTextGlossaryConfig message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextGlossaryConfig.verify|verify} messages. + * @param message TranslateTextGlossaryConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ITranslateTextGlossaryConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TranslateTextGlossaryConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextGlossaryConfig.verify|verify} messages. + * @param message TranslateTextGlossaryConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ITranslateTextGlossaryConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TranslateTextGlossaryConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TranslateTextGlossaryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.TranslateTextGlossaryConfig; + + /** + * Decodes a TranslateTextGlossaryConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TranslateTextGlossaryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.TranslateTextGlossaryConfig; + + /** + * Verifies a TranslateTextGlossaryConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TranslateTextGlossaryConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TranslateTextGlossaryConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.TranslateTextGlossaryConfig; + + /** + * Creates a plain object from a TranslateTextGlossaryConfig message. Also converts values to other types if specified. + * @param message TranslateTextGlossaryConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.TranslateTextGlossaryConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TranslateTextGlossaryConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a TranslateTextRequest. */ + interface ITranslateTextRequest { + + /** TranslateTextRequest contents */ + contents?: (string[]|null); + + /** TranslateTextRequest mimeType */ + mimeType?: (string|null); + + /** TranslateTextRequest sourceLanguageCode */ + sourceLanguageCode?: (string|null); + + /** TranslateTextRequest targetLanguageCode */ + targetLanguageCode?: (string|null); + + /** TranslateTextRequest parent */ + parent?: (string|null); + + /** TranslateTextRequest model */ + model?: (string|null); + + /** TranslateTextRequest glossaryConfig */ + glossaryConfig?: (google.cloud.translation.v3.ITranslateTextGlossaryConfig|null); + + /** TranslateTextRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a TranslateTextRequest. */ + class TranslateTextRequest implements ITranslateTextRequest { + + /** + * Constructs a new TranslateTextRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ITranslateTextRequest); + + /** TranslateTextRequest contents. */ + public contents: string[]; + + /** TranslateTextRequest mimeType. */ + public mimeType: string; + + /** TranslateTextRequest sourceLanguageCode. */ + public sourceLanguageCode: string; + + /** TranslateTextRequest targetLanguageCode. */ + public targetLanguageCode: string; + + /** TranslateTextRequest parent. */ + public parent: string; + + /** TranslateTextRequest model. */ + public model: string; + + /** TranslateTextRequest glossaryConfig. */ + public glossaryConfig?: (google.cloud.translation.v3.ITranslateTextGlossaryConfig|null); + + /** TranslateTextRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a new TranslateTextRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns TranslateTextRequest instance + */ + public static create(properties?: google.cloud.translation.v3.ITranslateTextRequest): google.cloud.translation.v3.TranslateTextRequest; + + /** + * Encodes the specified TranslateTextRequest message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextRequest.verify|verify} messages. + * @param message TranslateTextRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ITranslateTextRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TranslateTextRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextRequest.verify|verify} messages. + * @param message TranslateTextRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ITranslateTextRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TranslateTextRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.TranslateTextRequest; + + /** + * Decodes a TranslateTextRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.TranslateTextRequest; + + /** + * Verifies a TranslateTextRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TranslateTextRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TranslateTextRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.TranslateTextRequest; + + /** + * Creates a plain object from a TranslateTextRequest message. Also converts values to other types if specified. + * @param message TranslateTextRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.TranslateTextRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TranslateTextRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a TranslateTextResponse. */ + interface ITranslateTextResponse { + + /** TranslateTextResponse translations */ + translations?: (google.cloud.translation.v3.ITranslation[]|null); + + /** TranslateTextResponse glossaryTranslations */ + glossaryTranslations?: (google.cloud.translation.v3.ITranslation[]|null); + } + + /** Represents a TranslateTextResponse. */ + class TranslateTextResponse implements ITranslateTextResponse { + + /** + * Constructs a new TranslateTextResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ITranslateTextResponse); + + /** TranslateTextResponse translations. */ + public translations: google.cloud.translation.v3.ITranslation[]; + + /** TranslateTextResponse glossaryTranslations. */ + public glossaryTranslations: google.cloud.translation.v3.ITranslation[]; + + /** + * Creates a new TranslateTextResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns TranslateTextResponse instance + */ + public static create(properties?: google.cloud.translation.v3.ITranslateTextResponse): google.cloud.translation.v3.TranslateTextResponse; + + /** + * Encodes the specified TranslateTextResponse message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextResponse.verify|verify} messages. + * @param message TranslateTextResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ITranslateTextResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TranslateTextResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextResponse.verify|verify} messages. + * @param message TranslateTextResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ITranslateTextResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TranslateTextResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TranslateTextResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.TranslateTextResponse; + + /** + * Decodes a TranslateTextResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TranslateTextResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.TranslateTextResponse; + + /** + * Verifies a TranslateTextResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TranslateTextResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TranslateTextResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.TranslateTextResponse; + + /** + * Creates a plain object from a TranslateTextResponse message. Also converts values to other types if specified. + * @param message TranslateTextResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.TranslateTextResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TranslateTextResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Translation. */ + interface ITranslation { + + /** Translation translatedText */ + translatedText?: (string|null); + + /** Translation model */ + model?: (string|null); + + /** Translation detectedLanguageCode */ + detectedLanguageCode?: (string|null); + + /** Translation glossaryConfig */ + glossaryConfig?: (google.cloud.translation.v3.ITranslateTextGlossaryConfig|null); + } + + /** Represents a Translation. */ + class Translation implements ITranslation { + + /** + * Constructs a new Translation. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ITranslation); + + /** Translation translatedText. */ + public translatedText: string; + + /** Translation model. */ + public model: string; + + /** Translation detectedLanguageCode. */ + public detectedLanguageCode: string; + + /** Translation glossaryConfig. */ + public glossaryConfig?: (google.cloud.translation.v3.ITranslateTextGlossaryConfig|null); + + /** + * Creates a new Translation instance using the specified properties. + * @param [properties] Properties to set + * @returns Translation instance + */ + public static create(properties?: google.cloud.translation.v3.ITranslation): google.cloud.translation.v3.Translation; + + /** + * Encodes the specified Translation message. Does not implicitly {@link google.cloud.translation.v3.Translation.verify|verify} messages. + * @param message Translation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ITranslation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Translation message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Translation.verify|verify} messages. + * @param message Translation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ITranslation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Translation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Translation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.Translation; + + /** + * Decodes a Translation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Translation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.Translation; + + /** + * Verifies a Translation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Translation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Translation + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.Translation; + + /** + * Creates a plain object from a Translation message. Also converts values to other types if specified. + * @param message Translation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.Translation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Translation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DetectLanguageRequest. */ + interface IDetectLanguageRequest { + + /** DetectLanguageRequest parent */ + parent?: (string|null); + + /** DetectLanguageRequest model */ + model?: (string|null); + + /** DetectLanguageRequest content */ + content?: (string|null); + + /** DetectLanguageRequest mimeType */ + mimeType?: (string|null); + + /** DetectLanguageRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a DetectLanguageRequest. */ + class DetectLanguageRequest implements IDetectLanguageRequest { + + /** + * Constructs a new DetectLanguageRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDetectLanguageRequest); + + /** DetectLanguageRequest parent. */ + public parent: string; + + /** DetectLanguageRequest model. */ + public model: string; + + /** DetectLanguageRequest content. */ + public content: string; + + /** DetectLanguageRequest mimeType. */ + public mimeType: string; + + /** DetectLanguageRequest labels. */ + public labels: { [k: string]: string }; + + /** DetectLanguageRequest source. */ + public source?: "content"; + + /** + * Creates a new DetectLanguageRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DetectLanguageRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IDetectLanguageRequest): google.cloud.translation.v3.DetectLanguageRequest; + + /** + * Encodes the specified DetectLanguageRequest message. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageRequest.verify|verify} messages. + * @param message DetectLanguageRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDetectLanguageRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DetectLanguageRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageRequest.verify|verify} messages. + * @param message DetectLanguageRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDetectLanguageRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DetectLanguageRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DetectLanguageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DetectLanguageRequest; + + /** + * Decodes a DetectLanguageRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DetectLanguageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DetectLanguageRequest; + + /** + * Verifies a DetectLanguageRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DetectLanguageRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DetectLanguageRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DetectLanguageRequest; + + /** + * Creates a plain object from a DetectLanguageRequest message. Also converts values to other types if specified. + * @param message DetectLanguageRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DetectLanguageRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DetectLanguageRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DetectedLanguage. */ + interface IDetectedLanguage { + + /** DetectedLanguage languageCode */ + languageCode?: (string|null); + + /** DetectedLanguage confidence */ + confidence?: (number|null); + } + + /** Represents a DetectedLanguage. */ + class DetectedLanguage implements IDetectedLanguage { + + /** + * Constructs a new DetectedLanguage. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDetectedLanguage); + + /** DetectedLanguage languageCode. */ + public languageCode: string; + + /** DetectedLanguage confidence. */ + public confidence: number; + + /** + * Creates a new DetectedLanguage instance using the specified properties. + * @param [properties] Properties to set + * @returns DetectedLanguage instance + */ + public static create(properties?: google.cloud.translation.v3.IDetectedLanguage): google.cloud.translation.v3.DetectedLanguage; + + /** + * Encodes the specified DetectedLanguage message. Does not implicitly {@link google.cloud.translation.v3.DetectedLanguage.verify|verify} messages. + * @param message DetectedLanguage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDetectedLanguage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DetectedLanguage message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectedLanguage.verify|verify} messages. + * @param message DetectedLanguage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDetectedLanguage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DetectedLanguage message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DetectedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DetectedLanguage; + + /** + * Decodes a DetectedLanguage message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DetectedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DetectedLanguage; + + /** + * Verifies a DetectedLanguage message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DetectedLanguage message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DetectedLanguage + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DetectedLanguage; + + /** + * Creates a plain object from a DetectedLanguage message. Also converts values to other types if specified. + * @param message DetectedLanguage + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DetectedLanguage, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DetectedLanguage to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DetectLanguageResponse. */ + interface IDetectLanguageResponse { + + /** DetectLanguageResponse languages */ + languages?: (google.cloud.translation.v3.IDetectedLanguage[]|null); + } + + /** Represents a DetectLanguageResponse. */ + class DetectLanguageResponse implements IDetectLanguageResponse { + + /** + * Constructs a new DetectLanguageResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDetectLanguageResponse); + + /** DetectLanguageResponse languages. */ + public languages: google.cloud.translation.v3.IDetectedLanguage[]; + + /** + * Creates a new DetectLanguageResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns DetectLanguageResponse instance + */ + public static create(properties?: google.cloud.translation.v3.IDetectLanguageResponse): google.cloud.translation.v3.DetectLanguageResponse; + + /** + * Encodes the specified DetectLanguageResponse message. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageResponse.verify|verify} messages. + * @param message DetectLanguageResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDetectLanguageResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DetectLanguageResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageResponse.verify|verify} messages. + * @param message DetectLanguageResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDetectLanguageResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DetectLanguageResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DetectLanguageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DetectLanguageResponse; + + /** + * Decodes a DetectLanguageResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DetectLanguageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DetectLanguageResponse; + + /** + * Verifies a DetectLanguageResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DetectLanguageResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DetectLanguageResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DetectLanguageResponse; + + /** + * Creates a plain object from a DetectLanguageResponse message. Also converts values to other types if specified. + * @param message DetectLanguageResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DetectLanguageResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DetectLanguageResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetSupportedLanguagesRequest. */ + interface IGetSupportedLanguagesRequest { + + /** GetSupportedLanguagesRequest parent */ + parent?: (string|null); + + /** GetSupportedLanguagesRequest displayLanguageCode */ + displayLanguageCode?: (string|null); + + /** GetSupportedLanguagesRequest model */ + model?: (string|null); + } + + /** Represents a GetSupportedLanguagesRequest. */ + class GetSupportedLanguagesRequest implements IGetSupportedLanguagesRequest { + + /** + * Constructs a new GetSupportedLanguagesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGetSupportedLanguagesRequest); + + /** GetSupportedLanguagesRequest parent. */ + public parent: string; + + /** GetSupportedLanguagesRequest displayLanguageCode. */ + public displayLanguageCode: string; + + /** GetSupportedLanguagesRequest model. */ + public model: string; + + /** + * Creates a new GetSupportedLanguagesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetSupportedLanguagesRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IGetSupportedLanguagesRequest): google.cloud.translation.v3.GetSupportedLanguagesRequest; + + /** + * Encodes the specified GetSupportedLanguagesRequest message. Does not implicitly {@link google.cloud.translation.v3.GetSupportedLanguagesRequest.verify|verify} messages. + * @param message GetSupportedLanguagesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGetSupportedLanguagesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetSupportedLanguagesRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GetSupportedLanguagesRequest.verify|verify} messages. + * @param message GetSupportedLanguagesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGetSupportedLanguagesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetSupportedLanguagesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetSupportedLanguagesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.GetSupportedLanguagesRequest; + + /** + * Decodes a GetSupportedLanguagesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetSupportedLanguagesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.GetSupportedLanguagesRequest; + + /** + * Verifies a GetSupportedLanguagesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetSupportedLanguagesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetSupportedLanguagesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.GetSupportedLanguagesRequest; + + /** + * Creates a plain object from a GetSupportedLanguagesRequest message. Also converts values to other types if specified. + * @param message GetSupportedLanguagesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.GetSupportedLanguagesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetSupportedLanguagesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SupportedLanguages. */ + interface ISupportedLanguages { + + /** SupportedLanguages languages */ + languages?: (google.cloud.translation.v3.ISupportedLanguage[]|null); + } + + /** Represents a SupportedLanguages. */ + class SupportedLanguages implements ISupportedLanguages { + + /** + * Constructs a new SupportedLanguages. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ISupportedLanguages); + + /** SupportedLanguages languages. */ + public languages: google.cloud.translation.v3.ISupportedLanguage[]; + + /** + * Creates a new SupportedLanguages instance using the specified properties. + * @param [properties] Properties to set + * @returns SupportedLanguages instance + */ + public static create(properties?: google.cloud.translation.v3.ISupportedLanguages): google.cloud.translation.v3.SupportedLanguages; + + /** + * Encodes the specified SupportedLanguages message. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguages.verify|verify} messages. + * @param message SupportedLanguages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ISupportedLanguages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SupportedLanguages message, length delimited. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguages.verify|verify} messages. + * @param message SupportedLanguages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ISupportedLanguages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SupportedLanguages message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SupportedLanguages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.SupportedLanguages; + + /** + * Decodes a SupportedLanguages message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SupportedLanguages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.SupportedLanguages; + + /** + * Verifies a SupportedLanguages message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SupportedLanguages message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SupportedLanguages + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.SupportedLanguages; + + /** + * Creates a plain object from a SupportedLanguages message. Also converts values to other types if specified. + * @param message SupportedLanguages + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.SupportedLanguages, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SupportedLanguages to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SupportedLanguage. */ + interface ISupportedLanguage { + + /** SupportedLanguage languageCode */ + languageCode?: (string|null); + + /** SupportedLanguage displayName */ + displayName?: (string|null); + + /** SupportedLanguage supportSource */ + supportSource?: (boolean|null); + + /** SupportedLanguage supportTarget */ + supportTarget?: (boolean|null); + } + + /** Represents a SupportedLanguage. */ + class SupportedLanguage implements ISupportedLanguage { + + /** + * Constructs a new SupportedLanguage. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ISupportedLanguage); + + /** SupportedLanguage languageCode. */ + public languageCode: string; + + /** SupportedLanguage displayName. */ + public displayName: string; + + /** SupportedLanguage supportSource. */ + public supportSource: boolean; + + /** SupportedLanguage supportTarget. */ + public supportTarget: boolean; + + /** + * Creates a new SupportedLanguage instance using the specified properties. + * @param [properties] Properties to set + * @returns SupportedLanguage instance + */ + public static create(properties?: google.cloud.translation.v3.ISupportedLanguage): google.cloud.translation.v3.SupportedLanguage; + + /** + * Encodes the specified SupportedLanguage message. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguage.verify|verify} messages. + * @param message SupportedLanguage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ISupportedLanguage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SupportedLanguage message, length delimited. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguage.verify|verify} messages. + * @param message SupportedLanguage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ISupportedLanguage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SupportedLanguage message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SupportedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.SupportedLanguage; + + /** + * Decodes a SupportedLanguage message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SupportedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.SupportedLanguage; + + /** + * Verifies a SupportedLanguage message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SupportedLanguage message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SupportedLanguage + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.SupportedLanguage; + + /** + * Creates a plain object from a SupportedLanguage message. Also converts values to other types if specified. + * @param message SupportedLanguage + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.SupportedLanguage, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SupportedLanguage to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GcsSource. */ + interface IGcsSource { + + /** GcsSource inputUri */ + inputUri?: (string|null); + } + + /** Represents a GcsSource. */ + class GcsSource implements IGcsSource { + + /** + * Constructs a new GcsSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGcsSource); + + /** GcsSource inputUri. */ + public inputUri: string; + + /** + * Creates a new GcsSource instance using the specified properties. + * @param [properties] Properties to set + * @returns GcsSource instance + */ + public static create(properties?: google.cloud.translation.v3.IGcsSource): google.cloud.translation.v3.GcsSource; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.translation.v3.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.GcsSource; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.GcsSource; + + /** + * Verifies a GcsSource message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GcsSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GcsSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.GcsSource; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @param message GcsSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.GcsSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GcsSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an InputConfig. */ + interface IInputConfig { + + /** InputConfig mimeType */ + mimeType?: (string|null); + + /** InputConfig gcsSource */ + gcsSource?: (google.cloud.translation.v3.IGcsSource|null); + } + + /** Represents an InputConfig. */ + class InputConfig implements IInputConfig { + + /** + * Constructs a new InputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IInputConfig); + + /** InputConfig mimeType. */ + public mimeType: string; + + /** InputConfig gcsSource. */ + public gcsSource?: (google.cloud.translation.v3.IGcsSource|null); + + /** InputConfig source. */ + public source?: "gcsSource"; + + /** + * Creates a new InputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns InputConfig instance + */ + public static create(properties?: google.cloud.translation.v3.IInputConfig): google.cloud.translation.v3.InputConfig; + + /** + * Encodes the specified InputConfig message. Does not implicitly {@link google.cloud.translation.v3.InputConfig.verify|verify} messages. + * @param message InputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified InputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.InputConfig.verify|verify} messages. + * @param message InputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns InputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.InputConfig; + + /** + * Decodes an InputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns InputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.InputConfig; + + /** + * Verifies an InputConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an InputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns InputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.InputConfig; + + /** + * Creates a plain object from an InputConfig message. Also converts values to other types if specified. + * @param message InputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.InputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this InputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GcsDestination. */ + interface IGcsDestination { + + /** GcsDestination outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents a GcsDestination. */ + class GcsDestination implements IGcsDestination { + + /** + * Constructs a new GcsDestination. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGcsDestination); + + /** GcsDestination outputUriPrefix. */ + public outputUriPrefix: string; + + /** + * Creates a new GcsDestination instance using the specified properties. + * @param [properties] Properties to set + * @returns GcsDestination instance + */ + public static create(properties?: google.cloud.translation.v3.IGcsDestination): google.cloud.translation.v3.GcsDestination; + + /** + * Encodes the specified GcsDestination message. Does not implicitly {@link google.cloud.translation.v3.GcsDestination.verify|verify} messages. + * @param message GcsDestination message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGcsDestination, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GcsDestination message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GcsDestination.verify|verify} messages. + * @param message GcsDestination message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGcsDestination, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GcsDestination message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GcsDestination + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.GcsDestination; + + /** + * Decodes a GcsDestination message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GcsDestination + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.GcsDestination; + + /** + * Verifies a GcsDestination message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GcsDestination message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GcsDestination + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.GcsDestination; + + /** + * Creates a plain object from a GcsDestination message. Also converts values to other types if specified. + * @param message GcsDestination + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.GcsDestination, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GcsDestination to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an OutputConfig. */ + interface IOutputConfig { + + /** OutputConfig gcsDestination */ + gcsDestination?: (google.cloud.translation.v3.IGcsDestination|null); + } + + /** Represents an OutputConfig. */ + class OutputConfig implements IOutputConfig { + + /** + * Constructs a new OutputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IOutputConfig); + + /** OutputConfig gcsDestination. */ + public gcsDestination?: (google.cloud.translation.v3.IGcsDestination|null); + + /** OutputConfig destination. */ + public destination?: "gcsDestination"; + + /** + * Creates a new OutputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns OutputConfig instance + */ + public static create(properties?: google.cloud.translation.v3.IOutputConfig): google.cloud.translation.v3.OutputConfig; + + /** + * Encodes the specified OutputConfig message. Does not implicitly {@link google.cloud.translation.v3.OutputConfig.verify|verify} messages. + * @param message OutputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IOutputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OutputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.OutputConfig.verify|verify} messages. + * @param message OutputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IOutputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OutputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.OutputConfig; + + /** + * Decodes an OutputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.OutputConfig; + + /** + * Verifies an OutputConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OutputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OutputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.OutputConfig; + + /** + * Creates a plain object from an OutputConfig message. Also converts values to other types if specified. + * @param message OutputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.OutputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OutputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchTranslateTextRequest. */ + interface IBatchTranslateTextRequest { + + /** BatchTranslateTextRequest parent */ + parent?: (string|null); + + /** BatchTranslateTextRequest sourceLanguageCode */ + sourceLanguageCode?: (string|null); + + /** BatchTranslateTextRequest targetLanguageCodes */ + targetLanguageCodes?: (string[]|null); + + /** BatchTranslateTextRequest models */ + models?: ({ [k: string]: string }|null); + + /** BatchTranslateTextRequest inputConfigs */ + inputConfigs?: (google.cloud.translation.v3.IInputConfig[]|null); + + /** BatchTranslateTextRequest outputConfig */ + outputConfig?: (google.cloud.translation.v3.IOutputConfig|null); + + /** BatchTranslateTextRequest glossaries */ + glossaries?: ({ [k: string]: google.cloud.translation.v3.ITranslateTextGlossaryConfig }|null); + + /** BatchTranslateTextRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a BatchTranslateTextRequest. */ + class BatchTranslateTextRequest implements IBatchTranslateTextRequest { + + /** + * Constructs a new BatchTranslateTextRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IBatchTranslateTextRequest); + + /** BatchTranslateTextRequest parent. */ + public parent: string; + + /** BatchTranslateTextRequest sourceLanguageCode. */ + public sourceLanguageCode: string; + + /** BatchTranslateTextRequest targetLanguageCodes. */ + public targetLanguageCodes: string[]; + + /** BatchTranslateTextRequest models. */ + public models: { [k: string]: string }; + + /** BatchTranslateTextRequest inputConfigs. */ + public inputConfigs: google.cloud.translation.v3.IInputConfig[]; + + /** BatchTranslateTextRequest outputConfig. */ + public outputConfig?: (google.cloud.translation.v3.IOutputConfig|null); + + /** BatchTranslateTextRequest glossaries. */ + public glossaries: { [k: string]: google.cloud.translation.v3.ITranslateTextGlossaryConfig }; + + /** BatchTranslateTextRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a new BatchTranslateTextRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchTranslateTextRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IBatchTranslateTextRequest): google.cloud.translation.v3.BatchTranslateTextRequest; + + /** + * Encodes the specified BatchTranslateTextRequest message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateTextRequest.verify|verify} messages. + * @param message BatchTranslateTextRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IBatchTranslateTextRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchTranslateTextRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateTextRequest.verify|verify} messages. + * @param message BatchTranslateTextRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IBatchTranslateTextRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchTranslateTextRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchTranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.BatchTranslateTextRequest; + + /** + * Decodes a BatchTranslateTextRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchTranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.BatchTranslateTextRequest; + + /** + * Verifies a BatchTranslateTextRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BatchTranslateTextRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchTranslateTextRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.BatchTranslateTextRequest; + + /** + * Creates a plain object from a BatchTranslateTextRequest message. Also converts values to other types if specified. + * @param message BatchTranslateTextRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.BatchTranslateTextRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchTranslateTextRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchTranslateMetadata. */ + interface IBatchTranslateMetadata { + + /** BatchTranslateMetadata state */ + state?: (google.cloud.translation.v3.BatchTranslateMetadata.State|null); + + /** BatchTranslateMetadata translatedCharacters */ + translatedCharacters?: (number|Long|null); + + /** BatchTranslateMetadata failedCharacters */ + failedCharacters?: (number|Long|null); + + /** BatchTranslateMetadata totalCharacters */ + totalCharacters?: (number|Long|null); + + /** BatchTranslateMetadata submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchTranslateMetadata. */ + class BatchTranslateMetadata implements IBatchTranslateMetadata { + + /** + * Constructs a new BatchTranslateMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IBatchTranslateMetadata); + + /** BatchTranslateMetadata state. */ + public state: google.cloud.translation.v3.BatchTranslateMetadata.State; + + /** BatchTranslateMetadata translatedCharacters. */ + public translatedCharacters: (number|Long); + + /** BatchTranslateMetadata failedCharacters. */ + public failedCharacters: (number|Long); + + /** BatchTranslateMetadata totalCharacters. */ + public totalCharacters: (number|Long); + + /** BatchTranslateMetadata submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new BatchTranslateMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchTranslateMetadata instance + */ + public static create(properties?: google.cloud.translation.v3.IBatchTranslateMetadata): google.cloud.translation.v3.BatchTranslateMetadata; + + /** + * Encodes the specified BatchTranslateMetadata message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateMetadata.verify|verify} messages. + * @param message BatchTranslateMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IBatchTranslateMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchTranslateMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateMetadata.verify|verify} messages. + * @param message BatchTranslateMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IBatchTranslateMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchTranslateMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchTranslateMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.BatchTranslateMetadata; + + /** + * Decodes a BatchTranslateMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchTranslateMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.BatchTranslateMetadata; + + /** + * Verifies a BatchTranslateMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BatchTranslateMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchTranslateMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.BatchTranslateMetadata; + + /** + * Creates a plain object from a BatchTranslateMetadata message. Also converts values to other types if specified. + * @param message BatchTranslateMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.BatchTranslateMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchTranslateMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BatchTranslateMetadata { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + RUNNING = 1, + SUCCEEDED = 2, + FAILED = 3, + CANCELLING = 4, + CANCELLED = 5 + } + } + + /** Properties of a BatchTranslateResponse. */ + interface IBatchTranslateResponse { + + /** BatchTranslateResponse totalCharacters */ + totalCharacters?: (number|Long|null); + + /** BatchTranslateResponse translatedCharacters */ + translatedCharacters?: (number|Long|null); + + /** BatchTranslateResponse failedCharacters */ + failedCharacters?: (number|Long|null); + + /** BatchTranslateResponse submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + + /** BatchTranslateResponse endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchTranslateResponse. */ + class BatchTranslateResponse implements IBatchTranslateResponse { + + /** + * Constructs a new BatchTranslateResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IBatchTranslateResponse); + + /** BatchTranslateResponse totalCharacters. */ + public totalCharacters: (number|Long); + + /** BatchTranslateResponse translatedCharacters. */ + public translatedCharacters: (number|Long); + + /** BatchTranslateResponse failedCharacters. */ + public failedCharacters: (number|Long); + + /** BatchTranslateResponse submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** BatchTranslateResponse endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new BatchTranslateResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchTranslateResponse instance + */ + public static create(properties?: google.cloud.translation.v3.IBatchTranslateResponse): google.cloud.translation.v3.BatchTranslateResponse; + + /** + * Encodes the specified BatchTranslateResponse message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateResponse.verify|verify} messages. + * @param message BatchTranslateResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IBatchTranslateResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchTranslateResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateResponse.verify|verify} messages. + * @param message BatchTranslateResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IBatchTranslateResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchTranslateResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchTranslateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.BatchTranslateResponse; + + /** + * Decodes a BatchTranslateResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchTranslateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.BatchTranslateResponse; + + /** + * Verifies a BatchTranslateResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BatchTranslateResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchTranslateResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.BatchTranslateResponse; + + /** + * Creates a plain object from a BatchTranslateResponse message. Also converts values to other types if specified. + * @param message BatchTranslateResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.BatchTranslateResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchTranslateResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GlossaryInputConfig. */ + interface IGlossaryInputConfig { + + /** GlossaryInputConfig gcsSource */ + gcsSource?: (google.cloud.translation.v3.IGcsSource|null); + } + + /** Represents a GlossaryInputConfig. */ + class GlossaryInputConfig implements IGlossaryInputConfig { + + /** + * Constructs a new GlossaryInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGlossaryInputConfig); + + /** GlossaryInputConfig gcsSource. */ + public gcsSource?: (google.cloud.translation.v3.IGcsSource|null); + + /** GlossaryInputConfig source. */ + public source?: "gcsSource"; + + /** + * Creates a new GlossaryInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns GlossaryInputConfig instance + */ + public static create(properties?: google.cloud.translation.v3.IGlossaryInputConfig): google.cloud.translation.v3.GlossaryInputConfig; + + /** + * Encodes the specified GlossaryInputConfig message. Does not implicitly {@link google.cloud.translation.v3.GlossaryInputConfig.verify|verify} messages. + * @param message GlossaryInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGlossaryInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GlossaryInputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GlossaryInputConfig.verify|verify} messages. + * @param message GlossaryInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGlossaryInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GlossaryInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GlossaryInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.GlossaryInputConfig; + + /** + * Decodes a GlossaryInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GlossaryInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.GlossaryInputConfig; + + /** + * Verifies a GlossaryInputConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GlossaryInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GlossaryInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.GlossaryInputConfig; + + /** + * Creates a plain object from a GlossaryInputConfig message. Also converts values to other types if specified. + * @param message GlossaryInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.GlossaryInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GlossaryInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Glossary. */ + interface IGlossary { + + /** Glossary name */ + name?: (string|null); + + /** Glossary languagePair */ + languagePair?: (google.cloud.translation.v3.Glossary.ILanguageCodePair|null); + + /** Glossary languageCodesSet */ + languageCodesSet?: (google.cloud.translation.v3.Glossary.ILanguageCodesSet|null); + + /** Glossary inputConfig */ + inputConfig?: (google.cloud.translation.v3.IGlossaryInputConfig|null); + + /** Glossary entryCount */ + entryCount?: (number|null); + + /** Glossary submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + + /** Glossary endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Glossary. */ + class Glossary implements IGlossary { + + /** + * Constructs a new Glossary. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGlossary); + + /** Glossary name. */ + public name: string; + + /** Glossary languagePair. */ + public languagePair?: (google.cloud.translation.v3.Glossary.ILanguageCodePair|null); + + /** Glossary languageCodesSet. */ + public languageCodesSet?: (google.cloud.translation.v3.Glossary.ILanguageCodesSet|null); + + /** Glossary inputConfig. */ + public inputConfig?: (google.cloud.translation.v3.IGlossaryInputConfig|null); + + /** Glossary entryCount. */ + public entryCount: number; + + /** Glossary submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** Glossary endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** Glossary languages. */ + public languages?: ("languagePair"|"languageCodesSet"); + + /** + * Creates a new Glossary instance using the specified properties. + * @param [properties] Properties to set + * @returns Glossary instance + */ + public static create(properties?: google.cloud.translation.v3.IGlossary): google.cloud.translation.v3.Glossary; + + /** + * Encodes the specified Glossary message. Does not implicitly {@link google.cloud.translation.v3.Glossary.verify|verify} messages. + * @param message Glossary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGlossary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Glossary message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.verify|verify} messages. + * @param message Glossary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGlossary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Glossary message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Glossary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.Glossary; + + /** + * Decodes a Glossary message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Glossary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.Glossary; + + /** + * Verifies a Glossary message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Glossary message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Glossary + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.Glossary; + + /** + * Creates a plain object from a Glossary message. Also converts values to other types if specified. + * @param message Glossary + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.Glossary, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Glossary to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Glossary { + + /** Properties of a LanguageCodePair. */ + interface ILanguageCodePair { + + /** LanguageCodePair sourceLanguageCode */ + sourceLanguageCode?: (string|null); + + /** LanguageCodePair targetLanguageCode */ + targetLanguageCode?: (string|null); + } + + /** Represents a LanguageCodePair. */ + class LanguageCodePair implements ILanguageCodePair { + + /** + * Constructs a new LanguageCodePair. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.Glossary.ILanguageCodePair); + + /** LanguageCodePair sourceLanguageCode. */ + public sourceLanguageCode: string; + + /** LanguageCodePair targetLanguageCode. */ + public targetLanguageCode: string; + + /** + * Creates a new LanguageCodePair instance using the specified properties. + * @param [properties] Properties to set + * @returns LanguageCodePair instance + */ + public static create(properties?: google.cloud.translation.v3.Glossary.ILanguageCodePair): google.cloud.translation.v3.Glossary.LanguageCodePair; + + /** + * Encodes the specified LanguageCodePair message. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodePair.verify|verify} messages. + * @param message LanguageCodePair message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.Glossary.ILanguageCodePair, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LanguageCodePair message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodePair.verify|verify} messages. + * @param message LanguageCodePair message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.Glossary.ILanguageCodePair, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LanguageCodePair message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LanguageCodePair + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.Glossary.LanguageCodePair; + + /** + * Decodes a LanguageCodePair message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LanguageCodePair + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.Glossary.LanguageCodePair; + + /** + * Verifies a LanguageCodePair message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LanguageCodePair message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LanguageCodePair + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.Glossary.LanguageCodePair; + + /** + * Creates a plain object from a LanguageCodePair message. Also converts values to other types if specified. + * @param message LanguageCodePair + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.Glossary.LanguageCodePair, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LanguageCodePair to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a LanguageCodesSet. */ + interface ILanguageCodesSet { + + /** LanguageCodesSet languageCodes */ + languageCodes?: (string[]|null); + } + + /** Represents a LanguageCodesSet. */ + class LanguageCodesSet implements ILanguageCodesSet { + + /** + * Constructs a new LanguageCodesSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.Glossary.ILanguageCodesSet); + + /** LanguageCodesSet languageCodes. */ + public languageCodes: string[]; + + /** + * Creates a new LanguageCodesSet instance using the specified properties. + * @param [properties] Properties to set + * @returns LanguageCodesSet instance + */ + public static create(properties?: google.cloud.translation.v3.Glossary.ILanguageCodesSet): google.cloud.translation.v3.Glossary.LanguageCodesSet; + + /** + * Encodes the specified LanguageCodesSet message. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodesSet.verify|verify} messages. + * @param message LanguageCodesSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.Glossary.ILanguageCodesSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LanguageCodesSet message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodesSet.verify|verify} messages. + * @param message LanguageCodesSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.Glossary.ILanguageCodesSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LanguageCodesSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LanguageCodesSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.Glossary.LanguageCodesSet; + + /** + * Decodes a LanguageCodesSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LanguageCodesSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.Glossary.LanguageCodesSet; + + /** + * Verifies a LanguageCodesSet message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LanguageCodesSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LanguageCodesSet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.Glossary.LanguageCodesSet; + + /** + * Creates a plain object from a LanguageCodesSet message. Also converts values to other types if specified. + * @param message LanguageCodesSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.Glossary.LanguageCodesSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LanguageCodesSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a CreateGlossaryRequest. */ + interface ICreateGlossaryRequest { + + /** CreateGlossaryRequest parent */ + parent?: (string|null); + + /** CreateGlossaryRequest glossary */ + glossary?: (google.cloud.translation.v3.IGlossary|null); + } + + /** Represents a CreateGlossaryRequest. */ + class CreateGlossaryRequest implements ICreateGlossaryRequest { + + /** + * Constructs a new CreateGlossaryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ICreateGlossaryRequest); + + /** CreateGlossaryRequest parent. */ + public parent: string; + + /** CreateGlossaryRequest glossary. */ + public glossary?: (google.cloud.translation.v3.IGlossary|null); + + /** + * Creates a new CreateGlossaryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateGlossaryRequest instance + */ + public static create(properties?: google.cloud.translation.v3.ICreateGlossaryRequest): google.cloud.translation.v3.CreateGlossaryRequest; + + /** + * Encodes the specified CreateGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryRequest.verify|verify} messages. + * @param message CreateGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ICreateGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryRequest.verify|verify} messages. + * @param message CreateGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ICreateGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateGlossaryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.CreateGlossaryRequest; + + /** + * Decodes a CreateGlossaryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.CreateGlossaryRequest; + + /** + * Verifies a CreateGlossaryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateGlossaryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.CreateGlossaryRequest; + + /** + * Creates a plain object from a CreateGlossaryRequest message. Also converts values to other types if specified. + * @param message CreateGlossaryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.CreateGlossaryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateGlossaryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetGlossaryRequest. */ + interface IGetGlossaryRequest { + + /** GetGlossaryRequest name */ + name?: (string|null); + } + + /** Represents a GetGlossaryRequest. */ + class GetGlossaryRequest implements IGetGlossaryRequest { + + /** + * Constructs a new GetGlossaryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IGetGlossaryRequest); + + /** GetGlossaryRequest name. */ + public name: string; + + /** + * Creates a new GetGlossaryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetGlossaryRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IGetGlossaryRequest): google.cloud.translation.v3.GetGlossaryRequest; + + /** + * Encodes the specified GetGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.GetGlossaryRequest.verify|verify} messages. + * @param message GetGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IGetGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GetGlossaryRequest.verify|verify} messages. + * @param message GetGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IGetGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetGlossaryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.GetGlossaryRequest; + + /** + * Decodes a GetGlossaryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.GetGlossaryRequest; + + /** + * Verifies a GetGlossaryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetGlossaryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.GetGlossaryRequest; + + /** + * Creates a plain object from a GetGlossaryRequest message. Also converts values to other types if specified. + * @param message GetGlossaryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.GetGlossaryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetGlossaryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteGlossaryRequest. */ + interface IDeleteGlossaryRequest { + + /** DeleteGlossaryRequest name */ + name?: (string|null); + } + + /** Represents a DeleteGlossaryRequest. */ + class DeleteGlossaryRequest implements IDeleteGlossaryRequest { + + /** + * Constructs a new DeleteGlossaryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDeleteGlossaryRequest); + + /** DeleteGlossaryRequest name. */ + public name: string; + + /** + * Creates a new DeleteGlossaryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteGlossaryRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IDeleteGlossaryRequest): google.cloud.translation.v3.DeleteGlossaryRequest; + + /** + * Encodes the specified DeleteGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryRequest.verify|verify} messages. + * @param message DeleteGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDeleteGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryRequest.verify|verify} messages. + * @param message DeleteGlossaryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDeleteGlossaryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteGlossaryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DeleteGlossaryRequest; + + /** + * Decodes a DeleteGlossaryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DeleteGlossaryRequest; + + /** + * Verifies a DeleteGlossaryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteGlossaryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DeleteGlossaryRequest; + + /** + * Creates a plain object from a DeleteGlossaryRequest message. Also converts values to other types if specified. + * @param message DeleteGlossaryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DeleteGlossaryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteGlossaryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListGlossariesRequest. */ + interface IListGlossariesRequest { + + /** ListGlossariesRequest parent */ + parent?: (string|null); + + /** ListGlossariesRequest pageSize */ + pageSize?: (number|null); + + /** ListGlossariesRequest pageToken */ + pageToken?: (string|null); + + /** ListGlossariesRequest filter */ + filter?: (string|null); + } + + /** Represents a ListGlossariesRequest. */ + class ListGlossariesRequest implements IListGlossariesRequest { + + /** + * Constructs a new ListGlossariesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IListGlossariesRequest); + + /** ListGlossariesRequest parent. */ + public parent: string; + + /** ListGlossariesRequest pageSize. */ + public pageSize: number; + + /** ListGlossariesRequest pageToken. */ + public pageToken: string; + + /** ListGlossariesRequest filter. */ + public filter: string; + + /** + * Creates a new ListGlossariesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListGlossariesRequest instance + */ + public static create(properties?: google.cloud.translation.v3.IListGlossariesRequest): google.cloud.translation.v3.ListGlossariesRequest; + + /** + * Encodes the specified ListGlossariesRequest message. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesRequest.verify|verify} messages. + * @param message ListGlossariesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IListGlossariesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListGlossariesRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesRequest.verify|verify} messages. + * @param message ListGlossariesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IListGlossariesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListGlossariesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListGlossariesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.ListGlossariesRequest; + + /** + * Decodes a ListGlossariesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListGlossariesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.ListGlossariesRequest; + + /** + * Verifies a ListGlossariesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListGlossariesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListGlossariesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.ListGlossariesRequest; + + /** + * Creates a plain object from a ListGlossariesRequest message. Also converts values to other types if specified. + * @param message ListGlossariesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.ListGlossariesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListGlossariesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListGlossariesResponse. */ + interface IListGlossariesResponse { + + /** ListGlossariesResponse glossaries */ + glossaries?: (google.cloud.translation.v3.IGlossary[]|null); + + /** ListGlossariesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListGlossariesResponse. */ + class ListGlossariesResponse implements IListGlossariesResponse { + + /** + * Constructs a new ListGlossariesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IListGlossariesResponse); + + /** ListGlossariesResponse glossaries. */ + public glossaries: google.cloud.translation.v3.IGlossary[]; + + /** ListGlossariesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListGlossariesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListGlossariesResponse instance + */ + public static create(properties?: google.cloud.translation.v3.IListGlossariesResponse): google.cloud.translation.v3.ListGlossariesResponse; + + /** + * Encodes the specified ListGlossariesResponse message. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesResponse.verify|verify} messages. + * @param message ListGlossariesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IListGlossariesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListGlossariesResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesResponse.verify|verify} messages. + * @param message ListGlossariesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IListGlossariesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListGlossariesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListGlossariesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.ListGlossariesResponse; + + /** + * Decodes a ListGlossariesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListGlossariesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.ListGlossariesResponse; + + /** + * Verifies a ListGlossariesResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListGlossariesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListGlossariesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.ListGlossariesResponse; + + /** + * Creates a plain object from a ListGlossariesResponse message. Also converts values to other types if specified. + * @param message ListGlossariesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.ListGlossariesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListGlossariesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CreateGlossaryMetadata. */ + interface ICreateGlossaryMetadata { + + /** CreateGlossaryMetadata name */ + name?: (string|null); + + /** CreateGlossaryMetadata state */ + state?: (google.cloud.translation.v3.CreateGlossaryMetadata.State|null); + + /** CreateGlossaryMetadata submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CreateGlossaryMetadata. */ + class CreateGlossaryMetadata implements ICreateGlossaryMetadata { + + /** + * Constructs a new CreateGlossaryMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.ICreateGlossaryMetadata); + + /** CreateGlossaryMetadata name. */ + public name: string; + + /** CreateGlossaryMetadata state. */ + public state: google.cloud.translation.v3.CreateGlossaryMetadata.State; + + /** CreateGlossaryMetadata submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new CreateGlossaryMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateGlossaryMetadata instance + */ + public static create(properties?: google.cloud.translation.v3.ICreateGlossaryMetadata): google.cloud.translation.v3.CreateGlossaryMetadata; + + /** + * Encodes the specified CreateGlossaryMetadata message. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryMetadata.verify|verify} messages. + * @param message CreateGlossaryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.ICreateGlossaryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateGlossaryMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryMetadata.verify|verify} messages. + * @param message CreateGlossaryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.ICreateGlossaryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateGlossaryMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.CreateGlossaryMetadata; + + /** + * Decodes a CreateGlossaryMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.CreateGlossaryMetadata; + + /** + * Verifies a CreateGlossaryMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateGlossaryMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateGlossaryMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.CreateGlossaryMetadata; + + /** + * Creates a plain object from a CreateGlossaryMetadata message. Also converts values to other types if specified. + * @param message CreateGlossaryMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.CreateGlossaryMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateGlossaryMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace CreateGlossaryMetadata { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + RUNNING = 1, + SUCCEEDED = 2, + FAILED = 3, + CANCELLING = 4, + CANCELLED = 5 + } + } + + /** Properties of a DeleteGlossaryMetadata. */ + interface IDeleteGlossaryMetadata { + + /** DeleteGlossaryMetadata name */ + name?: (string|null); + + /** DeleteGlossaryMetadata state */ + state?: (google.cloud.translation.v3.DeleteGlossaryMetadata.State|null); + + /** DeleteGlossaryMetadata submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DeleteGlossaryMetadata. */ + class DeleteGlossaryMetadata implements IDeleteGlossaryMetadata { + + /** + * Constructs a new DeleteGlossaryMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDeleteGlossaryMetadata); + + /** DeleteGlossaryMetadata name. */ + public name: string; + + /** DeleteGlossaryMetadata state. */ + public state: google.cloud.translation.v3.DeleteGlossaryMetadata.State; + + /** DeleteGlossaryMetadata submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new DeleteGlossaryMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteGlossaryMetadata instance + */ + public static create(properties?: google.cloud.translation.v3.IDeleteGlossaryMetadata): google.cloud.translation.v3.DeleteGlossaryMetadata; + + /** + * Encodes the specified DeleteGlossaryMetadata message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryMetadata.verify|verify} messages. + * @param message DeleteGlossaryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDeleteGlossaryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteGlossaryMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryMetadata.verify|verify} messages. + * @param message DeleteGlossaryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDeleteGlossaryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteGlossaryMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DeleteGlossaryMetadata; + + /** + * Decodes a DeleteGlossaryMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DeleteGlossaryMetadata; + + /** + * Verifies a DeleteGlossaryMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteGlossaryMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteGlossaryMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DeleteGlossaryMetadata; + + /** + * Creates a plain object from a DeleteGlossaryMetadata message. Also converts values to other types if specified. + * @param message DeleteGlossaryMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DeleteGlossaryMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteGlossaryMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DeleteGlossaryMetadata { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + RUNNING = 1, + SUCCEEDED = 2, + FAILED = 3, + CANCELLING = 4, + CANCELLED = 5 + } + } + + /** Properties of a DeleteGlossaryResponse. */ + interface IDeleteGlossaryResponse { + + /** DeleteGlossaryResponse name */ + name?: (string|null); + + /** DeleteGlossaryResponse submitTime */ + submitTime?: (google.protobuf.ITimestamp|null); + + /** DeleteGlossaryResponse endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DeleteGlossaryResponse. */ + class DeleteGlossaryResponse implements IDeleteGlossaryResponse { + + /** + * Constructs a new DeleteGlossaryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.translation.v3.IDeleteGlossaryResponse); + + /** DeleteGlossaryResponse name. */ + public name: string; + + /** DeleteGlossaryResponse submitTime. */ + public submitTime?: (google.protobuf.ITimestamp|null); + + /** DeleteGlossaryResponse endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new DeleteGlossaryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteGlossaryResponse instance + */ + public static create(properties?: google.cloud.translation.v3.IDeleteGlossaryResponse): google.cloud.translation.v3.DeleteGlossaryResponse; + + /** + * Encodes the specified DeleteGlossaryResponse message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryResponse.verify|verify} messages. + * @param message DeleteGlossaryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.translation.v3.IDeleteGlossaryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteGlossaryResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryResponse.verify|verify} messages. + * @param message DeleteGlossaryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.translation.v3.IDeleteGlossaryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteGlossaryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteGlossaryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.translation.v3.DeleteGlossaryResponse; + + /** + * Decodes a DeleteGlossaryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteGlossaryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.translation.v3.DeleteGlossaryResponse; + + /** + * Verifies a DeleteGlossaryResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteGlossaryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteGlossaryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.translation.v3.DeleteGlossaryResponse; + + /** + * Creates a plain object from a DeleteGlossaryResponse message. Also converts values to other types if specified. + * @param message DeleteGlossaryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.translation.v3.DeleteGlossaryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteGlossaryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + /** Namespace v3beta1. */ namespace v3beta1 { diff --git a/protos/protos.js b/protos/protos.js index d78ca750..724b91d7 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -43,6 +43,7730 @@ */ var translation = {}; + translation.v3 = (function() { + + /** + * Namespace v3. + * @memberof google.cloud.translation + * @namespace + */ + var v3 = {}; + + v3.TranslationService = (function() { + + /** + * Constructs a new TranslationService service. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a TranslationService + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function TranslationService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (TranslationService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = TranslationService; + + /** + * Creates new TranslationService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.translation.v3.TranslationService + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {TranslationService} RPC service. Useful where requests and/or responses are streamed. + */ + TranslationService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#translateText}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef TranslateTextCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.translation.v3.TranslateTextResponse} [response] TranslateTextResponse + */ + + /** + * Calls TranslateText. + * @function translateText + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.ITranslateTextRequest} request TranslateTextRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.TranslateTextCallback} callback Node-style callback called with the error, if any, and TranslateTextResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.translateText = function translateText(request, callback) { + return this.rpcCall(translateText, $root.google.cloud.translation.v3.TranslateTextRequest, $root.google.cloud.translation.v3.TranslateTextResponse, request, callback); + }, "name", { value: "TranslateText" }); + + /** + * Calls TranslateText. + * @function translateText + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.ITranslateTextRequest} request TranslateTextRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#detectLanguage}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef DetectLanguageCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.translation.v3.DetectLanguageResponse} [response] DetectLanguageResponse + */ + + /** + * Calls DetectLanguage. + * @function detectLanguage + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IDetectLanguageRequest} request DetectLanguageRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.DetectLanguageCallback} callback Node-style callback called with the error, if any, and DetectLanguageResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.detectLanguage = function detectLanguage(request, callback) { + return this.rpcCall(detectLanguage, $root.google.cloud.translation.v3.DetectLanguageRequest, $root.google.cloud.translation.v3.DetectLanguageResponse, request, callback); + }, "name", { value: "DetectLanguage" }); + + /** + * Calls DetectLanguage. + * @function detectLanguage + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IDetectLanguageRequest} request DetectLanguageRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#getSupportedLanguages}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef GetSupportedLanguagesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.translation.v3.SupportedLanguages} [response] SupportedLanguages + */ + + /** + * Calls GetSupportedLanguages. + * @function getSupportedLanguages + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest} request GetSupportedLanguagesRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.GetSupportedLanguagesCallback} callback Node-style callback called with the error, if any, and SupportedLanguages + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.getSupportedLanguages = function getSupportedLanguages(request, callback) { + return this.rpcCall(getSupportedLanguages, $root.google.cloud.translation.v3.GetSupportedLanguagesRequest, $root.google.cloud.translation.v3.SupportedLanguages, request, callback); + }, "name", { value: "GetSupportedLanguages" }); + + /** + * Calls GetSupportedLanguages. + * @function getSupportedLanguages + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest} request GetSupportedLanguagesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#batchTranslateText}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef BatchTranslateTextCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls BatchTranslateText. + * @function batchTranslateText + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest} request BatchTranslateTextRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.BatchTranslateTextCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.batchTranslateText = function batchTranslateText(request, callback) { + return this.rpcCall(batchTranslateText, $root.google.cloud.translation.v3.BatchTranslateTextRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "BatchTranslateText" }); + + /** + * Calls BatchTranslateText. + * @function batchTranslateText + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest} request BatchTranslateTextRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#createGlossary}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef CreateGlossaryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateGlossary. + * @function createGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.ICreateGlossaryRequest} request CreateGlossaryRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.CreateGlossaryCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.createGlossary = function createGlossary(request, callback) { + return this.rpcCall(createGlossary, $root.google.cloud.translation.v3.CreateGlossaryRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateGlossary" }); + + /** + * Calls CreateGlossary. + * @function createGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.ICreateGlossaryRequest} request CreateGlossaryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#listGlossaries}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef ListGlossariesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.translation.v3.ListGlossariesResponse} [response] ListGlossariesResponse + */ + + /** + * Calls ListGlossaries. + * @function listGlossaries + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IListGlossariesRequest} request ListGlossariesRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.ListGlossariesCallback} callback Node-style callback called with the error, if any, and ListGlossariesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.listGlossaries = function listGlossaries(request, callback) { + return this.rpcCall(listGlossaries, $root.google.cloud.translation.v3.ListGlossariesRequest, $root.google.cloud.translation.v3.ListGlossariesResponse, request, callback); + }, "name", { value: "ListGlossaries" }); + + /** + * Calls ListGlossaries. + * @function listGlossaries + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IListGlossariesRequest} request ListGlossariesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#getGlossary}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef GetGlossaryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.translation.v3.Glossary} [response] Glossary + */ + + /** + * Calls GetGlossary. + * @function getGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IGetGlossaryRequest} request GetGlossaryRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.GetGlossaryCallback} callback Node-style callback called with the error, if any, and Glossary + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.getGlossary = function getGlossary(request, callback) { + return this.rpcCall(getGlossary, $root.google.cloud.translation.v3.GetGlossaryRequest, $root.google.cloud.translation.v3.Glossary, request, callback); + }, "name", { value: "GetGlossary" }); + + /** + * Calls GetGlossary. + * @function getGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IGetGlossaryRequest} request GetGlossaryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.translation.v3.TranslationService#deleteGlossary}. + * @memberof google.cloud.translation.v3.TranslationService + * @typedef DeleteGlossaryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeleteGlossary. + * @function deleteGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest} request DeleteGlossaryRequest message or plain object + * @param {google.cloud.translation.v3.TranslationService.DeleteGlossaryCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(TranslationService.prototype.deleteGlossary = function deleteGlossary(request, callback) { + return this.rpcCall(deleteGlossary, $root.google.cloud.translation.v3.DeleteGlossaryRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeleteGlossary" }); + + /** + * Calls DeleteGlossary. + * @function deleteGlossary + * @memberof google.cloud.translation.v3.TranslationService + * @instance + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest} request DeleteGlossaryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return TranslationService; + })(); + + v3.TranslateTextGlossaryConfig = (function() { + + /** + * Properties of a TranslateTextGlossaryConfig. + * @memberof google.cloud.translation.v3 + * @interface ITranslateTextGlossaryConfig + * @property {string|null} [glossary] TranslateTextGlossaryConfig glossary + * @property {boolean|null} [ignoreCase] TranslateTextGlossaryConfig ignoreCase + */ + + /** + * Constructs a new TranslateTextGlossaryConfig. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a TranslateTextGlossaryConfig. + * @implements ITranslateTextGlossaryConfig + * @constructor + * @param {google.cloud.translation.v3.ITranslateTextGlossaryConfig=} [properties] Properties to set + */ + function TranslateTextGlossaryConfig(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TranslateTextGlossaryConfig glossary. + * @member {string} glossary + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @instance + */ + TranslateTextGlossaryConfig.prototype.glossary = ""; + + /** + * TranslateTextGlossaryConfig ignoreCase. + * @member {boolean} ignoreCase + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @instance + */ + TranslateTextGlossaryConfig.prototype.ignoreCase = false; + + /** + * Creates a new TranslateTextGlossaryConfig instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {google.cloud.translation.v3.ITranslateTextGlossaryConfig=} [properties] Properties to set + * @returns {google.cloud.translation.v3.TranslateTextGlossaryConfig} TranslateTextGlossaryConfig instance + */ + TranslateTextGlossaryConfig.create = function create(properties) { + return new TranslateTextGlossaryConfig(properties); + }; + + /** + * Encodes the specified TranslateTextGlossaryConfig message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextGlossaryConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {google.cloud.translation.v3.ITranslateTextGlossaryConfig} message TranslateTextGlossaryConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextGlossaryConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.glossary != null && message.hasOwnProperty("glossary")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.glossary); + if (message.ignoreCase != null && message.hasOwnProperty("ignoreCase")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.ignoreCase); + return writer; + }; + + /** + * Encodes the specified TranslateTextGlossaryConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextGlossaryConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {google.cloud.translation.v3.ITranslateTextGlossaryConfig} message TranslateTextGlossaryConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextGlossaryConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TranslateTextGlossaryConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.TranslateTextGlossaryConfig} TranslateTextGlossaryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextGlossaryConfig.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.TranslateTextGlossaryConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.glossary = reader.string(); + break; + case 2: + message.ignoreCase = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TranslateTextGlossaryConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.TranslateTextGlossaryConfig} TranslateTextGlossaryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextGlossaryConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TranslateTextGlossaryConfig message. + * @function verify + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TranslateTextGlossaryConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.glossary != null && message.hasOwnProperty("glossary")) + if (!$util.isString(message.glossary)) + return "glossary: string expected"; + if (message.ignoreCase != null && message.hasOwnProperty("ignoreCase")) + if (typeof message.ignoreCase !== "boolean") + return "ignoreCase: boolean expected"; + return null; + }; + + /** + * Creates a TranslateTextGlossaryConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.TranslateTextGlossaryConfig} TranslateTextGlossaryConfig + */ + TranslateTextGlossaryConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.TranslateTextGlossaryConfig) + return object; + var message = new $root.google.cloud.translation.v3.TranslateTextGlossaryConfig(); + if (object.glossary != null) + message.glossary = String(object.glossary); + if (object.ignoreCase != null) + message.ignoreCase = Boolean(object.ignoreCase); + return message; + }; + + /** + * Creates a plain object from a TranslateTextGlossaryConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @static + * @param {google.cloud.translation.v3.TranslateTextGlossaryConfig} message TranslateTextGlossaryConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TranslateTextGlossaryConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.glossary = ""; + object.ignoreCase = false; + } + if (message.glossary != null && message.hasOwnProperty("glossary")) + object.glossary = message.glossary; + if (message.ignoreCase != null && message.hasOwnProperty("ignoreCase")) + object.ignoreCase = message.ignoreCase; + return object; + }; + + /** + * Converts this TranslateTextGlossaryConfig to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.TranslateTextGlossaryConfig + * @instance + * @returns {Object.} JSON object + */ + TranslateTextGlossaryConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return TranslateTextGlossaryConfig; + })(); + + v3.TranslateTextRequest = (function() { + + /** + * Properties of a TranslateTextRequest. + * @memberof google.cloud.translation.v3 + * @interface ITranslateTextRequest + * @property {Array.|null} [contents] TranslateTextRequest contents + * @property {string|null} [mimeType] TranslateTextRequest mimeType + * @property {string|null} [sourceLanguageCode] TranslateTextRequest sourceLanguageCode + * @property {string|null} [targetLanguageCode] TranslateTextRequest targetLanguageCode + * @property {string|null} [parent] TranslateTextRequest parent + * @property {string|null} [model] TranslateTextRequest model + * @property {google.cloud.translation.v3.ITranslateTextGlossaryConfig|null} [glossaryConfig] TranslateTextRequest glossaryConfig + * @property {Object.|null} [labels] TranslateTextRequest labels + */ + + /** + * Constructs a new TranslateTextRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a TranslateTextRequest. + * @implements ITranslateTextRequest + * @constructor + * @param {google.cloud.translation.v3.ITranslateTextRequest=} [properties] Properties to set + */ + function TranslateTextRequest(properties) { + this.contents = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TranslateTextRequest contents. + * @member {Array.} contents + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.contents = $util.emptyArray; + + /** + * TranslateTextRequest mimeType. + * @member {string} mimeType + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.mimeType = ""; + + /** + * TranslateTextRequest sourceLanguageCode. + * @member {string} sourceLanguageCode + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.sourceLanguageCode = ""; + + /** + * TranslateTextRequest targetLanguageCode. + * @member {string} targetLanguageCode + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.targetLanguageCode = ""; + + /** + * TranslateTextRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.parent = ""; + + /** + * TranslateTextRequest model. + * @member {string} model + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.model = ""; + + /** + * TranslateTextRequest glossaryConfig. + * @member {google.cloud.translation.v3.ITranslateTextGlossaryConfig|null|undefined} glossaryConfig + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.glossaryConfig = null; + + /** + * TranslateTextRequest labels. + * @member {Object.} labels + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + */ + TranslateTextRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a new TranslateTextRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {google.cloud.translation.v3.ITranslateTextRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.TranslateTextRequest} TranslateTextRequest instance + */ + TranslateTextRequest.create = function create(properties) { + return new TranslateTextRequest(properties); + }; + + /** + * Encodes the specified TranslateTextRequest message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {google.cloud.translation.v3.ITranslateTextRequest} message TranslateTextRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contents != null && message.contents.length) + for (var i = 0; i < message.contents.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.contents[i]); + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.mimeType); + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.sourceLanguageCode); + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.targetLanguageCode); + if (message.model != null && message.hasOwnProperty("model")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.model); + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) + $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.encode(message.glossaryConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.parent); + if (message.labels != null && message.hasOwnProperty("labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified TranslateTextRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {google.cloud.translation.v3.ITranslateTextRequest} message TranslateTextRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TranslateTextRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.TranslateTextRequest} TranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.TranslateTextRequest(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.contents && message.contents.length)) + message.contents = []; + message.contents.push(reader.string()); + break; + case 3: + message.mimeType = reader.string(); + break; + case 4: + message.sourceLanguageCode = reader.string(); + break; + case 5: + message.targetLanguageCode = reader.string(); + break; + case 8: + message.parent = reader.string(); + break; + case 6: + message.model = reader.string(); + break; + case 7: + message.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.decode(reader, reader.uint32()); + break; + case 10: + reader.skip().pos++; + if (message.labels === $util.emptyObject) + message.labels = {}; + key = reader.string(); + reader.pos++; + message.labels[key] = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TranslateTextRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.TranslateTextRequest} TranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TranslateTextRequest message. + * @function verify + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TranslateTextRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.contents != null && message.hasOwnProperty("contents")) { + if (!Array.isArray(message.contents)) + return "contents: array expected"; + for (var i = 0; i < message.contents.length; ++i) + if (!$util.isString(message.contents[i])) + return "contents: string[] expected"; + } + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + if (!$util.isString(message.mimeType)) + return "mimeType: string expected"; + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + if (!$util.isString(message.sourceLanguageCode)) + return "sourceLanguageCode: string expected"; + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + if (!$util.isString(message.targetLanguageCode)) + return "targetLanguageCode: string expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) { + var error = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.verify(message.glossaryConfig); + if (error) + return "glossaryConfig." + error; + } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + return null; + }; + + /** + * Creates a TranslateTextRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.TranslateTextRequest} TranslateTextRequest + */ + TranslateTextRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.TranslateTextRequest) + return object; + var message = new $root.google.cloud.translation.v3.TranslateTextRequest(); + if (object.contents) { + if (!Array.isArray(object.contents)) + throw TypeError(".google.cloud.translation.v3.TranslateTextRequest.contents: array expected"); + message.contents = []; + for (var i = 0; i < object.contents.length; ++i) + message.contents[i] = String(object.contents[i]); + } + if (object.mimeType != null) + message.mimeType = String(object.mimeType); + if (object.sourceLanguageCode != null) + message.sourceLanguageCode = String(object.sourceLanguageCode); + if (object.targetLanguageCode != null) + message.targetLanguageCode = String(object.targetLanguageCode); + if (object.parent != null) + message.parent = String(object.parent); + if (object.model != null) + message.model = String(object.model); + if (object.glossaryConfig != null) { + if (typeof object.glossaryConfig !== "object") + throw TypeError(".google.cloud.translation.v3.TranslateTextRequest.glossaryConfig: object expected"); + message.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.fromObject(object.glossaryConfig); + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.translation.v3.TranslateTextRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a TranslateTextRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @static + * @param {google.cloud.translation.v3.TranslateTextRequest} message TranslateTextRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TranslateTextRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.contents = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.mimeType = ""; + object.sourceLanguageCode = ""; + object.targetLanguageCode = ""; + object.model = ""; + object.glossaryConfig = null; + object.parent = ""; + } + if (message.contents && message.contents.length) { + object.contents = []; + for (var j = 0; j < message.contents.length; ++j) + object.contents[j] = message.contents[j]; + } + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + object.mimeType = message.mimeType; + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + object.sourceLanguageCode = message.sourceLanguageCode; + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + object.targetLanguageCode = message.targetLanguageCode; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) + object.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.toObject(message.glossaryConfig, options); + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this TranslateTextRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.TranslateTextRequest + * @instance + * @returns {Object.} JSON object + */ + TranslateTextRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return TranslateTextRequest; + })(); + + v3.TranslateTextResponse = (function() { + + /** + * Properties of a TranslateTextResponse. + * @memberof google.cloud.translation.v3 + * @interface ITranslateTextResponse + * @property {Array.|null} [translations] TranslateTextResponse translations + * @property {Array.|null} [glossaryTranslations] TranslateTextResponse glossaryTranslations + */ + + /** + * Constructs a new TranslateTextResponse. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a TranslateTextResponse. + * @implements ITranslateTextResponse + * @constructor + * @param {google.cloud.translation.v3.ITranslateTextResponse=} [properties] Properties to set + */ + function TranslateTextResponse(properties) { + this.translations = []; + this.glossaryTranslations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TranslateTextResponse translations. + * @member {Array.} translations + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @instance + */ + TranslateTextResponse.prototype.translations = $util.emptyArray; + + /** + * TranslateTextResponse glossaryTranslations. + * @member {Array.} glossaryTranslations + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @instance + */ + TranslateTextResponse.prototype.glossaryTranslations = $util.emptyArray; + + /** + * Creates a new TranslateTextResponse instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {google.cloud.translation.v3.ITranslateTextResponse=} [properties] Properties to set + * @returns {google.cloud.translation.v3.TranslateTextResponse} TranslateTextResponse instance + */ + TranslateTextResponse.create = function create(properties) { + return new TranslateTextResponse(properties); + }; + + /** + * Encodes the specified TranslateTextResponse message. Does not implicitly {@link google.cloud.translation.v3.TranslateTextResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {google.cloud.translation.v3.ITranslateTextResponse} message TranslateTextResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.translations != null && message.translations.length) + for (var i = 0; i < message.translations.length; ++i) + $root.google.cloud.translation.v3.Translation.encode(message.translations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.glossaryTranslations != null && message.glossaryTranslations.length) + for (var i = 0; i < message.glossaryTranslations.length; ++i) + $root.google.cloud.translation.v3.Translation.encode(message.glossaryTranslations[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TranslateTextResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.TranslateTextResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {google.cloud.translation.v3.ITranslateTextResponse} message TranslateTextResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranslateTextResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TranslateTextResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.TranslateTextResponse} TranslateTextResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.TranslateTextResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.translations && message.translations.length)) + message.translations = []; + message.translations.push($root.google.cloud.translation.v3.Translation.decode(reader, reader.uint32())); + break; + case 3: + if (!(message.glossaryTranslations && message.glossaryTranslations.length)) + message.glossaryTranslations = []; + message.glossaryTranslations.push($root.google.cloud.translation.v3.Translation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TranslateTextResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.TranslateTextResponse} TranslateTextResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranslateTextResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TranslateTextResponse message. + * @function verify + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TranslateTextResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.translations != null && message.hasOwnProperty("translations")) { + if (!Array.isArray(message.translations)) + return "translations: array expected"; + for (var i = 0; i < message.translations.length; ++i) { + var error = $root.google.cloud.translation.v3.Translation.verify(message.translations[i]); + if (error) + return "translations." + error; + } + } + if (message.glossaryTranslations != null && message.hasOwnProperty("glossaryTranslations")) { + if (!Array.isArray(message.glossaryTranslations)) + return "glossaryTranslations: array expected"; + for (var i = 0; i < message.glossaryTranslations.length; ++i) { + var error = $root.google.cloud.translation.v3.Translation.verify(message.glossaryTranslations[i]); + if (error) + return "glossaryTranslations." + error; + } + } + return null; + }; + + /** + * Creates a TranslateTextResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.TranslateTextResponse} TranslateTextResponse + */ + TranslateTextResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.TranslateTextResponse) + return object; + var message = new $root.google.cloud.translation.v3.TranslateTextResponse(); + if (object.translations) { + if (!Array.isArray(object.translations)) + throw TypeError(".google.cloud.translation.v3.TranslateTextResponse.translations: array expected"); + message.translations = []; + for (var i = 0; i < object.translations.length; ++i) { + if (typeof object.translations[i] !== "object") + throw TypeError(".google.cloud.translation.v3.TranslateTextResponse.translations: object expected"); + message.translations[i] = $root.google.cloud.translation.v3.Translation.fromObject(object.translations[i]); + } + } + if (object.glossaryTranslations) { + if (!Array.isArray(object.glossaryTranslations)) + throw TypeError(".google.cloud.translation.v3.TranslateTextResponse.glossaryTranslations: array expected"); + message.glossaryTranslations = []; + for (var i = 0; i < object.glossaryTranslations.length; ++i) { + if (typeof object.glossaryTranslations[i] !== "object") + throw TypeError(".google.cloud.translation.v3.TranslateTextResponse.glossaryTranslations: object expected"); + message.glossaryTranslations[i] = $root.google.cloud.translation.v3.Translation.fromObject(object.glossaryTranslations[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a TranslateTextResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @static + * @param {google.cloud.translation.v3.TranslateTextResponse} message TranslateTextResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TranslateTextResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.translations = []; + object.glossaryTranslations = []; + } + if (message.translations && message.translations.length) { + object.translations = []; + for (var j = 0; j < message.translations.length; ++j) + object.translations[j] = $root.google.cloud.translation.v3.Translation.toObject(message.translations[j], options); + } + if (message.glossaryTranslations && message.glossaryTranslations.length) { + object.glossaryTranslations = []; + for (var j = 0; j < message.glossaryTranslations.length; ++j) + object.glossaryTranslations[j] = $root.google.cloud.translation.v3.Translation.toObject(message.glossaryTranslations[j], options); + } + return object; + }; + + /** + * Converts this TranslateTextResponse to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.TranslateTextResponse + * @instance + * @returns {Object.} JSON object + */ + TranslateTextResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return TranslateTextResponse; + })(); + + v3.Translation = (function() { + + /** + * Properties of a Translation. + * @memberof google.cloud.translation.v3 + * @interface ITranslation + * @property {string|null} [translatedText] Translation translatedText + * @property {string|null} [model] Translation model + * @property {string|null} [detectedLanguageCode] Translation detectedLanguageCode + * @property {google.cloud.translation.v3.ITranslateTextGlossaryConfig|null} [glossaryConfig] Translation glossaryConfig + */ + + /** + * Constructs a new Translation. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a Translation. + * @implements ITranslation + * @constructor + * @param {google.cloud.translation.v3.ITranslation=} [properties] Properties to set + */ + function Translation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Translation translatedText. + * @member {string} translatedText + * @memberof google.cloud.translation.v3.Translation + * @instance + */ + Translation.prototype.translatedText = ""; + + /** + * Translation model. + * @member {string} model + * @memberof google.cloud.translation.v3.Translation + * @instance + */ + Translation.prototype.model = ""; + + /** + * Translation detectedLanguageCode. + * @member {string} detectedLanguageCode + * @memberof google.cloud.translation.v3.Translation + * @instance + */ + Translation.prototype.detectedLanguageCode = ""; + + /** + * Translation glossaryConfig. + * @member {google.cloud.translation.v3.ITranslateTextGlossaryConfig|null|undefined} glossaryConfig + * @memberof google.cloud.translation.v3.Translation + * @instance + */ + Translation.prototype.glossaryConfig = null; + + /** + * Creates a new Translation instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {google.cloud.translation.v3.ITranslation=} [properties] Properties to set + * @returns {google.cloud.translation.v3.Translation} Translation instance + */ + Translation.create = function create(properties) { + return new Translation(properties); + }; + + /** + * Encodes the specified Translation message. Does not implicitly {@link google.cloud.translation.v3.Translation.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {google.cloud.translation.v3.ITranslation} message Translation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Translation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.translatedText != null && message.hasOwnProperty("translatedText")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.translatedText); + if (message.model != null && message.hasOwnProperty("model")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.model); + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) + $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.encode(message.glossaryConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.detectedLanguageCode != null && message.hasOwnProperty("detectedLanguageCode")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.detectedLanguageCode); + return writer; + }; + + /** + * Encodes the specified Translation message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Translation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {google.cloud.translation.v3.ITranslation} message Translation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Translation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Translation message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.Translation} Translation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Translation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.Translation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.translatedText = reader.string(); + break; + case 2: + message.model = reader.string(); + break; + case 4: + message.detectedLanguageCode = reader.string(); + break; + case 3: + message.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Translation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.Translation} Translation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Translation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Translation message. + * @function verify + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Translation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.translatedText != null && message.hasOwnProperty("translatedText")) + if (!$util.isString(message.translatedText)) + return "translatedText: string expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + if (message.detectedLanguageCode != null && message.hasOwnProperty("detectedLanguageCode")) + if (!$util.isString(message.detectedLanguageCode)) + return "detectedLanguageCode: string expected"; + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) { + var error = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.verify(message.glossaryConfig); + if (error) + return "glossaryConfig." + error; + } + return null; + }; + + /** + * Creates a Translation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.Translation} Translation + */ + Translation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.Translation) + return object; + var message = new $root.google.cloud.translation.v3.Translation(); + if (object.translatedText != null) + message.translatedText = String(object.translatedText); + if (object.model != null) + message.model = String(object.model); + if (object.detectedLanguageCode != null) + message.detectedLanguageCode = String(object.detectedLanguageCode); + if (object.glossaryConfig != null) { + if (typeof object.glossaryConfig !== "object") + throw TypeError(".google.cloud.translation.v3.Translation.glossaryConfig: object expected"); + message.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.fromObject(object.glossaryConfig); + } + return message; + }; + + /** + * Creates a plain object from a Translation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.Translation + * @static + * @param {google.cloud.translation.v3.Translation} message Translation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Translation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.translatedText = ""; + object.model = ""; + object.glossaryConfig = null; + object.detectedLanguageCode = ""; + } + if (message.translatedText != null && message.hasOwnProperty("translatedText")) + object.translatedText = message.translatedText; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.glossaryConfig != null && message.hasOwnProperty("glossaryConfig")) + object.glossaryConfig = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.toObject(message.glossaryConfig, options); + if (message.detectedLanguageCode != null && message.hasOwnProperty("detectedLanguageCode")) + object.detectedLanguageCode = message.detectedLanguageCode; + return object; + }; + + /** + * Converts this Translation to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.Translation + * @instance + * @returns {Object.} JSON object + */ + Translation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Translation; + })(); + + v3.DetectLanguageRequest = (function() { + + /** + * Properties of a DetectLanguageRequest. + * @memberof google.cloud.translation.v3 + * @interface IDetectLanguageRequest + * @property {string|null} [parent] DetectLanguageRequest parent + * @property {string|null} [model] DetectLanguageRequest model + * @property {string|null} [content] DetectLanguageRequest content + * @property {string|null} [mimeType] DetectLanguageRequest mimeType + * @property {Object.|null} [labels] DetectLanguageRequest labels + */ + + /** + * Constructs a new DetectLanguageRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DetectLanguageRequest. + * @implements IDetectLanguageRequest + * @constructor + * @param {google.cloud.translation.v3.IDetectLanguageRequest=} [properties] Properties to set + */ + function DetectLanguageRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DetectLanguageRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + DetectLanguageRequest.prototype.parent = ""; + + /** + * DetectLanguageRequest model. + * @member {string} model + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + DetectLanguageRequest.prototype.model = ""; + + /** + * DetectLanguageRequest content. + * @member {string} content + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + DetectLanguageRequest.prototype.content = ""; + + /** + * DetectLanguageRequest mimeType. + * @member {string} mimeType + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + DetectLanguageRequest.prototype.mimeType = ""; + + /** + * DetectLanguageRequest labels. + * @member {Object.} labels + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + DetectLanguageRequest.prototype.labels = $util.emptyObject; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * DetectLanguageRequest source. + * @member {"content"|undefined} source + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + */ + Object.defineProperty(DetectLanguageRequest.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["content"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new DetectLanguageRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {google.cloud.translation.v3.IDetectLanguageRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DetectLanguageRequest} DetectLanguageRequest instance + */ + DetectLanguageRequest.create = function create(properties) { + return new DetectLanguageRequest(properties); + }; + + /** + * Encodes the specified DetectLanguageRequest message. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {google.cloud.translation.v3.IDetectLanguageRequest} message DetectLanguageRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectLanguageRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.content != null && message.hasOwnProperty("content")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.content); + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.mimeType); + if (message.model != null && message.hasOwnProperty("model")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.model); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.parent); + if (message.labels != null && message.hasOwnProperty("labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified DetectLanguageRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {google.cloud.translation.v3.IDetectLanguageRequest} message DetectLanguageRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectLanguageRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DetectLanguageRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DetectLanguageRequest} DetectLanguageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectLanguageRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DetectLanguageRequest(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 5: + message.parent = reader.string(); + break; + case 4: + message.model = reader.string(); + break; + case 1: + message.content = reader.string(); + break; + case 3: + message.mimeType = reader.string(); + break; + case 6: + reader.skip().pos++; + if (message.labels === $util.emptyObject) + message.labels = {}; + key = reader.string(); + reader.pos++; + message.labels[key] = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DetectLanguageRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DetectLanguageRequest} DetectLanguageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectLanguageRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DetectLanguageRequest message. + * @function verify + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DetectLanguageRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + if (message.content != null && message.hasOwnProperty("content")) { + properties.source = 1; + if (!$util.isString(message.content)) + return "content: string expected"; + } + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + if (!$util.isString(message.mimeType)) + return "mimeType: string expected"; + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + return null; + }; + + /** + * Creates a DetectLanguageRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DetectLanguageRequest} DetectLanguageRequest + */ + DetectLanguageRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DetectLanguageRequest) + return object; + var message = new $root.google.cloud.translation.v3.DetectLanguageRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.model != null) + message.model = String(object.model); + if (object.content != null) + message.content = String(object.content); + if (object.mimeType != null) + message.mimeType = String(object.mimeType); + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.translation.v3.DetectLanguageRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a DetectLanguageRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @static + * @param {google.cloud.translation.v3.DetectLanguageRequest} message DetectLanguageRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DetectLanguageRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.mimeType = ""; + object.model = ""; + object.parent = ""; + } + if (message.content != null && message.hasOwnProperty("content")) { + object.content = message.content; + if (options.oneofs) + object.source = "content"; + } + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + object.mimeType = message.mimeType; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this DetectLanguageRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DetectLanguageRequest + * @instance + * @returns {Object.} JSON object + */ + DetectLanguageRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DetectLanguageRequest; + })(); + + v3.DetectedLanguage = (function() { + + /** + * Properties of a DetectedLanguage. + * @memberof google.cloud.translation.v3 + * @interface IDetectedLanguage + * @property {string|null} [languageCode] DetectedLanguage languageCode + * @property {number|null} [confidence] DetectedLanguage confidence + */ + + /** + * Constructs a new DetectedLanguage. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DetectedLanguage. + * @implements IDetectedLanguage + * @constructor + * @param {google.cloud.translation.v3.IDetectedLanguage=} [properties] Properties to set + */ + function DetectedLanguage(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DetectedLanguage languageCode. + * @member {string} languageCode + * @memberof google.cloud.translation.v3.DetectedLanguage + * @instance + */ + DetectedLanguage.prototype.languageCode = ""; + + /** + * DetectedLanguage confidence. + * @member {number} confidence + * @memberof google.cloud.translation.v3.DetectedLanguage + * @instance + */ + DetectedLanguage.prototype.confidence = 0; + + /** + * Creates a new DetectedLanguage instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {google.cloud.translation.v3.IDetectedLanguage=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DetectedLanguage} DetectedLanguage instance + */ + DetectedLanguage.create = function create(properties) { + return new DetectedLanguage(properties); + }; + + /** + * Encodes the specified DetectedLanguage message. Does not implicitly {@link google.cloud.translation.v3.DetectedLanguage.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {google.cloud.translation.v3.IDetectedLanguage} message DetectedLanguage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectedLanguage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCode); + if (message.confidence != null && message.hasOwnProperty("confidence")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.confidence); + return writer; + }; + + /** + * Encodes the specified DetectedLanguage message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectedLanguage.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {google.cloud.translation.v3.IDetectedLanguage} message DetectedLanguage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectedLanguage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DetectedLanguage message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DetectedLanguage} DetectedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectedLanguage.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DetectedLanguage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.languageCode = reader.string(); + break; + case 2: + message.confidence = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DetectedLanguage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DetectedLanguage} DetectedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectedLanguage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DetectedLanguage message. + * @function verify + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DetectedLanguage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + if (message.confidence != null && message.hasOwnProperty("confidence")) + if (typeof message.confidence !== "number") + return "confidence: number expected"; + return null; + }; + + /** + * Creates a DetectedLanguage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DetectedLanguage} DetectedLanguage + */ + DetectedLanguage.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DetectedLanguage) + return object; + var message = new $root.google.cloud.translation.v3.DetectedLanguage(); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + if (object.confidence != null) + message.confidence = Number(object.confidence); + return message; + }; + + /** + * Creates a plain object from a DetectedLanguage message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DetectedLanguage + * @static + * @param {google.cloud.translation.v3.DetectedLanguage} message DetectedLanguage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DetectedLanguage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.languageCode = ""; + object.confidence = 0; + } + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + if (message.confidence != null && message.hasOwnProperty("confidence")) + object.confidence = options.json && !isFinite(message.confidence) ? String(message.confidence) : message.confidence; + return object; + }; + + /** + * Converts this DetectedLanguage to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DetectedLanguage + * @instance + * @returns {Object.} JSON object + */ + DetectedLanguage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DetectedLanguage; + })(); + + v3.DetectLanguageResponse = (function() { + + /** + * Properties of a DetectLanguageResponse. + * @memberof google.cloud.translation.v3 + * @interface IDetectLanguageResponse + * @property {Array.|null} [languages] DetectLanguageResponse languages + */ + + /** + * Constructs a new DetectLanguageResponse. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DetectLanguageResponse. + * @implements IDetectLanguageResponse + * @constructor + * @param {google.cloud.translation.v3.IDetectLanguageResponse=} [properties] Properties to set + */ + function DetectLanguageResponse(properties) { + this.languages = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DetectLanguageResponse languages. + * @member {Array.} languages + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @instance + */ + DetectLanguageResponse.prototype.languages = $util.emptyArray; + + /** + * Creates a new DetectLanguageResponse instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {google.cloud.translation.v3.IDetectLanguageResponse=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DetectLanguageResponse} DetectLanguageResponse instance + */ + DetectLanguageResponse.create = function create(properties) { + return new DetectLanguageResponse(properties); + }; + + /** + * Encodes the specified DetectLanguageResponse message. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {google.cloud.translation.v3.IDetectLanguageResponse} message DetectLanguageResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectLanguageResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languages != null && message.languages.length) + for (var i = 0; i < message.languages.length; ++i) + $root.google.cloud.translation.v3.DetectedLanguage.encode(message.languages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DetectLanguageResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DetectLanguageResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {google.cloud.translation.v3.IDetectLanguageResponse} message DetectLanguageResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectLanguageResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DetectLanguageResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DetectLanguageResponse} DetectLanguageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectLanguageResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DetectLanguageResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.languages && message.languages.length)) + message.languages = []; + message.languages.push($root.google.cloud.translation.v3.DetectedLanguage.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DetectLanguageResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DetectLanguageResponse} DetectLanguageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectLanguageResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DetectLanguageResponse message. + * @function verify + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DetectLanguageResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languages != null && message.hasOwnProperty("languages")) { + if (!Array.isArray(message.languages)) + return "languages: array expected"; + for (var i = 0; i < message.languages.length; ++i) { + var error = $root.google.cloud.translation.v3.DetectedLanguage.verify(message.languages[i]); + if (error) + return "languages." + error; + } + } + return null; + }; + + /** + * Creates a DetectLanguageResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DetectLanguageResponse} DetectLanguageResponse + */ + DetectLanguageResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DetectLanguageResponse) + return object; + var message = new $root.google.cloud.translation.v3.DetectLanguageResponse(); + if (object.languages) { + if (!Array.isArray(object.languages)) + throw TypeError(".google.cloud.translation.v3.DetectLanguageResponse.languages: array expected"); + message.languages = []; + for (var i = 0; i < object.languages.length; ++i) { + if (typeof object.languages[i] !== "object") + throw TypeError(".google.cloud.translation.v3.DetectLanguageResponse.languages: object expected"); + message.languages[i] = $root.google.cloud.translation.v3.DetectedLanguage.fromObject(object.languages[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DetectLanguageResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @static + * @param {google.cloud.translation.v3.DetectLanguageResponse} message DetectLanguageResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DetectLanguageResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languages = []; + if (message.languages && message.languages.length) { + object.languages = []; + for (var j = 0; j < message.languages.length; ++j) + object.languages[j] = $root.google.cloud.translation.v3.DetectedLanguage.toObject(message.languages[j], options); + } + return object; + }; + + /** + * Converts this DetectLanguageResponse to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DetectLanguageResponse + * @instance + * @returns {Object.} JSON object + */ + DetectLanguageResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DetectLanguageResponse; + })(); + + v3.GetSupportedLanguagesRequest = (function() { + + /** + * Properties of a GetSupportedLanguagesRequest. + * @memberof google.cloud.translation.v3 + * @interface IGetSupportedLanguagesRequest + * @property {string|null} [parent] GetSupportedLanguagesRequest parent + * @property {string|null} [displayLanguageCode] GetSupportedLanguagesRequest displayLanguageCode + * @property {string|null} [model] GetSupportedLanguagesRequest model + */ + + /** + * Constructs a new GetSupportedLanguagesRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a GetSupportedLanguagesRequest. + * @implements IGetSupportedLanguagesRequest + * @constructor + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest=} [properties] Properties to set + */ + function GetSupportedLanguagesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetSupportedLanguagesRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @instance + */ + GetSupportedLanguagesRequest.prototype.parent = ""; + + /** + * GetSupportedLanguagesRequest displayLanguageCode. + * @member {string} displayLanguageCode + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @instance + */ + GetSupportedLanguagesRequest.prototype.displayLanguageCode = ""; + + /** + * GetSupportedLanguagesRequest model. + * @member {string} model + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @instance + */ + GetSupportedLanguagesRequest.prototype.model = ""; + + /** + * Creates a new GetSupportedLanguagesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.GetSupportedLanguagesRequest} GetSupportedLanguagesRequest instance + */ + GetSupportedLanguagesRequest.create = function create(properties) { + return new GetSupportedLanguagesRequest(properties); + }; + + /** + * Encodes the specified GetSupportedLanguagesRequest message. Does not implicitly {@link google.cloud.translation.v3.GetSupportedLanguagesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest} message GetSupportedLanguagesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSupportedLanguagesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayLanguageCode != null && message.hasOwnProperty("displayLanguageCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayLanguageCode); + if (message.model != null && message.hasOwnProperty("model")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.model); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.parent); + return writer; + }; + + /** + * Encodes the specified GetSupportedLanguagesRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GetSupportedLanguagesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {google.cloud.translation.v3.IGetSupportedLanguagesRequest} message GetSupportedLanguagesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSupportedLanguagesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetSupportedLanguagesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.GetSupportedLanguagesRequest} GetSupportedLanguagesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSupportedLanguagesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.GetSupportedLanguagesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.parent = reader.string(); + break; + case 1: + message.displayLanguageCode = reader.string(); + break; + case 2: + message.model = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetSupportedLanguagesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.GetSupportedLanguagesRequest} GetSupportedLanguagesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSupportedLanguagesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetSupportedLanguagesRequest message. + * @function verify + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetSupportedLanguagesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.displayLanguageCode != null && message.hasOwnProperty("displayLanguageCode")) + if (!$util.isString(message.displayLanguageCode)) + return "displayLanguageCode: string expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + return null; + }; + + /** + * Creates a GetSupportedLanguagesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.GetSupportedLanguagesRequest} GetSupportedLanguagesRequest + */ + GetSupportedLanguagesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.GetSupportedLanguagesRequest) + return object; + var message = new $root.google.cloud.translation.v3.GetSupportedLanguagesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.displayLanguageCode != null) + message.displayLanguageCode = String(object.displayLanguageCode); + if (object.model != null) + message.model = String(object.model); + return message; + }; + + /** + * Creates a plain object from a GetSupportedLanguagesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @static + * @param {google.cloud.translation.v3.GetSupportedLanguagesRequest} message GetSupportedLanguagesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetSupportedLanguagesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayLanguageCode = ""; + object.model = ""; + object.parent = ""; + } + if (message.displayLanguageCode != null && message.hasOwnProperty("displayLanguageCode")) + object.displayLanguageCode = message.displayLanguageCode; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + return object; + }; + + /** + * Converts this GetSupportedLanguagesRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.GetSupportedLanguagesRequest + * @instance + * @returns {Object.} JSON object + */ + GetSupportedLanguagesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetSupportedLanguagesRequest; + })(); + + v3.SupportedLanguages = (function() { + + /** + * Properties of a SupportedLanguages. + * @memberof google.cloud.translation.v3 + * @interface ISupportedLanguages + * @property {Array.|null} [languages] SupportedLanguages languages + */ + + /** + * Constructs a new SupportedLanguages. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a SupportedLanguages. + * @implements ISupportedLanguages + * @constructor + * @param {google.cloud.translation.v3.ISupportedLanguages=} [properties] Properties to set + */ + function SupportedLanguages(properties) { + this.languages = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SupportedLanguages languages. + * @member {Array.} languages + * @memberof google.cloud.translation.v3.SupportedLanguages + * @instance + */ + SupportedLanguages.prototype.languages = $util.emptyArray; + + /** + * Creates a new SupportedLanguages instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {google.cloud.translation.v3.ISupportedLanguages=} [properties] Properties to set + * @returns {google.cloud.translation.v3.SupportedLanguages} SupportedLanguages instance + */ + SupportedLanguages.create = function create(properties) { + return new SupportedLanguages(properties); + }; + + /** + * Encodes the specified SupportedLanguages message. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguages.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {google.cloud.translation.v3.ISupportedLanguages} message SupportedLanguages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SupportedLanguages.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languages != null && message.languages.length) + for (var i = 0; i < message.languages.length; ++i) + $root.google.cloud.translation.v3.SupportedLanguage.encode(message.languages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SupportedLanguages message, length delimited. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguages.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {google.cloud.translation.v3.ISupportedLanguages} message SupportedLanguages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SupportedLanguages.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SupportedLanguages message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.SupportedLanguages} SupportedLanguages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SupportedLanguages.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.SupportedLanguages(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.languages && message.languages.length)) + message.languages = []; + message.languages.push($root.google.cloud.translation.v3.SupportedLanguage.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SupportedLanguages message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.SupportedLanguages} SupportedLanguages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SupportedLanguages.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SupportedLanguages message. + * @function verify + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SupportedLanguages.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languages != null && message.hasOwnProperty("languages")) { + if (!Array.isArray(message.languages)) + return "languages: array expected"; + for (var i = 0; i < message.languages.length; ++i) { + var error = $root.google.cloud.translation.v3.SupportedLanguage.verify(message.languages[i]); + if (error) + return "languages." + error; + } + } + return null; + }; + + /** + * Creates a SupportedLanguages message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.SupportedLanguages} SupportedLanguages + */ + SupportedLanguages.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.SupportedLanguages) + return object; + var message = new $root.google.cloud.translation.v3.SupportedLanguages(); + if (object.languages) { + if (!Array.isArray(object.languages)) + throw TypeError(".google.cloud.translation.v3.SupportedLanguages.languages: array expected"); + message.languages = []; + for (var i = 0; i < object.languages.length; ++i) { + if (typeof object.languages[i] !== "object") + throw TypeError(".google.cloud.translation.v3.SupportedLanguages.languages: object expected"); + message.languages[i] = $root.google.cloud.translation.v3.SupportedLanguage.fromObject(object.languages[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SupportedLanguages message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.SupportedLanguages + * @static + * @param {google.cloud.translation.v3.SupportedLanguages} message SupportedLanguages + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SupportedLanguages.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languages = []; + if (message.languages && message.languages.length) { + object.languages = []; + for (var j = 0; j < message.languages.length; ++j) + object.languages[j] = $root.google.cloud.translation.v3.SupportedLanguage.toObject(message.languages[j], options); + } + return object; + }; + + /** + * Converts this SupportedLanguages to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.SupportedLanguages + * @instance + * @returns {Object.} JSON object + */ + SupportedLanguages.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SupportedLanguages; + })(); + + v3.SupportedLanguage = (function() { + + /** + * Properties of a SupportedLanguage. + * @memberof google.cloud.translation.v3 + * @interface ISupportedLanguage + * @property {string|null} [languageCode] SupportedLanguage languageCode + * @property {string|null} [displayName] SupportedLanguage displayName + * @property {boolean|null} [supportSource] SupportedLanguage supportSource + * @property {boolean|null} [supportTarget] SupportedLanguage supportTarget + */ + + /** + * Constructs a new SupportedLanguage. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a SupportedLanguage. + * @implements ISupportedLanguage + * @constructor + * @param {google.cloud.translation.v3.ISupportedLanguage=} [properties] Properties to set + */ + function SupportedLanguage(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SupportedLanguage languageCode. + * @member {string} languageCode + * @memberof google.cloud.translation.v3.SupportedLanguage + * @instance + */ + SupportedLanguage.prototype.languageCode = ""; + + /** + * SupportedLanguage displayName. + * @member {string} displayName + * @memberof google.cloud.translation.v3.SupportedLanguage + * @instance + */ + SupportedLanguage.prototype.displayName = ""; + + /** + * SupportedLanguage supportSource. + * @member {boolean} supportSource + * @memberof google.cloud.translation.v3.SupportedLanguage + * @instance + */ + SupportedLanguage.prototype.supportSource = false; + + /** + * SupportedLanguage supportTarget. + * @member {boolean} supportTarget + * @memberof google.cloud.translation.v3.SupportedLanguage + * @instance + */ + SupportedLanguage.prototype.supportTarget = false; + + /** + * Creates a new SupportedLanguage instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {google.cloud.translation.v3.ISupportedLanguage=} [properties] Properties to set + * @returns {google.cloud.translation.v3.SupportedLanguage} SupportedLanguage instance + */ + SupportedLanguage.create = function create(properties) { + return new SupportedLanguage(properties); + }; + + /** + * Encodes the specified SupportedLanguage message. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguage.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {google.cloud.translation.v3.ISupportedLanguage} message SupportedLanguage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SupportedLanguage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCode); + if (message.displayName != null && message.hasOwnProperty("displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.supportSource != null && message.hasOwnProperty("supportSource")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.supportSource); + if (message.supportTarget != null && message.hasOwnProperty("supportTarget")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.supportTarget); + return writer; + }; + + /** + * Encodes the specified SupportedLanguage message, length delimited. Does not implicitly {@link google.cloud.translation.v3.SupportedLanguage.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {google.cloud.translation.v3.ISupportedLanguage} message SupportedLanguage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SupportedLanguage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SupportedLanguage message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.SupportedLanguage} SupportedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SupportedLanguage.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.SupportedLanguage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.languageCode = reader.string(); + break; + case 2: + message.displayName = reader.string(); + break; + case 3: + message.supportSource = reader.bool(); + break; + case 4: + message.supportTarget = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SupportedLanguage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.SupportedLanguage} SupportedLanguage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SupportedLanguage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SupportedLanguage message. + * @function verify + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SupportedLanguage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.supportSource != null && message.hasOwnProperty("supportSource")) + if (typeof message.supportSource !== "boolean") + return "supportSource: boolean expected"; + if (message.supportTarget != null && message.hasOwnProperty("supportTarget")) + if (typeof message.supportTarget !== "boolean") + return "supportTarget: boolean expected"; + return null; + }; + + /** + * Creates a SupportedLanguage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.SupportedLanguage} SupportedLanguage + */ + SupportedLanguage.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.SupportedLanguage) + return object; + var message = new $root.google.cloud.translation.v3.SupportedLanguage(); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.supportSource != null) + message.supportSource = Boolean(object.supportSource); + if (object.supportTarget != null) + message.supportTarget = Boolean(object.supportTarget); + return message; + }; + + /** + * Creates a plain object from a SupportedLanguage message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.SupportedLanguage + * @static + * @param {google.cloud.translation.v3.SupportedLanguage} message SupportedLanguage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SupportedLanguage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.languageCode = ""; + object.displayName = ""; + object.supportSource = false; + object.supportTarget = false; + } + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.supportSource != null && message.hasOwnProperty("supportSource")) + object.supportSource = message.supportSource; + if (message.supportTarget != null && message.hasOwnProperty("supportTarget")) + object.supportTarget = message.supportTarget; + return object; + }; + + /** + * Converts this SupportedLanguage to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.SupportedLanguage + * @instance + * @returns {Object.} JSON object + */ + SupportedLanguage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SupportedLanguage; + })(); + + v3.GcsSource = (function() { + + /** + * Properties of a GcsSource. + * @memberof google.cloud.translation.v3 + * @interface IGcsSource + * @property {string|null} [inputUri] GcsSource inputUri + */ + + /** + * Constructs a new GcsSource. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a GcsSource. + * @implements IGcsSource + * @constructor + * @param {google.cloud.translation.v3.IGcsSource=} [properties] Properties to set + */ + function GcsSource(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GcsSource inputUri. + * @member {string} inputUri + * @memberof google.cloud.translation.v3.GcsSource + * @instance + */ + GcsSource.prototype.inputUri = ""; + + /** + * Creates a new GcsSource instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {google.cloud.translation.v3.IGcsSource=} [properties] Properties to set + * @returns {google.cloud.translation.v3.GcsSource} GcsSource instance + */ + GcsSource.create = function create(properties) { + return new GcsSource(properties); + }; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.translation.v3.GcsSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {google.cloud.translation.v3.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputUri != null && message.hasOwnProperty("inputUri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.inputUri); + return writer; + }; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GcsSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {google.cloud.translation.v3.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.GcsSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inputUri = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GcsSource message. + * @function verify + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GcsSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputUri != null && message.hasOwnProperty("inputUri")) + if (!$util.isString(message.inputUri)) + return "inputUri: string expected"; + return null; + }; + + /** + * Creates a GcsSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.GcsSource} GcsSource + */ + GcsSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.GcsSource) + return object; + var message = new $root.google.cloud.translation.v3.GcsSource(); + if (object.inputUri != null) + message.inputUri = String(object.inputUri); + return message; + }; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.GcsSource + * @static + * @param {google.cloud.translation.v3.GcsSource} message GcsSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GcsSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.inputUri = ""; + if (message.inputUri != null && message.hasOwnProperty("inputUri")) + object.inputUri = message.inputUri; + return object; + }; + + /** + * Converts this GcsSource to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.GcsSource + * @instance + * @returns {Object.} JSON object + */ + GcsSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GcsSource; + })(); + + v3.InputConfig = (function() { + + /** + * Properties of an InputConfig. + * @memberof google.cloud.translation.v3 + * @interface IInputConfig + * @property {string|null} [mimeType] InputConfig mimeType + * @property {google.cloud.translation.v3.IGcsSource|null} [gcsSource] InputConfig gcsSource + */ + + /** + * Constructs a new InputConfig. + * @memberof google.cloud.translation.v3 + * @classdesc Represents an InputConfig. + * @implements IInputConfig + * @constructor + * @param {google.cloud.translation.v3.IInputConfig=} [properties] Properties to set + */ + function InputConfig(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * InputConfig mimeType. + * @member {string} mimeType + * @memberof google.cloud.translation.v3.InputConfig + * @instance + */ + InputConfig.prototype.mimeType = ""; + + /** + * InputConfig gcsSource. + * @member {google.cloud.translation.v3.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.translation.v3.InputConfig + * @instance + */ + InputConfig.prototype.gcsSource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * InputConfig source. + * @member {"gcsSource"|undefined} source + * @memberof google.cloud.translation.v3.InputConfig + * @instance + */ + Object.defineProperty(InputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["gcsSource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new InputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {google.cloud.translation.v3.IInputConfig=} [properties] Properties to set + * @returns {google.cloud.translation.v3.InputConfig} InputConfig instance + */ + InputConfig.create = function create(properties) { + return new InputConfig(properties); + }; + + /** + * Encodes the specified InputConfig message. Does not implicitly {@link google.cloud.translation.v3.InputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {google.cloud.translation.v3.IInputConfig} message InputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.mimeType); + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) + $root.google.cloud.translation.v3.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified InputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.InputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {google.cloud.translation.v3.IInputConfig} message InputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.InputConfig} InputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputConfig.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.InputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mimeType = reader.string(); + break; + case 2: + message.gcsSource = $root.google.cloud.translation.v3.GcsSource.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.InputConfig} InputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InputConfig message. + * @function verify + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + if (!$util.isString(message.mimeType)) + return "mimeType: string expected"; + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + properties.source = 1; + { + var error = $root.google.cloud.translation.v3.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + return null; + }; + + /** + * Creates an InputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.InputConfig} InputConfig + */ + InputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.InputConfig) + return object; + var message = new $root.google.cloud.translation.v3.InputConfig(); + if (object.mimeType != null) + message.mimeType = String(object.mimeType); + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.translation.v3.InputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.translation.v3.GcsSource.fromObject(object.gcsSource); + } + return message; + }; + + /** + * Creates a plain object from an InputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.InputConfig + * @static + * @param {google.cloud.translation.v3.InputConfig} message InputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mimeType = ""; + if (message.mimeType != null && message.hasOwnProperty("mimeType")) + object.mimeType = message.mimeType; + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.translation.v3.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + return object; + }; + + /** + * Converts this InputConfig to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.InputConfig + * @instance + * @returns {Object.} JSON object + */ + InputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return InputConfig; + })(); + + v3.GcsDestination = (function() { + + /** + * Properties of a GcsDestination. + * @memberof google.cloud.translation.v3 + * @interface IGcsDestination + * @property {string|null} [outputUriPrefix] GcsDestination outputUriPrefix + */ + + /** + * Constructs a new GcsDestination. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a GcsDestination. + * @implements IGcsDestination + * @constructor + * @param {google.cloud.translation.v3.IGcsDestination=} [properties] Properties to set + */ + function GcsDestination(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GcsDestination outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.cloud.translation.v3.GcsDestination + * @instance + */ + GcsDestination.prototype.outputUriPrefix = ""; + + /** + * Creates a new GcsDestination instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {google.cloud.translation.v3.IGcsDestination=} [properties] Properties to set + * @returns {google.cloud.translation.v3.GcsDestination} GcsDestination instance + */ + GcsDestination.create = function create(properties) { + return new GcsDestination(properties); + }; + + /** + * Encodes the specified GcsDestination message. Does not implicitly {@link google.cloud.translation.v3.GcsDestination.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {google.cloud.translation.v3.IGcsDestination} message GcsDestination message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsDestination.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.outputUriPrefix); + return writer; + }; + + /** + * Encodes the specified GcsDestination message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GcsDestination.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {google.cloud.translation.v3.IGcsDestination} message GcsDestination message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsDestination.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GcsDestination message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.GcsDestination} GcsDestination + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsDestination.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.GcsDestination(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.outputUriPrefix = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GcsDestination message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.GcsDestination} GcsDestination + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsDestination.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GcsDestination message. + * @function verify + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GcsDestination.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + if (!$util.isString(message.outputUriPrefix)) + return "outputUriPrefix: string expected"; + return null; + }; + + /** + * Creates a GcsDestination message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.GcsDestination} GcsDestination + */ + GcsDestination.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.GcsDestination) + return object; + var message = new $root.google.cloud.translation.v3.GcsDestination(); + if (object.outputUriPrefix != null) + message.outputUriPrefix = String(object.outputUriPrefix); + return message; + }; + + /** + * Creates a plain object from a GcsDestination message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.GcsDestination + * @static + * @param {google.cloud.translation.v3.GcsDestination} message GcsDestination + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GcsDestination.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.outputUriPrefix = ""; + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + object.outputUriPrefix = message.outputUriPrefix; + return object; + }; + + /** + * Converts this GcsDestination to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.GcsDestination + * @instance + * @returns {Object.} JSON object + */ + GcsDestination.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GcsDestination; + })(); + + v3.OutputConfig = (function() { + + /** + * Properties of an OutputConfig. + * @memberof google.cloud.translation.v3 + * @interface IOutputConfig + * @property {google.cloud.translation.v3.IGcsDestination|null} [gcsDestination] OutputConfig gcsDestination + */ + + /** + * Constructs a new OutputConfig. + * @memberof google.cloud.translation.v3 + * @classdesc Represents an OutputConfig. + * @implements IOutputConfig + * @constructor + * @param {google.cloud.translation.v3.IOutputConfig=} [properties] Properties to set + */ + function OutputConfig(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OutputConfig gcsDestination. + * @member {google.cloud.translation.v3.IGcsDestination|null|undefined} gcsDestination + * @memberof google.cloud.translation.v3.OutputConfig + * @instance + */ + OutputConfig.prototype.gcsDestination = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * OutputConfig destination. + * @member {"gcsDestination"|undefined} destination + * @memberof google.cloud.translation.v3.OutputConfig + * @instance + */ + Object.defineProperty(OutputConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsDestination"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new OutputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {google.cloud.translation.v3.IOutputConfig=} [properties] Properties to set + * @returns {google.cloud.translation.v3.OutputConfig} OutputConfig instance + */ + OutputConfig.create = function create(properties) { + return new OutputConfig(properties); + }; + + /** + * Encodes the specified OutputConfig message. Does not implicitly {@link google.cloud.translation.v3.OutputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {google.cloud.translation.v3.IOutputConfig} message OutputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) + $root.google.cloud.translation.v3.GcsDestination.encode(message.gcsDestination, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OutputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.OutputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {google.cloud.translation.v3.IOutputConfig} message OutputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OutputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.OutputConfig} OutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputConfig.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.OutputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gcsDestination = $root.google.cloud.translation.v3.GcsDestination.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OutputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.OutputConfig} OutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OutputConfig message. + * @function verify + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OutputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) { + properties.destination = 1; + { + var error = $root.google.cloud.translation.v3.GcsDestination.verify(message.gcsDestination); + if (error) + return "gcsDestination." + error; + } + } + return null; + }; + + /** + * Creates an OutputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.OutputConfig} OutputConfig + */ + OutputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.OutputConfig) + return object; + var message = new $root.google.cloud.translation.v3.OutputConfig(); + if (object.gcsDestination != null) { + if (typeof object.gcsDestination !== "object") + throw TypeError(".google.cloud.translation.v3.OutputConfig.gcsDestination: object expected"); + message.gcsDestination = $root.google.cloud.translation.v3.GcsDestination.fromObject(object.gcsDestination); + } + return message; + }; + + /** + * Creates a plain object from an OutputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.OutputConfig + * @static + * @param {google.cloud.translation.v3.OutputConfig} message OutputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OutputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) { + object.gcsDestination = $root.google.cloud.translation.v3.GcsDestination.toObject(message.gcsDestination, options); + if (options.oneofs) + object.destination = "gcsDestination"; + } + return object; + }; + + /** + * Converts this OutputConfig to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.OutputConfig + * @instance + * @returns {Object.} JSON object + */ + OutputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OutputConfig; + })(); + + v3.BatchTranslateTextRequest = (function() { + + /** + * Properties of a BatchTranslateTextRequest. + * @memberof google.cloud.translation.v3 + * @interface IBatchTranslateTextRequest + * @property {string|null} [parent] BatchTranslateTextRequest parent + * @property {string|null} [sourceLanguageCode] BatchTranslateTextRequest sourceLanguageCode + * @property {Array.|null} [targetLanguageCodes] BatchTranslateTextRequest targetLanguageCodes + * @property {Object.|null} [models] BatchTranslateTextRequest models + * @property {Array.|null} [inputConfigs] BatchTranslateTextRequest inputConfigs + * @property {google.cloud.translation.v3.IOutputConfig|null} [outputConfig] BatchTranslateTextRequest outputConfig + * @property {Object.|null} [glossaries] BatchTranslateTextRequest glossaries + * @property {Object.|null} [labels] BatchTranslateTextRequest labels + */ + + /** + * Constructs a new BatchTranslateTextRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a BatchTranslateTextRequest. + * @implements IBatchTranslateTextRequest + * @constructor + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest=} [properties] Properties to set + */ + function BatchTranslateTextRequest(properties) { + this.targetLanguageCodes = []; + this.models = {}; + this.inputConfigs = []; + this.glossaries = {}; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchTranslateTextRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.parent = ""; + + /** + * BatchTranslateTextRequest sourceLanguageCode. + * @member {string} sourceLanguageCode + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.sourceLanguageCode = ""; + + /** + * BatchTranslateTextRequest targetLanguageCodes. + * @member {Array.} targetLanguageCodes + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.targetLanguageCodes = $util.emptyArray; + + /** + * BatchTranslateTextRequest models. + * @member {Object.} models + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.models = $util.emptyObject; + + /** + * BatchTranslateTextRequest inputConfigs. + * @member {Array.} inputConfigs + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.inputConfigs = $util.emptyArray; + + /** + * BatchTranslateTextRequest outputConfig. + * @member {google.cloud.translation.v3.IOutputConfig|null|undefined} outputConfig + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.outputConfig = null; + + /** + * BatchTranslateTextRequest glossaries. + * @member {Object.} glossaries + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.glossaries = $util.emptyObject; + + /** + * BatchTranslateTextRequest labels. + * @member {Object.} labels + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + */ + BatchTranslateTextRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a new BatchTranslateTextRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.BatchTranslateTextRequest} BatchTranslateTextRequest instance + */ + BatchTranslateTextRequest.create = function create(properties) { + return new BatchTranslateTextRequest(properties); + }; + + /** + * Encodes the specified BatchTranslateTextRequest message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateTextRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest} message BatchTranslateTextRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateTextRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.sourceLanguageCode); + if (message.targetLanguageCodes != null && message.targetLanguageCodes.length) + for (var i = 0; i < message.targetLanguageCodes.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.targetLanguageCodes[i]); + if (message.models != null && message.hasOwnProperty("models")) + for (var keys = Object.keys(message.models), i = 0; i < keys.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.models[keys[i]]).ldelim(); + if (message.inputConfigs != null && message.inputConfigs.length) + for (var i = 0; i < message.inputConfigs.length; ++i) + $root.google.cloud.translation.v3.InputConfig.encode(message.inputConfigs[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) + $root.google.cloud.translation.v3.OutputConfig.encode(message.outputConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.glossaries != null && message.hasOwnProperty("glossaries")) + for (var keys = Object.keys(message.glossaries), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.encode(message.glossaries[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.labels != null && message.hasOwnProperty("labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchTranslateTextRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateTextRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {google.cloud.translation.v3.IBatchTranslateTextRequest} message BatchTranslateTextRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateTextRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchTranslateTextRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.BatchTranslateTextRequest} BatchTranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateTextRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.BatchTranslateTextRequest(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.sourceLanguageCode = reader.string(); + break; + case 3: + if (!(message.targetLanguageCodes && message.targetLanguageCodes.length)) + message.targetLanguageCodes = []; + message.targetLanguageCodes.push(reader.string()); + break; + case 4: + reader.skip().pos++; + if (message.models === $util.emptyObject) + message.models = {}; + key = reader.string(); + reader.pos++; + message.models[key] = reader.string(); + break; + case 5: + if (!(message.inputConfigs && message.inputConfigs.length)) + message.inputConfigs = []; + message.inputConfigs.push($root.google.cloud.translation.v3.InputConfig.decode(reader, reader.uint32())); + break; + case 6: + message.outputConfig = $root.google.cloud.translation.v3.OutputConfig.decode(reader, reader.uint32()); + break; + case 7: + reader.skip().pos++; + if (message.glossaries === $util.emptyObject) + message.glossaries = {}; + key = reader.string(); + reader.pos++; + message.glossaries[key] = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.decode(reader, reader.uint32()); + break; + case 9: + reader.skip().pos++; + if (message.labels === $util.emptyObject) + message.labels = {}; + key = reader.string(); + reader.pos++; + message.labels[key] = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchTranslateTextRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.BatchTranslateTextRequest} BatchTranslateTextRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateTextRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchTranslateTextRequest message. + * @function verify + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchTranslateTextRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + if (!$util.isString(message.sourceLanguageCode)) + return "sourceLanguageCode: string expected"; + if (message.targetLanguageCodes != null && message.hasOwnProperty("targetLanguageCodes")) { + if (!Array.isArray(message.targetLanguageCodes)) + return "targetLanguageCodes: array expected"; + for (var i = 0; i < message.targetLanguageCodes.length; ++i) + if (!$util.isString(message.targetLanguageCodes[i])) + return "targetLanguageCodes: string[] expected"; + } + if (message.models != null && message.hasOwnProperty("models")) { + if (!$util.isObject(message.models)) + return "models: object expected"; + var key = Object.keys(message.models); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.models[key[i]])) + return "models: string{k:string} expected"; + } + if (message.inputConfigs != null && message.hasOwnProperty("inputConfigs")) { + if (!Array.isArray(message.inputConfigs)) + return "inputConfigs: array expected"; + for (var i = 0; i < message.inputConfigs.length; ++i) { + var error = $root.google.cloud.translation.v3.InputConfig.verify(message.inputConfigs[i]); + if (error) + return "inputConfigs." + error; + } + } + if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) { + var error = $root.google.cloud.translation.v3.OutputConfig.verify(message.outputConfig); + if (error) + return "outputConfig." + error; + } + if (message.glossaries != null && message.hasOwnProperty("glossaries")) { + if (!$util.isObject(message.glossaries)) + return "glossaries: object expected"; + var key = Object.keys(message.glossaries); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.verify(message.glossaries[key[i]]); + if (error) + return "glossaries." + error; + } + } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + return null; + }; + + /** + * Creates a BatchTranslateTextRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.BatchTranslateTextRequest} BatchTranslateTextRequest + */ + BatchTranslateTextRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.BatchTranslateTextRequest) + return object; + var message = new $root.google.cloud.translation.v3.BatchTranslateTextRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.sourceLanguageCode != null) + message.sourceLanguageCode = String(object.sourceLanguageCode); + if (object.targetLanguageCodes) { + if (!Array.isArray(object.targetLanguageCodes)) + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.targetLanguageCodes: array expected"); + message.targetLanguageCodes = []; + for (var i = 0; i < object.targetLanguageCodes.length; ++i) + message.targetLanguageCodes[i] = String(object.targetLanguageCodes[i]); + } + if (object.models) { + if (typeof object.models !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.models: object expected"); + message.models = {}; + for (var keys = Object.keys(object.models), i = 0; i < keys.length; ++i) + message.models[keys[i]] = String(object.models[keys[i]]); + } + if (object.inputConfigs) { + if (!Array.isArray(object.inputConfigs)) + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.inputConfigs: array expected"); + message.inputConfigs = []; + for (var i = 0; i < object.inputConfigs.length; ++i) { + if (typeof object.inputConfigs[i] !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.inputConfigs: object expected"); + message.inputConfigs[i] = $root.google.cloud.translation.v3.InputConfig.fromObject(object.inputConfigs[i]); + } + } + if (object.outputConfig != null) { + if (typeof object.outputConfig !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.outputConfig: object expected"); + message.outputConfig = $root.google.cloud.translation.v3.OutputConfig.fromObject(object.outputConfig); + } + if (object.glossaries) { + if (typeof object.glossaries !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.glossaries: object expected"); + message.glossaries = {}; + for (var keys = Object.keys(object.glossaries), i = 0; i < keys.length; ++i) { + if (typeof object.glossaries[keys[i]] !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.glossaries: object expected"); + message.glossaries[keys[i]] = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.fromObject(object.glossaries[keys[i]]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateTextRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a BatchTranslateTextRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @static + * @param {google.cloud.translation.v3.BatchTranslateTextRequest} message BatchTranslateTextRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchTranslateTextRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.targetLanguageCodes = []; + object.inputConfigs = []; + } + if (options.objects || options.defaults) { + object.models = {}; + object.glossaries = {}; + object.labels = {}; + } + if (options.defaults) { + object.parent = ""; + object.sourceLanguageCode = ""; + object.outputConfig = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + object.sourceLanguageCode = message.sourceLanguageCode; + if (message.targetLanguageCodes && message.targetLanguageCodes.length) { + object.targetLanguageCodes = []; + for (var j = 0; j < message.targetLanguageCodes.length; ++j) + object.targetLanguageCodes[j] = message.targetLanguageCodes[j]; + } + var keys2; + if (message.models && (keys2 = Object.keys(message.models)).length) { + object.models = {}; + for (var j = 0; j < keys2.length; ++j) + object.models[keys2[j]] = message.models[keys2[j]]; + } + if (message.inputConfigs && message.inputConfigs.length) { + object.inputConfigs = []; + for (var j = 0; j < message.inputConfigs.length; ++j) + object.inputConfigs[j] = $root.google.cloud.translation.v3.InputConfig.toObject(message.inputConfigs[j], options); + } + if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) + object.outputConfig = $root.google.cloud.translation.v3.OutputConfig.toObject(message.outputConfig, options); + if (message.glossaries && (keys2 = Object.keys(message.glossaries)).length) { + object.glossaries = {}; + for (var j = 0; j < keys2.length; ++j) + object.glossaries[keys2[j]] = $root.google.cloud.translation.v3.TranslateTextGlossaryConfig.toObject(message.glossaries[keys2[j]], options); + } + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this BatchTranslateTextRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.BatchTranslateTextRequest + * @instance + * @returns {Object.} JSON object + */ + BatchTranslateTextRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchTranslateTextRequest; + })(); + + v3.BatchTranslateMetadata = (function() { + + /** + * Properties of a BatchTranslateMetadata. + * @memberof google.cloud.translation.v3 + * @interface IBatchTranslateMetadata + * @property {google.cloud.translation.v3.BatchTranslateMetadata.State|null} [state] BatchTranslateMetadata state + * @property {number|Long|null} [translatedCharacters] BatchTranslateMetadata translatedCharacters + * @property {number|Long|null} [failedCharacters] BatchTranslateMetadata failedCharacters + * @property {number|Long|null} [totalCharacters] BatchTranslateMetadata totalCharacters + * @property {google.protobuf.ITimestamp|null} [submitTime] BatchTranslateMetadata submitTime + */ + + /** + * Constructs a new BatchTranslateMetadata. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a BatchTranslateMetadata. + * @implements IBatchTranslateMetadata + * @constructor + * @param {google.cloud.translation.v3.IBatchTranslateMetadata=} [properties] Properties to set + */ + function BatchTranslateMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchTranslateMetadata state. + * @member {google.cloud.translation.v3.BatchTranslateMetadata.State} state + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + */ + BatchTranslateMetadata.prototype.state = 0; + + /** + * BatchTranslateMetadata translatedCharacters. + * @member {number|Long} translatedCharacters + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + */ + BatchTranslateMetadata.prototype.translatedCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateMetadata failedCharacters. + * @member {number|Long} failedCharacters + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + */ + BatchTranslateMetadata.prototype.failedCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateMetadata totalCharacters. + * @member {number|Long} totalCharacters + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + */ + BatchTranslateMetadata.prototype.totalCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateMetadata submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + */ + BatchTranslateMetadata.prototype.submitTime = null; + + /** + * Creates a new BatchTranslateMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {google.cloud.translation.v3.IBatchTranslateMetadata=} [properties] Properties to set + * @returns {google.cloud.translation.v3.BatchTranslateMetadata} BatchTranslateMetadata instance + */ + BatchTranslateMetadata.create = function create(properties) { + return new BatchTranslateMetadata(properties); + }; + + /** + * Encodes the specified BatchTranslateMetadata message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {google.cloud.translation.v3.IBatchTranslateMetadata} message BatchTranslateMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.state != null && message.hasOwnProperty("state")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.translatedCharacters); + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.failedCharacters); + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.totalCharacters); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchTranslateMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {google.cloud.translation.v3.IBatchTranslateMetadata} message BatchTranslateMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchTranslateMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.BatchTranslateMetadata} BatchTranslateMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.BatchTranslateMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32(); + break; + case 2: + message.translatedCharacters = reader.int64(); + break; + case 3: + message.failedCharacters = reader.int64(); + break; + case 4: + message.totalCharacters = reader.int64(); + break; + case 5: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchTranslateMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.BatchTranslateMetadata} BatchTranslateMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchTranslateMetadata message. + * @function verify + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchTranslateMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + if (!$util.isInteger(message.translatedCharacters) && !(message.translatedCharacters && $util.isInteger(message.translatedCharacters.low) && $util.isInteger(message.translatedCharacters.high))) + return "translatedCharacters: integer|Long expected"; + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + if (!$util.isInteger(message.failedCharacters) && !(message.failedCharacters && $util.isInteger(message.failedCharacters.low) && $util.isInteger(message.failedCharacters.high))) + return "failedCharacters: integer|Long expected"; + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + if (!$util.isInteger(message.totalCharacters) && !(message.totalCharacters && $util.isInteger(message.totalCharacters.low) && $util.isInteger(message.totalCharacters.high))) + return "totalCharacters: integer|Long expected"; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + return null; + }; + + /** + * Creates a BatchTranslateMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.BatchTranslateMetadata} BatchTranslateMetadata + */ + BatchTranslateMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.BatchTranslateMetadata) + return object; + var message = new $root.google.cloud.translation.v3.BatchTranslateMetadata(); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "RUNNING": + case 1: + message.state = 1; + break; + case "SUCCEEDED": + case 2: + message.state = 2; + break; + case "FAILED": + case 3: + message.state = 3; + break; + case "CANCELLING": + case 4: + message.state = 4; + break; + case "CANCELLED": + case 5: + message.state = 5; + break; + } + if (object.translatedCharacters != null) + if ($util.Long) + (message.translatedCharacters = $util.Long.fromValue(object.translatedCharacters)).unsigned = false; + else if (typeof object.translatedCharacters === "string") + message.translatedCharacters = parseInt(object.translatedCharacters, 10); + else if (typeof object.translatedCharacters === "number") + message.translatedCharacters = object.translatedCharacters; + else if (typeof object.translatedCharacters === "object") + message.translatedCharacters = new $util.LongBits(object.translatedCharacters.low >>> 0, object.translatedCharacters.high >>> 0).toNumber(); + if (object.failedCharacters != null) + if ($util.Long) + (message.failedCharacters = $util.Long.fromValue(object.failedCharacters)).unsigned = false; + else if (typeof object.failedCharacters === "string") + message.failedCharacters = parseInt(object.failedCharacters, 10); + else if (typeof object.failedCharacters === "number") + message.failedCharacters = object.failedCharacters; + else if (typeof object.failedCharacters === "object") + message.failedCharacters = new $util.LongBits(object.failedCharacters.low >>> 0, object.failedCharacters.high >>> 0).toNumber(); + if (object.totalCharacters != null) + if ($util.Long) + (message.totalCharacters = $util.Long.fromValue(object.totalCharacters)).unsigned = false; + else if (typeof object.totalCharacters === "string") + message.totalCharacters = parseInt(object.totalCharacters, 10); + else if (typeof object.totalCharacters === "number") + message.totalCharacters = object.totalCharacters; + else if (typeof object.totalCharacters === "object") + message.totalCharacters = new $util.LongBits(object.totalCharacters.low >>> 0, object.totalCharacters.high >>> 0).toNumber(); + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateMetadata.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchTranslateMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @static + * @param {google.cloud.translation.v3.BatchTranslateMetadata} message BatchTranslateMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchTranslateMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.translatedCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.translatedCharacters = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failedCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failedCharacters = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.totalCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.totalCharacters = options.longs === String ? "0" : 0; + object.submitTime = null; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.translation.v3.BatchTranslateMetadata.State[message.state] : message.state; + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + if (typeof message.translatedCharacters === "number") + object.translatedCharacters = options.longs === String ? String(message.translatedCharacters) : message.translatedCharacters; + else + object.translatedCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.translatedCharacters) : options.longs === Number ? new $util.LongBits(message.translatedCharacters.low >>> 0, message.translatedCharacters.high >>> 0).toNumber() : message.translatedCharacters; + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + if (typeof message.failedCharacters === "number") + object.failedCharacters = options.longs === String ? String(message.failedCharacters) : message.failedCharacters; + else + object.failedCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.failedCharacters) : options.longs === Number ? new $util.LongBits(message.failedCharacters.low >>> 0, message.failedCharacters.high >>> 0).toNumber() : message.failedCharacters; + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + if (typeof message.totalCharacters === "number") + object.totalCharacters = options.longs === String ? String(message.totalCharacters) : message.totalCharacters; + else + object.totalCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.totalCharacters) : options.longs === Number ? new $util.LongBits(message.totalCharacters.low >>> 0, message.totalCharacters.high >>> 0).toNumber() : message.totalCharacters; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + return object; + }; + + /** + * Converts this BatchTranslateMetadata to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.BatchTranslateMetadata + * @instance + * @returns {Object.} JSON object + */ + BatchTranslateMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.cloud.translation.v3.BatchTranslateMetadata.State + * @enum {string} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} RUNNING=1 RUNNING value + * @property {number} SUCCEEDED=2 SUCCEEDED value + * @property {number} FAILED=3 FAILED value + * @property {number} CANCELLING=4 CANCELLING value + * @property {number} CANCELLED=5 CANCELLED value + */ + BatchTranslateMetadata.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "RUNNING"] = 1; + values[valuesById[2] = "SUCCEEDED"] = 2; + values[valuesById[3] = "FAILED"] = 3; + values[valuesById[4] = "CANCELLING"] = 4; + values[valuesById[5] = "CANCELLED"] = 5; + return values; + })(); + + return BatchTranslateMetadata; + })(); + + v3.BatchTranslateResponse = (function() { + + /** + * Properties of a BatchTranslateResponse. + * @memberof google.cloud.translation.v3 + * @interface IBatchTranslateResponse + * @property {number|Long|null} [totalCharacters] BatchTranslateResponse totalCharacters + * @property {number|Long|null} [translatedCharacters] BatchTranslateResponse translatedCharacters + * @property {number|Long|null} [failedCharacters] BatchTranslateResponse failedCharacters + * @property {google.protobuf.ITimestamp|null} [submitTime] BatchTranslateResponse submitTime + * @property {google.protobuf.ITimestamp|null} [endTime] BatchTranslateResponse endTime + */ + + /** + * Constructs a new BatchTranslateResponse. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a BatchTranslateResponse. + * @implements IBatchTranslateResponse + * @constructor + * @param {google.cloud.translation.v3.IBatchTranslateResponse=} [properties] Properties to set + */ + function BatchTranslateResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchTranslateResponse totalCharacters. + * @member {number|Long} totalCharacters + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + */ + BatchTranslateResponse.prototype.totalCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateResponse translatedCharacters. + * @member {number|Long} translatedCharacters + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + */ + BatchTranslateResponse.prototype.translatedCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateResponse failedCharacters. + * @member {number|Long} failedCharacters + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + */ + BatchTranslateResponse.prototype.failedCharacters = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * BatchTranslateResponse submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + */ + BatchTranslateResponse.prototype.submitTime = null; + + /** + * BatchTranslateResponse endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + */ + BatchTranslateResponse.prototype.endTime = null; + + /** + * Creates a new BatchTranslateResponse instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {google.cloud.translation.v3.IBatchTranslateResponse=} [properties] Properties to set + * @returns {google.cloud.translation.v3.BatchTranslateResponse} BatchTranslateResponse instance + */ + BatchTranslateResponse.create = function create(properties) { + return new BatchTranslateResponse(properties); + }; + + /** + * Encodes the specified BatchTranslateResponse message. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {google.cloud.translation.v3.IBatchTranslateResponse} message BatchTranslateResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.totalCharacters); + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.translatedCharacters); + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.failedCharacters); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.endTime != null && message.hasOwnProperty("endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchTranslateResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.BatchTranslateResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {google.cloud.translation.v3.IBatchTranslateResponse} message BatchTranslateResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchTranslateResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchTranslateResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.BatchTranslateResponse} BatchTranslateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.BatchTranslateResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.totalCharacters = reader.int64(); + break; + case 2: + message.translatedCharacters = reader.int64(); + break; + case 3: + message.failedCharacters = reader.int64(); + break; + case 4: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 5: + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchTranslateResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.BatchTranslateResponse} BatchTranslateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchTranslateResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchTranslateResponse message. + * @function verify + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchTranslateResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + if (!$util.isInteger(message.totalCharacters) && !(message.totalCharacters && $util.isInteger(message.totalCharacters.low) && $util.isInteger(message.totalCharacters.high))) + return "totalCharacters: integer|Long expected"; + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + if (!$util.isInteger(message.translatedCharacters) && !(message.translatedCharacters && $util.isInteger(message.translatedCharacters.low) && $util.isInteger(message.translatedCharacters.high))) + return "translatedCharacters: integer|Long expected"; + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + if (!$util.isInteger(message.failedCharacters) && !(message.failedCharacters && $util.isInteger(message.failedCharacters.low) && $util.isInteger(message.failedCharacters.high))) + return "failedCharacters: integer|Long expected"; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } + return null; + }; + + /** + * Creates a BatchTranslateResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.BatchTranslateResponse} BatchTranslateResponse + */ + BatchTranslateResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.BatchTranslateResponse) + return object; + var message = new $root.google.cloud.translation.v3.BatchTranslateResponse(); + if (object.totalCharacters != null) + if ($util.Long) + (message.totalCharacters = $util.Long.fromValue(object.totalCharacters)).unsigned = false; + else if (typeof object.totalCharacters === "string") + message.totalCharacters = parseInt(object.totalCharacters, 10); + else if (typeof object.totalCharacters === "number") + message.totalCharacters = object.totalCharacters; + else if (typeof object.totalCharacters === "object") + message.totalCharacters = new $util.LongBits(object.totalCharacters.low >>> 0, object.totalCharacters.high >>> 0).toNumber(); + if (object.translatedCharacters != null) + if ($util.Long) + (message.translatedCharacters = $util.Long.fromValue(object.translatedCharacters)).unsigned = false; + else if (typeof object.translatedCharacters === "string") + message.translatedCharacters = parseInt(object.translatedCharacters, 10); + else if (typeof object.translatedCharacters === "number") + message.translatedCharacters = object.translatedCharacters; + else if (typeof object.translatedCharacters === "object") + message.translatedCharacters = new $util.LongBits(object.translatedCharacters.low >>> 0, object.translatedCharacters.high >>> 0).toNumber(); + if (object.failedCharacters != null) + if ($util.Long) + (message.failedCharacters = $util.Long.fromValue(object.failedCharacters)).unsigned = false; + else if (typeof object.failedCharacters === "string") + message.failedCharacters = parseInt(object.failedCharacters, 10); + else if (typeof object.failedCharacters === "number") + message.failedCharacters = object.failedCharacters; + else if (typeof object.failedCharacters === "object") + message.failedCharacters = new $util.LongBits(object.failedCharacters.low >>> 0, object.failedCharacters.high >>> 0).toNumber(); + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateResponse.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.translation.v3.BatchTranslateResponse.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchTranslateResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @static + * @param {google.cloud.translation.v3.BatchTranslateResponse} message BatchTranslateResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchTranslateResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.totalCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.totalCharacters = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.translatedCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.translatedCharacters = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failedCharacters = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failedCharacters = options.longs === String ? "0" : 0; + object.submitTime = null; + object.endTime = null; + } + if (message.totalCharacters != null && message.hasOwnProperty("totalCharacters")) + if (typeof message.totalCharacters === "number") + object.totalCharacters = options.longs === String ? String(message.totalCharacters) : message.totalCharacters; + else + object.totalCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.totalCharacters) : options.longs === Number ? new $util.LongBits(message.totalCharacters.low >>> 0, message.totalCharacters.high >>> 0).toNumber() : message.totalCharacters; + if (message.translatedCharacters != null && message.hasOwnProperty("translatedCharacters")) + if (typeof message.translatedCharacters === "number") + object.translatedCharacters = options.longs === String ? String(message.translatedCharacters) : message.translatedCharacters; + else + object.translatedCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.translatedCharacters) : options.longs === Number ? new $util.LongBits(message.translatedCharacters.low >>> 0, message.translatedCharacters.high >>> 0).toNumber() : message.translatedCharacters; + if (message.failedCharacters != null && message.hasOwnProperty("failedCharacters")) + if (typeof message.failedCharacters === "number") + object.failedCharacters = options.longs === String ? String(message.failedCharacters) : message.failedCharacters; + else + object.failedCharacters = options.longs === String ? $util.Long.prototype.toString.call(message.failedCharacters) : options.longs === Number ? new $util.LongBits(message.failedCharacters.low >>> 0, message.failedCharacters.high >>> 0).toNumber() : message.failedCharacters; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + return object; + }; + + /** + * Converts this BatchTranslateResponse to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.BatchTranslateResponse + * @instance + * @returns {Object.} JSON object + */ + BatchTranslateResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchTranslateResponse; + })(); + + v3.GlossaryInputConfig = (function() { + + /** + * Properties of a GlossaryInputConfig. + * @memberof google.cloud.translation.v3 + * @interface IGlossaryInputConfig + * @property {google.cloud.translation.v3.IGcsSource|null} [gcsSource] GlossaryInputConfig gcsSource + */ + + /** + * Constructs a new GlossaryInputConfig. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a GlossaryInputConfig. + * @implements IGlossaryInputConfig + * @constructor + * @param {google.cloud.translation.v3.IGlossaryInputConfig=} [properties] Properties to set + */ + function GlossaryInputConfig(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GlossaryInputConfig gcsSource. + * @member {google.cloud.translation.v3.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @instance + */ + GlossaryInputConfig.prototype.gcsSource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GlossaryInputConfig source. + * @member {"gcsSource"|undefined} source + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @instance + */ + Object.defineProperty(GlossaryInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["gcsSource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GlossaryInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {google.cloud.translation.v3.IGlossaryInputConfig=} [properties] Properties to set + * @returns {google.cloud.translation.v3.GlossaryInputConfig} GlossaryInputConfig instance + */ + GlossaryInputConfig.create = function create(properties) { + return new GlossaryInputConfig(properties); + }; + + /** + * Encodes the specified GlossaryInputConfig message. Does not implicitly {@link google.cloud.translation.v3.GlossaryInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {google.cloud.translation.v3.IGlossaryInputConfig} message GlossaryInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GlossaryInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) + $root.google.cloud.translation.v3.GcsSource.encode(message.gcsSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GlossaryInputConfig message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GlossaryInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {google.cloud.translation.v3.IGlossaryInputConfig} message GlossaryInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GlossaryInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GlossaryInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.GlossaryInputConfig} GlossaryInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GlossaryInputConfig.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.GlossaryInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gcsSource = $root.google.cloud.translation.v3.GcsSource.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GlossaryInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.GlossaryInputConfig} GlossaryInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GlossaryInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GlossaryInputConfig message. + * @function verify + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GlossaryInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + properties.source = 1; + { + var error = $root.google.cloud.translation.v3.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + return null; + }; + + /** + * Creates a GlossaryInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.GlossaryInputConfig} GlossaryInputConfig + */ + GlossaryInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.GlossaryInputConfig) + return object; + var message = new $root.google.cloud.translation.v3.GlossaryInputConfig(); + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.translation.v3.GlossaryInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.translation.v3.GcsSource.fromObject(object.gcsSource); + } + return message; + }; + + /** + * Creates a plain object from a GlossaryInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @static + * @param {google.cloud.translation.v3.GlossaryInputConfig} message GlossaryInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GlossaryInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.translation.v3.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + return object; + }; + + /** + * Converts this GlossaryInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.GlossaryInputConfig + * @instance + * @returns {Object.} JSON object + */ + GlossaryInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GlossaryInputConfig; + })(); + + v3.Glossary = (function() { + + /** + * Properties of a Glossary. + * @memberof google.cloud.translation.v3 + * @interface IGlossary + * @property {string|null} [name] Glossary name + * @property {google.cloud.translation.v3.Glossary.ILanguageCodePair|null} [languagePair] Glossary languagePair + * @property {google.cloud.translation.v3.Glossary.ILanguageCodesSet|null} [languageCodesSet] Glossary languageCodesSet + * @property {google.cloud.translation.v3.IGlossaryInputConfig|null} [inputConfig] Glossary inputConfig + * @property {number|null} [entryCount] Glossary entryCount + * @property {google.protobuf.ITimestamp|null} [submitTime] Glossary submitTime + * @property {google.protobuf.ITimestamp|null} [endTime] Glossary endTime + */ + + /** + * Constructs a new Glossary. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a Glossary. + * @implements IGlossary + * @constructor + * @param {google.cloud.translation.v3.IGlossary=} [properties] Properties to set + */ + function Glossary(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Glossary name. + * @member {string} name + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.name = ""; + + /** + * Glossary languagePair. + * @member {google.cloud.translation.v3.Glossary.ILanguageCodePair|null|undefined} languagePair + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.languagePair = null; + + /** + * Glossary languageCodesSet. + * @member {google.cloud.translation.v3.Glossary.ILanguageCodesSet|null|undefined} languageCodesSet + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.languageCodesSet = null; + + /** + * Glossary inputConfig. + * @member {google.cloud.translation.v3.IGlossaryInputConfig|null|undefined} inputConfig + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.inputConfig = null; + + /** + * Glossary entryCount. + * @member {number} entryCount + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.entryCount = 0; + + /** + * Glossary submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.submitTime = null; + + /** + * Glossary endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Glossary.prototype.endTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Glossary languages. + * @member {"languagePair"|"languageCodesSet"|undefined} languages + * @memberof google.cloud.translation.v3.Glossary + * @instance + */ + Object.defineProperty(Glossary.prototype, "languages", { + get: $util.oneOfGetter($oneOfFields = ["languagePair", "languageCodesSet"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Glossary instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {google.cloud.translation.v3.IGlossary=} [properties] Properties to set + * @returns {google.cloud.translation.v3.Glossary} Glossary instance + */ + Glossary.create = function create(properties) { + return new Glossary(properties); + }; + + /** + * Encodes the specified Glossary message. Does not implicitly {@link google.cloud.translation.v3.Glossary.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {google.cloud.translation.v3.IGlossary} message Glossary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Glossary.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.languagePair != null && message.hasOwnProperty("languagePair")) + $root.google.cloud.translation.v3.Glossary.LanguageCodePair.encode(message.languagePair, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.languageCodesSet != null && message.hasOwnProperty("languageCodesSet")) + $root.google.cloud.translation.v3.Glossary.LanguageCodesSet.encode(message.languageCodesSet, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + $root.google.cloud.translation.v3.GlossaryInputConfig.encode(message.inputConfig, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.entryCount != null && message.hasOwnProperty("entryCount")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.entryCount); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.endTime != null && message.hasOwnProperty("endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Glossary message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {google.cloud.translation.v3.IGlossary} message Glossary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Glossary.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Glossary message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.Glossary} Glossary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Glossary.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.Glossary(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.languagePair = $root.google.cloud.translation.v3.Glossary.LanguageCodePair.decode(reader, reader.uint32()); + break; + case 4: + message.languageCodesSet = $root.google.cloud.translation.v3.Glossary.LanguageCodesSet.decode(reader, reader.uint32()); + break; + case 5: + message.inputConfig = $root.google.cloud.translation.v3.GlossaryInputConfig.decode(reader, reader.uint32()); + break; + case 6: + message.entryCount = reader.int32(); + break; + case 7: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 8: + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Glossary message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.Glossary} Glossary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Glossary.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Glossary message. + * @function verify + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Glossary.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.languagePair != null && message.hasOwnProperty("languagePair")) { + properties.languages = 1; + { + var error = $root.google.cloud.translation.v3.Glossary.LanguageCodePair.verify(message.languagePair); + if (error) + return "languagePair." + error; + } + } + if (message.languageCodesSet != null && message.hasOwnProperty("languageCodesSet")) { + if (properties.languages === 1) + return "languages: multiple values"; + properties.languages = 1; + { + var error = $root.google.cloud.translation.v3.Glossary.LanguageCodesSet.verify(message.languageCodesSet); + if (error) + return "languageCodesSet." + error; + } + } + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.translation.v3.GlossaryInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.entryCount != null && message.hasOwnProperty("entryCount")) + if (!$util.isInteger(message.entryCount)) + return "entryCount: integer expected"; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } + return null; + }; + + /** + * Creates a Glossary message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.Glossary} Glossary + */ + Glossary.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.Glossary) + return object; + var message = new $root.google.cloud.translation.v3.Glossary(); + if (object.name != null) + message.name = String(object.name); + if (object.languagePair != null) { + if (typeof object.languagePair !== "object") + throw TypeError(".google.cloud.translation.v3.Glossary.languagePair: object expected"); + message.languagePair = $root.google.cloud.translation.v3.Glossary.LanguageCodePair.fromObject(object.languagePair); + } + if (object.languageCodesSet != null) { + if (typeof object.languageCodesSet !== "object") + throw TypeError(".google.cloud.translation.v3.Glossary.languageCodesSet: object expected"); + message.languageCodesSet = $root.google.cloud.translation.v3.Glossary.LanguageCodesSet.fromObject(object.languageCodesSet); + } + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.translation.v3.Glossary.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.translation.v3.GlossaryInputConfig.fromObject(object.inputConfig); + } + if (object.entryCount != null) + message.entryCount = object.entryCount | 0; + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.Glossary.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.translation.v3.Glossary.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a Glossary message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.Glossary + * @static + * @param {google.cloud.translation.v3.Glossary} message Glossary + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Glossary.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.inputConfig = null; + object.entryCount = 0; + object.submitTime = null; + object.endTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.languagePair != null && message.hasOwnProperty("languagePair")) { + object.languagePair = $root.google.cloud.translation.v3.Glossary.LanguageCodePair.toObject(message.languagePair, options); + if (options.oneofs) + object.languages = "languagePair"; + } + if (message.languageCodesSet != null && message.hasOwnProperty("languageCodesSet")) { + object.languageCodesSet = $root.google.cloud.translation.v3.Glossary.LanguageCodesSet.toObject(message.languageCodesSet, options); + if (options.oneofs) + object.languages = "languageCodesSet"; + } + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.translation.v3.GlossaryInputConfig.toObject(message.inputConfig, options); + if (message.entryCount != null && message.hasOwnProperty("entryCount")) + object.entryCount = message.entryCount; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + return object; + }; + + /** + * Converts this Glossary to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.Glossary + * @instance + * @returns {Object.} JSON object + */ + Glossary.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + Glossary.LanguageCodePair = (function() { + + /** + * Properties of a LanguageCodePair. + * @memberof google.cloud.translation.v3.Glossary + * @interface ILanguageCodePair + * @property {string|null} [sourceLanguageCode] LanguageCodePair sourceLanguageCode + * @property {string|null} [targetLanguageCode] LanguageCodePair targetLanguageCode + */ + + /** + * Constructs a new LanguageCodePair. + * @memberof google.cloud.translation.v3.Glossary + * @classdesc Represents a LanguageCodePair. + * @implements ILanguageCodePair + * @constructor + * @param {google.cloud.translation.v3.Glossary.ILanguageCodePair=} [properties] Properties to set + */ + function LanguageCodePair(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LanguageCodePair sourceLanguageCode. + * @member {string} sourceLanguageCode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @instance + */ + LanguageCodePair.prototype.sourceLanguageCode = ""; + + /** + * LanguageCodePair targetLanguageCode. + * @member {string} targetLanguageCode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @instance + */ + LanguageCodePair.prototype.targetLanguageCode = ""; + + /** + * Creates a new LanguageCodePair instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodePair=} [properties] Properties to set + * @returns {google.cloud.translation.v3.Glossary.LanguageCodePair} LanguageCodePair instance + */ + LanguageCodePair.create = function create(properties) { + return new LanguageCodePair(properties); + }; + + /** + * Encodes the specified LanguageCodePair message. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodePair.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodePair} message LanguageCodePair message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LanguageCodePair.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.sourceLanguageCode); + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.targetLanguageCode); + return writer; + }; + + /** + * Encodes the specified LanguageCodePair message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodePair.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodePair} message LanguageCodePair message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LanguageCodePair.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LanguageCodePair message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.Glossary.LanguageCodePair} LanguageCodePair + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LanguageCodePair.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.Glossary.LanguageCodePair(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sourceLanguageCode = reader.string(); + break; + case 2: + message.targetLanguageCode = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LanguageCodePair message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.Glossary.LanguageCodePair} LanguageCodePair + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LanguageCodePair.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LanguageCodePair message. + * @function verify + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LanguageCodePair.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + if (!$util.isString(message.sourceLanguageCode)) + return "sourceLanguageCode: string expected"; + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + if (!$util.isString(message.targetLanguageCode)) + return "targetLanguageCode: string expected"; + return null; + }; + + /** + * Creates a LanguageCodePair message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.Glossary.LanguageCodePair} LanguageCodePair + */ + LanguageCodePair.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.Glossary.LanguageCodePair) + return object; + var message = new $root.google.cloud.translation.v3.Glossary.LanguageCodePair(); + if (object.sourceLanguageCode != null) + message.sourceLanguageCode = String(object.sourceLanguageCode); + if (object.targetLanguageCode != null) + message.targetLanguageCode = String(object.targetLanguageCode); + return message; + }; + + /** + * Creates a plain object from a LanguageCodePair message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @static + * @param {google.cloud.translation.v3.Glossary.LanguageCodePair} message LanguageCodePair + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LanguageCodePair.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.sourceLanguageCode = ""; + object.targetLanguageCode = ""; + } + if (message.sourceLanguageCode != null && message.hasOwnProperty("sourceLanguageCode")) + object.sourceLanguageCode = message.sourceLanguageCode; + if (message.targetLanguageCode != null && message.hasOwnProperty("targetLanguageCode")) + object.targetLanguageCode = message.targetLanguageCode; + return object; + }; + + /** + * Converts this LanguageCodePair to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.Glossary.LanguageCodePair + * @instance + * @returns {Object.} JSON object + */ + LanguageCodePair.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LanguageCodePair; + })(); + + Glossary.LanguageCodesSet = (function() { + + /** + * Properties of a LanguageCodesSet. + * @memberof google.cloud.translation.v3.Glossary + * @interface ILanguageCodesSet + * @property {Array.|null} [languageCodes] LanguageCodesSet languageCodes + */ + + /** + * Constructs a new LanguageCodesSet. + * @memberof google.cloud.translation.v3.Glossary + * @classdesc Represents a LanguageCodesSet. + * @implements ILanguageCodesSet + * @constructor + * @param {google.cloud.translation.v3.Glossary.ILanguageCodesSet=} [properties] Properties to set + */ + function LanguageCodesSet(properties) { + this.languageCodes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LanguageCodesSet languageCodes. + * @member {Array.} languageCodes + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @instance + */ + LanguageCodesSet.prototype.languageCodes = $util.emptyArray; + + /** + * Creates a new LanguageCodesSet instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodesSet=} [properties] Properties to set + * @returns {google.cloud.translation.v3.Glossary.LanguageCodesSet} LanguageCodesSet instance + */ + LanguageCodesSet.create = function create(properties) { + return new LanguageCodesSet(properties); + }; + + /** + * Encodes the specified LanguageCodesSet message. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodesSet.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodesSet} message LanguageCodesSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LanguageCodesSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languageCodes != null && message.languageCodes.length) + for (var i = 0; i < message.languageCodes.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCodes[i]); + return writer; + }; + + /** + * Encodes the specified LanguageCodesSet message, length delimited. Does not implicitly {@link google.cloud.translation.v3.Glossary.LanguageCodesSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {google.cloud.translation.v3.Glossary.ILanguageCodesSet} message LanguageCodesSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LanguageCodesSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LanguageCodesSet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.Glossary.LanguageCodesSet} LanguageCodesSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LanguageCodesSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.Glossary.LanguageCodesSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.languageCodes && message.languageCodes.length)) + message.languageCodes = []; + message.languageCodes.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LanguageCodesSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.Glossary.LanguageCodesSet} LanguageCodesSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LanguageCodesSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LanguageCodesSet message. + * @function verify + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LanguageCodesSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languageCodes != null && message.hasOwnProperty("languageCodes")) { + if (!Array.isArray(message.languageCodes)) + return "languageCodes: array expected"; + for (var i = 0; i < message.languageCodes.length; ++i) + if (!$util.isString(message.languageCodes[i])) + return "languageCodes: string[] expected"; + } + return null; + }; + + /** + * Creates a LanguageCodesSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.Glossary.LanguageCodesSet} LanguageCodesSet + */ + LanguageCodesSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.Glossary.LanguageCodesSet) + return object; + var message = new $root.google.cloud.translation.v3.Glossary.LanguageCodesSet(); + if (object.languageCodes) { + if (!Array.isArray(object.languageCodes)) + throw TypeError(".google.cloud.translation.v3.Glossary.LanguageCodesSet.languageCodes: array expected"); + message.languageCodes = []; + for (var i = 0; i < object.languageCodes.length; ++i) + message.languageCodes[i] = String(object.languageCodes[i]); + } + return message; + }; + + /** + * Creates a plain object from a LanguageCodesSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @static + * @param {google.cloud.translation.v3.Glossary.LanguageCodesSet} message LanguageCodesSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LanguageCodesSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languageCodes = []; + if (message.languageCodes && message.languageCodes.length) { + object.languageCodes = []; + for (var j = 0; j < message.languageCodes.length; ++j) + object.languageCodes[j] = message.languageCodes[j]; + } + return object; + }; + + /** + * Converts this LanguageCodesSet to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.Glossary.LanguageCodesSet + * @instance + * @returns {Object.} JSON object + */ + LanguageCodesSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LanguageCodesSet; + })(); + + return Glossary; + })(); + + v3.CreateGlossaryRequest = (function() { + + /** + * Properties of a CreateGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @interface ICreateGlossaryRequest + * @property {string|null} [parent] CreateGlossaryRequest parent + * @property {google.cloud.translation.v3.IGlossary|null} [glossary] CreateGlossaryRequest glossary + */ + + /** + * Constructs a new CreateGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a CreateGlossaryRequest. + * @implements ICreateGlossaryRequest + * @constructor + * @param {google.cloud.translation.v3.ICreateGlossaryRequest=} [properties] Properties to set + */ + function CreateGlossaryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateGlossaryRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @instance + */ + CreateGlossaryRequest.prototype.parent = ""; + + /** + * CreateGlossaryRequest glossary. + * @member {google.cloud.translation.v3.IGlossary|null|undefined} glossary + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @instance + */ + CreateGlossaryRequest.prototype.glossary = null; + + /** + * Creates a new CreateGlossaryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.CreateGlossaryRequest} CreateGlossaryRequest instance + */ + CreateGlossaryRequest.create = function create(properties) { + return new CreateGlossaryRequest(properties); + }; + + /** + * Encodes the specified CreateGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryRequest} message CreateGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateGlossaryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.glossary != null && message.hasOwnProperty("glossary")) + $root.google.cloud.translation.v3.Glossary.encode(message.glossary, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryRequest} message CreateGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateGlossaryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateGlossaryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.CreateGlossaryRequest} CreateGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateGlossaryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.CreateGlossaryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.glossary = $root.google.cloud.translation.v3.Glossary.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateGlossaryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.CreateGlossaryRequest} CreateGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateGlossaryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateGlossaryRequest message. + * @function verify + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateGlossaryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.glossary != null && message.hasOwnProperty("glossary")) { + var error = $root.google.cloud.translation.v3.Glossary.verify(message.glossary); + if (error) + return "glossary." + error; + } + return null; + }; + + /** + * Creates a CreateGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.CreateGlossaryRequest} CreateGlossaryRequest + */ + CreateGlossaryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.CreateGlossaryRequest) + return object; + var message = new $root.google.cloud.translation.v3.CreateGlossaryRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.glossary != null) { + if (typeof object.glossary !== "object") + throw TypeError(".google.cloud.translation.v3.CreateGlossaryRequest.glossary: object expected"); + message.glossary = $root.google.cloud.translation.v3.Glossary.fromObject(object.glossary); + } + return message; + }; + + /** + * Creates a plain object from a CreateGlossaryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @static + * @param {google.cloud.translation.v3.CreateGlossaryRequest} message CreateGlossaryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateGlossaryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.glossary = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.glossary != null && message.hasOwnProperty("glossary")) + object.glossary = $root.google.cloud.translation.v3.Glossary.toObject(message.glossary, options); + return object; + }; + + /** + * Converts this CreateGlossaryRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.CreateGlossaryRequest + * @instance + * @returns {Object.} JSON object + */ + CreateGlossaryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateGlossaryRequest; + })(); + + v3.GetGlossaryRequest = (function() { + + /** + * Properties of a GetGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @interface IGetGlossaryRequest + * @property {string|null} [name] GetGlossaryRequest name + */ + + /** + * Constructs a new GetGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a GetGlossaryRequest. + * @implements IGetGlossaryRequest + * @constructor + * @param {google.cloud.translation.v3.IGetGlossaryRequest=} [properties] Properties to set + */ + function GetGlossaryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetGlossaryRequest name. + * @member {string} name + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @instance + */ + GetGlossaryRequest.prototype.name = ""; + + /** + * Creates a new GetGlossaryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IGetGlossaryRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.GetGlossaryRequest} GetGlossaryRequest instance + */ + GetGlossaryRequest.create = function create(properties) { + return new GetGlossaryRequest(properties); + }; + + /** + * Encodes the specified GetGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.GetGlossaryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IGetGlossaryRequest} message GetGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetGlossaryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.GetGlossaryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IGetGlossaryRequest} message GetGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetGlossaryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetGlossaryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.GetGlossaryRequest} GetGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetGlossaryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.GetGlossaryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetGlossaryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.GetGlossaryRequest} GetGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetGlossaryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetGlossaryRequest message. + * @function verify + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetGlossaryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.GetGlossaryRequest} GetGlossaryRequest + */ + GetGlossaryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.GetGlossaryRequest) + return object; + var message = new $root.google.cloud.translation.v3.GetGlossaryRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetGlossaryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @static + * @param {google.cloud.translation.v3.GetGlossaryRequest} message GetGlossaryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetGlossaryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetGlossaryRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.GetGlossaryRequest + * @instance + * @returns {Object.} JSON object + */ + GetGlossaryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetGlossaryRequest; + })(); + + v3.DeleteGlossaryRequest = (function() { + + /** + * Properties of a DeleteGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @interface IDeleteGlossaryRequest + * @property {string|null} [name] DeleteGlossaryRequest name + */ + + /** + * Constructs a new DeleteGlossaryRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DeleteGlossaryRequest. + * @implements IDeleteGlossaryRequest + * @constructor + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest=} [properties] Properties to set + */ + function DeleteGlossaryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteGlossaryRequest name. + * @member {string} name + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @instance + */ + DeleteGlossaryRequest.prototype.name = ""; + + /** + * Creates a new DeleteGlossaryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DeleteGlossaryRequest} DeleteGlossaryRequest instance + */ + DeleteGlossaryRequest.create = function create(properties) { + return new DeleteGlossaryRequest(properties); + }; + + /** + * Encodes the specified DeleteGlossaryRequest message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest} message DeleteGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteGlossaryRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryRequest} message DeleteGlossaryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteGlossaryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DeleteGlossaryRequest} DeleteGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DeleteGlossaryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteGlossaryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DeleteGlossaryRequest} DeleteGlossaryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteGlossaryRequest message. + * @function verify + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteGlossaryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeleteGlossaryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DeleteGlossaryRequest} DeleteGlossaryRequest + */ + DeleteGlossaryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DeleteGlossaryRequest) + return object; + var message = new $root.google.cloud.translation.v3.DeleteGlossaryRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteGlossaryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @static + * @param {google.cloud.translation.v3.DeleteGlossaryRequest} message DeleteGlossaryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteGlossaryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteGlossaryRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DeleteGlossaryRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteGlossaryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteGlossaryRequest; + })(); + + v3.ListGlossariesRequest = (function() { + + /** + * Properties of a ListGlossariesRequest. + * @memberof google.cloud.translation.v3 + * @interface IListGlossariesRequest + * @property {string|null} [parent] ListGlossariesRequest parent + * @property {number|null} [pageSize] ListGlossariesRequest pageSize + * @property {string|null} [pageToken] ListGlossariesRequest pageToken + * @property {string|null} [filter] ListGlossariesRequest filter + */ + + /** + * Constructs a new ListGlossariesRequest. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a ListGlossariesRequest. + * @implements IListGlossariesRequest + * @constructor + * @param {google.cloud.translation.v3.IListGlossariesRequest=} [properties] Properties to set + */ + function ListGlossariesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListGlossariesRequest parent. + * @member {string} parent + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @instance + */ + ListGlossariesRequest.prototype.parent = ""; + + /** + * ListGlossariesRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @instance + */ + ListGlossariesRequest.prototype.pageSize = 0; + + /** + * ListGlossariesRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @instance + */ + ListGlossariesRequest.prototype.pageToken = ""; + + /** + * ListGlossariesRequest filter. + * @member {string} filter + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @instance + */ + ListGlossariesRequest.prototype.filter = ""; + + /** + * Creates a new ListGlossariesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {google.cloud.translation.v3.IListGlossariesRequest=} [properties] Properties to set + * @returns {google.cloud.translation.v3.ListGlossariesRequest} ListGlossariesRequest instance + */ + ListGlossariesRequest.create = function create(properties) { + return new ListGlossariesRequest(properties); + }; + + /** + * Encodes the specified ListGlossariesRequest message. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {google.cloud.translation.v3.IListGlossariesRequest} message ListGlossariesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListGlossariesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.filter != null && message.hasOwnProperty("filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + return writer; + }; + + /** + * Encodes the specified ListGlossariesRequest message, length delimited. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {google.cloud.translation.v3.IListGlossariesRequest} message ListGlossariesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListGlossariesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListGlossariesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.ListGlossariesRequest} ListGlossariesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListGlossariesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.ListGlossariesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + case 4: + message.filter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListGlossariesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.ListGlossariesRequest} ListGlossariesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListGlossariesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListGlossariesRequest message. + * @function verify + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListGlossariesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a ListGlossariesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.ListGlossariesRequest} ListGlossariesRequest + */ + ListGlossariesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.ListGlossariesRequest) + return object; + var message = new $root.google.cloud.translation.v3.ListGlossariesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a ListGlossariesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @static + * @param {google.cloud.translation.v3.ListGlossariesRequest} message ListGlossariesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListGlossariesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this ListGlossariesRequest to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.ListGlossariesRequest + * @instance + * @returns {Object.} JSON object + */ + ListGlossariesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListGlossariesRequest; + })(); + + v3.ListGlossariesResponse = (function() { + + /** + * Properties of a ListGlossariesResponse. + * @memberof google.cloud.translation.v3 + * @interface IListGlossariesResponse + * @property {Array.|null} [glossaries] ListGlossariesResponse glossaries + * @property {string|null} [nextPageToken] ListGlossariesResponse nextPageToken + */ + + /** + * Constructs a new ListGlossariesResponse. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a ListGlossariesResponse. + * @implements IListGlossariesResponse + * @constructor + * @param {google.cloud.translation.v3.IListGlossariesResponse=} [properties] Properties to set + */ + function ListGlossariesResponse(properties) { + this.glossaries = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListGlossariesResponse glossaries. + * @member {Array.} glossaries + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @instance + */ + ListGlossariesResponse.prototype.glossaries = $util.emptyArray; + + /** + * ListGlossariesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @instance + */ + ListGlossariesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListGlossariesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {google.cloud.translation.v3.IListGlossariesResponse=} [properties] Properties to set + * @returns {google.cloud.translation.v3.ListGlossariesResponse} ListGlossariesResponse instance + */ + ListGlossariesResponse.create = function create(properties) { + return new ListGlossariesResponse(properties); + }; + + /** + * Encodes the specified ListGlossariesResponse message. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {google.cloud.translation.v3.IListGlossariesResponse} message ListGlossariesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListGlossariesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.glossaries != null && message.glossaries.length) + for (var i = 0; i < message.glossaries.length; ++i) + $root.google.cloud.translation.v3.Glossary.encode(message.glossaries[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListGlossariesResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.ListGlossariesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {google.cloud.translation.v3.IListGlossariesResponse} message ListGlossariesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListGlossariesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListGlossariesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.ListGlossariesResponse} ListGlossariesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListGlossariesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.ListGlossariesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.glossaries && message.glossaries.length)) + message.glossaries = []; + message.glossaries.push($root.google.cloud.translation.v3.Glossary.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListGlossariesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.ListGlossariesResponse} ListGlossariesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListGlossariesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListGlossariesResponse message. + * @function verify + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListGlossariesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.glossaries != null && message.hasOwnProperty("glossaries")) { + if (!Array.isArray(message.glossaries)) + return "glossaries: array expected"; + for (var i = 0; i < message.glossaries.length; ++i) { + var error = $root.google.cloud.translation.v3.Glossary.verify(message.glossaries[i]); + if (error) + return "glossaries." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListGlossariesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.ListGlossariesResponse} ListGlossariesResponse + */ + ListGlossariesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.ListGlossariesResponse) + return object; + var message = new $root.google.cloud.translation.v3.ListGlossariesResponse(); + if (object.glossaries) { + if (!Array.isArray(object.glossaries)) + throw TypeError(".google.cloud.translation.v3.ListGlossariesResponse.glossaries: array expected"); + message.glossaries = []; + for (var i = 0; i < object.glossaries.length; ++i) { + if (typeof object.glossaries[i] !== "object") + throw TypeError(".google.cloud.translation.v3.ListGlossariesResponse.glossaries: object expected"); + message.glossaries[i] = $root.google.cloud.translation.v3.Glossary.fromObject(object.glossaries[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListGlossariesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @static + * @param {google.cloud.translation.v3.ListGlossariesResponse} message ListGlossariesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListGlossariesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.glossaries = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.glossaries && message.glossaries.length) { + object.glossaries = []; + for (var j = 0; j < message.glossaries.length; ++j) + object.glossaries[j] = $root.google.cloud.translation.v3.Glossary.toObject(message.glossaries[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListGlossariesResponse to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.ListGlossariesResponse + * @instance + * @returns {Object.} JSON object + */ + ListGlossariesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListGlossariesResponse; + })(); + + v3.CreateGlossaryMetadata = (function() { + + /** + * Properties of a CreateGlossaryMetadata. + * @memberof google.cloud.translation.v3 + * @interface ICreateGlossaryMetadata + * @property {string|null} [name] CreateGlossaryMetadata name + * @property {google.cloud.translation.v3.CreateGlossaryMetadata.State|null} [state] CreateGlossaryMetadata state + * @property {google.protobuf.ITimestamp|null} [submitTime] CreateGlossaryMetadata submitTime + */ + + /** + * Constructs a new CreateGlossaryMetadata. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a CreateGlossaryMetadata. + * @implements ICreateGlossaryMetadata + * @constructor + * @param {google.cloud.translation.v3.ICreateGlossaryMetadata=} [properties] Properties to set + */ + function CreateGlossaryMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateGlossaryMetadata name. + * @member {string} name + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @instance + */ + CreateGlossaryMetadata.prototype.name = ""; + + /** + * CreateGlossaryMetadata state. + * @member {google.cloud.translation.v3.CreateGlossaryMetadata.State} state + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @instance + */ + CreateGlossaryMetadata.prototype.state = 0; + + /** + * CreateGlossaryMetadata submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @instance + */ + CreateGlossaryMetadata.prototype.submitTime = null; + + /** + * Creates a new CreateGlossaryMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryMetadata=} [properties] Properties to set + * @returns {google.cloud.translation.v3.CreateGlossaryMetadata} CreateGlossaryMetadata instance + */ + CreateGlossaryMetadata.create = function create(properties) { + return new CreateGlossaryMetadata(properties); + }; + + /** + * Encodes the specified CreateGlossaryMetadata message. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryMetadata} message CreateGlossaryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateGlossaryMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.state != null && message.hasOwnProperty("state")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.state); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateGlossaryMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.CreateGlossaryMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.ICreateGlossaryMetadata} message CreateGlossaryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateGlossaryMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateGlossaryMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.CreateGlossaryMetadata} CreateGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateGlossaryMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.CreateGlossaryMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.state = reader.int32(); + break; + case 3: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateGlossaryMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.CreateGlossaryMetadata} CreateGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateGlossaryMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateGlossaryMetadata message. + * @function verify + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateGlossaryMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + return null; + }; + + /** + * Creates a CreateGlossaryMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.CreateGlossaryMetadata} CreateGlossaryMetadata + */ + CreateGlossaryMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.CreateGlossaryMetadata) + return object; + var message = new $root.google.cloud.translation.v3.CreateGlossaryMetadata(); + if (object.name != null) + message.name = String(object.name); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "RUNNING": + case 1: + message.state = 1; + break; + case "SUCCEEDED": + case 2: + message.state = 2; + break; + case "FAILED": + case 3: + message.state = 3; + break; + case "CANCELLING": + case 4: + message.state = 4; + break; + case "CANCELLED": + case 5: + message.state = 5; + break; + } + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.CreateGlossaryMetadata.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + return message; + }; + + /** + * Creates a plain object from a CreateGlossaryMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.CreateGlossaryMetadata} message CreateGlossaryMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateGlossaryMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.submitTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.translation.v3.CreateGlossaryMetadata.State[message.state] : message.state; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + return object; + }; + + /** + * Converts this CreateGlossaryMetadata to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.CreateGlossaryMetadata + * @instance + * @returns {Object.} JSON object + */ + CreateGlossaryMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.cloud.translation.v3.CreateGlossaryMetadata.State + * @enum {string} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} RUNNING=1 RUNNING value + * @property {number} SUCCEEDED=2 SUCCEEDED value + * @property {number} FAILED=3 FAILED value + * @property {number} CANCELLING=4 CANCELLING value + * @property {number} CANCELLED=5 CANCELLED value + */ + CreateGlossaryMetadata.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "RUNNING"] = 1; + values[valuesById[2] = "SUCCEEDED"] = 2; + values[valuesById[3] = "FAILED"] = 3; + values[valuesById[4] = "CANCELLING"] = 4; + values[valuesById[5] = "CANCELLED"] = 5; + return values; + })(); + + return CreateGlossaryMetadata; + })(); + + v3.DeleteGlossaryMetadata = (function() { + + /** + * Properties of a DeleteGlossaryMetadata. + * @memberof google.cloud.translation.v3 + * @interface IDeleteGlossaryMetadata + * @property {string|null} [name] DeleteGlossaryMetadata name + * @property {google.cloud.translation.v3.DeleteGlossaryMetadata.State|null} [state] DeleteGlossaryMetadata state + * @property {google.protobuf.ITimestamp|null} [submitTime] DeleteGlossaryMetadata submitTime + */ + + /** + * Constructs a new DeleteGlossaryMetadata. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DeleteGlossaryMetadata. + * @implements IDeleteGlossaryMetadata + * @constructor + * @param {google.cloud.translation.v3.IDeleteGlossaryMetadata=} [properties] Properties to set + */ + function DeleteGlossaryMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteGlossaryMetadata name. + * @member {string} name + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @instance + */ + DeleteGlossaryMetadata.prototype.name = ""; + + /** + * DeleteGlossaryMetadata state. + * @member {google.cloud.translation.v3.DeleteGlossaryMetadata.State} state + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @instance + */ + DeleteGlossaryMetadata.prototype.state = 0; + + /** + * DeleteGlossaryMetadata submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @instance + */ + DeleteGlossaryMetadata.prototype.submitTime = null; + + /** + * Creates a new DeleteGlossaryMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryMetadata=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DeleteGlossaryMetadata} DeleteGlossaryMetadata instance + */ + DeleteGlossaryMetadata.create = function create(properties) { + return new DeleteGlossaryMetadata(properties); + }; + + /** + * Encodes the specified DeleteGlossaryMetadata message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryMetadata} message DeleteGlossaryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.state != null && message.hasOwnProperty("state")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.state); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DeleteGlossaryMetadata message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryMetadata} message DeleteGlossaryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteGlossaryMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DeleteGlossaryMetadata} DeleteGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DeleteGlossaryMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.state = reader.int32(); + break; + case 3: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteGlossaryMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DeleteGlossaryMetadata} DeleteGlossaryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteGlossaryMetadata message. + * @function verify + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteGlossaryMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + return null; + }; + + /** + * Creates a DeleteGlossaryMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DeleteGlossaryMetadata} DeleteGlossaryMetadata + */ + DeleteGlossaryMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DeleteGlossaryMetadata) + return object; + var message = new $root.google.cloud.translation.v3.DeleteGlossaryMetadata(); + if (object.name != null) + message.name = String(object.name); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "RUNNING": + case 1: + message.state = 1; + break; + case "SUCCEEDED": + case 2: + message.state = 2; + break; + case "FAILED": + case 3: + message.state = 3; + break; + case "CANCELLING": + case 4: + message.state = 4; + break; + case "CANCELLED": + case 5: + message.state = 5; + break; + } + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.DeleteGlossaryMetadata.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + return message; + }; + + /** + * Creates a plain object from a DeleteGlossaryMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @static + * @param {google.cloud.translation.v3.DeleteGlossaryMetadata} message DeleteGlossaryMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteGlossaryMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.submitTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.translation.v3.DeleteGlossaryMetadata.State[message.state] : message.state; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + return object; + }; + + /** + * Converts this DeleteGlossaryMetadata to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DeleteGlossaryMetadata + * @instance + * @returns {Object.} JSON object + */ + DeleteGlossaryMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.cloud.translation.v3.DeleteGlossaryMetadata.State + * @enum {string} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} RUNNING=1 RUNNING value + * @property {number} SUCCEEDED=2 SUCCEEDED value + * @property {number} FAILED=3 FAILED value + * @property {number} CANCELLING=4 CANCELLING value + * @property {number} CANCELLED=5 CANCELLED value + */ + DeleteGlossaryMetadata.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "RUNNING"] = 1; + values[valuesById[2] = "SUCCEEDED"] = 2; + values[valuesById[3] = "FAILED"] = 3; + values[valuesById[4] = "CANCELLING"] = 4; + values[valuesById[5] = "CANCELLED"] = 5; + return values; + })(); + + return DeleteGlossaryMetadata; + })(); + + v3.DeleteGlossaryResponse = (function() { + + /** + * Properties of a DeleteGlossaryResponse. + * @memberof google.cloud.translation.v3 + * @interface IDeleteGlossaryResponse + * @property {string|null} [name] DeleteGlossaryResponse name + * @property {google.protobuf.ITimestamp|null} [submitTime] DeleteGlossaryResponse submitTime + * @property {google.protobuf.ITimestamp|null} [endTime] DeleteGlossaryResponse endTime + */ + + /** + * Constructs a new DeleteGlossaryResponse. + * @memberof google.cloud.translation.v3 + * @classdesc Represents a DeleteGlossaryResponse. + * @implements IDeleteGlossaryResponse + * @constructor + * @param {google.cloud.translation.v3.IDeleteGlossaryResponse=} [properties] Properties to set + */ + function DeleteGlossaryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteGlossaryResponse name. + * @member {string} name + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @instance + */ + DeleteGlossaryResponse.prototype.name = ""; + + /** + * DeleteGlossaryResponse submitTime. + * @member {google.protobuf.ITimestamp|null|undefined} submitTime + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @instance + */ + DeleteGlossaryResponse.prototype.submitTime = null; + + /** + * DeleteGlossaryResponse endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @instance + */ + DeleteGlossaryResponse.prototype.endTime = null; + + /** + * Creates a new DeleteGlossaryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryResponse=} [properties] Properties to set + * @returns {google.cloud.translation.v3.DeleteGlossaryResponse} DeleteGlossaryResponse instance + */ + DeleteGlossaryResponse.create = function create(properties) { + return new DeleteGlossaryResponse(properties); + }; + + /** + * Encodes the specified DeleteGlossaryResponse message. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryResponse} message DeleteGlossaryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + $root.google.protobuf.Timestamp.encode(message.submitTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.endTime != null && message.hasOwnProperty("endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DeleteGlossaryResponse message, length delimited. Does not implicitly {@link google.cloud.translation.v3.DeleteGlossaryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {google.cloud.translation.v3.IDeleteGlossaryResponse} message DeleteGlossaryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteGlossaryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteGlossaryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.translation.v3.DeleteGlossaryResponse} DeleteGlossaryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.translation.v3.DeleteGlossaryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.submitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 3: + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteGlossaryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.translation.v3.DeleteGlossaryResponse} DeleteGlossaryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteGlossaryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteGlossaryResponse message. + * @function verify + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteGlossaryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.submitTime); + if (error) + return "submitTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } + return null; + }; + + /** + * Creates a DeleteGlossaryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.translation.v3.DeleteGlossaryResponse} DeleteGlossaryResponse + */ + DeleteGlossaryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.translation.v3.DeleteGlossaryResponse) + return object; + var message = new $root.google.cloud.translation.v3.DeleteGlossaryResponse(); + if (object.name != null) + message.name = String(object.name); + if (object.submitTime != null) { + if (typeof object.submitTime !== "object") + throw TypeError(".google.cloud.translation.v3.DeleteGlossaryResponse.submitTime: object expected"); + message.submitTime = $root.google.protobuf.Timestamp.fromObject(object.submitTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.translation.v3.DeleteGlossaryResponse.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a DeleteGlossaryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @static + * @param {google.cloud.translation.v3.DeleteGlossaryResponse} message DeleteGlossaryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteGlossaryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.submitTime = null; + object.endTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.submitTime != null && message.hasOwnProperty("submitTime")) + object.submitTime = $root.google.protobuf.Timestamp.toObject(message.submitTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + return object; + }; + + /** + * Converts this DeleteGlossaryResponse to JSON. + * @function toJSON + * @memberof google.cloud.translation.v3.DeleteGlossaryResponse + * @instance + * @returns {Object.} JSON object + */ + DeleteGlossaryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteGlossaryResponse; + })(); + + return v3; + })(); + translation.v3beta1 = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index 44bec2d7..38a285d9 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -6,6 +6,773 @@ "nested": { "translation": { "nested": { + "v3": { + "options": { + "cc_enable_arenas": true, + "csharp_namespace": "Google.Cloud.Translate.V3", + "go_package": "google.golang.org/genproto/googleapis/cloud/translate/v3;translate", + "java_multiple_files": true, + "java_outer_classname": "TranslationServiceProto", + "java_package": "com.google.cloud.translate.v3", + "php_namespace": "Google\\Cloud\\Translate\\V3", + "ruby_package": "Google::Cloud::Translate::V3" + }, + "nested": { + "TranslationService": { + "options": { + "(google.api.default_host)": "translate.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-translation" + }, + "methods": { + "TranslateText": { + "requestType": "TranslateTextRequest", + "responseType": "TranslateTextResponse", + "options": { + "(google.api.http).post": "/v3/{parent=projects/*/locations/*}:translateText", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v3/{parent=projects/*}:translateText", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "parent,model,mime_type,source_language_code,target_language_code,contents" + } + }, + "DetectLanguage": { + "requestType": "DetectLanguageRequest", + "responseType": "DetectLanguageResponse", + "options": { + "(google.api.http).post": "/v3/{parent=projects/*/locations/*}:detectLanguage", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v3/{parent=projects/*}:detectLanguage", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "parent,model,mime_type,content" + } + }, + "GetSupportedLanguages": { + "requestType": "GetSupportedLanguagesRequest", + "responseType": "SupportedLanguages", + "options": { + "(google.api.http).get": "/v3/{parent=projects/*/locations/*}/supportedLanguages", + "(google.api.http).additional_bindings.get": "/v3/{parent=projects/*}/supportedLanguages", + "(google.api.method_signature)": "parent,model,display_language_code" + } + }, + "BatchTranslateText": { + "requestType": "BatchTranslateTextRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v3/{parent=projects/*/locations/*}:batchTranslateText", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "BatchTranslateResponse", + "(google.longrunning.operation_info).metadata_type": "BatchTranslateMetadata" + } + }, + "CreateGlossary": { + "requestType": "CreateGlossaryRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v3/{parent=projects/*/locations/*}/glossaries", + "(google.api.http).body": "glossary", + "(google.api.method_signature)": "parent,glossary", + "(google.longrunning.operation_info).response_type": "Glossary", + "(google.longrunning.operation_info).metadata_type": "CreateGlossaryMetadata" + } + }, + "ListGlossaries": { + "requestType": "ListGlossariesRequest", + "responseType": "ListGlossariesResponse", + "options": { + "(google.api.http).get": "/v3/{parent=projects/*/locations/*}/glossaries", + "(google.api.method_signature)": "parent" + } + }, + "GetGlossary": { + "requestType": "GetGlossaryRequest", + "responseType": "Glossary", + "options": { + "(google.api.http).get": "/v3/{name=projects/*/locations/*/glossaries/*}", + "(google.api.method_signature)": "name" + } + }, + "DeleteGlossary": { + "requestType": "DeleteGlossaryRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v3/{name=projects/*/locations/*/glossaries/*}", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "DeleteGlossaryResponse", + "(google.longrunning.operation_info).metadata_type": "DeleteGlossaryMetadata" + } + } + } + }, + "TranslateTextGlossaryConfig": { + "fields": { + "glossary": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "ignoreCase": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "TranslateTextRequest": { + "fields": { + "contents": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "mimeType": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "sourceLanguageCode": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "targetLanguageCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "parent": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "model": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "glossaryConfig": { + "type": "TranslateTextGlossaryConfig", + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "TranslateTextResponse": { + "fields": { + "translations": { + "rule": "repeated", + "type": "Translation", + "id": 1 + }, + "glossaryTranslations": { + "rule": "repeated", + "type": "Translation", + "id": 3 + } + } + }, + "Translation": { + "fields": { + "translatedText": { + "type": "string", + "id": 1 + }, + "model": { + "type": "string", + "id": 2 + }, + "detectedLanguageCode": { + "type": "string", + "id": 4 + }, + "glossaryConfig": { + "type": "TranslateTextGlossaryConfig", + "id": 3 + } + } + }, + "DetectLanguageRequest": { + "oneofs": { + "source": { + "oneof": [ + "content" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "model": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "content": { + "type": "string", + "id": 1 + }, + "mimeType": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "DetectedLanguage": { + "fields": { + "languageCode": { + "type": "string", + "id": 1 + }, + "confidence": { + "type": "float", + "id": 2 + } + } + }, + "DetectLanguageResponse": { + "fields": { + "languages": { + "rule": "repeated", + "type": "DetectedLanguage", + "id": 1 + } + } + }, + "GetSupportedLanguagesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "displayLanguageCode": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "model": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "SupportedLanguages": { + "fields": { + "languages": { + "rule": "repeated", + "type": "SupportedLanguage", + "id": 1 + } + } + }, + "SupportedLanguage": { + "fields": { + "languageCode": { + "type": "string", + "id": 1 + }, + "displayName": { + "type": "string", + "id": 2 + }, + "supportSource": { + "type": "bool", + "id": 3 + }, + "supportTarget": { + "type": "bool", + "id": 4 + } + } + }, + "GcsSource": { + "fields": { + "inputUri": { + "type": "string", + "id": 1 + } + } + }, + "InputConfig": { + "oneofs": { + "source": { + "oneof": [ + "gcsSource" + ] + } + }, + "fields": { + "mimeType": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "gcsSource": { + "type": "GcsSource", + "id": 2 + } + } + }, + "GcsDestination": { + "fields": { + "outputUriPrefix": { + "type": "string", + "id": 1 + } + } + }, + "OutputConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsDestination" + ] + } + }, + "fields": { + "gcsDestination": { + "type": "GcsDestination", + "id": 1 + } + } + }, + "BatchTranslateTextRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "sourceLanguageCode": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "targetLanguageCodes": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "models": { + "keyType": "string", + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "inputConfigs": { + "rule": "repeated", + "type": "InputConfig", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "outputConfig": { + "type": "OutputConfig", + "id": 6, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "glossaries": { + "keyType": "string", + "type": "TranslateTextGlossaryConfig", + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 9, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "BatchTranslateMetadata": { + "fields": { + "state": { + "type": "State", + "id": 1 + }, + "translatedCharacters": { + "type": "int64", + "id": 2 + }, + "failedCharacters": { + "type": "int64", + "id": 3 + }, + "totalCharacters": { + "type": "int64", + "id": 4 + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "RUNNING": 1, + "SUCCEEDED": 2, + "FAILED": 3, + "CANCELLING": 4, + "CANCELLED": 5 + } + } + } + }, + "BatchTranslateResponse": { + "fields": { + "totalCharacters": { + "type": "int64", + "id": 1 + }, + "translatedCharacters": { + "type": "int64", + "id": 2 + }, + "failedCharacters": { + "type": "int64", + "id": 3 + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + } + } + }, + "GlossaryInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "gcsSource" + ] + } + }, + "fields": { + "gcsSource": { + "type": "GcsSource", + "id": 1 + } + } + }, + "Glossary": { + "options": { + "(google.api.resource).type": "translate.googleapis.com/Glossary", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/glossaries/{glossary}" + }, + "oneofs": { + "languages": { + "oneof": [ + "languagePair", + "languageCodesSet" + ] + } + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "languagePair": { + "type": "LanguageCodePair", + "id": 3 + }, + "languageCodesSet": { + "type": "LanguageCodesSet", + "id": 4 + }, + "inputConfig": { + "type": "GlossaryInputConfig", + "id": 5 + }, + "entryCount": { + "type": "int32", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "LanguageCodePair": { + "fields": { + "sourceLanguageCode": { + "type": "string", + "id": 1 + }, + "targetLanguageCode": { + "type": "string", + "id": 2 + } + } + }, + "LanguageCodesSet": { + "fields": { + "languageCodes": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + } + } + }, + "CreateGlossaryRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "glossary": { + "type": "Glossary", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetGlossaryRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "translate.googleapis.com/Glossary" + } + } + } + }, + "DeleteGlossaryRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "translate.googleapis.com/Glossary" + } + } + } + }, + "ListGlossariesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "filter": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListGlossariesResponse": { + "fields": { + "glossaries": { + "rule": "repeated", + "type": "Glossary", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "CreateGlossaryMetadata": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "state": { + "type": "State", + "id": 2 + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "RUNNING": 1, + "SUCCEEDED": 2, + "FAILED": 3, + "CANCELLING": 4, + "CANCELLED": 5 + } + } + } + }, + "DeleteGlossaryMetadata": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "state": { + "type": "State", + "id": 2 + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "RUNNING": 1, + "SUCCEEDED": 2, + "FAILED": 3, + "CANCELLING": 4, + "CANCELLED": 5 + } + } + } + }, + "DeleteGlossaryResponse": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "submitTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + } + } + }, "v3beta1": { "options": { "cc_enable_arenas": true, diff --git a/samples/package.json b/samples/package.json index e7d46106..1de8f466 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "node": ">=8" }, "scripts": { - "test": "mocha --recursive --timeout 90000" + "test": "mocha --recursive --timeout 150000" }, "dependencies": { "@google-cloud/automl": "^1.0.0", diff --git a/samples/quickstart.js b/samples/quickstart.js index 95af33d7..2423f4dd 100644 --- a/samples/quickstart.js +++ b/samples/quickstart.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2017 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 @@ -15,28 +15,36 @@ 'use strict'; -async function main( +function main( projectId = 'YOUR_PROJECT_ID' // Your GCP Project Id ) { // [START translate_quickstart] + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Instantiates a client const translate = new Translate({projectId}); - // The text to translate - const text = 'Hello, world!'; + async function quickStart() { + // The text to translate + const text = 'Hello, world!'; + + // The target language + const target = 'ru'; - // The target language - const target = 'ru'; + // Translates some text into Russian + const [translation] = await translate.translate(text, target); + console.log(`Text: ${text}`); + console.log(`Translation: ${translation}`); + } - // Translates some text into Russian - const [translation] = await translate.translate(text, target); - console.log(`Text: ${text}`); - console.log(`Translation: ${translation}`); + quickStart(); // [END translate_quickstart] } -const args = process.argv.slice(2); -main(...args).catch(console.error); +main(...process.argv.slice(2)); diff --git a/samples/test/quickstart.test.js b/samples/test/quickstart.test.js index 36efd924..5b75ed58 100644 --- a/samples/test/quickstart.test.js +++ b/samples/test/quickstart.test.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2017 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 diff --git a/samples/test/translate.test.js b/samples/test/translate.test.js index 07adde11..733c0d4d 100644 --- a/samples/test/translate.test.js +++ b/samples/test/translate.test.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2017 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 @@ -16,7 +16,7 @@ 'use strict'; const {assert} = require('chai'); -const {Translate} = require('@google-cloud/translate'); +const {Translate} = require('@google-cloud/translate').v2; const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}).trim(); diff --git a/samples/test/v3/translate_batch_translate_text.test.js b/samples/test/v3/translate_batch_translate_text.test.js new file mode 100644 index 00000000..b9633337 --- /dev/null +++ b/samples/test/v3/translate_batch_translate_text.test.js @@ -0,0 +1,77 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const {Storage} = require('@google-cloud/storage'); +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_batch_translate_text'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const bucketUuid = uuid.v4(); + const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`; + const storage = new Storage(); + + before(async () => { + const projectId = await translationClient.getProjectId(); + + //Create bucket if needed + await storage + .createBucket(projectId, { + location: 'US', + storageClass: 'COLDLINE', + }) + .catch(error => { + if (error.code !== 409) { + //if it's not a duplicate bucket error, let the user know + console.error(error); + } + }); + }); + + it('should batch translate the input text', async () => { + const projectId = await translationClient.getProjectId(); + const inputUri = `gs://cloud-samples-data/translation/text.txt`; + + const outputUri = `gs://${projectId}/${bucketName}`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}` + ); + assert.match(output, /Total Characters: 13/); + assert.match(output, /Translated Characters: 13/); + }); + + // Delete the folder from GCS for cleanup + after(async function() { + const projectId = await translationClient.getProjectId(); + const options = { + prefix: `translation-${bucketUuid}`, + }; + + const bucket = await storage.bucket(projectId); + const [files] = await bucket.getFiles(options); + const length = files.length; + if (length > 0) { + await Promise.all(files.map(file => file.delete())); + } + }); +}); diff --git a/samples/test/v3/translate_batch_translate_text_with_glossary.test.js b/samples/test/v3/translate_batch_translate_text_with_glossary.test.js new file mode 100644 index 00000000..bcb7615f --- /dev/null +++ b/samples/test/v3/translate_batch_translate_text_with_glossary.test.js @@ -0,0 +1,110 @@ +/** + * Copyright 2019 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. + */ + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const {Storage} = require('@google-cloud/storage'); +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_batch_translate_text_with_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'my-fake_glossary'; + const bucketUuid = uuid.v4(); + const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`; + const storage = new Storage(); + + before(async () => { + const projectId = await translationClient.getProjectId(); + + //Create bucket if needed + await storage + .createBucket(projectId, { + location: 'US', + storageClass: 'COLDLINE', + }) + .catch(error => { + if (error.code !== 409) { + //if it's not a duplicate bucket error, let the user know + console.error(error); + } + }); + + // Create glossary + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }, + }; + + // Create glossary using a long-running operation. + const [operation] = await translationClient.createGlossary(request); + // Wait for operation to complete. + await operation.promise(); + }); + + it('should batch translate the input text with a glossary', async () => { + const projectId = await translationClient.getProjectId(); + const inputUri = `gs://cloud-samples-data/translation/text.txt`; + + const outputUri = `gs://${projectId}/${bucketName}`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri} ${glossaryId}` + ); + assert.match(output, /Total Characters: 13/); + assert.match(output, /Translated Characters: 13/); + }); + + // Delete the folder from GCS for cleanup + after(async function() { + const projectId = await translationClient.getProjectId(); + const options = { + prefix: `translation-${bucketUuid}`, + }; + + const bucket = await storage.bucket(projectId); + const [files] = await bucket.getFiles(options); + const length = files.length; + if (length > 0) { + await Promise.all(files.map(file => file.delete())); + } + + // Delete the Glossary + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + // Delete glossary using a long-running operation. + const [operation] = await translationClient.deleteGlossary(request); + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_batch_translate_text_with_glossary_and_model.test.js b/samples/test/v3/translate_batch_translate_text_with_glossary_and_model.test.js new file mode 100644 index 00000000..bbc733c1 --- /dev/null +++ b/samples/test/v3/translate_batch_translate_text_with_glossary_and_model.test.js @@ -0,0 +1,111 @@ +/** + * Copyright 2019 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. + */ + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const {Storage} = require('@google-cloud/storage'); +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_batch_translate_text_with_glossary_and_model'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'my-fake_glossary'; + const modelId = 'TRL1218052175389786112'; + const bucketUuid = uuid.v4(); + const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`; + const storage = new Storage(); + + before(async () => { + const projectId = await translationClient.getProjectId(); + + //Create bucket if needed + await storage + .createBucket(projectId, { + location: 'US', + storageClass: 'COLDLINE', + }) + .catch(error => { + if (error.code !== 409) { + //if it's not a duplicate bucket error, let the user know + console.error(error); + } + }); + + // Create glossary + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: { + languageCodesSet: { + languageCodes: ['en', 'ja'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary_ja.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }, + }; + + // Create glossary using a long-running operation. + const [operation] = await translationClient.createGlossary(request); + // Wait for operation to complete. + await operation.promise(); + }); + + it('should batch translate the input text with a glossary', async () => { + const projectId = await translationClient.getProjectId(); + const inputUri = `gs://cloud-samples-data/translation/text_with_custom_model_and_glossary.txt`; + + const outputUri = `gs://${projectId}/${bucketName}`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri} ${glossaryId} ${modelId}` + ); + assert.match(output, /Total Characters: 25/); + assert.match(output, /Translated Characters: 25/); + }); + + // Delete the folder from GCS for cleanup + after(async function() { + const projectId = await translationClient.getProjectId(); + const options = { + prefix: `translation-${bucketUuid}`, + }; + + const bucket = await storage.bucket(projectId); + const [files] = await bucket.getFiles(options); + const length = files.length; + if (length > 0) { + await Promise.all(files.map(file => file.delete())); + } + + // Delete the Glossary + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + // Delete glossary using a long-running operation. + const [operation] = await translationClient.deleteGlossary(request); + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_batch_translate_text_with_model.test.js b/samples/test/v3/translate_batch_translate_text_with_model.test.js new file mode 100644 index 00000000..a668bb05 --- /dev/null +++ b/samples/test/v3/translate_batch_translate_text_with_model.test.js @@ -0,0 +1,78 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const {Storage} = require('@google-cloud/storage'); +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_batch_translate_text_with_model'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const modelId = 'TRL1218052175389786112'; + const bucketUuid = uuid.v4(); + const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`; + const storage = new Storage(); + + before(async () => { + const projectId = await translationClient.getProjectId(); + + //Create bucket if needed + await storage + .createBucket(projectId, { + location: 'US', + storageClass: 'COLDLINE', + }) + .catch(error => { + if (error.code !== 409) { + //if it's not a duplicate bucket error, let the user know + console.error(error); + } + }); + }); + + it('should batch translate the input text with a model', async () => { + const projectId = await translationClient.getProjectId(); + const inputUri = `gs://cloud-samples-data/translation/custom_model_text.txt`; + + const outputUri = `gs://${projectId}/${bucketName}`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri} ${modelId}` + ); + assert.match(output, /Total Characters: 15/); + assert.match(output, /Translated Characters: 15/); + }); + + // Delete the folder from GCS for cleanup + after(async function() { + const projectId = await translationClient.getProjectId(); + const options = { + prefix: `translation-${bucketUuid}`, + }; + + const bucket = await storage.bucket(projectId); + const [files] = await bucket.getFiles(options); + const length = files.length; + if (length > 0) { + await Promise.all(files.map(file => file.delete())); + } + }); +}); diff --git a/samples/test/v3/translate_create_glossary.test.js b/samples/test/v3/translate_create_glossary.test.js new file mode 100644 index 00000000..44f8ae0a --- /dev/null +++ b/samples/test/v3/translate_create_glossary.test.js @@ -0,0 +1,58 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_create_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + + it('should create a glossary', async function() { + const projectId = await translationClient.getProjectId(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` + ); + assert.match( + output, + /gs:\/\/cloud-samples-data\/translation\/glossary.csv/ + ); + }); + + after('cleanup for glossary create', async function() { + const projectId = await translationClient.getProjectId(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + // Delete the glossary to clean up + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_delete_glossary.test.js b/samples/test/v3/translate_delete_glossary.test.js new file mode 100644 index 00000000..b5ce3f36 --- /dev/null +++ b/samples/test/v3/translate_delete_glossary.test.js @@ -0,0 +1,68 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_delete_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'glossary'; + + before(async function() { + // Add a glossary to be deleted + // const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); + + it('should delete a glossary', async () => { + const projectId = await translationClient.getProjectId(); + + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` + ); + assert.match(output, /glossary/); + }); +}); diff --git a/samples/test/v3/translate_detect_language.test.js b/samples/test/v3/translate_detect_language.test.js new file mode 100644 index 00000000..3ebf4be0 --- /dev/null +++ b/samples/test/v3/translate_detect_language.test.js @@ -0,0 +1,37 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_detect_language'; + +describe(REGION_TAG, () => { + it('should detect the language of the input text', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const location = 'global'; + const text = `'Hæ sæta'`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${text}` + ); + assert.match(output, /Language Code: is/); + assert.match(output, /Confidence: 1/); + }); +}); diff --git a/samples/test/v3/translate_get_glossary.test.js b/samples/test/v3/translate_get_glossary.test.js new file mode 100644 index 00000000..eb7de3ed --- /dev/null +++ b/samples/test/v3/translate_get_glossary.test.js @@ -0,0 +1,83 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_get_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + + before(async function() { + // Add a glossary to get + const projectId = await translationClient.getProjectId(); + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); + + it('should get a glossary', async () => { + const projectId = await translationClient.getProjectId(); + + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` + ); + assert.match(output, /test-glossary/); + }); + + after(async function() { + //delete the glossary we created + const projectId = await translationClient.getProjectId(); + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_get_supported_languages.test.js b/samples/test/v3/translate_get_supported_languages.test.js new file mode 100644 index 00000000..990ffbec --- /dev/null +++ b/samples/test/v3/translate_get_supported_languages.test.js @@ -0,0 +1,32 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_get_supported_languages'; + +describe(REGION_TAG, () => { + it('should get supported langauges', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const output = execSync(`node v3/${REGION_TAG}.js ${projectId}`); + assert.match(output, /zh-CN/); + }); +}); diff --git a/samples/test/v3/translate_get_supported_languages_for_targets.test.js b/samples/test/v3/translate_get_supported_languages_for_targets.test.js new file mode 100644 index 00000000..c16b5413 --- /dev/null +++ b/samples/test/v3/translate_get_supported_languages_for_targets.test.js @@ -0,0 +1,33 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_get_supported_languages_for_target'; + +describe(REGION_TAG, () => { + it('should get supported langauges for target', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const output = execSync(`node v3/${REGION_TAG}.js ${projectId}`); + assert.match(output, /Language Code: yi/); + assert.match(output, /Display Name: Yiddish/); + }); +}); diff --git a/samples/test/v3/translate_list_codes.test.js b/samples/test/v3/translate_list_codes.test.js new file mode 100644 index 00000000..725a86fd --- /dev/null +++ b/samples/test/v3/translate_list_codes.test.js @@ -0,0 +1,33 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_list_codes'; + +describe(REGION_TAG, () => { + it('should list available language codes', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const output = execSync(`node v3/${REGION_TAG}.js ${projectId}`); + assert.match(output, /Language Code: en/); + assert.match(output, /Language Code: fr/); + }); +}); diff --git a/samples/test/v3/translate_list_glossary.test.js b/samples/test/v3/translate_list_glossary.test.js new file mode 100644 index 00000000..eb7d3764 --- /dev/null +++ b/samples/test/v3/translate_list_glossary.test.js @@ -0,0 +1,86 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_list_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + + before(async function() { + // Add a glossary to be deleted + const projectId = await translationClient.getProjectId(); + + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); + + it('should list glossaries in project', async () => { + const projectId = await translationClient.getProjectId(); + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location}` + ); + assert.match( + output, + /gs:\/\/cloud-samples-data\/translation\/glossary.csv/ + ); + }); + + after(async function() { + const projectId = await translationClient.getProjectId(); + + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_list_language_names.test.js b/samples/test/v3/translate_list_language_names.test.js new file mode 100644 index 00000000..e8343fff --- /dev/null +++ b/samples/test/v3/translate_list_language_names.test.js @@ -0,0 +1,35 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_list_language_names'; + +describe(REGION_TAG, () => { + it('should list available language names', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const output = execSync(`node v3/${REGION_TAG}.js ${projectId}`); + assert.match(output, /Language Code: en/); + assert.match(output, /Display Name: Anglais/); + assert.match(output, /Language Code: fr/); + assert.match(output, /Display Name: Français/); + }); +}); diff --git a/samples/test/v3/translate_translate_text.test.js b/samples/test/v3/translate_translate_text.test.js new file mode 100644 index 00000000..efc11b45 --- /dev/null +++ b/samples/test/v3/translate_translate_text.test.js @@ -0,0 +1,36 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_translate_text'; + +describe(REGION_TAG, () => { + it('should translate the input text', async () => { + const translationClient = new TranslationServiceClient(); + const projectId = await translationClient.getProjectId(); + const location = `global`; + const text = `"Hello world"`; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${text}` + ); + assert.match(output, /Translation: Pozdrav svijetu/); + }); +}); diff --git a/samples/test/v3/translate_translate_text_with_glossary.test.js b/samples/test/v3/translate_translate_text_with_glossary.test.js new file mode 100644 index 00000000..e66eeef0 --- /dev/null +++ b/samples/test/v3/translate_translate_text_with_glossary.test.js @@ -0,0 +1,83 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_translate_text_with_glossary'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + + before(async function() { + // Add a glossary to be translate with + const projectId = await translationClient.getProjectId(); + + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); + + it('should translate text with a glossary in project', async () => { + const projectId = await translationClient.getProjectId(); + const input = 'directions'; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId} ${input}` + ); + assert.match(output, /indicaciones/); + }); + + after(async function() { + const projectId = await translationClient.getProjectId(); + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_translate_text_with_glossary_and_model.test.js b/samples/test/v3/translate_translate_text_with_glossary_and_model.test.js new file mode 100644 index 00000000..1f374831 --- /dev/null +++ b/samples/test/v3/translate_translate_text_with_glossary_and_model.test.js @@ -0,0 +1,84 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const REGION_TAG = 'translate_translate_text_with_glossary_and_model'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const glossaryId = 'test-glossary'; + const modelId = 'TRL1218052175389786112'; + + before(async function() { + // Add a glossary to be translate with + const projectId = await translationClient.getProjectId(); + + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'ja'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary_ja.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); + + it('should translate text with a glossary and Automl model in project', async () => { + const projectId = await translationClient.getProjectId(); + const input = 'directions'; + const output = execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId} ${modelId} ${input}` + ); + assert.match(output, /道順/); + }); + + after(async function() { + const projectId = await translationClient.getProjectId(); + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + }); +}); diff --git a/samples/test/v3/translate_translate_text_with_model.test.js b/samples/test/v3/translate_translate_text_with_model.test.js new file mode 100644 index 00000000..938d0398 --- /dev/null +++ b/samples/test/v3/translate_translate_text_with_model.test.js @@ -0,0 +1,37 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const {TranslationServiceClient} = require('@google-cloud/translate'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); +const REGION_TAG = 'translate_translate_text_with_model'; + +describe(REGION_TAG, () => { + const translationClient = new TranslationServiceClient(); + const location = 'us-central1'; + const modelId = 'TRL1218052175389786112'; + const input = 'Tell me how this ends'; + + it('should translate text with an automl model in project', async () => { + const projectId = await translationClient.getProjectId(); + const output = await execSync( + `node v3/${REGION_TAG}.js ${projectId} ${location} ${modelId} ${input}` + ); + assert.match(output, /Translated Content: 教えて/); + }); +}); diff --git a/samples/translate.js b/samples/translate.js index 25f4d4b2..7ce148f4 100644 --- a/samples/translate.js +++ b/samples/translate.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2017 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 @@ -15,10 +15,10 @@ 'use strict'; -async function detectLanguage(text) { +function detectLanguageSample(text) { // [START translate_detect_language] // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Creates a client const translate = new Translate(); @@ -31,36 +31,43 @@ async function detectLanguage(text) { // Detects the language. "text" can be a string for detecting the language of // a single piece of text, or an array of strings for detecting the languages // of multiple texts. - let [detections] = await translate.detect(text); - detections = Array.isArray(detections) ? detections : [detections]; - console.log('Detections:'); - detections.forEach(detection => { - console.log(`${detection.input} => ${detection.language}`); - }); - + async function detectLanguage() { + let [detections] = await translate.detect(text); + detections = Array.isArray(detections) ? detections : [detections]; + console.log('Detections:'); + detections.forEach(detection => { + console.log(`${detection.input} => ${detection.language}`); + }); + } + + detectLanguage(); // [END translate_detect_language] } -async function listLanguages() { +function listLanguagesSample() { // [START translate_list_codes] // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Creates a client const translate = new Translate(); - // Lists available translation language with their names in English (the default). - const [languages] = await translate.getLanguages(); + async function listLanguages() { + // Lists available translation language with their names in English (the default). + const [languages] = await translate.getLanguages(); + + console.log('Languages:'); + languages.forEach(language => console.log(language)); + } - console.log('Languages:'); - languages.forEach(language => console.log(language)); + listLanguages(); // [END translate_list_codes] } -async function listLanguagesWithTarget(target) { +function listLanguagesWithTargetSample(target) { // [START translate_list_language_names] // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Creates a client const translate = new Translate(); @@ -70,19 +77,22 @@ async function listLanguagesWithTarget(target) { */ // const target = 'The target language for language names, e.g. ru'; - // Lists available translation language with their names in a target language - const [languages] = await translate.getLanguages(target); + async function listLanguagesWithTarget() { + // Lists available translation language with their names in a target language + const [languages] = await translate.getLanguages(target); - console.log('Languages:'); - languages.forEach(language => console.log(language)); + console.log('Languages:'); + languages.forEach(language => console.log(language)); + } + listLanguagesWithTarget(); // [END translate_list_language_names] } -async function translateText(text, target) { +function translateTextSample(text, target) { // [START translate_translate_text] // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Creates a client const translate = new Translate(); @@ -93,23 +103,26 @@ async function translateText(text, target) { // const text = 'The text to translate, e.g. Hello, world!'; // const target = 'The target language, e.g. ru'; - // Translates the text into the target language. "text" can be a string for - // translating a single piece of text, or an array of strings for translating - // multiple texts. - let [translations] = await translate.translate(text, target); - translations = Array.isArray(translations) ? translations : [translations]; - console.log('Translations:'); - translations.forEach((translation, i) => { - console.log(`${text[i]} => (${target}) ${translation}`); - }); - + async function translateText() { + // Translates the text into the target language. "text" can be a string for + // translating a single piece of text, or an array of strings for translating + // multiple texts. + let [translations] = await translate.translate(text, target); + translations = Array.isArray(translations) ? translations : [translations]; + console.log('Translations:'); + translations.forEach((translation, i) => { + console.log(`${text[i]} => (${target}) ${translation}`); + }); + } + + translateText(); // [END translate_translate_text] } -async function translateTextWithModel(text, target, model) { +function translateTextWithModelSample(text, target, model) { // [START translate_text_with_model] // Imports the Google Cloud client library - const {Translate} = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate').v2; // Creates a client const translate = new Translate(); @@ -121,23 +134,27 @@ async function translateTextWithModel(text, target, model) { // const target = 'The target language, e.g. ru'; // const model = 'The model to use, e.g. nmt'; - const options = { - // The target language, e.g. "ru" - to: target, - // Make sure your project is whitelisted. - // Possible values are "base" and "nmt" - model: model, - }; - - // Translates the text into the target language. "text" can be a string for - // translating a single piece of text, or an array of strings for translating - // multiple texts. - let [translations] = await translate.translate(text, options); - translations = Array.isArray(translations) ? translations : [translations]; - console.log('Translations:'); - translations.forEach((translation, i) => { - console.log(`${text[i]} => (${target}) ${translation}`); - }); + async function translateTextWithModel() { + const options = { + // The target language, e.g. "ru" + to: target, + // Make sure your project is whitelisted. + // Possible values are "base" and "nmt" + model: model, + }; + + // Translates the text into the target language. "text" can be a string for + // translating a single piece of text, or an array of strings for translating + // multiple texts. + let [translations] = await translate.translate(text, options); + translations = Array.isArray(translations) ? translations : [translations]; + console.log('Translations:'); + translations.forEach((translation, i) => { + console.log(`${text[i]} => (${target}) ${translation}`); + }); + } + + translateTextWithModel(); // [END translate_text_with_model] } @@ -147,7 +164,7 @@ require(`yargs`) `detect `, `Detects the language of one or more strings.`, {}, - async opts => await detectLanguage(opts.text).catch(console.error) + async opts => await detectLanguageSample(opts.text) ) .command( `list [target]`, @@ -155,9 +172,9 @@ require(`yargs`) {}, async opts => { if (opts.target) { - await listLanguagesWithTarget(opts.target).catch(console.error); + await listLanguagesWithTargetSample(opts.target); } else { - await listLanguages().catch(console.error); + await listLanguagesSample(); } } ) @@ -165,17 +182,14 @@ require(`yargs`) `translate `, `Translates one or more strings into the target language.`, {}, - async opts => - await translateText(opts.text, opts.toLang).catch(console.error) + async opts => await translateTextSample(opts.text, opts.toLang) ) .command( `translate-with-model `, `Translates one or more strings into the target language using the specified model.`, {}, async opts => - await translateTextWithModel(opts.text, opts.toLang, opts.model).catch( - console.error - ) + await translateTextWithModelSample(opts.text, opts.toLang, opts.model) ) .example(`node $0 detect "Hello world!"`, `Detects the language of a string.`) .example( diff --git a/samples/v3/translate_batch_translate_text.js b/samples/v3/translate_batch_translate_text.js new file mode 100644 index 00000000..ae904b84 --- /dev/null +++ b/samples/v3/translate_batch_translate_text.js @@ -0,0 +1,73 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + inputUri = 'gs://cloud-samples-data/translation/text.txt', + outputUri = 'gs://YOUR_PROJECT_ID/translation/BATCH_TRANSLATION_OUTPUT/' +) { + // [START translate_v3_batch_translate_text] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const inputUri = 'gs://cloud-samples-data/text.txt'; + // const outputUri = 'gs://YOUR_BUCKET_ID/path_to_store_results/'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + async function batchTranslateText() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + sourceLanguageCode: 'en', + targetLanguageCodes: ['ja'], + inputConfigs: [ + { + mimeType: 'text/plain', // mime types: text/plain, text/html + gcsSource: { + inputUri: inputUri, + }, + }, + ], + outputConfig: { + gcsDestination: { + outputUriPrefix: outputUri, + }, + }, + }; + + // Batch translate text using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.batchTranslateText(request); + + // Wait for operation to complete. + const [response] = await operation.promise(); + + console.log(`Total Characters: ${response.totalCharacters}`); + console.log(`Translated Characters: ${response.translatedCharacters}`); + } + + batchTranslateText(); + // [END translate_v3_batch_translate_text] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_batch_translate_text_with_glossary.js b/samples/v3/translate_batch_translate_text_with_glossary.js new file mode 100644 index 00000000..2616ac96 --- /dev/null +++ b/samples/v3/translate_batch_translate_text_with_glossary.js @@ -0,0 +1,80 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + inputUri = 'gs://cloud-samples-data/translation/text.txt', + outputUri = 'gs://YOUR_PROJECT_ID/translation/BATCH_TRANSLATION_OUTPUT/', + glossaryId = 'YOUR_GLOSSARY_ID' +) { + // [START translate_v3_batch_translate_text_with_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const inputUri = 'gs://cloud-samples-data/text.txt'; + // const outputUri = 'gs://YOUR_BUCKET_ID/path_to_store_results/'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const client = new TranslationServiceClient(); + async function batchTranslateTextWithGlossary() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + sourceLanguageCode: 'en', + targetLanguageCodes: ['es'], + inputConfigs: [ + { + mimeType: 'text/plain', // mime types: text/plain, text/html + gcsSource: { + inputUri: inputUri, + }, + }, + ], + outputConfig: { + gcsDestination: { + outputUriPrefix: outputUri, + }, + }, + glossaries: { + es: { + glossary: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }, + }, + }; + + // Create a job whose results you can either wait for now, or get later + const [operation] = await client.batchTranslateText(request); + + // Get a Promise representation of the final result of the job + const [response] = await operation.promise(); + + // Display the translation for each input text provided + console.log(`Total Characters: ${response.totalCharacters}`); + console.log(`Translated Characters: ${response.translatedCharacters}`); + } + + batchTranslateTextWithGlossary(); + // [END translate_v3_batch_translate_text_with_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_batch_translate_text_with_glossary_and_model.js b/samples/v3/translate_batch_translate_text_with_glossary_and_model.js new file mode 100644 index 00000000..e72dc618 --- /dev/null +++ b/samples/v3/translate_batch_translate_text_with_glossary_and_model.js @@ -0,0 +1,85 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + inputUri = 'gs://cloud-samples-data/translation/text.txt', + outputUri = 'gs://YOUR_PROJECT_ID/translation/BATCH_TRANSLATION_OUTPUT/', + glossaryId = 'YOUR_GLOSSARY_ID', + modelId = 'YOUR_MODEL_ID' +) { + // [START translate_v3_batch_translate_text_with_glossary_and_model] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const inputUri = 'gs://cloud-samples-data/text.txt'; + // const outputUri = 'gs://YOUR_BUCKET_ID/path_to_store_results/'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + // const modelId = 'YOUR_MODEL_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const client = new TranslationServiceClient(); + async function batchTranslateTextWithGlossaryAndModel() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + sourceLanguageCode: 'en', + targetLanguageCodes: ['ja'], + inputConfigs: [ + { + mimeType: 'text/plain', // mime types: text/plain, text/html + gcsSource: { + inputUri: inputUri, + }, + }, + ], + outputConfig: { + gcsDestination: { + outputUriPrefix: outputUri, + }, + }, + glossaries: { + ja: { + glossary: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }, + }, + models: { + ja: `projects/${projectId}/locations/${location}/models/${modelId}`, + }, + }; + + // Create a job whose results you can either wait for now, or get later + const [operation] = await client.batchTranslateText(request); + + // Get a Promise representation of the final result of the job + const [response] = await operation.promise(); + + // Display the translation for each input text provided + console.log(`Total Characters: ${response.totalCharacters}`); + console.log(`Translated Characters: ${response.translatedCharacters}`); + } + + batchTranslateTextWithGlossaryAndModel(); + // [END translate_v3_batch_translate_text_with_glossary_and_model] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_batch_translate_text_with_model.js b/samples/v3/translate_batch_translate_text_with_model.js new file mode 100644 index 00000000..4ec26b02 --- /dev/null +++ b/samples/v3/translate_batch_translate_text_with_model.js @@ -0,0 +1,78 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + inputUri = 'gs://cloud-samples-data/translation/text.txt', + outputUri = 'gs://YOUR_PROJECT_ID/translation/BATCH_TRANSLATION_OUTPUT/', + modelId = 'YOUR_MODEL_ID' +) { + // [START translate_v3_batch_translate_text_with_model] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const inputUri = 'gs://cloud-samples-data/text.txt'; + // const outputUri = 'gs://YOUR_BUCKET_ID/path_to_store_results/'; + // const modelId = 'YOUR_MODEL_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const client = new TranslationServiceClient(); + async function batchTranslateTextWithModel() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + sourceLanguageCode: 'en', + targetLanguageCodes: ['ja'], + inputConfigs: [ + { + mimeType: 'text/plain', // mime types: text/plain, text/html + gcsSource: { + inputUri: inputUri, + }, + }, + ], + outputConfig: { + gcsDestination: { + outputUriPrefix: outputUri, + }, + }, + models: { + ja: `projects/${projectId}/locations/${location}/models/${modelId}`, + }, + }; + + // Create a job whose results you can either wait for now, or get later + const [operation] = await client.batchTranslateText(request); + + // Get a Promise representation of the final result of the job + const [response] = await operation.promise(); + + // Display the translation for each input text provided + console.log(`Total Characters: ${response.totalCharacters}`); + console.log(`Translated Characters: ${response.translatedCharacters}`); + } + + batchTranslateTextWithModel(); + // [END translate_v3_batch_translate_text_with_model] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_create_glossary.js b/samples/v3/translate_create_glossary.js new file mode 100644 index 00000000..88b96942 --- /dev/null +++ b/samples/v3/translate_create_glossary.js @@ -0,0 +1,71 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + glossaryId = 'glossary-id' +) { + // [START translate_v3_create_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function createGlossary() { + // Construct glossary + const glossary = { + languageCodesSet: { + languageCodes: ['en', 'es'], + }, + inputConfig: { + gcsSource: { + inputUri: 'gs://cloud-samples-data/translation/glossary.csv', + }, + }, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + glossary: glossary, + }; + + // Create glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.createGlossary(request); + + // Wait for operation to complete. + await operation.promise(); + + console.log(`Created glossary:`); + console.log(`InputUri ${request.glossary.inputConfig.gcsSource.inputUri}`); + } + + createGlossary(); + // [END translate_v3_create_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_delete_glossary.js b/samples/v3/translate_delete_glossary.js new file mode 100644 index 00000000..bfe2b735 --- /dev/null +++ b/samples/v3/translate_delete_glossary.js @@ -0,0 +1,57 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + glossaryId = 'glossary-id' +) { + // [START translate_v3_delete_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function deleteGlossary() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Delete glossary using a long-running operation. + // You can wait for now, or get results later. + const [operation] = await translationClient.deleteGlossary(request); + + // Wait for operation to complete. + const [response] = await operation.promise(); + + console.log(`Deleted glossary: ${response.name}`); + } + + deleteGlossary(); + // [END translate_v3_delete_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_detect_language.js b/samples/v3/translate_detect_language.js new file mode 100644 index 00000000..d0bf3822 --- /dev/null +++ b/samples/v3/translate_detect_language.js @@ -0,0 +1,57 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'global', + text = 'text to translate' +) { + // [START translate_v3_detect_language] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const text = 'text to translate'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function detectLanguage() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + content: text, + }; + + // Run request + const [response] = await translationClient.detectLanguage(request); + + console.log(`Detected Languages:`); + for (const language of response.languages) { + console.log(`Language Code: ${language.languageCode}`); + console.log(`Confidence: ${language.confidence}`); + } + } + + detectLanguage(); + // [END translate_v3_detect_language] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_get_glossary.js b/samples/v3/translate_get_glossary.js new file mode 100644 index 00000000..3486e402 --- /dev/null +++ b/samples/v3/translate_get_glossary.js @@ -0,0 +1,53 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + glossaryId = 'glossary-id' +) { + // [START translate_v3_get_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function getGlossary() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + name: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + + // Get glossary + const [response] = await translationClient.getGlossary(request); + + console.log(`Got glossary: ${response.name}`); + } + + getGlossary(); + // [END translate_v3_get_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_get_supported_languages.js b/samples/v3/translate_get_supported_languages.js new file mode 100644 index 00000000..8204d916 --- /dev/null +++ b/samples/v3/translate_get_supported_languages.js @@ -0,0 +1,59 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main(projectId = 'YOUR_PROJECT_ID', location = 'global') { + // [START translate_v3_get_supported_languages] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function getSupportedLanguages() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + }; + + // Get supported languages + const [response] = await translationClient.getSupportedLanguages(request); + + for (const language of response.languages) { + // Supported language code, generally consisting of its ISO 639-1 identifier, for + // example, 'en', 'ja'. In certain cases, BCP-47 codes including language and + // region identifiers are returned (for example, 'zh-TW' and 'zh-CN') + console.log(`Language - Language Code: ${language.languageCode}`); + // Human readable name of the language localized in the display language specified + // in the request. + console.log(`Language - Display Name: ${language.displayName}`); + // Can be used as source language. + console.log(`Language - Support Source: ${language.supportSource}`); + // Can be used as target language. + console.log(`Language - Support Target: ${language.supportTarget}`); + } + } + + getSupportedLanguages(); + // [END translate_v3_get_supported_languages] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_get_supported_languages_for_target.js b/samples/v3/translate_get_supported_languages_for_target.js new file mode 100644 index 00000000..5ea4b919 --- /dev/null +++ b/samples/v3/translate_get_supported_languages_for_target.js @@ -0,0 +1,60 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main(projectId = 'YOUR_PROJECT_ID', location = 'global') { + // [START translate_v3_get_supported_languages_for_target] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function getSupportedLanguages() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + displayLanguageCode: 'en', + }; + + // Get supported languages + const [response] = await translationClient.getSupportedLanguages(request); + + for (const language of response.languages) { + // Supported language code, generally consisting of its ISO 639-1 identifier, for + // example, 'en', 'ja'. In certain cases, BCP-47 codes including language and + // region identifiers are returned (for example, 'zh-TW' and 'zh-CN') + console.log(`Language - Language Code: ${language.languageCode}`); + // Human readable name of the language localized in the display language specified + // in the request. + console.log(`Language - Display Name: ${language.displayName}`); + // Can be used as source language. + console.log(`Language - Support Source: ${language.supportSource}`); + // Can be used as target language. + console.log(`Language - Support Target: ${language.supportTarget}`); + } + } + + getSupportedLanguages(); + // [END translate_v3_get_supported_languages_for_target] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_list_codes.js b/samples/v3/translate_list_codes.js new file mode 100644 index 00000000..37c4c732 --- /dev/null +++ b/samples/v3/translate_list_codes.js @@ -0,0 +1,50 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main(projectId = 'YOUR_PROJECT_ID', location = 'global') { + // [START translate_v3_list_codes] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function listLanguages() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + }; + + // Run request + const [response] = await translationClient.getSupportedLanguages(request); + + console.log(`Supported languages:`); + for (const language of response.languages) { + console.log(`Language Code: ${language.languageCode}`); + } + } + + listLanguages(); + // [END translate_v3_list_codes] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_list_glossary.js b/samples/v3/translate_list_glossary.js new file mode 100644 index 00000000..f96eb4a1 --- /dev/null +++ b/samples/v3/translate_list_glossary.js @@ -0,0 +1,54 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main(projectId = 'YOUR_PROJECT_ID', location = 'us-central1') { + // [START translate_v3_list_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function listGlossaries() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + }; + + // Run request + const [response] = await translationClient.listGlossaries(request); + + for (const glossary of response) { + console.log(`Name: ${glossary.name}`); + console.log(`Entry count: ${glossary.entryCount}`); + console.log(`Input uri: ${glossary.inputConfig.gcsSource.inputUri}`); + for (const languageCode of glossary.languageCodesSet.languageCodes) { + console.log(`Language code: ${languageCode}`); + } + } + } + + listGlossaries(); + // [END translate_v3_list_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_list_language_names.js b/samples/v3/translate_list_language_names.js new file mode 100644 index 00000000..92aa9ece --- /dev/null +++ b/samples/v3/translate_list_language_names.js @@ -0,0 +1,52 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main(projectId = 'YOUR_PROJECT_ID', location = 'global') { + // [START translate_v3_list_language_names] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + + async function listLanguages() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + displayLanguageCode: 'fr', + }; + + // Run request + const [response] = await translationClient.getSupportedLanguages(request); + + console.log(`Supported languages:`); + for (const language of response.languages) { + console.log(`Language Code: ${language.languageCode}`); + console.log(`Display Name: ${language.displayName}`); + } + } + + listLanguages(); + // [END translate_v3_list_language_names] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_translate_text.js b/samples/v3/translate_translate_text.js new file mode 100644 index 00000000..51a1a750 --- /dev/null +++ b/samples/v3/translate_translate_text.js @@ -0,0 +1,57 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'global', + text = 'text to translate' +) { + // [START translate_v3_translate_text] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const text = 'text to translate'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + async function translateText() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + contents: [text], + mimeType: 'text/plain', // mime types: text/plain, text/html + sourceLanguageCode: 'en', + targetLanguageCode: 'sr-Latn', + }; + + // Run request + const [response] = await translationClient.translateText(request); + + for (const translation of response.translations) { + console.log(`Translation: ${translation.translatedText}`); + } + } + + translateText(); + // [END translate_v3_translate_text] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_translate_text_with_glossary.js b/samples/v3/translate_translate_text_with_glossary.js new file mode 100644 index 00000000..e40c6d4c --- /dev/null +++ b/samples/v3/translate_translate_text_with_glossary.js @@ -0,0 +1,63 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + glossaryId = 'glossary', + text = 'text to translate' +) { + // [START translate_v3_translate_text_with_glossary] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'global'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + // const text = 'text to translate'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + async function translateTextWithGlossary() { + const glossaryConfig = { + glossary: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + contents: [text], + mimeType: 'text/plain', // mime types: text/plain, text/html + sourceLanguageCode: 'en', + targetLanguageCode: 'es', + glossaryConfig: glossaryConfig, + }; + + // Run request + const [response] = await translationClient.translateText(request); + + for (const translation of response.glossaryTranslations) { + console.log(`Translation: ${translation.translatedText}`); + } + } + + translateTextWithGlossary(); + // [END translate_v3_translate_text_with_glossary] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_translate_text_with_glossary_and_model.js b/samples/v3/translate_translate_text_with_glossary_and_model.js new file mode 100644 index 00000000..a09432ac --- /dev/null +++ b/samples/v3/translate_translate_text_with_glossary_and_model.js @@ -0,0 +1,66 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + glossaryId = 'glossary', + modelId = 'YOUR_MODEL_ID', + text = 'text to translate' +) { + // [START translate_v3_translate_text_with_glossary_and_model] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const glossaryId = 'YOUR_GLOSSARY_ID'; + // const modelId = 'YOUR_MODEL_ID'; + // const text = 'text to translate'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + async function translateTextWithGlossaryAndModel() { + const glossaryConfig = { + glossary: `projects/${projectId}/locations/${location}/glossaries/${glossaryId}`, + }; + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + contents: [text], + mimeType: 'text/plain', // mime types: text/plain, text/html + sourceLanguageCode: 'en', + targetLanguageCode: 'ja', + glossaryConfig: glossaryConfig, + model: `projects/${projectId}/locations/${location}/models/${modelId}`, + }; + + // Run request + const [response] = await translationClient.translateText(request); + + for (const translation of response.glossaryTranslations) { + console.log(`Translation: ${translation.translatedText}`); + } + } + + translateTextWithGlossaryAndModel(); + // [END translate_v3_translate_text_with_glossary_and_model] +} + +main(...process.argv.slice(2)); diff --git a/samples/v3/translate_translate_text_with_model.js b/samples/v3/translate_translate_text_with_model.js new file mode 100644 index 00000000..5a1d71d0 --- /dev/null +++ b/samples/v3/translate_translate_text_with_model.js @@ -0,0 +1,60 @@ +// Copyright 2019 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 +// +// https://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. + +'use strict'; + +function main( + projectId = 'YOUR_PROJECT_ID', + location = 'us-central1', + modelId = 'model-id', + text = 'text to translate' +) { + // [START translate_v3_text_with_model] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1'; + // const modelId = 'YOUR_MODEL_ID'; + // const text = 'text to translate'; + + // Imports the Google Cloud Translation library + const {TranslationServiceClient} = require('@google-cloud/translate'); + + // Instantiates a client + const translationClient = new TranslationServiceClient(); + async function translateTextWithModel() { + // Construct request + const request = { + parent: `projects/${projectId}/locations/${location}`, + contents: [text], + mimeType: 'text/plain', // mime types: text/plain, text/html + sourceLanguageCode: 'en', + targetLanguageCode: 'ja', + model: `projects/${projectId}/locations/${location}/models/${modelId}`, + }; + + // Run request + const [response] = await translationClient.translateText(request); + + for (const translation of response.translations) { + console.log(`Translated Content: ${translation.translatedText}`); + } + } + + translateTextWithModel(); + // [END translate_v3_text_with_model] +} + +main(...process.argv.slice(2)); diff --git a/src/index.ts b/src/index.ts index 879116bf..7a6c4b12 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,7 @@ * @namespace google.protobuf */ const v3beta1 = require('./v3beta1'); +import * as v2 from './v2'; /** * The `@google-cloud/translate` package has the following named exports: @@ -73,11 +74,12 @@ const v3beta1 = require('./v3beta1'); * const {TranslationServiceClient} = * require('@google-cloud/translate').v3beta1; */ -export * from './v2'; +import * as v3 from './v3'; +export * from './v3'; /** * @type {object} * @property {constructor} TranslationServiceClient * Reference to {@link v3beta1.TranslationServiceClient} */ -export {v3beta1}; +export {v2, v3beta1, v3}; diff --git a/src/v3/index.ts b/src/v3/index.ts new file mode 100644 index 00000000..07f3c18e --- /dev/null +++ b/src/v3/index.ts @@ -0,0 +1,19 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {TranslationServiceClient} from './translation_service_client'; diff --git a/src/v3/translation_service_client.ts b/src/v3/translation_service_client.ts new file mode 100644 index 00000000..3cb89bba --- /dev/null +++ b/src/v3/translation_service_client.ts @@ -0,0 +1,692 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import * as path from 'path'; + +import * as packageJson from '../../package.json'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './translation_service_client_config.json'; + +const version = packageJson.version; + +export interface ClientOptions extends gax.GrpcClientOptions, + gax.GoogleAuthOptions { + libName?: string; + libVersion?: string; + clientConfig?: gax.ClientConfig; + fallback?: boolean; + apiEndpoint?: string; + port?: number; + servicePath?: string; + sslCreds?: object; +} + +interface Descriptors { + page: {[name: string]: gax.PageDescriptor}; + stream: {[name: string]: gax.StreamDescriptor}; + longrunning: {[name: string]: gax.LongrunningDescriptor}; +} + +export interface Callback< + ResponseObject, NextRequestObject, RawResponseObject> { + (err: Error|null|undefined, value?: ResponseObject|null, + nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void; +} + +export interface Operation extends gax.Operation { + promise(): Promise< + [ResultType, MetadataType, protosTypes.google.longrunning.IOperation]>; +} + + +export interface PaginationCallback< + RequestObject, ResponseObject, ResponseType> { + (err: Error|null, values?: ResponseType[], nextPageRequest?: RequestObject, + rawResponse?: ResponseObject): void; +} + +export interface PaginationResponse< + RequestObject, ResponseObject, ResponseType> { + values?: ResponseType[]; + nextPageRequest?: RequestObject; + rawResponse?: ResponseObject; +} + +export class TranslationServiceClient { + /* + Provides natural language translation operations. + */ + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + auth: gax.GoogleAuth; + + /** + * Construct an instance of TranslationServiceClient. + * + * @@param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @@param {object} [options.credentials] - Credentials object. + * @@param {string} [options.credentials.client_email] + * @@param {string} [options.credentials.private_key] + * @@param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @@param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @@param {number} [options.port] - The port on which to connect to + * the remote host. + * @@param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@@link + * https://developers.google.com/identity/protocols/application-default-credentials + * Application Default Credentials}, your project ID will be detected + * automatically. + * @@param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @@param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof TranslationServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser) { + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof TranslationServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gl-node/${process.version}`, `grpc/${gaxGrpc.grpcVersion}`, + `gax/${gaxModule.version}`, `gapic/${version}`, + `gl-web/${gaxModule.version}` + ]; + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = + path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listGlossaries: new gaxModule.PageDescriptor( + 'pageToken', 'nextPageToken', 'glossaries') + }; + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const protoFilesRoot = opts.fallback ? + gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json')) : + gaxModule.protobuf.loadSync(nodejsProtoPath); + + const operationsClient = + gaxModule + .lro({ + auth: this.auth, + grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined + }) + .operationsClient(opts); + const batchTranslateTextResponse = + protoFilesRoot.lookup('BatchTranslateResponse') as gax.protobuf.Type; + const batchTranslateTextMetadata = + protoFilesRoot.lookup('BatchTranslateMetadata') as gax.protobuf.Type; + const createGlossaryResponse = + protoFilesRoot.lookup('Glossary') as gax.protobuf.Type; + const createGlossaryMetadata = + protoFilesRoot.lookup('CreateGlossaryMetadata') as gax.protobuf.Type; + const deleteGlossaryResponse = + protoFilesRoot.lookup('DeleteGlossaryResponse') as gax.protobuf.Type; + const deleteGlossaryMetadata = + protoFilesRoot.lookup('DeleteGlossaryMetadata') as gax.protobuf.Type; + + this._descriptors.longrunning = { + batchTranslateText: new gaxModule.LongrunningDescriptor( + operationsClient, + batchTranslateTextResponse.decode.bind(batchTranslateTextResponse), + batchTranslateTextMetadata.decode.bind(batchTranslateTextMetadata)), + createGlossary: new gaxModule.LongrunningDescriptor( + operationsClient, + createGlossaryResponse.decode.bind(createGlossaryResponse), + createGlossaryMetadata.decode.bind(createGlossaryMetadata)), + deleteGlossary: new gaxModule.LongrunningDescriptor( + operationsClient, + deleteGlossaryResponse.decode.bind(deleteGlossaryResponse), + deleteGlossaryMetadata.decode.bind(deleteGlossaryMetadata)) + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.cloud.translation.v3.TranslationService', + gapicConfig as gax.ClientConfig, opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.showcase.v1alpha2.Echo. + const translationServiceStub = + gaxGrpc.createStub( + opts.fallback ? + // @ts-ignore Do not check types for loaded protos + protos.lookupService( + 'google.cloud.translation.v3.TranslationService') : + // @ts-ignore Do not check types for loaded protos + protos.google.cloud.translation.v3.TranslationService, + opts as gax.ClientStubOptions) as Promise<{[method: string]: Function}>; + + const translationServiceStubMethods = [ + 'translateText', 'detectLanguage', 'getSupportedLanguages', + 'batchTranslateText', 'createGlossary', 'listGlossaries', 'getGlossary', + 'deleteGlossary' + ]; + + for (const methodName of translationServiceStubMethods) { + const innerCallPromise = translationServiceStub.then( + (stub: {[method: string]: Function}) => (...args: Array<{}>) => { + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + this._innerApiCalls[methodName] = gax.createApiCall( + innerCallPromise, defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName]); + } + } + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'translate.googleapis.com'; + } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'translate.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-translation' + ]; + } + + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(): Promise; + getProjectId(callback: Callback): void; + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + /* + Translates input text and returns translated text. + */ + translateText( + request: protosTypes.google.cloud.translation.v3.ITranslateTextRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.translation.v3.ITranslateTextResponse, + protosTypes.google.cloud.translation.v3.ITranslateTextRequest|undefined, + {}|undefined + ]>; + translateText( + request: protosTypes.google.cloud.translation.v3.ITranslateTextRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.translation.v3.ITranslateTextResponse, + protosTypes.google.cloud.translation.v3.ITranslateTextRequest| + undefined, + {}|undefined>): void; + translateText( + request: protosTypes.google.cloud.translation.v3.ITranslateTextRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.translation.v3.ITranslateTextResponse, + protosTypes.google.cloud.translation.v3.ITranslateTextRequest| + undefined, + {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.translation.v3.ITranslateTextResponse, + protosTypes.google.cloud.translation.v3.ITranslateTextRequest| + undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.translation.v3.ITranslateTextResponse, + protosTypes.google.cloud.translation.v3.ITranslateTextRequest|undefined, + {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.translateText(request, options, callback); + } + /* + Detects the language of text within a request. + */ + detectLanguage( + request: protosTypes.google.cloud.translation.v3.IDetectLanguageRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.translation.v3.IDetectLanguageResponse, + protosTypes.google.cloud.translation.v3.IDetectLanguageRequest| + undefined, + {}|undefined + ]>; + detectLanguage( + request: protosTypes.google.cloud.translation.v3.IDetectLanguageRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.translation.v3.IDetectLanguageResponse, + protosTypes.google.cloud.translation.v3.IDetectLanguageRequest| + undefined, + {}|undefined>): void; + detectLanguage( + request: protosTypes.google.cloud.translation.v3.IDetectLanguageRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.translation.v3.IDetectLanguageResponse, + protosTypes.google.cloud.translation.v3.IDetectLanguageRequest| + undefined, + {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.translation.v3.IDetectLanguageResponse, + protosTypes.google.cloud.translation.v3.IDetectLanguageRequest| + undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.translation.v3.IDetectLanguageResponse, + protosTypes.google.cloud.translation.v3.IDetectLanguageRequest| + undefined, + {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.detectLanguage(request, options, callback); + } + /* + Returns a list of supported languages for translation. + */ + getSupportedLanguages( + request: + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.translation.v3.ISupportedLanguages, + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest| + undefined, + {}|undefined + ]>; + getSupportedLanguages( + request: + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.translation.v3.ISupportedLanguages, + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest| + undefined, + {}|undefined>): void; + getSupportedLanguages( + request: + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.translation.v3.ISupportedLanguages, + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest| + undefined, + {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.translation.v3.ISupportedLanguages, + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest| + undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.translation.v3.ISupportedLanguages, + protosTypes.google.cloud.translation.v3.IGetSupportedLanguagesRequest| + undefined, + {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.getSupportedLanguages( + request, options, callback); + } + /* + Gets a glossary. Returns NOT_FOUND, if the glossary doesn't + exist. + */ + getGlossary( + request: protosTypes.google.cloud.translation.v3.IGetGlossaryRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.IGetGlossaryRequest|undefined, + {}|undefined + ]>; + getGlossary( + request: protosTypes.google.cloud.translation.v3.IGetGlossaryRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.IGetGlossaryRequest|undefined, + {}|undefined>): void; + getGlossary( + request: protosTypes.google.cloud.translation.v3.IGetGlossaryRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.IGetGlossaryRequest|undefined, + {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.IGetGlossaryRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.IGetGlossaryRequest|undefined, + {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.getGlossary(request, options, callback); + } + + /* + Translates a large volume of text in asynchronous batch mode. + This function provides real-time output as the inputs are being processed. + If caller cancels a request, the partial results (for an input file, it's + all or nothing) may still be available on the specified output location. + + This call returns immediately and you can + use google.longrunning.Operation.name to poll the status of the call. + */ + batchTranslateText( + request: + protosTypes.google.cloud.translation.v3.IBatchTranslateTextRequest, + options?: gax.CallOptions): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IBatchTranslateResponse, + protosTypes.google.cloud.translation.v3.IBatchTranslateMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchTranslateText( + request: + protosTypes.google.cloud.translation.v3.IBatchTranslateTextRequest, + options: gax.CallOptions, + callback: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IBatchTranslateResponse, + protosTypes.google.cloud.translation.v3.IBatchTranslateMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + void; + batchTranslateText( + request: + protosTypes.google.cloud.translation.v3.IBatchTranslateTextRequest, + optionsOrCallback?: gax.CallOptions|Callback< + Operation< + protosTypes.google.cloud.translation.v3.IBatchTranslateResponse, + protosTypes.google.cloud.translation.v3.IBatchTranslateMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>, + callback?: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IBatchTranslateResponse, + protosTypes.google.cloud.translation.v3.IBatchTranslateMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IBatchTranslateResponse, + protosTypes.google.cloud.translation.v3.IBatchTranslateMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.batchTranslateText(request, options, callback); + } + /* + Creates a glossary and returns the long-running operation. Returns + NOT_FOUND, if the project doesn't exist. + */ + createGlossary( + request: protosTypes.google.cloud.translation.v3.ICreateGlossaryRequest, + options?: gax.CallOptions): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.ICreateGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createGlossary( + request: protosTypes.google.cloud.translation.v3.ICreateGlossaryRequest, + options: gax.CallOptions, + callback: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.ICreateGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + void; + createGlossary( + request: protosTypes.google.cloud.translation.v3.ICreateGlossaryRequest, + optionsOrCallback?: gax.CallOptions|Callback< + Operation< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.ICreateGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>, + callback?: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.ICreateGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IGlossary, + protosTypes.google.cloud.translation.v3.ICreateGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.createGlossary(request, options, callback); + } + /* + Deletes a glossary, or cancels glossary construction + if the glossary isn't created yet. + Returns NOT_FOUND, if the glossary doesn't exist. + */ + deleteGlossary( + request: protosTypes.google.cloud.translation.v3.IDeleteGlossaryRequest, + options?: gax.CallOptions): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IDeleteGlossaryResponse, + protosTypes.google.cloud.translation.v3.IDeleteGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteGlossary( + request: protosTypes.google.cloud.translation.v3.IDeleteGlossaryRequest, + options: gax.CallOptions, + callback: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IDeleteGlossaryResponse, + protosTypes.google.cloud.translation.v3.IDeleteGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + void; + deleteGlossary( + request: protosTypes.google.cloud.translation.v3.IDeleteGlossaryRequest, + optionsOrCallback?: gax.CallOptions|Callback< + Operation< + protosTypes.google.cloud.translation.v3.IDeleteGlossaryResponse, + protosTypes.google.cloud.translation.v3.IDeleteGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>, + callback?: Callback< + Operation< + protosTypes.google.cloud.translation.v3.IDeleteGlossaryResponse, + protosTypes.google.cloud.translation.v3.IDeleteGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined>): + Promise<[ + Operation< + protosTypes.google.cloud.translation.v3.IDeleteGlossaryResponse, + protosTypes.google.cloud.translation.v3.IDeleteGlossaryMetadata>, + protosTypes.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.deleteGlossary(request, options, callback); + } + /* + Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't + exist. + */ + listGlossaries( + request: protosTypes.google.cloud.translation.v3.IListGlossariesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.translation.v3.IGlossary[], + protosTypes.google.cloud.translation.v3.IListGlossariesRequest|null, + protosTypes.google.cloud.translation.v3.IListGlossariesResponse + ]>; + listGlossaries( + request: protosTypes.google.cloud.translation.v3.IListGlossariesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.translation.v3.IGlossary[], + protosTypes.google.cloud.translation.v3.IListGlossariesRequest|null, + protosTypes.google.cloud.translation.v3.IListGlossariesResponse>): + void; + listGlossaries( + request: protosTypes.google.cloud.translation.v3.IListGlossariesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.translation.v3.IGlossary[], + protosTypes.google.cloud.translation.v3.IListGlossariesRequest|null, + protosTypes.google.cloud.translation.v3.IListGlossariesResponse>, + callback?: Callback< + protosTypes.google.cloud.translation.v3.IGlossary[], + protosTypes.google.cloud.translation.v3.IListGlossariesRequest|null, + protosTypes.google.cloud.translation.v3.IListGlossariesResponse>): + Promise<[ + protosTypes.google.cloud.translation.v3.IGlossary[], + protosTypes.google.cloud.translation.v3.IListGlossariesRequest|null, + protosTypes.google.cloud.translation.v3.IListGlossariesResponse + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.listGlossaries(request, options, callback); + } +} diff --git a/src/v3/translation_service_client_config.json b/src/v3/translation_service_client_config.json new file mode 100644 index 00000000..fda9369d --- /dev/null +++ b/src/v3/translation_service_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.translation.v3.TranslationService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "TranslateText": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DetectLanguage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSupportedLanguages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchTranslateText": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateGlossary": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListGlossaries": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetGlossary": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteGlossary": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/src/v3/translation_service_proto_list.json b/src/v3/translation_service_proto_list.json new file mode 100644 index 00000000..21e41c10 --- /dev/null +++ b/src/v3/translation_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/translate/v3/translation_service.proto" +] diff --git a/system-test/translate.ts b/system-test/translate.ts index 41e67e0f..9bf02152 100644 --- a/system-test/translate.ts +++ b/system-test/translate.ts @@ -15,41 +15,48 @@ */ import * as assert from 'assert'; -import {Translate} from '../src'; +import {TranslationServiceClient} from '../src'; const API_KEY = process.env.TRANSLATE_API_KEY; describe('translate', () => { - let translate = new Translate(); + const translate = new TranslationServiceClient(); describe('detecting language from input', () => { const INPUT = [ { - input: 'Hello!', + content: 'Hello!', expectedLanguage: 'en', }, { - input: '¡Hola!', + content: '¡Hola!', expectedLanguage: 'es', }, ]; it('should detect a langauge', async () => { - const input = INPUT.map(x => x.input); - const [results] = await translate.detect(input); - assert.strictEqual(results[0].language, INPUT[0].expectedLanguage); - assert.strictEqual(results[1].language, INPUT[1].expectedLanguage); + const projectId = await translate.getProjectId(); + for (const input of INPUT) { + const [result] = await translate.detectLanguage({ + content: input.content, + parent: `projects/${projectId}`, + }); + assert.strictEqual( + result.languages![0].languageCode, + input.expectedLanguage + ); + } }); }); describe('translations', () => { const INPUT = [ { - input: 'Hello!', + content: 'Hello!', expectedTranslation: 'Hola', }, { - input: 'How are you today?', + content: 'How are you today?', expectedTranslation: 'Cómo estás hoy', }, ]; @@ -62,33 +69,32 @@ describe('translate', () => { } it('should translate input', async () => { - const input = INPUT.map(x => x.input); - let [results] = await translate.translate(input, 'es'); - results = results.map(removeSymbols); - assert.strictEqual(results[0], INPUT[0].expectedTranslation); - assert.strictEqual(results[1], INPUT[1].expectedTranslation); - }); - - it('should translate input with from and to options', async () => { - const input = INPUT.map(x => x.input); - const opts = { - from: 'en', - to: 'es', - }; - let [results] = await translate.translate(input, opts); - results = results.map(removeSymbols); - assert.strictEqual(results[0], INPUT[0].expectedTranslation); - assert.strictEqual(results[1], INPUT[1].expectedTranslation); + const projectId = await translate.getProjectId(); + const [results] = await translate.translateText({ + contents: INPUT.map(intput => intput.content), + sourceLanguageCode: 'en', + targetLanguageCode: 'es', + parent: `projects/${projectId}`, + }); + const translations = results.translations!.map(translation => + removeSymbols(translation.translatedText as string) + ); + assert.strictEqual(translations[0], INPUT[0].expectedTranslation); + assert.strictEqual(translations[1], INPUT[1].expectedTranslation); }); it('should autodetect HTML', async () => { - const input = '' + INPUT[0].input + ''; - const opts = { - from: 'en', - to: 'es', - }; - const [results] = await translate.translate(input, opts); - const translation = results.split(/<\/*body>/g)[1].trim(); + const input = '' + INPUT[0].content + ''; + const projectId = await translate.getProjectId(); + const [results] = await translate.translateText({ + contents: [input], + sourceLanguageCode: 'en', + targetLanguageCode: 'es', + parent: `projects/${projectId}`, + }); + const translation = (results.translations![0].translatedText as string) + .split(/<\/*body>/g)[1] + .trim(); assert.strictEqual( removeSymbols(translation), INPUT[0].expectedTranslation @@ -98,38 +104,36 @@ describe('translate', () => { describe('supported languages', () => { it('should get a list of supported languages', async () => { - const [languages] = await translate.getLanguages(); - const englishResult = languages.filter(l => l.code === 'en')[0]; + const projectId = await translate.getProjectId(); + const [result] = await translate.getSupportedLanguages({ + parent: `projects/${projectId}`, + }); + const englishResult = result.languages!.filter( + l => l.languageCode === 'en' + )[0]; assert.deepStrictEqual(englishResult, { - code: 'en', - name: 'English', + languageCode: 'en', + displayName: '', + supportSource: true, + supportTarget: true, }); }); - it('should accept a target language', async () => { - const [languages] = await translate.getLanguages('es'); - const englishResult = languages.filter(language => { - return language.code === 'en'; - })[0]; + it('should accept displayLanguageCode, and show appropriate displayName', async () => { + const projectId = await translate.getProjectId(); + const [result] = await translate.getSupportedLanguages({ + parent: `projects/${projectId}`, + displayLanguageCode: 'es', + }); + const englishResult = result.languages!.filter( + l => l.languageCode === 'en' + )[0]; assert.deepStrictEqual(englishResult, { - code: 'en', - name: 'inglés', + languageCode: 'en', + displayName: 'inglés', + supportSource: true, + supportTarget: true, }); }); }); - - describe('authentication', () => { - beforeEach(() => { - if (!API_KEY) { - throw new Error( - 'The `TRANSLATE_API_KEY` environment variable is required!' - ); - } - translate = new Translate({key: API_KEY}); - }); - - it('should use an API key to authenticate', done => { - translate.getLanguages(done); - }); - }); }); diff --git a/test/gapic-translation_service-v3.ts b/test/gapic-translation_service-v3.ts new file mode 100644 index 00000000..98c05937 --- /dev/null +++ b/test/gapic-translation_service-v3.ts @@ -0,0 +1,497 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +const assert = require('assert'); +const translationServiceModule = require('../src'); + +const FAKE_STATUS_CODE = 1; +class FakeError { + code: number; + constructor(n: number) { + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError | null, response?: {} | null): {}; +} + +export class Operation { + constructor() {} + promise() {} +} + +function mockSimpleGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +function mockLongRunningGrpcMethod( + expectedRequest: {}, + response: {} | null, + error?: {} | null +) { + return (request: {}) => { + assert.deepStrictEqual(request, expectedRequest); + const mockOperation = { + promise() { + return new Promise((resolve, reject) => { + if (error) { + reject(error); + } else { + resolve([response]); + } + }); + }, + }; + return Promise.resolve([mockOperation]); + }; +} +describe('TranslationServiceClient', () => { + it('has servicePath', () => { + const servicePath = + translationServiceModule.v3.TranslationServiceClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = + translationServiceModule.v3.TranslationServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = translationServiceModule.v3.TranslationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new translationServiceModule.v3.TranslationServiceClient(); + assert(client); + }); + it('should create a client with gRPC option', () => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + fallback: true, + }); + assert(client); + }); + describe('translateText', () => { + it('invokes translateText without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.translateText = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.translateText(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes translateText with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.translateText = mockSimpleGrpcMethod( + request, + null, + error + ); + client.translateText(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('detectLanguage', () => { + it('invokes detectLanguage without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.detectLanguage = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.detectLanguage(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes detectLanguage with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.detectLanguage = mockSimpleGrpcMethod( + request, + null, + error + ); + client.detectLanguage(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('getSupportedLanguages', () => { + it('invokes getSupportedLanguages without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getSupportedLanguages = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getSupportedLanguages(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes getSupportedLanguages with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getSupportedLanguages = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getSupportedLanguages(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('getGlossary', () => { + it('invokes getGlossary without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getGlossary = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getGlossary(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes getGlossary with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getGlossary = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getGlossary(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('batchTranslateText', () => { + it('invokes batchTranslateText without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchTranslateText = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .batchTranslateText(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes batchTranslateText with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchTranslateText = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .batchTranslateText(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('createGlossary', () => { + it('invokes createGlossary without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createGlossary = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .createGlossary(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes createGlossary with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createGlossary = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .createGlossary(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('deleteGlossary', () => { + it('invokes deleteGlossary without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteGlossary = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .deleteGlossary(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes deleteGlossary with error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteGlossary = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .deleteGlossary(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('listGlossaries', () => { + it('invokes listGlossaries without error', done => { + const client = new translationServiceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listGlossaries = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listGlossaries(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); +}); diff --git a/test/index.ts b/test/index.ts index 2b4141ac..25f2652c 100644 --- a/test/index.ts +++ b/test/index.ts @@ -68,7 +68,7 @@ describe('Translate v2', () => { }; // tslint:disable-next-line variable-name - let Translate: typeof orig.Translate; + let Translate: typeof orig.v2.Translate; // tslint:disable-next-line no-any let translate: any; diff --git a/tsconfig.json b/tsconfig.json index b10ee498..32d9ad48 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,10 @@ { "extends": "./node_modules/gts/tsconfig-google.json", "compilerOptions": { + "lib": ["es2016", "dom"], "rootDir": ".", - "outDir": "build" + "outDir": "build", + "resolveJsonModule": true }, "include": [ "src/*.ts", diff --git a/tslint.json b/tslint.json index 617dc975..b3bfaf59 100644 --- a/tslint.json +++ b/tslint.json @@ -1,3 +1,6 @@ { - "extends": "gts/tslint.json" + "extends": "gts/tslint.json", + "rules": { + "ban-ts-ignore": false + } }