Create a cluster object to interact with your cluster.
Package
@google-cloud/bigtableExample
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
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.
id
string
The backup name or id.
create()
create
()
:
Promise<CreateClusterResponse>
;
create(options)
create
(
options
:
CreateClusterOptions
)
:
Promise<CreateClusterResponse>
;
create(callback)
create
(
callback
:
CreateClusterCallback
)
:
void
;
void
create(options, callback)
create
(
options
:
CreateClusterOptions
,
callback
:
CreateClusterCallback
)
:
void
;
void
createBackup(id, config)
createBackup
(
id
:
string
,
config
:
CreateBackupConfig
)
:
Promise<CreateBackupResponse>
;
id
string
config
CreateBackupConfig
createBackup(id, config, callback)
createBackup
(
id
:
string
,
config
:
CreateBackupConfig
,
callback
:
CreateBackupCallback
)
:
void
;
void
delete()
delete
()
:
Promise<ApiResponse>
;
delete(gaxOptions)
delete
(
gaxOptions
:
CallOptions
)
:
Promise<ApiResponse>
;
gaxOptions
CallOptions
delete(callback)
delete
(
callback
:
DeleteClusterCallback
)
:
void
;
void
delete(gaxOptions, callback)
delete
(
gaxOptions
:
CallOptions
,
callback
:
DeleteClusterCallback
)
:
void
;
void
exists()
exists
()
:
Promise<BooleanResponse>
;
exists(gaxOptions)
exists
(
gaxOptions
:
CallOptions
)
:
Promise<BooleanResponse>
;
gaxOptions
CallOptions
exists(callback)
exists
(
callback
:
ExistsClusterCallback
)
:
void
;
void
exists(gaxOptions, callback)
exists
(
gaxOptions
:
CallOptions
,
callback
:
ExistsClusterCallback
)
:
void
;
void
get()
get
()
:
Promise<GetClusterResponse>
;
get(gaxOptions)
get
(
gaxOptions
:
CallOptions
)
:
Promise<GetClusterResponse>
;
gaxOptions
CallOptions
get(callback)
get
(
callback
:
GetClusterCallback
)
:
void
;
void
get(gaxOptions, callback)
get
(
gaxOptions
:
CallOptions
,
callback
:
GetClusterCallback
)
:
void
;
void
getBackups(options)
getBackups
(
options
?:
GetBackupsOptions
)
:
Promise<GetBackupsResponse>
;
getBackups(options, callback)
getBackups
(
options
:
GetBackupsOptions
,
callback
:
GetBackupsCallback
)
:
void
;
void
getBackups(callback)
getBackups
(
callback
:
GetBackupsCallback
)
:
void
;
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.
options
NodeJS.ReadableStream
{ReadableStream
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.
project
string
The project ID.
location
string
The zone location.
string
{string}
Cluster
.
getLocation_
(
'my-project'
,
'us-central1-b'
);
// 'projects/my-project/locations/us-central1-b'
getMetadata()
getMetadata
()
:
Promise<GetClusterMetadataResponse>
;
getMetadata(gaxOptions)
getMetadata
(
gaxOptions
:
CallOptions
)
:
Promise<GetClusterMetadataResponse>
;
gaxOptions
CallOptions
getMetadata(callback)
getMetadata
(
callback
:
GetClusterMetadataCallback
)
:
void
;
void
getMetadata(gaxOptions, callback)
getMetadata
(
gaxOptions
:
CallOptions
,
callback
:
GetClusterMetadataCallback
)
:
void
;
void
getStorageType_(type)
static
getStorageType_
(
type
:
string
)
:
number
;
Maps the storage type to the proper integer.
type
string
The storage type (hdd, ssd).
number
{number}
Cluster
.
getStorageType_
(
'ssd'
);
// 1
setMetadata(metadata, gaxOptions)
setMetadata
(
metadata
:
SetClusterMetadataOptions
,
gaxOptions
?:
CallOptions
)
:
Promise<SetClusterMetadataResponse>
;
metadata
SetClusterMetadataOptions
gaxOptions
CallOptions
setMetadata(metadata, callback)
setMetadata
(
metadata
:
SetClusterMetadataOptions
,
callback
:
SetClusterMetadataCallback
)
:
void
;
void
setMetadata(metadata, gaxOptions, callback)
setMetadata
(
metadata
:
SetClusterMetadataOptions
,
gaxOptions
:
CallOptions
,
callback
:
SetClusterMetadataCallback
)
:
void
;
metadata
SetClusterMetadataOptions
gaxOptions
CallOptions
callback
void