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:

Note

For now, we leave out the properties hdd_bytes and ssd_bytes (both integers) and also the default_storage_type (an enum) which if not sent will end up as data_pb2.STORAGE_SSD.

Parameters:
  • zone (string) – The name of the zone where the cluster resides.
  • cluster_id (string) – The ID of the cluster.
  • client (client.Client) – The client that owns the cluster. Provides authorization and a project ID.
  • display_name (string) – (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 (integer) – (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 and cluster_id on the current Cluster in addition to the display_name and serve_nodes. If you’d like to change them before creating, reset the values via

cluster.display_name = 'New display name'
cluster.cluster_id = 'i-changed-my-mind'

before calling create().

Parameters:timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
credentials

Getter for cluster’s credentials.

Return type:oauth2client.client.OAuth2Credentials
Returns:The credentials stored on the cluster’s client.
delete(timeout_seconds=None)[source]

Delete this cluster.

Parameters:timeout_seconds (integer) – 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:

Cluster

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.

list_tables(timeout_seconds=None)[source]

List the tables in this cluster.

Parameters:timeout_seconds (integer) – 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 and cluster_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:string
Returns:The cluster name.
operation_finished(timeout_seconds=None)[source]

Check if the current operation has finished.

Parameters:timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.
Return type:boolean
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:string
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 (integer) – 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 (string) – 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:integer
Returns:The timeout seconds default stored on the cluster’s client.
undelete(timeout_seconds=None)[source]

Undelete this cluster.

Parameters:timeout_seconds (integer) – 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 and serve_nodes. If you’d like to change them before updating, reset the values via

cluster.display_name = 'New display name'
cluster.serve_nodes = 3

before calling update().

Parameters:timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on cluster.