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

Function main

compute/reservations/getReservation.js:19–51  ·  view source on GitHub ↗
(reservationName)

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(reservationName) {
20 // [START compute_reservation_get]
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/uncomment these variables before running the sample.
29 */
30 // The ID of the project where your reservation is located.
31 const projectId = await reservationsClient.getProjectId();
32 // The zone where your reservation is located.
33 const zone = 'us-central1-a';
34 // The name of the reservation to return.
35 // reservationName = 'reservation-01';
36
37 async function callGetReservation() {
38 const requestedReservation = (
39 await reservationsClient.get({
40 project: projectId,
41 zone,
42 reservation: reservationName,
43 })
44 )[0];
45
46 console.log(JSON.stringify(requestedReservation));
47 }
48
49 await callGetReservation();
50 // [END compute_reservation_get]
51}
52
53main(...process.argv.slice(2)).catch(err => {
54 console.error(err);

Callers 1

getReservation.jsFile · 0.70

Calls 2

callGetReservationFunction · 0.85
getProjectIdMethod · 0.80

Tested by

no test coverage detected