Properties

new MachineType(zone, name)

Example

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

Parameters

Name Type Optional Description

zone

 

 

name

 

 

See also

Machine Types Overview

MachineType Resource

Properties

id  string

name  string

zone  Zone

The parent Zone instance of this MachineType instance.

Methods

create(callback)

Check if the machine type 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.exists(function(err, exists) {});

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

Parameters

Name Type Optional Description

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

exists

boolean

 

Whether the machine type exists or not.

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([callback])

Get the machine type's metadata.

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

Parameters

Name Type Optional Description

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

metadata

object

 

The machine type's metadata.

apiResponse

object

 

The full API response.

See also

MachineTypes: get API Documentation

MachineType Resource