(projectId = 'YOUR_PROJECT_ID', location = 'us-central1')
| 15 | 'use strict'; |
| 16 | |
| 17 | function main(projectId = 'YOUR_PROJECT_ID', location = 'us-central1') { |
| 18 | // [START automl_list_operation_status] |
| 19 | /** |
| 20 | * TODO(developer): Uncomment these variables before running the sample. |
| 21 | */ |
| 22 | // const projectId = 'YOUR_PROJECT_ID'; |
| 23 | // const location = 'us-central1'; |
| 24 | |
| 25 | // Imports the Google Cloud AutoML library |
| 26 | const {AutoMlClient} = require('@google-cloud/automl').v1; |
| 27 | |
| 28 | // Instantiates a client |
| 29 | const client = new AutoMlClient(); |
| 30 | |
| 31 | async function listOperationStatus() { |
| 32 | // Construct request |
| 33 | const request = { |
| 34 | name: client.locationPath(projectId, location), |
| 35 | filter: `worksOn=projects/${projectId}/locations/${location}/models/*`, |
| 36 | }; |
| 37 | |
| 38 | const [response] = await client.operationsClient.listOperations(request); |
| 39 | |
| 40 | console.log('List of operation status:'); |
| 41 | for (const operation of response) { |
| 42 | console.log(`Name: ${operation.name}`); |
| 43 | console.log('Operation details:'); |
| 44 | console.log(`${operation}`); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | listOperationStatus(); |
| 49 | // [END automl_list_operation_status] |
| 50 | } |
| 51 | |
| 52 | process.on('unhandledRejection', err => { |
| 53 | console.error(err.message); |
no test coverage detected