How to use the @google-cloud/automl.v1beta1.AutoMlClient function in @google-cloud/automl

To help you get started, we’ve selected a few @google-cloud/automl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-automl / samples / beta / setEndpoint.js View on Github external
async function setEndpoint(projectId) {
  // [START automl_set_endpoint]
  const automl = require('@google-cloud/automl').v1beta1;

  // You must first create a dataset, using the `eu` endpoint, before you can
  // call other operations such as: list, get, import, delete, etc.
  const clientOptions = {apiEndpoint: 'eu-automl.googleapis.com'};

  // Instantiates a client
  const client = new automl.AutoMlClient(clientOptions);

  // A resource that represents Google Cloud Platform location.
  const projectLocation = client.locationPath(projectId, 'eu');
  // [END automl_set_endpoint]

  // Grabs the list of datasets in a given project location.
  // Note: create a dataset in `eu` before calling `listDatasets`.
  const responses = await client.listDatasets({parent: projectLocation});

  // Prints out each dataset.
  const datasets = responses[0];
  datasets.forEach(dataset => {
    console.log(dataset);
  });
}