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

Function listImages

compute/listImages.js:29–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 const compute = require('@google-cloud/compute');
28
29 async function listImages() {
30 const imagesClient = new compute.ImagesClient();
31
32 // Listing only non-deprecated images to reduce the size of the reply.
33 const images = imagesClient.listAsync({
34 project: projectId,
35 maxResults: 3,
36 filter: 'deprecated.state != DEPRECATED',
37 });
38
39 // Although the `maxResults` parameter is specified in the request, the iterable returned
40 // by the `listAsync()` method hides the pagination mechanic. The library makes multiple
41 // requests to the API for you, so you can simply iterate over all the images.
42 for await (const image of images) {
43 console.log(` - ${image.name}`);
44 }
45 }
46
47 listImages();
48 // [END compute_images_list]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected