gce-images
Get a list of globally available Google Compute Engine images
$ npm install gce-images
const {GCEImages} = require('gce-images');
const images = new GCEImages();
images.getAll((err, images) => {
});
Get the latest image for a specific OS
images.getLatest('ubuntu', (err, image) => {
});
Get the latest image for a specific OS from your project
images.getLatest('your-project-id-or-name/ubuntu', (err, image) => {
});
Get the latest image for a specific version of an OS
images.getLatest('ubuntu-1404', (err, image) => {
});
Get a map of OS names to their project's api URL
images.OS_URLS;
Authorization
This module uses google-auth-library to get the required access token. If you don't meet the requirements for automatic authentication, you will need to provide the same configuration object detailed in that readme.
const {GCEImages} = require('gce-images');
const images = new GCEImages({ keyFile: '/Users/stephen/dev/key.json' });
images.getAll((err, images) => {});
images.getLatest('ubuntu', (err, image) => {});
Accepted OS names
centos
(also centos-cloud
)container-vm
(also google-containers
)coreos
(also coreos-cloud
)debian
(also debian-cloud
)redhat
(also rhel
, rhel-cloud
)opensuse
(also opensuse-cloud
)suse
(also suse-cloud
)ubuntu
(also ubuntu-cloud
, ubuntu-os-cloud
)windows
(also windows-cloud
)
All accepted names may be suffixed with a version, e.g. ubuntu-1404
.
API
{GCEImages} = require('gce-images')
gceImages.OS_URLS
A map of OS names to their Google APIs public image URL.
images = gceImages([authConfig])
authConfig
See the above section on Authorization. This object is only necessary if automatic authentication is not available in your environment. See the google-auto-auth documentation for the accepted properties.
authConfig.authClient
If you want to re-use an auth client from google-auto-auth, pass an instance here.
images.getAll([options], callback)
images.getLatest([options], callback)
options
- Optional
- Type:
String
or Object
If a string, it is expanded to: options = { osNames: [**string input**] }
.
If not provided, the default options
detailed below are used.
options.osNames
- Type:
String[]
- Default: All
All operating systems you wish to receive image metadata for. See Accepted OS names.
options.deprecated
- Type:
Boolean
- Default:
false
Include deprecated image metadata in results.
callback(err, images)
callback.err
An error that occurred during an API request or if no results match the provided OS name or version.
callback.images
With getAll
:
If only a single OS is being looked up, you will receive an array of all image metadata objects for that OS.
If multiple OS names were given, you will receive an object keyed by the OS name. Each key will reference an array of metadata objects for that OS.
With getLatest
:
If only a single OS is being looked up, you will receive its metadata object back.
If multiple OS names were given, you will receive an object keyed by the OS name. Each key will reference a metadata object.
Disclaimer
This is not an officially supported Google product.