MachineType

MachineType

A MachineType object allows you to interact with a Google Compute Engine machine type.

Constructor

new MachineType(zone, name)

Parameters:
Name Type Description
zone Zone
name string
See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');

Members

id

name

zone

The parent Zone instance of this MachineType instance.

Methods

create(callback)

Check if the machine type exists.

Parameters:
Name Type Description
callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

exists boolean

Whether the machine type exists or not.

Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');

machineType.exists(function(err, exists) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.exists().then(function(data) {
  const exists = data[0];
});

get()

Get a machine type if it exists.

Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');

machineType.get(function(err, machineType, apiResponse) {
  // `machineType` is a MachineType object.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.get().then(function(data) {
  const machineType = data[0];
  const apiResponse = data[1];
});

getMetadata(callbackopt)

Get the machine type's metadata.

Parameters:
Name Type Attributes Description
callback function <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

metadata object

The machine type's metadata.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');

machineType.getMetadata(function(err, metadata, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.getMetadata().then(function(data) {
  const metadata = data[0];
  const apiResponse = data[1];
});