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.

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

Methods

backup(id) → {Backup}

Get a reference to a Bigtable Cluster.

Parameters:
Name Type Description
id string

The backup name or id.

Returns:
Type Description
Backup

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_create_cluster

createBackup(id, config, callbackopt) → {void|Promise.<CreateBackupResponse>}

Backup a table from this cluster.

Parameters:
Name Type Attributes Description
id string

A unique ID for the backup.

config object

Configuration object.

Properties
Name Type Attributes Description
expireTime BackupTimestamp

When the backup will be automatically deleted.

table string | Table

Table to create the backup from.

gaxOptions CallOptions <optional>

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

callback CreateBackupCallback <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

backup Backup

The newly created Backup.

operation Operation

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

apiResponse object

The full API response.

Returns:
Type Description
void | Promise.<CreateBackupResponse>
Example

include:samples/api-reference-doc-snippets/backups.create.js

region_tag:bigtable_api_create_backup

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_delete_cluster

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_exists_cluster

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_get_cluster

getBackups(optionsOrCallbackopt, callbackopt) → {void|Promise.<ListBackupsResponse>}

Get Cloud Bigtable Backup instances within this cluster. This returns both completed and pending backups.

Parameters:
Name Type Attributes Description
optionsOrCallback GetBackupsOptions | GetBackupsCallback <optional>
callback GetBackupsResponse <optional>

The callback function.

Properties
Name Type Attributes Description
error error <nullable>

An error returned while making this request.

backups Array.<Backup>

All matching Backup instances.

apiResponse object

The full API response.

Returns:
Type Description
void | Promise.<ListBackupsResponse>
Example

include:samples/api-reference-doc-snippets/backups.list.js

region_tag:bigtable_api_list_backups

getBackupsStream(optionsopt) → {ReadableStream.<Backup>}

Lists Cloud Bigtable backups within this cluster. Provides both completed and pending backups as a readable object stream.

Parameters:
Name Type Attributes Description
options GetBackupsOptions <optional>

Configuration object. See Cluster#getBackups for a complete list of options.

Returns:
Type Description
ReadableStream.<Backup>
Example
```
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const cluster = instance.cluster('my-cluster');

cluster.getBackupsStream()
  .on('error', console.error)
  .on('data', function(backup) {
    // backup is a Backup object.
  })
  .on('end', () => {
    // All backups retrieved.
  });

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

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_cluster_get_meta

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.

Example

include:samples/api-reference-doc-snippets/cluster.js

region_tag:bigtable_api_cluster_set_meta