Constructor

Zone

new Zone(compute, name)

A Zone object allows you to interact with a Google Compute Engine zone.

Parameter

compute

Compute

Compute object this zone belongs to.

name

string

Name of the zone.

See also

Regions & Zones Overview

Zone Resource

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

Properties

compute

Compute

The parent Compute instance of this Zone instance.

getAutoscalersStream

Get a list of Autoscaler objects from this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getAutoscalers for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getAutoscalersStream()
  .on('error', console.error)
  .on('data', function(autoscaler) {
    // `autoscaler` is an `Autoscaler` object.
  })
  .on('end', function() {
    // All autoscalers retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getAutoscalersStream()
  .on('data', function(autoscaler) {
    this.end();
  });

getDisksStream

Get a list of Disk objects in this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getDisks for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getDisksStream()
  .on('error', console.error)
  .on('data', function(disk) {
    // `disk` is a `Disk` object.
  })
  .on('end', function() {
    // All disks retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getDisksStream()
  .on('data', function(disk) {
    this.end();
  });

getInstanceGroupsStream

Get a list of InstanceGroup objects for this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getInstanceGroups for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getInstanceGroupsStream()
  .on('error', console.error)
  .on('data', function(instanceGroup) {
    // `instanceGroup` is an `InstanceGroup` object.
  })
  .on('end', function() {
    // All instance groups retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getInstanceGroupsStream()
  .on('data', function(instanceGroup) {
    this.end();
  });

getMachineTypesStream

Get a list of MachineType objects for this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getMachineTypes for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getMachineTypesStream()
  .on('error', console.error)
  .on('data', function(machineType) {
    // `machineType` is a `MachineType` object.
  })
  .on('end', function() {
    // All machine types retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getMachineTypesStream()
  .on('data', function(machineType) {
    this.end();
  });

getOperationsStream

Get a list of Operation objects for this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getOperations for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getOperationsStream()
  .on('error', console.error)
  .on('data', function(operation) {
    // `operation` is an `Operation` object.
  })
  .on('end', function() {
    // All operations retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getOperationsStream()
  .on('data', function(operation) {
    this.end();
  });

getVMsStream

Get a list of VM instances in this zone as a readable object stream.

Parameter

options

Optional

object

Configuration object. See Zone#getVMs for a complete list of options.

Returns

stream 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getVMsStream()
  .on('error', console.error)
  .on('data', function(vm) {
    // `vm` is a `VM` object.
  })
  .on('end', function() {
    // All instances retrieved.
  });

//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
zone.getVMsStream()
  .on('data', function(vm) {
    this.end();
  });

id

string

name

string

Methods

autoscaler

autoscaler(name) returns Autoscaler

Get a reference to a Google Compute Engine autoscaler in this zone.

Parameter

name

string

Name of the autoscaler.

Returns

Autoscaler 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const autoscaler = zone.autoscaler('autoscaler-name');

createAutoscaler

createAutoscaler(name, config, callback)

Create an autoscaler in this zone.

Parameter

name

string

Name of the autoscaler.

config

object

See an Autoscaler resource.

Values in config have the following properties:

Parameter

coolDown

number

The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. Alias for config.autoscalingPolicy.coolDownPeriodSec.

cpu

number

The target CPU utilization that the autoscaler should maintain, between 1 - 100. Alias for config.autoscalingPolicy.cpuUtilization.utilizationTarget.

loadBalance

number

Backend capacity utilization that autoscaler should maintain, between 1 - 100. Alias for config.autoscalingPolicy.loadBalancingUtilization.utilizationTarget.

maxReplicas

number

The maximum number of instances that the autoscaler can scale up to. Alias for config.autoscalingPolicy.maxNumReplicas.

minReplicas

number

The minimum number of replicas that the autoscaler can scale down to. Alias for config.autoscalingPolicy.minNumReplicas.

target

string

The name of the managed instance group that this autoscaler will scale.

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.

autoscaler

Autoscaler

The created Autoscaler object.

operation

Operation

An operation object that can be used to check the status of the request.

apiResponse

object

The full API response.

See also

Load Balancing and Scaling

Autoscaler Resource

Autoscalers: insert API Documentation

Throws

Error 

If config.target is not provided.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const config = {
  coolDown: 30,
  cpu: 80,
  loadBalance: 40,
  maxReplicas: 5,
  minReplicas: 0,
  target: 'instance-group-manager-1'
};

function callback(err, autoscaler, operation, apiResponse) {
  // `autoscaler` is an Autoscaler object.

  // `operation` is an Operation object that can be used to check the status
  // of the request.
}

zone.createAutoscaler('name', config, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
zone.createAutoscaler('name', config).then(function(data) {
  const autoscaler = data[0];
  const operation = data[1];
  const apiResponse = data[2];
});

createDisk

createDisk(name, config, callback)

Create a persistent disk in this zone.

Parameter

name

string

Name of the disk.

config

object

See a Disk resource.

Values in config have the following properties:

Parameter

os

Optional

string

Specify the name of an OS, and we will use the latest version as the source image of a new boot disk. See this list of accepted OS names.

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.

disk

Disk

The created Disk object.

operation

Operation

An operation object that can be used to check the status of the request.

apiResponse

object

The full API response.

See also

Disk Resource

Disks: insert API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

//-
// Create a persistent disk using the latest Ubuntu version
// as the source image.
//-
const config = {
  os: 'ubuntu',
  sizeGb: 10
};

//-
// Create a persistent disk using the latest Ubuntu version from your project
// as the source image.
//-
const config = {
  os: 'your-project-id-or-name/ubuntu',
  sizeGb: 10
};

zone.createDisk('name', config, function(err, disk, operation, apiResponse) {
  // `disk` is a Disk 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.
//-
zone.createDisk('name', config).then(function(data) {
  const disk = data[0];
  const operation = data[1];
  const apiResponse = data[2];
});

createInstanceGroup

createInstanceGroup(name, options, callback)

Create an instance group in this zone.

Parameter

name

string

Name of the instance group.

options

object

See an InstanceGroup resource.

Values in options have the following properties:

Parameter

ports

object

A map of names to ports. The key should be the name, and the value the port number. Maps to options.namedPorts.

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.

instanceGroup

InstanceGroup

The created InstanceGroup object.

operation

Operation

An operation object that can be used to check the status of the request.

apiResponse

object

The full API response.

See also

InstanceGroup Resource

InstanceGroups: insert API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

function onCreated(err, instanceGroup, operation, apiResponse) {
  // `instanceGroup` is an InstanceGroup object.

  // `operation` is an Operation object that can be used to check the status
  // of the request.
}

zone.createInstanceGroup('instance-group-name', onCreated);

//-
// If the callback is omitted, we'll return a Promise.
//-
zone.createInstanceGroup('instance-group-name', config).then(function(data) {
  const instanceGroup = data[0];
  const operation = data[1];
  const apiResponse = data[2];
});

createVM

createVM(name, config, callback)

Create a virtual machine in this zone.

Parameter

name

string

Name of the instance.

config

object

See an Instance resource.

Values in config have the following properties:

Parameter

disks

Array of object

See a Disk resource.

Value may be null.

http

Optional

boolean

Allow HTTP traffic. Default: false

https

Optional

boolean

Allow HTTPS traffic. Default: false

networkInterfaces

Array of object

An array of configurations for this interface. This specifies how this interface should interact with other network services, such as connecting to the internet. Default: [ { network: 'global/networks/default' } ]

Value may be null.

machineType

Optional

string

The machine type resource to use. Provide only the name of the machine, e.g. n1-standard-16. Refer to Available Machine Types. Default: n1-standard-1

os

Optional

string

Specify the name of an OS, and we will use the latest version as the source image of a new boot disk. See this list of accepted OS names.

tags

Array of string

An array of tags.

Value may be null.

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.

vm

VM

The created VM object.

operation

Operation

An operation object that can be used to check the status of the request.

apiResponse

object

The full API response.

See also

Instance Resource

Instances: insert API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

//-
// Create a new instance using the latest Debian version from your project
// as the source image for a new boot disk.
//-
const config = {
  os: 'your-project-id-or-name/debian',
  http: true,
  tags: ['debian-server']
};

//-
// Create a new instance using the latest Debian version as the source image
// for a new boot disk.
//-
const config = {
  os: 'debian',
  http: true,
  tags: ['debian-server']
};

//-
// The above object will auto-expand behind the scenes to something like the
// following. The Debian version may be different when you run the command.
//-
const config = {
  machineType: 'n1-standard-1',
  disks: [
    {
      boot: true,
      initializeParams: {
        sourceImage:
          'https://www.googleapis.com/compute/v1/projects' +
          '/debian-cloud/global/images/debian-7-wheezy-v20150710'
      }
    }
  ],
  networkInterfaces: [
    {
      network: 'global/networks/default'
    }
  ],
  tags: [
    {
      items: [
        'debian-server',
        'http-server'
      ]
    }
  ]
};

function callback(err, vm, operation, apiResponse) {
  // `vm` is a VM object.

  // `operation` is an Operation object that can be used to check the status
  // of the request.
}

zone.createVM('new-vm-name', config, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
zone.createVM('new-vm-name', config).then(function(data) {
  const vm = data[0];
  const operation = data[1];
  const apiResponse = data[2];
});

disk

disk(name) returns Disk

Get a reference to a Google Compute Engine disk in this zone.

Parameter

name

string

Name of the disk.

See also

Disks Overview

Returns

Disk 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const disk = zone.disk('disk1');

exists

exists(callback)

Check if the zone 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 zone exists or not.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

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

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

get

get()

Get a zone.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

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

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

getAutoscalers

getAutoscalers(options, callback)

Get a list of autoscalers from this zone.

Parameter

options

Optional

object

Autoscaler search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

filter

string

Search filter in the format of {name} {comparison} {filterString}.

- **`name`**: the name of the field to compare
- **`comparison`**: the comparison operator, `eq` (equal) or `ne`
  (not equal)
- **`filterString`**: the string to filter to. For string fields, this
  can be a regular expression.

maxApiCalls

number

Maximum number of API calls to make.

maxResults

number

Maximum number of autoscalers to return.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

autoscalers

Array of Autoscaler

Autoscaler objects from your project.

apiResponse

object

The full API response.

See also

Managing Autoscalers

Understanding Autoscaler Decisions

Autoscalers: aggregatedList API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getAutoscalers(function(err, autoscalers) {
  // autoscalers is an array of `Autoscaler` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, autoscalers, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getAutoscalers(nextQuery, callback);
  }
}

zone.getAutoscalers({
  autoPaginate: false
}, callback);

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

getDisks

getDisks(options, callback)

Get a list of disks in this zone.

Parameter

options

Optional

object

Disk search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

filter

string

Search filter in the format of {name} {comparison} {filterString}.

- **`name`**: the name of the field to compare
- **`comparison`**: the comparison operator, `eq` (equal) or `ne`
  (not equal)
- **`filterString`**: the string to filter to. For string fields, this
  can be a regular expression.

maxApiCalls

number

Maximum number of API calls to make.

maxResults

number

Maximum number of disks to return.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

disks

Array of Disk

Disk objects from this zone.

apiResponse

object

The full API response.

See also

Disks Overview

Disks: list API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getDisks(function(err, disks) {
  // `disks` is an array of `Disk` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, disks, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getDisks(nextQuery, callback);
  }
}

zone.getDisks({
  autoPaginate: false
}, callback);

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

getInstanceGroups

getInstanceGroups(options, callback)

Get a list of instance groups for this zone.

Parameter

options

Optional

object

Instance group search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

filter

string

Search filter in the format of {name} {comparison} {filterString}.

- **`name`**: the name of the field to compare
- **`comparison`**: the comparison operator, `eq` (equal) or `ne`
  (not equal)
- **`filterString`**: the string to filter to. For string fields, this
  can be a regular expression.

maxApiCalls

number

Maximum number of API calls to make.

maxResults

number

Maximum number of instance groups to return.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

instanceGroups

Array of InstanceGroup

InstanceGroup objects from this zone.

apiResponse

object

The full API response.

See also

InstanceGroups Overview

InstanceGroups: list API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getInstanceGroups(function(err, instanceGroups) {
  // `instanceGroups` is an array of `InstanceGroup` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, instanceGroups, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getInstanceGroups(nextQuery, callback);
  }
}

zone.getInstanceGroups({
  autoPaginate: false
}, callback);

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

getMachineTypes

getMachineTypes(options, callback)

Get a list of machine types for this zone.

Parameter

options

Optional

object

Machine type search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

maxApiCalls

number

Maximum number of API calls to make.

maxResults

number

Maximum number of machineTypes to return.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

machineTypes

Array of MachineType

MachineType objects from this zone.

apiResponse

object

The full API response.

See also

MachineTypes: list API Documentation

Machine Types Overview

MachineType Resource

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getMachineTypes(function(err, machineTypes) {
  // `machineTypes` is an array of `MachineType` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, machineTypes, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getMachineTypes(nextQuery, callback);
  }
}

zone.getMachineTypes({
  autoPaginate: false
}, callback);

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

getMetadata

getMetadata(callback)

Get the zone'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 zone's metadata.

apiResponse

object

The full API response.

See also

Zone Resource

Zones: get API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

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

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

getOperations

getOperations(options, callback)

Get a list of operations for this zone.

Parameter

options

Optional

object

Operation search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

filter

string

Search filter in the format of {name} {comparison} {filterString}.

- **`name`**: the name of the field to compare
- **`comparison`**: the comparison operator, `eq` (equal) or `ne`
  (not equal)
- **`filterString`**: the string to filter to. For string fields, this
  can be a regular expression.

maxApiCalls

number

Maximum number of API calls to make.

maxResults

number

Maximum number of operations to return.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

operations

Array of Operation

Operation objects from this zone.

apiResponse

object

The full API response.

See also

Zone Operation Overview

ZoneOperations: list API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getOperations(function(err, operations) {
  // `operations` is an array of `Operation` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, operations, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getOperations(nextQuery, callback);
  }
}

zone.getOperations({
  autoPaginate: false
}, callback);

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

getVMs

getVMs(options, callback)

Get a list of VM instances in this zone.

Parameter

options

Optional

object

Instance search options.

Values in options have the following properties:

Parameter

autoPaginate

boolean

Have pagination handled automatically. Default: true.

filter

string

Search filter in the format of {name} {comparison} {filterString}.

- **`name`**: the name of the field to compare
- **`comparison`**: the comparison operator, `eq` (equal) or `ne`
  (not equal)
- **`filterString`**: the string to filter to. For string fields, this
  can be a regular expression.

pageToken

string

A previously-returned page token representing part of the larger set of results to view.

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.

vms

Array of VM

VM objects from this zone.

apiResponse

object

The full API response.

See also

Instances and Networks

Instances: list API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

zone.getVMs(function(err, vms) {
  // `vms` is an array of `VM` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, vms, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    zone.getVMs(nextQuery, callback);
  }
}

zone.getVMs({
  autoPaginate: false
}, callback);

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

instanceGroup

instanceGroup(name) returns InstanceGroup

Get a reference to a Google Compute Engine instance group.

Parameter

name

string

Name of the existing instance group.

See also

InstanceGroups Overview

Returns

InstanceGroup 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const instanceGroup = zone.instanceGroup('my-instance-group');

machineType

machineType(name) returns MachineType

Get a reference to a Google Compute Engine machine type.

Parameter

name

string

Name of the existing machine type.

See also

Machine Types Overview

MachineType Resource

Returns

MachineType 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const machineType = zone.machineType('g1-small');

operation

operation(name) returns Operation

Get a reference to a Google Compute Engine zone operation.

Parameter

name

string

Name of the existing operation.

See also

Zone Operation Overview

Returns

Operation 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const operation = zone.operation('operation-1445532685163-8b137d2a-1822afe7');

vm

vm(name) returns VM

Get a reference to a Google Compute Engine virtual machine instance.

Parameter

name

string

Name of the virtual machine.

See also

Instances and Networks

Returns

VM 

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');

const vm = zone.vm('vm-name');