TranslationServiceClient

TranslationServiceClient

Provides natural language translation operations.

Constructor

new TranslationServiceClient(optionsopt, gaxInstanceopt)

Construct an instance of TranslationServiceClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. The options accepted by the constructor are described in detail in this document. The common options are:

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

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.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

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 Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean <optional>

Use HTTP/1.1 REST mode. For more information, please check the documentation.

gaxInstance gax <optional>

loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new TranslationServiceClient({fallback: true}, gax);

Members

apiEndpoint

The DNS address for this API service.

apiEndpoint

The DNS address for this API service - same as servicePath.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

adaptiveMtDatasetPath(project, location, dataset) → {string}

Return a fully-qualified adaptiveMtDataset resource name string.

Parameters:
Name Type Description
project string
location string
dataset string
Returns:
Type Description
string

Resource name string.

adaptiveMtFilePath(project, location, dataset, file) → {string}

Return a fully-qualified adaptiveMtFile resource name string.

Parameters:
Name Type Description
project string
location string
dataset string
file string
Returns:
Type Description
string

Resource name string.

adaptiveMtSentencePath(project, location, dataset, file, sentence) → {string}

Return a fully-qualified adaptiveMtSentence resource name string.

Parameters:
Name Type Description
project string
location string
dataset string
file string
sentence string
Returns:
Type Description
string

Resource name string.

cancelOperation(request, optionsopt, callbackopt) → {Promise}

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource to be cancelled.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Returns:
Type Description
Promise
  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
```

(async) checkBatchTranslateDocumentProgress(name) → {Promise}

Check the status of the long running operation returned by batchTranslateDocument().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Location to make a regional call.
   *  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.
   */
  // const parent = 'abc123'
  /**
   *  Required. The ISO-639 language code of the input document if known, for
   *  example, "en-US" or "sr-Latn". Supported language codes are listed in
   *  Language Support (https://cloud.google.com/translate/docs/languages).
   */
  // const sourceLanguageCode = 'abc123'
  /**
   *  Required. The ISO-639 language code to use for translation of the input
   *  document. Specify up to 10 language codes here.
   */
  // const targetLanguageCodes = ['abc','def']
  /**
   *  Required. Input configurations.
   *  The total number of files matched should be <= 100.
   *  The total content size to translate should be <= 100M Unicode codepoints.
   *  The files must use UTF-8 encoding.
   */
  // const inputConfigs = [1,2,3,4]
  /**
   *  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.
   */
  // const outputConfig = {}
  /**
   *  Optional. The models to use for translation. Map's key is target language
   *  code. Map's value is the 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`,
   *  If the map is empty or a specific model is
   *  not requested for a language pair, then default google model (nmt) is used.
   */
  // const models = [1,2,3,4]
  /**
   *  Optional. Glossaries to be applied. It's keyed by target language code.
   */
  // const glossaries = [1,2,3,4]
  /**
   *  Optional. The file format conversion map that is applied to all input
   *  files. The map key is the original mime_type. The map value is the target
   *  mime_type of translated documents.
   *  Supported file format conversion includes:
   *  - `application/pdf` to
   *    `application/vnd.openxmlformats-officedocument.wordprocessingml.document`
   *  If nothing specified, output files will be in the same format as the
   *  original file.
   */
  // const formatConversions = [1,2,3,4]
  /**
   *  Optional. This flag is to support user customized attribution.
   *  If not provided, the default is `Machine Translated by Google`.
   *  Customized attribution should follow rules in
   *  https://cloud.google.com/translate/attribution#attribution_and_logos
   */
  // const customizedAttribution = 'abc123'
  /**
   *  Optional. If true, use the text removal server to remove the shadow text on
   *  background image for native pdf translation.
   *  Shadow removal feature can only be enabled when
   *  is_translate_native_pdf_only: false && pdf_native_only: false
   */
  // const enableShadowRemovalNativePdf = true
  /**
   *  Optional. If true, enable auto rotation correction in DVS.
   */
  // const enableRotationCorrection = true

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callBatchTranslateDocument() {
    // Construct request
    const request = {
      parent,
      sourceLanguageCode,
      targetLanguageCodes,
      inputConfigs,
      outputConfig,
    };

    // Run request
    const [operation] = await translationClient.batchTranslateDocument(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callBatchTranslateDocument();

(async) checkBatchTranslateTextProgress(name) → {Promise}

Check the status of the long running operation returned by batchTranslateText().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  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.
   */
  // const parent = 'abc123'
  /**
   *  Required. Source language code.
   */
  // const sourceLanguageCode = 'abc123'
  /**
   *  Required. Specify up to 10 language codes here.
   */
  // const targetLanguageCodes = ['abc','def']
  /**
   *  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`,
   *  If the map is empty or a specific model is
   *  not requested for a language pair, then default google model (nmt) is used.
   */
  // const models = [1,2,3,4]
  /**
   *  Required. Input configurations.
   *  The total number of files matched should be <= 100.
   *  The total content size should be <= 100M Unicode codepoints.
   *  The files must use UTF-8 encoding.
   */
  // const inputConfigs = [1,2,3,4]
  /**
   *  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.
   */
  // const outputConfig = {}
  /**
   *  Optional. Glossaries to be applied for translation.
   *  It's keyed by target language code.
   */
  // const glossaries = [1,2,3,4]
  /**
   *  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/advanced/labels for more
   *  information.
   */
  // const labels = [1,2,3,4]

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callBatchTranslateText() {
    // Construct request
    const request = {
      parent,
      sourceLanguageCode,
      targetLanguageCodes,
      inputConfigs,
      outputConfig,
    };

    // Run request
    const [operation] = await translationClient.batchTranslateText(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callBatchTranslateText();

(async) checkCreateDatasetProgress(name) → {Promise}

Check the status of the long running operation returned by createDataset().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The project name.
   */
  // const parent = 'abc123'
  /**
   *  Required. The Dataset to create.
   */
  // const dataset = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callCreateDataset() {
    // Construct request
    const request = {
      parent,
      dataset,
    };

    // Run request
    const [operation] = await translationClient.createDataset(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateDataset();

(async) checkCreateGlossaryProgress(name) → {Promise}

Check the status of the long running operation returned by createGlossary().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The project name.
   */
  // const parent = 'abc123'
  /**
   *  Required. The glossary to create.
   */
  // const glossary = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callCreateGlossary() {
    // Construct request
    const request = {
      parent,
      glossary,
    };

    // Run request
    const [operation] = await translationClient.createGlossary(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateGlossary();

(async) checkCreateModelProgress(name) → {Promise}

Check the status of the long running operation returned by createModel().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The project name, in form of
   *  `projects/{project}/locations/{location}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The Model to create.
   */
  // const model = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callCreateModel() {
    // Construct request
    const request = {
      parent,
      model,
    };

    // Run request
    const [operation] = await translationClient.createModel(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateModel();

(async) checkDeleteDatasetProgress(name) → {Promise}

Check the status of the long running operation returned by deleteDataset().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the dataset to delete.
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callDeleteDataset() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await translationClient.deleteDataset(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteDataset();

(async) checkDeleteGlossaryProgress(name) → {Promise}

Check the status of the long running operation returned by deleteGlossary().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the glossary to delete.
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callDeleteGlossary() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await translationClient.deleteGlossary(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteGlossary();

(async) checkDeleteModelProgress(name) → {Promise}

Check the status of the long running operation returned by deleteModel().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the model to delete.
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callDeleteModel() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await translationClient.deleteModel(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteModel();

(async) checkExportDataProgress(name) → {Promise}

Check the status of the long running operation returned by exportData().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the dataset. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
   */
  // const dataset = 'abc123'
  /**
   *  Required. The config for the output content.
   */
  // const outputConfig = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callExportData() {
    // Construct request
    const request = {
      dataset,
      outputConfig,
    };

    // Run request
    const [operation] = await translationClient.exportData(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callExportData();

(async) checkImportDataProgress(name) → {Promise}

Check the status of the long running operation returned by importData().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the dataset. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
   */
  // const dataset = 'abc123'
  /**
   *  Required. The config for the input content.
   */
  // const inputConfig = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callImportData() {
    // Construct request
    const request = {
      dataset,
      inputConfig,
    };

    // Run request
    const [operation] = await translationClient.importData(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callImportData();

(async) checkUpdateGlossaryProgress(name) → {Promise}

Check the status of the long running operation returned by updateGlossary().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The glossary entry to update.
   */
  // const glossary = {}
  /**
   *  The list of fields to be updated. Currently only `display_name` and
   *  'input_config'
   */
  // const updateMask = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callUpdateGlossary() {
    // Construct request
    const request = {
      glossary,
    };

    // Run request
    const [operation] = await translationClient.updateGlossary(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateGlossary();

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

datasetPath(project, location, dataset) → {string}

Return a fully-qualified dataset resource name string.

Parameters:
Name Type Description
project string
location string
dataset string
Returns:
Type Description
string

Resource name string.

deleteOperation(request, optionsopt, callbackopt) → {Promise}

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource to be deleted.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Returns:
Type Description
Promise
  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});
```

examplePath(project, location, dataset, example) → {string}

Return a fully-qualified example resource name string.

Parameters:
Name Type Description
project string
location string
dataset string
example string
Returns:
Type Description
string

Resource name string.

getIamPolicy(request, optionsopt, callbackopt) → {Promise}

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

options Object <optional>

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy. This field is only used by Cloud IAM.

This object should have the same structure as GetPolicyOptions.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

getLocation(request, optionsopt) → {Promise}

Gets information about a location.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Resource name for the location.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Location. Please see the documentation for more details and examples.
Example
```
const [response] = await client.getLocation(request);
```

getOperation(request, optionsopt, callbackopt) → {Promise}

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing google.longrunning.Operation.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing google.longrunning.Operation. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
```

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

glossaryEntryPath(project, location, glossary, glossary_entry) → {string}

Return a fully-qualified glossaryEntry resource name string.

Parameters:
Name Type Description
project string
location string
glossary string
glossary_entry string
Returns:
Type Description
string

Resource name string.

glossaryPath(project, location, glossary) → {string}

Return a fully-qualified glossary resource name string.

Parameters:
Name Type Description
project string
location string
glossary string
Returns:
Type Description
string

Resource name string.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

listAdaptiveMtDatasetsAsync(request, optionsopt) → {Object}

Equivalent to listAdaptiveMtDatasets, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}

pageSize number <optional>

Optional. Requested page size. The server may return fewer results than requested. If unspecified, the server picks an appropriate default.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtDatasetsResponse.next_page_token returned from the previous call to ListAdaptiveMtDatasets method. The first page is returned if page_tokenis empty or missing.

filter string <optional>

Optional. An expression for filtering the results of the request. Filter is not supported yet.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtDataset. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the project from which to list the Adaptive
   *  MT datasets. `projects/{project-number-or-id}/locations/{location-id}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. The server may return fewer results than
   *  requested. If unspecified, the server picks an appropriate default.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListAdaptiveMtDatasetsResponse.next_page_token returned from the
   *  previous call to `ListAdaptiveMtDatasets` method. The first page is
   *  returned if `page_token`is empty or missing.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. An expression for filtering the results of the request.
   *  Filter is not supported yet.
   */
  // const filter = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtDatasets() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listAdaptiveMtDatasetsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtDatasets();

listAdaptiveMtDatasetsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}

pageSize number <optional>

Optional. Requested page size. The server may return fewer results than requested. If unspecified, the server picks an appropriate default.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtDatasetsResponse.next_page_token returned from the previous call to ListAdaptiveMtDatasets method. The first page is returned if page_tokenis empty or missing.

filter string <optional>

Optional. An expression for filtering the results of the request. Filter is not supported yet.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing AdaptiveMtDataset on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listAdaptiveMtDatasetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtFilesAsync(request, optionsopt) → {Object}

Equivalent to listAdaptiveMtFiles, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

pageSize number <optional>

Optional.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtFilesResponse.next_page_token returned from the previous call to ListAdaptiveMtFiles method. The first page is returned if page_tokenis empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtFile. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the project from which to list the Adaptive
   *  MT files.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
   */
  // const parent = 'abc123'
  /**
   *  Optional.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListAdaptiveMtFilesResponse.next_page_token returned from the
   *  previous call to `ListAdaptiveMtFiles` method. The first page is
   *  returned if `page_token`is empty or missing.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtFiles() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listAdaptiveMtFilesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtFiles();

listAdaptiveMtFilesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

pageSize number <optional>

Optional.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtFilesResponse.next_page_token returned from the previous call to ListAdaptiveMtFiles method. The first page is returned if page_tokenis empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing AdaptiveMtFile on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listAdaptiveMtFilesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtSentencesAsync(request, optionsopt) → {Object}

Equivalent to listAdaptiveMtSentences, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

pageSize number
pageToken string

A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to ListTranslationMemories method. The first page is returned if page_token is empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtSentence. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the project from which to list the Adaptive
   *  MT files. The following format lists all sentences under a file.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
   *  The following format lists all sentences within a dataset.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
   */
  // const parent = 'abc123'
  /**
   */
  // const pageSize = 1234
  /**
   *  A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListAdaptiveMtSentencesRequest.next_page_token returned from the
   *  previous call to `ListTranslationMemories` method. The first page is
   *  returned if `page_token` is empty or missing.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtSentences() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listAdaptiveMtSentencesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtSentences();

listAdaptiveMtSentencesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

pageSize number
pageToken string

A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to ListTranslationMemories method. The first page is returned if page_token is empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing AdaptiveMtSentence on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listAdaptiveMtSentencesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listDatasetsAsync(request, optionsopt) → {Object}

Equivalent to listDatasets, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListDatasets call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Dataset. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the parent project. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. The server can return fewer results than
   *  requested.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results for the server to return.
   *  Typically obtained from next_page_token field in the response of a
   *  ListDatasets call.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListDatasets() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listDatasetsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListDatasets();

listDatasetsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListDatasets call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Dataset on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listDatasetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listExamplesAsync(request, optionsopt) → {Object}

Equivalent to listExamples, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent dataset. In form of projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}

filter string <optional>

Optional. An expression for filtering the examples that will be returned. Example filter:

  • usage=TRAIN
pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListExamples call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Example. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the parent dataset. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. An expression for filtering the examples that will be returned.
   *  Example filter:
   *  * `usage=TRAIN`
   */
  // const filter = 'abc123'
  /**
   *  Optional. Requested page size. The server can return fewer results than
   *  requested.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results for the server to return.
   *  Typically obtained from next_page_token field in the response of a
   *  ListExamples call.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListExamples() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listExamplesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListExamples();

listExamplesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent dataset. In form of projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}

filter string <optional>

Optional. An expression for filtering the examples that will be returned. Example filter:

  • usage=TRAIN
pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListExamples call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Example on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listExamplesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listGlossariesAsync(request, optionsopt) → {Object}

Equivalent to listGlossaries, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The name of the project from which to list all of the glossaries.

pageSize number <optional>

Optional. Requested page size. The server may return fewer glossaries than requested. If unspecified, the server picks an appropriate default.

pageToken string <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_tokenis empty or missing.

filter string <optional>

Optional. Filter specifying constraints of a list operation. Specify the constraint by the format of "key=value", where key must be "src" or "tgt", and the value must be a valid language code. For multiple restrictions, concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used here, which means using 'en-US' and 'en' can lead to different results, which depends on the language code you used when you create the glossary. For the unidirectional glossaries, the "src" and "tgt" add restrictions on the source and target language code separately. For the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional glossaries which exactly match the source language code as "en-US" and the target language code "zh-CN", but all equivalent term set glossaries which contain "en-US" and "zh-CN" in their language set will be picked. If missing, no filtering is performed.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Glossary. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the project from which to list all of the glossaries.
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. The server may return fewer glossaries than
   *  requested. If unspecified, the server picks an appropriate default.
   */
  // const pageSize = 1234
  /**
   *  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.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. Filter specifying constraints of a list operation.
   *  Specify the constraint by the format of "key=value", where key must be
   *  "src" or "tgt", and the value must be a valid language code.
   *  For multiple restrictions, concatenate them by "AND" (uppercase only),
   *  such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used
   *  here, which means using 'en-US' and 'en' can lead to different results,
   *  which depends on the language code you used when you create the glossary.
   *  For the unidirectional glossaries, the "src" and "tgt" add restrictions
   *  on the source and target language code separately.
   *  For the equivalent term set glossaries, the "src" and/or "tgt" add
   *  restrictions on the term set.
   *  For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional
   *  glossaries which exactly match the source language code as "en-US" and the
   *  target language code "zh-CN", but all equivalent term set glossaries which
   *  contain "en-US" and "zh-CN" in their language set will be picked.
   *  If missing, no filtering is performed.
   */
  // const filter = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListGlossaries() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listGlossariesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListGlossaries();

listGlossariesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The name of the project from which to list all of the glossaries.

pageSize number <optional>

Optional. Requested page size. The server may return fewer glossaries than requested. If unspecified, the server picks an appropriate default.

pageToken string <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_tokenis empty or missing.

filter string <optional>

Optional. Filter specifying constraints of a list operation. Specify the constraint by the format of "key=value", where key must be "src" or "tgt", and the value must be a valid language code. For multiple restrictions, concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used here, which means using 'en-US' and 'en' can lead to different results, which depends on the language code you used when you create the glossary. For the unidirectional glossaries, the "src" and "tgt" add restrictions on the source and target language code separately. For the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional glossaries which exactly match the source language code as "en-US" and the target language code "zh-CN", but all equivalent term set glossaries which contain "en-US" and "zh-CN" in their language set will be picked. If missing, no filtering is performed.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Glossary on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listGlossariesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listGlossaryEntriesAsync(request, optionsopt) → {Object}

Equivalent to listGlossaryEntries, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The parent glossary resource name for listing the glossary's entries.

pageSize number <optional>

Optional. Requested page size. The server may return fewer glossary entries than requested. If unspecified, the server picks an appropriate default.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossaryEntriesResponse.next_page_token] returned from the previous call. The first page is returned if page_tokenis empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing GlossaryEntry. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The parent glossary resource name for listing the glossary's
   *  entries.
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. The server may return fewer glossary entries
   *  than requested. If unspecified, the server picks an appropriate default.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListGlossaryEntriesResponse.next_page_token  returned from the previous
   *  call. The first page is returned if `page_token`is empty or missing.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListGlossaryEntries() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listGlossaryEntriesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListGlossaryEntries();

listGlossaryEntriesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The parent glossary resource name for listing the glossary's entries.

pageSize number <optional>

Optional. Requested page size. The server may return fewer glossary entries than requested. If unspecified, the server picks an appropriate default.

pageToken string <optional>

Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossaryEntriesResponse.next_page_token] returned from the previous call. The first page is returned if page_tokenis empty or missing.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing GlossaryEntry on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listGlossaryEntriesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listLocationsAsync(request, optionsopt) → {Object}

Lists information about the supported locations for this service. Returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The resource that owns the locations collection, if applicable.

filter string

The standard list filter.

pageSize number

The standard list page size.

pageToken string

The standard list page token.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Location. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
```
const iterable = client.listLocationsAsync(request);
for await (const response of iterable) {
  // process response
}
```

listModelsAsync(request, optionsopt) → {Object}

Equivalent to listModels, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

filter string <optional>

Optional. An expression for filtering the models that will be returned. Supported filter: dataset_id=${dataset_id}

pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListModels call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Model. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the parent project. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. An expression for filtering the models that will be returned.
   *  Supported filter:
   *  `dataset_id=${dataset_id}`
   */
  // const filter = 'abc123'
  /**
   *  Optional. Requested page size. The server can return fewer results than
   *  requested.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results for the server to return.
   *  Typically obtained from next_page_token field in the response of a
   *  ListModels call.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListModels() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = translationClient.listModelsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListModels();

listModelsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

filter string <optional>

Optional. An expression for filtering the models that will be returned. Supported filter: dataset_id=${dataset_id}

pageSize number <optional>

Optional. Requested page size. The server can return fewer results than requested.

pageToken string <optional>

Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListModels call.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Model on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listModelsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listOperationsAsync(request, optionsopt) → {Object}

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. Returns an iterable object.

For-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The name of the operation collection.

filter string

The standard list filter.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns:
Type Description
Object

An iterable Object that conforms to iteration protocols.

Example
```
const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)
```

locationPath(project, location) → {string}

Return a fully-qualified location resource name string.

Parameters:
Name Type Description
project string
location string
Returns:
Type Description
string

Resource name string.

matchDatasetFromAdaptiveMtDatasetName(adaptiveMtDatasetName) → {string}

Parse the dataset from AdaptiveMtDataset resource.

Parameters:
Name Type Description
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns:
Type Description
string

A string representing the dataset.

matchDatasetFromAdaptiveMtFileName(adaptiveMtFileName) → {string}

Parse the dataset from AdaptiveMtFile resource.

Parameters:
Name Type Description
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns:
Type Description
string

A string representing the dataset.

matchDatasetFromAdaptiveMtSentenceName(adaptiveMtSentenceName) → {string}

Parse the dataset from AdaptiveMtSentence resource.

Parameters:
Name Type Description
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns:
Type Description
string

A string representing the dataset.

matchDatasetFromDatasetName(datasetName) → {string}

Parse the dataset from Dataset resource.

Parameters:
Name Type Description
datasetName string

A fully-qualified path representing Dataset resource.

Returns:
Type Description
string

A string representing the dataset.

matchDatasetFromExampleName(exampleName) → {string}

Parse the dataset from Example resource.

Parameters:
Name Type Description
exampleName string

A fully-qualified path representing Example resource.

Returns:
Type Description
string

A string representing the dataset.

matchExampleFromExampleName(exampleName) → {string}

Parse the example from Example resource.

Parameters:
Name Type Description
exampleName string

A fully-qualified path representing Example resource.

Returns:
Type Description
string

A string representing the example.

matchFileFromAdaptiveMtFileName(adaptiveMtFileName) → {string}

Parse the file from AdaptiveMtFile resource.

Parameters:
Name Type Description
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns:
Type Description
string

A string representing the file.

matchFileFromAdaptiveMtSentenceName(adaptiveMtSentenceName) → {string}

Parse the file from AdaptiveMtSentence resource.

Parameters:
Name Type Description
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns:
Type Description
string

A string representing the file.

matchGlossaryEntryFromGlossaryEntryName(glossaryEntryName) → {string}

Parse the glossary_entry from GlossaryEntry resource.

Parameters:
Name Type Description
glossaryEntryName string

A fully-qualified path representing GlossaryEntry resource.

Returns:
Type Description
string

A string representing the glossary_entry.

matchGlossaryFromGlossaryEntryName(glossaryEntryName) → {string}

Parse the glossary from GlossaryEntry resource.

Parameters:
Name Type Description
glossaryEntryName string

A fully-qualified path representing GlossaryEntry resource.

Returns:
Type Description
string

A string representing the glossary.

matchGlossaryFromGlossaryName(glossaryName) → {string}

Parse the glossary from Glossary resource.

Parameters:
Name Type Description
glossaryName string

A fully-qualified path representing Glossary resource.

Returns:
Type Description
string

A string representing the glossary.

matchLocationFromAdaptiveMtDatasetName(adaptiveMtDatasetName) → {string}

Parse the location from AdaptiveMtDataset resource.

Parameters:
Name Type Description
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromAdaptiveMtFileName(adaptiveMtFileName) → {string}

Parse the location from AdaptiveMtFile resource.

Parameters:
Name Type Description
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromAdaptiveMtSentenceName(adaptiveMtSentenceName) → {string}

Parse the location from AdaptiveMtSentence resource.

Parameters:
Name Type Description
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromDatasetName(datasetName) → {string}

Parse the location from Dataset resource.

Parameters:
Name Type Description
datasetName string

A fully-qualified path representing Dataset resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromExampleName(exampleName) → {string}

Parse the location from Example resource.

Parameters:
Name Type Description
exampleName string

A fully-qualified path representing Example resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromGlossaryEntryName(glossaryEntryName) → {string}

Parse the location from GlossaryEntry resource.

Parameters:
Name Type Description
glossaryEntryName string

A fully-qualified path representing GlossaryEntry resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromGlossaryName(glossaryName) → {string}

Parse the location from Glossary resource.

Parameters:
Name Type Description
glossaryName string

A fully-qualified path representing Glossary resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromLocationName(locationName) → {string}

Parse the location from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromModelName(modelName) → {string}

Parse the location from Model resource.

Parameters:
Name Type Description
modelName string

A fully-qualified path representing Model resource.

Returns:
Type Description
string

A string representing the location.

matchModelFromModelName(modelName) → {string}

Parse the model from Model resource.

Parameters:
Name Type Description
modelName string

A fully-qualified path representing Model resource.

Returns:
Type Description
string

A string representing the model.

matchProjectFromAdaptiveMtDatasetName(adaptiveMtDatasetName) → {string}

Parse the project from AdaptiveMtDataset resource.

Parameters:
Name Type Description
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromAdaptiveMtFileName(adaptiveMtFileName) → {string}

Parse the project from AdaptiveMtFile resource.

Parameters:
Name Type Description
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromAdaptiveMtSentenceName(adaptiveMtSentenceName) → {string}

Parse the project from AdaptiveMtSentence resource.

Parameters:
Name Type Description
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromDatasetName(datasetName) → {string}

Parse the project from Dataset resource.

Parameters:
Name Type Description
datasetName string

A fully-qualified path representing Dataset resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromExampleName(exampleName) → {string}

Parse the project from Example resource.

Parameters:
Name Type Description
exampleName string

A fully-qualified path representing Example resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromGlossaryEntryName(glossaryEntryName) → {string}

Parse the project from GlossaryEntry resource.

Parameters:
Name Type Description
glossaryEntryName string

A fully-qualified path representing GlossaryEntry resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromGlossaryName(glossaryName) → {string}

Parse the project from Glossary resource.

Parameters:
Name Type Description
glossaryName string

A fully-qualified path representing Glossary resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromLocationName(locationName) → {string}

Parse the project from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromModelName(modelName) → {string}

Parse the project from Model resource.

Parameters:
Name Type Description
modelName string

A fully-qualified path representing Model resource.

Returns:
Type Description
string

A string representing the project.

matchSentenceFromAdaptiveMtSentenceName(adaptiveMtSentenceName) → {string}

Parse the sentence from AdaptiveMtSentence resource.

Parameters:
Name Type Description
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns:
Type Description
string

A string representing the sentence.

modelPath(project, location, model) → {string}

Return a fully-qualified model resource name string.

Parameters:
Name Type Description
project string
location string
model string
Returns:
Type Description
string

Resource name string.

setIamPolicy(request, optionsopt, callbackopt) → {Promise}

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions Array.<string>

The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

testIamPermissions(request, optionsopt, callbackopt) → {Promise}

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions Array.<string>

The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.