Cluster¶
User friendly container for Google Cloud Bigtable Cluster.
-
class
gcloud_bigtable.cluster.
Cluster
(zone, cluster_id, client, display_name=None, serve_nodes=3)[source]¶ Bases:
object
Representation of a Google Cloud Bigtable Cluster.
We can use a
Cluster
to:reload()
itselfcreate()
itself- Check if an
operation_finished()
(each ofcreate()
,update()
andundelete()
return with long-running operations) update()
itselfdelete()
itselfundelete()
itself
Note
For now, we leave out the properties
hdd_bytes
andssd_bytes
(both integers) and also thedefault_storage_type
(an enum) which if not sent will end up asdata_pb2.STORAGE_SSD
.Parameters: - zone (str) – The name of the zone where the cluster resides.
- cluster_id (str) – The ID of the cluster.
- client (
client.Client
) – The client that owns the cluster. Provides authorization and a project ID. - display_name (str) – (Optional) The display name for the cluster in the Cloud Console UI. (Must be between 4 and 30 characters.) If this value is not set in the constructor, will fall back to the cluster ID.
- serve_nodes (int) – (Optional) The number of nodes in the cluster. Defaults to 3.
-
client
¶ Getter for cluster’s client.
Return type: client.Client
Returns: The client stored on the cluster.
-
create
(timeout_seconds=None)[source]¶ Create this cluster.
Note
Uses the
project_id
,zone
andcluster_id
on the currentCluster
in addition to thedisplay_name
andserve_nodes
. If you’d like to change them before creating, reset the values viacluster.display_name = 'New display name' cluster.cluster_id = 'i-changed-my-mind'
before calling
create()
.Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
-
delete
(timeout_seconds=None)[source]¶ Delete this cluster.
Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
-
classmethod
from_pb
(cluster_pb, client)[source]¶ Creates a cluster instance from a protobuf.
Parameters: - cluster_pb (
bigtable_cluster_data_pb2.Cluster
) – A cluster protobuf object. - client (
client.Client
) – The client that owns the cluster.
Return type: Returns: The cluster parsed from the protobuf response.
Raises: ValueError
if the cluster name does not match_CLUSTER_NAME_RE
or if the parsed project ID does not match the project ID on the client.- cluster_pb (
-
list_tables
(timeout_seconds=None)[source]¶ List the tables in this cluster.
Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster. Return type: list of Table
Returns: The list of tables owned by the cluster. Raises: ValueError
if one of the returned tables has a name that is not of the expected format.
-
name
¶ Cluster name used in requests.
Note
This property will not change if
zone
andcluster_id
do not, but the return value is not cached.The cluster name is of the form
"projects/{project_id}/zones/{zone}/clusters/{cluster_id}"
Return type: str Returns: The cluster name.
-
operation_finished
(timeout_seconds=None)[source]¶ Check if the current operation has finished.
Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster. Return type: bool Returns: A boolean indicating if the current operation has completed. Raises: ValueError
if there is no current operation set.
-
project_id
¶ Getter for cluster’s project ID.
Return type: str Returns: The project ID for the cluster (is stored on the client).
-
reload
(timeout_seconds=None)[source]¶ Reload the metadata for this cluster.
Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
-
table
(table_id)[source]¶ Factory to create a table associated with this cluster.
Parameters: table_id (str) – The ID of the table. Return type: Table
Returns: The table owned by this cluster.
-
timeout_seconds
¶ Getter for cluster’s default timeout seconds.
Return type: int Returns: The timeout seconds default stored on the cluster’s client.
-
undelete
(timeout_seconds=None)[source]¶ Undelete this cluster.
Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
-
update
(timeout_seconds=None)[source]¶ Update this cluster.
Note
Updates the
display_name
andserve_nodes
. If you’d like to change them before updating, reset the values viacluster.display_name = 'New display name' cluster.serve_nodes = 3
before calling
update()
.Parameters: timeout_seconds (int) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.