Constructor

Cluster

new Cluster(instance, name)

Create a cluster object to interact with your cluster.

Parameter

instance

Instance

The parent instance of this cluster.

name

string

Name 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');

Property

id

string

Methods

create

create(options)

Create a cluster.

Parameter

options

object

See Instance#createCluster

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

Delete the cluster.

Parameter

callback

Optional

function()

The callback function.

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

Check if a cluster exists.

Parameter

callback

function()

The callback function.

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

Get a cluster if it exists.

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

Get the cluster metadata.

Parameter

callback

function()

The callback function.

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, callback)

Set the cluster metadata.

See Instance#createCluster for a detailed explanation of the arguments.

Parameter

metadata

object

Metadata object.

callback

function()

The callback function.

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