Cluster Admin API#

After creating a Client, you can interact with individual clusters, groups of clusters or available zones for a project.

List Clusters#

If you want a comprehensive list of all existing clusters, make a ListClusters API request with Client.list_clusters():

clusters = client.list_clusters()

List Zones#

If you aren’t sure which zone to create a cluster in, find out which zones your project has access to with a ListZones API request with Client.list_zones():

zones = client.list_zones()

You can choose a string from among the result to pass to the Cluster constructor.

The available zones (as of February 2016) are

>>> zones
[u'asia-east1-b', u'europe-west1-c', u'us-central1-c', u'us-central1-b']

Cluster Factory#

To create a Cluster object:

cluster = client.cluster(zone, cluster_id,
                         display_name=display_name,
                         serve_nodes=3)

Both display_name and serve_nodes are optional. When not provided, display_name defaults to the cluster_id value and serve_nodes defaults to the minimum allowed: DEFAULT_SERVE_NODES.

Even if this Cluster already has been created with the API, you’ll want this object to use as a parent of a Table just as the Client is used as the parent of a Cluster.

Create a new Cluster#

After creating the cluster object, make a CreateCluster API request with create():

cluster.display_name = 'My very own cluster'
cluster.create()

If you would like more than the minimum number of nodes (DEFAULT_SERVE_NODES) in your cluster:

cluster.serve_nodes = 10
cluster.create()

Check on Current Operation#

Note

When modifying a cluster (via a CreateCluster, UpdateCluster or UndeleteCluster request), the Bigtable API will return a long-running Operation. This will be stored on the object after each of create(), update() and undelete() are called.

You can check if a long-running operation (for a create(), update() or undelete()) has finished by making a GetOperation request with Operation.finished():

>>> operation = cluster.create()
>>> operation.finished()
True

Note

Once an Operation object has returned True from finished(), the object should not be re-used. Subsequent calls to finished() will result in a ValueError.

Get metadata for an existing Cluster#

After creating the cluster object, make a GetCluster API request with reload():

cluster.reload()

This will load serve_nodes and display_name for the existing cluster in addition to the cluster_id, zone and project already set on the Cluster object.

Update an existing Cluster#

After creating the cluster object, make an UpdateCluster API request with update():

client.display_name = 'New display_name'
cluster.update()

Delete an existing Cluster#

Make a DeleteCluster API request with delete():

cluster.delete()

Undelete a deleted Cluster#

Make an UndeleteCluster API request with undelete():

cluster.undelete()

Next Step#

Now we go down the hierarchy from Cluster to a Table.

Head next to learn about the Table Admin API.