Releases: dhermes/gcloud-python-bigtable
Table and Cluster Admin APIs (fully working and tested)
Table and Cluster Admin APIs (fully working and tested)
We have moved from a connection based approach to a Client
hierarchy.
See http://gcloud-python-bigtable.readthedocs.org/en/table-api-complete/ for docs at this release.
Cluster Admin API (fully working and tested)
The Cluster Admin API has been fully implemented in this release.
To use the API, the Cluster
class defines a high-level interface:
from gcloud_bigtable.cluster import Cluster
cluster = Cluster(project_id, zone, cluster_id)
Create a new Cluster
After creating the cluster object, make a CreateCluster
API request:
display_name = 'My very own cluster'
cluster.create(display_name)
If you would like more than the minimum number of nodes (3
) in your cluster:
serve_nodes = 10
cluster.create(display_name, serve_nodes=serve_nodes)
NOTE: Currently serve_nodes
will default to 3
if not passed to create
and display_name
is mandatory in create
since it is mandatory in CreateCluster
. However, we could easily set
display_name = cluster.cluster_id
if cluster.create()
were called with no arguments.
Get metadata for an existing Cluster
After creating the cluster object, make a GetCluster
API request:
cluster.reload()
This will load serve_nodes
and display_name
for the existing cluster
in addition to the cluster_id
, zone
and project_id
already set on the Cluster
object.
Update an existing Cluster
After creating the cluster object, make an UpdateCluster
API request:
cluster.update(display_name=display_name, serve_nodes=serve_nodes)
Both display_name
and serve_nodes
are optional arguments. If neither are passed in, the method will do nothing.
NOTE: This means that if you change them via:
cluster.display_name = 'Brand new display name'
cluster.update()
then the update
won't actually occur. (Though we are open to changing this behavior. The current behavior is in place to avoid an HTTP/2 request if one is not necessary. This behavior would not be possible if display_name
and serve_nodes
were read-only properties.)
Delete an existing Cluster
Make a DeleteCluster
API request:
cluster.delete()
Low-level Methods
The ListClusters
, UndeleteCluster
, and ListZones
methods
have been implemented on the ClusterConnection
class, but not on
the Cluster
convenience class.
For now, you can access a cluster connection as a protected attribute of a Cluster
:
cluster_connection = cluster._cluster_conn
# Returns a
# (gcloud_bigtable._generated.bigtable_cluster_service_messages_pb2.
# ListClustersResponse)
list_of_clusters = cluster_connection.list_clusters(project_id)
# Returns a
# gcloud_bigtable._generated.operations_pb2.Operation
long_running_operation = cluster_connection.undelete_cluster(
project_id, zone, cluster_id)
If you don't know which zone you want the cluster in, create a
Cluster
without one and then make a ListZones
request
to choose one:
cluster = Cluster(project_id, None, cluster_id)
cluster_connection = cluster._cluster_conn
# Returns a
# (gcloud_bigtable._generated.bigtable_cluster_service_messages_pb2.
# ListZonesResponse)
list_zones_response = cluster_connection.list_zones(
cluster.cluster_id)
zone_choices = [zone.display_name
for zone in list_zones_response.zones]
# Found the best choice! The 4th zone.
cluster.zone = zone_choices[3]
Low-level Responses
These are low-level because list_of_clusters
will be a
ListClustersResponse
, long_running_operation
will be a
long-running Operation
and list_zones_response
will be a
ListZonesResponse