Constructor

MachineType

new MachineType(zone, name)

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

Parameter

zone

Zone

name

string

See also

Machine Types Overview

MachineType Resource

Example

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

Properties

id

string

name

string

zone

Zone

The parent Zone instance of this MachineType instance.

Methods

create

create(callback)

Check if the machine type exists.

Parameter

callback

function()

The callback function.

Values in callback have the following properties:

Parameter

err

error

An error returned while making this request.

Value may be null.

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()

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

getMetadata(callback)

Get the machine type's metadata.

Parameter

callback

Optional

function()

The callback function.

Values in callback have the following properties:

Parameter

err

error

An error returned while making this request.

Value may be null.

metadata

object

The machine type's metadata.

apiResponse

object

The full API response.

See also

MachineTypes: get API Documentation

MachineType Resource

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];
});