Cluster

Cluster

Create a cluster object to interact with your cluster.

Constructor

new Cluster(instance, id)

Parameters:
Name Type Description
instance Instance

The parent instance of this cluster.

id string

Id of the cluster.

Source:
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(optionsopt, callbackopt)

Create a cluster.

Parameters:
Name Type Attributes Description
options object <optional>

See Instance#createCluster.

callback function <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

Source:
Example
    const clusterOptions = {
      location: 'us-central1-c',
      nodes: 3,
      storage: 'ssd',
    };

    const [cluster] = await instance.createCluster(clusterID, clusterOptions);
    console.log(`Cluster created: ${cluster.id}`);

delete(gaxOptionsopt, callbackopt)

Delete the cluster.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

callback function <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

Source:
Example
  console.log(); //for just a new-line
  console.log(`Deleting Cluster`);
  await cluster.delete();
  console.log(`Cluster deleted: ${cluster.id}`);

exists(gaxOptionsopt, callback)

Check if a cluster exists.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

exists boolean

Whether the cluster exists or not.

Source:
Example
    const Bigtable = require('@google-cloud/bigtable');
    const bigtable = new Bigtable();
    const instance = bigtable.instance(instanceId);
    const cluster = instance.cluster(clusterId);

    cluster
      .exists()
      .then(result => {
        const exists = result[0];
      })
      .catch(err => {
        // Handle the error.
      });

get(gaxOptionsopt, callback)

Get a cluster if it exists.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

Source:
Example
    const Bigtable = require('@google-cloud/bigtable');
    const bigtable = new Bigtable();
    const instance = bigtable.instance(instanceId);
    const cluster = instance.cluster(clusterId);

    cluster
      .get()
      .then(result => {
        const cluster = result[0];
        const apiResponse = result[1];
      })
      .catch(err => {
        // Handle the error.
      });

getMetadata(gaxOptionsopt, callback)

Get the cluster metadata.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

metadata object

The metadata.

apiResponse object

The full API response.

Source:
Example
    const Bigtable = require('@google-cloud/bigtable');
    const bigtable = new Bigtable();
    const instance = bigtable.instance(instanceId);
    const cluster = instance.cluster(clusterId);

    cluster
      .getMetadata()
      .then(result => {
        const metadata = result[0];
        const apiResponse = result[1];
      })
      .catch(err => {
        // Handle the error.
      });

setMetadata(metadata, gaxOptionsopt, callback)

Set the cluster metadata.

Parameters:
Name Type Attributes Description
metadata object

See Instance#createCluster for the available metadata options.

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

operation Operation

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

apiResponse object

The full API response.

Source:
Example
    const Bigtable = require('@google-cloud/bigtable');
    const bigtable = new Bigtable();
    const instance = bigtable.instance(instanceId);
    const cluster = instance.cluster(clusterId);

    const metadata = {
      nodes: 4,
    };

    cluster
      .setMetadata(metadata)
      .then(result => {
        const operation = result[0];
        const apiResponse = result[1];
      })
      .catch(err => {
        // Handle the error.
      });