Class Cluster (5.0.0)

Create a cluster object to interact with your cluster.

Package

@google-cloud/bigtable

Example


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

Constructors

(constructor)(instance, id)

constructor(instance: Instance, id: string);

Constructs a new instance of the Cluster class

Parameters
NameDescription
instance Instance
id string

Properties

bigtable

bigtable: Bigtable;

id

id: string;

instance

instance: Instance;

metadata

metadata?: ICluster;

name

name: string;

Methods

backup(id)

backup(id: string): Backup;

Get a reference to a Bigtable Cluster.

Parameter
NameDescription
id string

The backup name or id.

Returns
TypeDescription
Backup

{Backup}

create()

create(): Promise<CreateClusterResponse>;
Returns
TypeDescription
Promise<CreateClusterResponse>

create(options)

create(options: CreateClusterOptions): Promise<CreateClusterResponse>;
Parameter
NameDescription
options CreateClusterOptions
Returns
TypeDescription
Promise<CreateClusterResponse>

create(callback)

create(callback: CreateClusterCallback): void;
Parameter
NameDescription
callback CreateClusterCallback
Returns
TypeDescription
void

create(options, callback)

create(options: CreateClusterOptions, callback: CreateClusterCallback): void;
Parameters
NameDescription
options CreateClusterOptions
callback CreateClusterCallback
Returns
TypeDescription
void

createBackup(id, config)

createBackup(id: string, config: CreateBackupConfig): Promise<CreateBackupResponse>;
Parameters
NameDescription
id string
config CreateBackupConfig
Returns
TypeDescription
Promise<CreateBackupResponse>

createBackup(id, config, callback)

createBackup(id: string, config: CreateBackupConfig, callback: CreateBackupCallback): void;
Parameters
NameDescription
id string
config CreateBackupConfig
callback CreateBackupCallback
Returns
TypeDescription
void

delete()

delete(): Promise<ApiResponse>;
Returns
TypeDescription
Promise<ApiResponse>

delete(gaxOptions)

delete(gaxOptions: CallOptions): Promise<ApiResponse>;
Parameter
NameDescription
gaxOptions CallOptions
Returns
TypeDescription
Promise<ApiResponse>

delete(callback)

delete(callback: DeleteClusterCallback): void;
Parameter
NameDescription
callback DeleteClusterCallback
Returns
TypeDescription
void

delete(gaxOptions, callback)

delete(gaxOptions: CallOptions, callback: DeleteClusterCallback): void;
Parameters
NameDescription
gaxOptions CallOptions
callback DeleteClusterCallback
Returns
TypeDescription
void

exists()

exists(): Promise<BooleanResponse>;
Returns
TypeDescription
Promise<BooleanResponse>

exists(gaxOptions)

exists(gaxOptions: CallOptions): Promise<BooleanResponse>;
Parameter
NameDescription
gaxOptions CallOptions
Returns
TypeDescription
Promise<BooleanResponse>

exists(callback)

exists(callback: ExistsClusterCallback): void;
Parameter
NameDescription
callback ExistsClusterCallback
Returns
TypeDescription
void

exists(gaxOptions, callback)

exists(gaxOptions: CallOptions, callback: ExistsClusterCallback): void;
Parameters
NameDescription
gaxOptions CallOptions
callback ExistsClusterCallback
Returns
TypeDescription
void

get()

get(): Promise<GetClusterResponse>;
Returns
TypeDescription
Promise<GetClusterResponse>

get(gaxOptions)

get(gaxOptions: CallOptions): Promise<GetClusterResponse>;
Parameter
NameDescription
gaxOptions CallOptions
Returns
TypeDescription
Promise<GetClusterResponse>

get(callback)

get(callback: GetClusterCallback): void;
Parameter
NameDescription
callback GetClusterCallback
Returns
TypeDescription
void

get(gaxOptions, callback)

get(gaxOptions: CallOptions, callback: GetClusterCallback): void;
Parameters
NameDescription
gaxOptions CallOptions
callback GetClusterCallback
Returns
TypeDescription
void

getBackups(options)

getBackups(options?: GetBackupsOptions): Promise<GetBackupsResponse>;
Parameter
NameDescription
options GetBackupsOptions
Returns
TypeDescription
Promise<GetBackupsResponse>

getBackups(options, callback)

getBackups(options: GetBackupsOptions, callback: GetBackupsCallback): void;
Parameters
NameDescription
options GetBackupsOptions
callback GetBackupsCallback
Returns
TypeDescription
void

getBackups(callback)

getBackups(callback: GetBackupsCallback): void;
Parameter
NameDescription
callback GetBackupsCallback
Returns
TypeDescription
void

getBackupsStream(options)

getBackupsStream(options?: GetBackupsOptions): NodeJS.ReadableStream;

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

Parameter
NameDescription
options GetBackupsOptions

Configuration object. See for a complete list of options.

Returns
TypeDescription
NodeJS.ReadableStream

{ReadableStream

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

getLocation_(project, location)

static getLocation_(project: string, location: string): string;

Formats zone location.

Parameters
NameDescription
project string

The project ID.

location string

The zone location.

Returns
TypeDescription
string

{string}

Example

Cluster.getLocation_('my-project', 'us-central1-b');
// 'projects/my-project/locations/us-central1-b'

getMetadata()

getMetadata(): Promise<GetClusterMetadataResponse>;
Returns
TypeDescription
Promise<GetClusterMetadataResponse>

getMetadata(gaxOptions)

getMetadata(gaxOptions: CallOptions): Promise<GetClusterMetadataResponse>;
Parameter
NameDescription
gaxOptions CallOptions
Returns
TypeDescription
Promise<GetClusterMetadataResponse>

getMetadata(callback)

getMetadata(callback: GetClusterMetadataCallback): void;
Parameter
NameDescription
callback GetClusterMetadataCallback
Returns
TypeDescription
void

getMetadata(gaxOptions, callback)

getMetadata(gaxOptions: CallOptions, callback: GetClusterMetadataCallback): void;
Parameters
NameDescription
gaxOptions CallOptions
callback GetClusterMetadataCallback
Returns
TypeDescription
void

getStorageType_(type)

static getStorageType_(type: string): number;

Maps the storage type to the proper integer.

Parameter
NameDescription
type string

The storage type (hdd, ssd).

Returns
TypeDescription
number

{number}

Example

Cluster.getStorageType_('ssd');
// 1

setMetadata(metadata, gaxOptions)

setMetadata(metadata: SetClusterMetadataOptions, gaxOptions?: CallOptions): Promise<SetClusterMetadataResponse>;
Parameters
NameDescription
metadata SetClusterMetadataOptions
gaxOptions CallOptions
Returns
TypeDescription
Promise<SetClusterMetadataResponse>

setMetadata(metadata, callback)

setMetadata(metadata: SetClusterMetadataOptions, callback: SetClusterMetadataCallback): void;
Parameters
NameDescription
metadata SetClusterMetadataOptions
callback SetClusterMetadataCallback
Returns
TypeDescription
void

setMetadata(metadata, gaxOptions, callback)

setMetadata(metadata: SetClusterMetadataOptions, gaxOptions: CallOptions, callback: SetClusterMetadataCallback): void;
Parameters
NameDescription
metadata SetClusterMetadataOptions
gaxOptions CallOptions
callback SetClusterMetadataCallback
Returns
TypeDescription
void