Я пытаюсь использовать NodeJS, чтобы перечислить все изображения, доступные для учетной записи Google Compute Engine.как перечислить изображения, хранящиеся в Google Engine с помощью Node?
Я стараюсь, чтобы получить тот же результат, что и этой командной строке в формате JSON с помощью Node:
gcutil listimages --project=google
- Я начал с этого куска кода https://github.com/google/google-api-nodejs-client
- я смотрю в этот TODO»образца также: https://developers.google.com/datastore/docs/getstarted/start_nodejs/
но сейчас я застрял, и я не могу связать образцы с документацией (см. Ссылку в коде, поскольку я не могу вставить больше, чем 2 ссылки, если репутация < до 10 :-)
Вот код, который я начинаю. Не могли бы вы сказать мне, как
/*
Retrieves the list of image resources available to the specified project.
command line: gcutil listimages --project=google
REST API: https://developers.google.com/compute/docs/reference/latest/images/list
*/
"use strict";
var googleapis = require('googleapis');
var authclient = new googleapis.OAuth2Client();
var compute = new googleapis.auth.Compute();
var projectName = process.argv[2] || 'google';
var gceService;
var usage = 'usage: listimages.js <project name>';
compute.authorize(function (err, result) {
console.assert(!err, err);
googleapis.discover('compute', 'v1beta15')
.withAuthClient(compute)
.execute(function (err, client) {
console.assert(!err, err);
//here I want to instantiate a Google Compute Engine service
//this does not work (obviously)
gceService = client.instanciateGoogleComputeEngineService();
console.log('an instance of a GCE service is made !');
});
});
// the following line isn't part of the code, I just try to help you understand my needs :-)
console.log(gceService.listimages(projectName);
заранее спасибо за вашу помощь