| 15 | 'use strict'; |
| 16 | |
| 17 | async function setEndpoint(projectId) { |
| 18 | // [START automl_set_endpoint] |
| 19 | const automl = require('@google-cloud/automl').v1beta1; |
| 20 | |
| 21 | // You must first create a dataset, using the `eu` endpoint, before you can |
| 22 | // call other operations such as: list, get, import, delete, etc. |
| 23 | const clientOptions = {apiEndpoint: 'eu-automl.googleapis.com'}; |
| 24 | |
| 25 | // Instantiates a client |
| 26 | const client = new automl.AutoMlClient(clientOptions); |
| 27 | |
| 28 | // A resource that represents Google Cloud Platform location. |
| 29 | const projectLocation = client.locationPath(projectId, 'eu'); |
| 30 | // [END automl_set_endpoint] |
| 31 | |
| 32 | // Grabs the list of datasets in a given project location. |
| 33 | // Note: create a dataset in `eu` before calling `listDatasets`. |
| 34 | const responses = await client.listDatasets({parent: projectLocation}); |
| 35 | |
| 36 | // Prints out each dataset. |
| 37 | const datasets = responses[0]; |
| 38 | datasets.forEach(dataset => { |
| 39 | console.log(dataset); |
| 40 | }); |
| 41 | } |
| 42 | |
| 43 | setEndpoint(...process.argv.slice(2)).catch(err => { |
| 44 | console.error(err); |