MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

automl/list_models.js:17–55  ·  view source on GitHub ↗
(projectId = 'YOUR_PROJECT_ID', location = 'us-central1')

Source from the content-addressed store, hash-verified

15'use strict';
16
17function main(projectId = 'YOUR_PROJECT_ID', location = 'us-central1') {
18 // [START automl_list_models]
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 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]
55}
56
57process.on('unhandledRejection', err => {
58 console.error(err.message);

Callers 1

list_models.jsFile · 0.70

Calls 1

listModelsFunction · 0.70

Tested by

no test coverage detected