(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_models_beta] |
| 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').v1beta1; |
| 27 | |
| 28 | // Instantiates a client |
| 29 | const client = new AutoMlClient(); |
| 30 | |
| 31 | async function listModels() { |
| 32 | // Construct request |
| 33 | const request = { |
| 34 | parent: client.locationPath(projectId, location), |
| 35 | filter: 'translation_model_metadata:*', |
| 36 | }; |
| 37 | |
| 38 | const [response] = await client.listModels(request); |
| 39 | |
| 40 | console.log('List of models:'); |
| 41 | for (const model of response) { |
| 42 | console.log(`Model name: ${model.name}`); |
| 43 | console.log(` |
| 44 | Model id: ${model.name.split('/')[model.name.split('/').length - 1]}`); |
| 45 | console.log(`Model display name: ${model.displayName}`); |
| 46 | console.log('Model create time'); |
| 47 | console.log(`\tseconds ${model.createTime.seconds}`); |
| 48 | console.log(`\tnanos ${model.createTime.nanos / 1e9}`); |
| 49 | console.log(`Model deployment state: ${model.deploymentState}`); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | listModels(); |
| 54 | // [END automl_list_models_beta] |
| 55 | } |
| 56 | |
| 57 | process.on('unhandledRejection', err => { |
| 58 | console.error(err.message); |
no test coverage detected