Constructor
new Image(compute, name)
Parameters:
| Name | Type | Description |
|---|---|---|
compute |
Compute |
The parent Compute instance this Image belongs to. |
name |
string |
Image name. |
Members
id
Methods
create(disk, optionsopt)
Create an image.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
disk |
Disk |
See Compute#createImage. |
|
options |
object |
<optional> |
See Compute#createImage. |
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const disk = zone.disk('disk1');
const image = compute.image('image-name');
image.create(disk, function(err, image, operation, apiResponse) {
// `image` is an Image object.
// `operation` is an Operation object that can be used to check the
// status of the request.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
image.create(disk).then(function(data) {
const image = data[0];
const operation = data[1];
const apiResponse = data[2];
});
delete(callbackopt)
Delete the image.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function |
<optional> |
The callback function. Properties
|
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const image = compute.image('image-name');
image.delete(function(err, operation, apiResponse) {
// `operation` is an Operation object that can be used to check the status
// of the request.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
image.delete().then(function(data) {
const operation = data[0];
const apiResponse = data[1];
});
exists(callback)
Check if the image exists.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function |
The callback function. Properties
|
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const image = compute.image('image-name');
image.exists(function(err, exists) {});
//-
// If the callback is omitted, we'll return a Promise.
//-
image.exists().then(function(data) {
const exists = data[0];
});
get(optionsopt)
Get an image if it exists.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
options |
<optional> |
Configuration object. |
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const image = compute.image('image-name');
image.get(function(err, image, apiResponse) {
// `image` is an Image object.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
image.get().then(function(data) {
const image = data[0];
const apiResponse = data[1];
});
getMetadata(callbackopt)
Get the image's metadata.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function |
<optional> |
The callback function. Properties
|
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const image = compute.image('image-name');
image.getMetadata(function(err, metadata, apiResponse) {});
//-
// If the callback is omitted, we'll return a Promise.
//-
image.getMetadata().then(function(data) {
const metadata = data[0];
const apiResponse = data[1];
});