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

Function main

compute/reservations/getReservations.js:19–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main() {
20 // [START compute_reservation_list]
21 // Import the Compute library
22 const computeLib = require('@google-cloud/compute');
23
24 // Instantiate a reservationsClient
25 const reservationsClient = new computeLib.ReservationsClient();
26
27 /**
28 * TODO(developer): Update these variables before running the sample.
29 */
30 // The ID of the project where your reservations are located.
31 const projectId = await reservationsClient.getProjectId();
32 // The zone where your reservations are located.
33 const zone = 'us-central1-a';
34
35 async function callGetReservations() {
36 const reservations = (
37 await reservationsClient.list({
38 project: projectId,
39 zone,
40 })
41 )[0];
42
43 console.log(JSON.stringify(reservations));
44 }
45
46 await callGetReservations();
47 // [END compute_reservation_list]
48}
49
50main().catch(err => {
51 console.error(err);

Callers 1

getReservations.jsFile · 0.70

Calls 2

callGetReservationsFunction · 0.85
getProjectIdMethod · 0.80

Tested by

no test coverage detected