Constructor

Address

new Address(region, name)

An Address object allows you to interact with a Google Compute Engine address.

Parameter

region

Region

name

string

See also

Instances and Networks

Address Resource *

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

Properties

name

string

region

Region

The parent Region instance of this Address instance.

Methods

create

create(options)

Create an address.

Parameter

options

Optional

object

See {Region#createAddress}.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

address.create(function(err, address, operation, apiResponse) {
  // `address` is an Address object.

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

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

delete

delete(callback)

Delete the address.

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.

operation

Operation

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

apiResponse

object

The full API response.

See also

Addresses: delete API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

address.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.
//-
address.delete().then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

exists

exists(callback)

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

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

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

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

get

get(options)

Get an address if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Parameter

options

Optional

options

Configuration object.

Values in options have the following properties:

Parameter

autoCreate

boolean

Automatically create the object if it does not exist. Default: false

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

address.get(function(err, address, apiResponse) {
  // `address` is an Address object.
});

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

getMetadata

getMetadata(callback)

Get the metadata of this address.

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 address's metadata.

apiResponse

object

The full API response.

See also

Address Resource

Addresses: get API Documentation

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const region = compute.region('region-name');
const address = region.address('address1');

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

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