Constructor

Cluster

new Cluster(instance, id)

Parameter

instance

Instance

The parent instance of this cluster.

id

string

Id of the cluster.

Example

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const cluster = instance.cluster('my-cluster');

Methods

create

create(options, callback)

Create a cluster.

Parameter

options

Optional

object

See Instance#createCluster.

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.

apiResponse

object

The full API response.

Example

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const cluster = instance.cluster('my-cluster');

cluster.create(function(err, cluster, operation, apiResponse) {
  if (err) {
    // Error handling omitted.
  }

  operation
    .on('error', console.error)
    .on('complete', function() {
      // The cluster was created successfully.
    });
});

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

delete

delete(gaxOptions, callback)

Delete the cluster.

Parameter

gaxOptions

Optional

object

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

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.

apiResponse

object

The full API response.

Example

cluster.delete(function(err, apiResponse) {});

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

exists

exists(gaxOptions, callback)

Check if a cluster exists.

Parameter

gaxOptions

Optional

object

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

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 cluster exists or not.

Example

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

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

get

get(gaxOptions, callback)

Get a cluster if it exists.

Parameter

gaxOptions

Optional

object

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

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.

apiResponse

object

The full API response.

Example

cluster.get(function(err, cluster, apiResponse) {
  // The `cluster` data has been populated.
});

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

getMetadata

getMetadata(gaxOptions, callback)

Get the cluster metadata.

Parameter

gaxOptions

Optional

object

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

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.

metadata

object

The metadata.

apiResponse

object

The full API response.

Example

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

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

setMetadata

setMetadata(metadata, gaxOptions, callback)

Set the cluster metadata.

Parameter

metadata

object

See Instance#createCluster for the available metadata options.

gaxOptions

Optional

object

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

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.

operation

Operation

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

apiResponse

object

The full API response.

Example

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const cluster = instance.cluster('my-cluster');

const callback = function(err, operation, apiResponse) {
  if (err) {
    // Error handling omitted.
  }

  operation
    .on('error', console.error)
    .on('complete', function() {
      // The cluster was updated successfully.
    });
};

const metadata = {
  location: 'us-central1-b',
  nodes: 3,
  storage: 'ssd'
};

cluster.setMetadata(metadata, callback);

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