Constructor

AutoMlClient

new AutoMlClient(options)

Construct an instance of AutoMlClient.

Parameter

options

Optional

object

The configuration object. See the subsequent parameters for more details.

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

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

servicePath

static

The DNS address for this API service.

Methods

createDataset

createDataset(request, options, callback) returns Promise

Creates a dataset.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The resource name of the project to create the dataset for.

dataset

Object

The dataset to create.

This object should have the same structure as Dataset

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Dataset. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
const dataset = {};
const request = {
  parent: formattedParent,
  dataset: dataset,
};
client.createDataset(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

createModel

createModel(request, options, callback) returns Promise

Creates a model. Returns a Model in the response field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the parent project where the model is being created.

model

Object

The model to create.

This object should have the same structure as Model

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
const model = {};
const request = {
  parent: formattedParent,
  model: model,
};

// Handle the operation using the promise pattern.
client.createModel(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
const model = {};
const request = {
  parent: formattedParent,
  model: model,
};

// Handle the operation using the event emitter pattern.
client.createModel(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
const model = {};
const request = {
  parent: formattedParent,
  model: model,
};

// Handle the operation using the await pattern.
const [operation] = await client.createModel(request);

const [response] = await operation.promise();

datasetPath

datasetPath(project, location, dataset) returns String

Return a fully-qualified dataset resource name string.

Parameter

project

String

location

String

dataset

String

Returns

String 

deleteDataset

deleteDataset(request, options, callback) returns Promise

Deletes a dataset and all of its contents. Returns empty response in the response field when it completes, and delete_details in the metadata field.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name of the dataset to delete.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');

// Handle the operation using the promise pattern.
client.deleteDataset({name: formattedName})
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');

// Handle the operation using the event emitter pattern.
client.deleteDataset({name: formattedName})
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');

// Handle the operation using the await pattern.
const [operation] = await client.deleteDataset({name: formattedName});

const [response] = await operation.promise();

deleteModel

deleteModel(request, options, callback) returns Promise

Deletes a model. If a model is already deployed, this only deletes the model in AutoML BE, and does not change the status of the deployed model in the production environment. Returns google.protobuf.Empty in the response field when it completes, and delete_details in the metadata field.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the model being deleted.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');

// Handle the operation using the promise pattern.
client.deleteModel({name: formattedName})
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');

// Handle the operation using the event emitter pattern.
client.deleteModel({name: formattedName})
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');

// Handle the operation using the await pattern.
const [operation] = await client.deleteModel({name: formattedName});

const [response] = await operation.promise();

deployModel

deployModel(request, options, callback) returns Promise

Deploys model. Returns a DeployModelResponse in the response field when it completes.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the model to deploy.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');
client.deployModel({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

exportData

exportData(request, options, callback) returns Promise

Exports dataset's data to a Google Cloud Storage bucket. Returns an empty response in the response field when it completes.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. The resource name of the dataset.

outputConfig

Object

Required. The desired output location.

This object should have the same structure as OutputConfig

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const outputConfig = {};
const request = {
  name: formattedName,
  outputConfig: outputConfig,
};

// Handle the operation using the promise pattern.
client.exportData(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const outputConfig = {};
const request = {
  name: formattedName,
  outputConfig: outputConfig,
};

// Handle the operation using the event emitter pattern.
client.exportData(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const outputConfig = {};
const request = {
  name: formattedName,
  outputConfig: outputConfig,
};

// Handle the operation using the await pattern.
const [operation] = await client.exportData(request);

const [response] = await operation.promise();

getDataset

getDataset(request, options, callback) returns Promise

Gets a dataset.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name of the dataset to retrieve.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Dataset. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
client.getDataset({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getModel

getModel(request, options, callback) returns Promise

Gets a model.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the model.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Model. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');
client.getModel({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getModelEvaluation

getModelEvaluation(request, options, callback) returns Promise

Gets a model evaluation.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name for the model evaluation.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ModelEvaluation. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.modelEvaluationPath('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]');
client.getModelEvaluation({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

importData

importData(request, options, callback) returns Promise

Imports data into a dataset. Returns an empty response in the response field when it completes.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Dataset name. Dataset must already exist. All imported annotations and examples will be added.

inputConfig

Object

Required. The desired input location.

This object should have the same structure as InputConfig

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

// Handle the operation using the promise pattern.
client.importData(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

// Handle the operation using the event emitter pattern.
client.importData(request)
  .then(responses => {
    const [operation, initialApiResponse] = responses;

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[LOCATION]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

// Handle the operation using the await pattern.
const [operation] = await client.importData(request);

const [response] = await operation.promise();

listDatasets

listDatasets(request, options, callback) returns Promise

Lists datasets in a project.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The resource name of the project from which to list datasets.

filter

Optional

string

An expression for filtering the results of the request.

* `dataset_metadata` - for existence of the case.

An example of using the filter is:

* `translation_dataset_metadata:*` --> The dataset has
                                       translation_dataset_metadata.

pageSize

Optional

number

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

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

The second parameter to the callback is Array of Dataset.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListDatasetsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Dataset.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Dataset in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListDatasetsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');

client.listDatasets({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listDatasets(nextRequest, options).then(callback);
  }
}
client.listDatasets({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listDatasetsStream

listDatasetsStream(request, options) returns Stream

Equivalent to listDatasets, but returns a NodeJS Stream object.

This fetches the paged responses for listDatasets continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The resource name of the project from which to list datasets.

filter

Optional

string

An expression for filtering the results of the request.

* `dataset_metadata` - for existence of the case.

An example of using the filter is:

* `translation_dataset_metadata:*` --> The dataset has
                                       translation_dataset_metadata.

pageSize

Optional

number

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

Optional

Object

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

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Dataset on 'data' event.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
client.listDatasetsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listModelEvaluations

listModelEvaluations(request, options, callback) returns Promise

Lists model evaluations.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the model to list the model evaluations for. If modelId is set as "-", this will list model evaluations from across all models of the parent location.

filter

Optional

string

An expression for filtering the results of the request.

* `annotation_spec_id` - for =, !=  or existence. See example below for
                       the last.

Some examples of using the filter are:

* `annotation_spec_id!=4` --> The model evaluation was done for
                          annotation spec with ID different than 4.
* `NOT annotation_spec_id:*` --> The model evaluation was done for
                             aggregate of all annotation specs.

pageSize

Optional

number

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

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

The second parameter to the callback is Array of ModelEvaluation.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListModelEvaluationsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of ModelEvaluation.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of ModelEvaluation in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListModelEvaluationsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');

client.listModelEvaluations({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listModelEvaluations(nextRequest, options).then(callback);
  }
}
client.listModelEvaluations({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listModelEvaluationsStream

listModelEvaluationsStream(request, options) returns Stream

Equivalent to listModelEvaluations, but returns a NodeJS Stream object.

This fetches the paged responses for listModelEvaluations continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the model to list the model evaluations for. If modelId is set as "-", this will list model evaluations from across all models of the parent location.

filter

Optional

string

An expression for filtering the results of the request.

* `annotation_spec_id` - for =, !=  or existence. See example below for
                       the last.

Some examples of using the filter are:

* `annotation_spec_id!=4` --> The model evaluation was done for
                          annotation spec with ID different than 4.
* `NOT annotation_spec_id:*` --> The model evaluation was done for
                             aggregate of all annotation specs.

pageSize

Optional

number

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

Optional

Object

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

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing ModelEvaluation on 'data' event.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedParent = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');
client.listModelEvaluationsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listModels

listModels(request, options, callback) returns Promise

Lists models.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the project, from which to list the models.

filter

Optional

string

An expression for filtering the results of the request.

* `model_metadata` - for existence of the case.
* `dataset_id` - for = or !=.

Some examples of using the filter are:

* `image_classification_model_metadata:*` --> The model has
                                     image_classification_model_metadata.
* `dataset_id=5` --> The model was created from a sibling dataset with
                 ID 5.

pageSize

Optional

number

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

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

The second parameter to the callback is Array of Model.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListModelsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Model.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Model in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListModelsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');

client.listModels({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listModels(nextRequest, options).then(callback);
  }
}
client.listModels({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listModelsStream

listModelsStream(request, options) returns Stream

Equivalent to listModels, but returns a NodeJS Stream object.

This fetches the paged responses for listModels continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the project, from which to list the models.

filter

Optional

string

An expression for filtering the results of the request.

* `model_metadata` - for existence of the case.
* `dataset_id` - for = or !=.

Some examples of using the filter are:

* `image_classification_model_metadata:*` --> The model has
                                     image_classification_model_metadata.
* `dataset_id=5` --> The model was created from a sibling dataset with
                 ID 5.

pageSize

Optional

number

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

Optional

Object

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

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Model on 'data' event.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
client.listModelsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

locationPath

locationPath(project, location) returns String

Return a fully-qualified location resource name string.

Parameter

project

String

location

String

Returns

String 

matchDatasetFromDatasetName

matchDatasetFromDatasetName(datasetName) returns String

Parse the datasetName from a dataset resource.

Parameter

datasetName

String

A fully-qualified path representing a dataset resources.

Returns

String 

  • A string representing the dataset.

matchLocationFromDatasetName

matchLocationFromDatasetName(datasetName) returns String

Parse the datasetName from a dataset resource.

Parameter

datasetName

String

A fully-qualified path representing a dataset resources.

Returns

String 

  • A string representing the location.

matchLocationFromLocationName

matchLocationFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the location.

matchLocationFromModelEvaluationName

matchLocationFromModelEvaluationName(modelEvaluationName) returns String

Parse the modelEvaluationName from a model_evaluation resource.

Parameter

modelEvaluationName

String

A fully-qualified path representing a model_evaluation resources.

Returns

String 

  • A string representing the location.

matchLocationFromModelName

matchLocationFromModelName(modelName) returns String

Parse the modelName from a model resource.

Parameter

modelName

String

A fully-qualified path representing a model resources.

Returns

String 

  • A string representing the location.

matchModelEvaluationFromModelEvaluationName

matchModelEvaluationFromModelEvaluationName(modelEvaluationName) returns String

Parse the modelEvaluationName from a model_evaluation resource.

Parameter

modelEvaluationName

String

A fully-qualified path representing a model_evaluation resources.

Returns

String 

  • A string representing the model_evaluation.

matchModelFromModelEvaluationName

matchModelFromModelEvaluationName(modelEvaluationName) returns String

Parse the modelEvaluationName from a model_evaluation resource.

Parameter

modelEvaluationName

String

A fully-qualified path representing a model_evaluation resources.

Returns

String 

  • A string representing the model.

matchModelFromModelName

matchModelFromModelName(modelName) returns String

Parse the modelName from a model resource.

Parameter

modelName

String

A fully-qualified path representing a model resources.

Returns

String 

  • A string representing the model.

matchProjectFromDatasetName

matchProjectFromDatasetName(datasetName) returns String

Parse the datasetName from a dataset resource.

Parameter

datasetName

String

A fully-qualified path representing a dataset resources.

Returns

String 

  • A string representing the project.

matchProjectFromLocationName

matchProjectFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the project.

matchProjectFromModelEvaluationName

matchProjectFromModelEvaluationName(modelEvaluationName) returns String

Parse the modelEvaluationName from a model_evaluation resource.

Parameter

modelEvaluationName

String

A fully-qualified path representing a model_evaluation resources.

Returns

String 

  • A string representing the project.

matchProjectFromModelName

matchProjectFromModelName(modelName) returns String

Parse the modelName from a model resource.

Parameter

modelName

String

A fully-qualified path representing a model resources.

Returns

String 

  • A string representing the project.

modelEvaluationPath

modelEvaluationPath(project, location, model, modelEvaluation) returns String

Return a fully-qualified model_evaluation resource name string.

Parameter

project

String

location

String

model

String

modelEvaluation

String

Returns

String 

modelPath

modelPath(project, location, model) returns String

Return a fully-qualified model resource name string.

Parameter

project

String

location

String

model

String

Returns

String 

undeployModel

undeployModel(request, options, callback) returns Promise

Undeploys model. Returns an UndeployModelResponse in the response field when it completes.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the model to undeploy.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const automl = require('@google-cloud/automl');

const client = new automl.v1beta1.AutoMlClient({
  // optional auth parameters.
});

const formattedName = client.modelPath('[PROJECT]', '[LOCATION]', '[MODEL]');
client.undeployModel({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });