|
| 1 | +Cluster Admin API |
| 2 | +================= |
| 3 | + |
| 4 | +After creating a :class:`Client <gcloud.bigtable.client.Client>`, you can |
| 5 | +interact with individual clusters, groups of clusters or available |
| 6 | +zones for a project. |
| 7 | + |
| 8 | +List Clusters |
| 9 | +------------- |
| 10 | + |
| 11 | +If you want a comprehensive list of all existing clusters, make a |
| 12 | +`ListClusters`_ API request with |
| 13 | +:meth:`Client.list_clusters() <gcloud.bigtable.client.Client.list_clusters>`: |
| 14 | + |
| 15 | +.. code:: python |
| 16 | +
|
| 17 | + clusters = client.list_clusters() |
| 18 | +
|
| 19 | +List Zones |
| 20 | +---------- |
| 21 | + |
| 22 | +If you aren't sure which ``zone`` to create a cluster in, find out |
| 23 | +which zones your project has access to with a `ListZones`_ API request |
| 24 | +with :meth:`Client.list_zones() <gcloud.bigtable.client.Client.list_zones>`: |
| 25 | + |
| 26 | +.. code:: python |
| 27 | +
|
| 28 | + zones = client.list_zones() |
| 29 | +
|
| 30 | +You can choose a :class:`string <str>` from among the result to pass to |
| 31 | +the :class:`Cluster <gcloud.bigtable.cluster.Cluster>` constructor. |
| 32 | + |
| 33 | +The available zones (as of February 2016) are |
| 34 | + |
| 35 | +.. code:: python |
| 36 | +
|
| 37 | + >>> zones |
| 38 | + [u'asia-east1-b', u'europe-west1-c', u'us-central1-c', u'us-central1-b'] |
| 39 | +
|
| 40 | +Cluster Factory |
| 41 | +--------------- |
| 42 | + |
| 43 | +To create a :class:`Cluster <gcloud.bigtable.cluster.Cluster>` object: |
| 44 | + |
| 45 | +.. code:: python |
| 46 | +
|
| 47 | + cluster = client.cluster(zone, cluster_id, |
| 48 | + display_name=display_name, |
| 49 | + serve_nodes=3) |
| 50 | +
|
| 51 | +Both ``display_name`` and ``serve_nodes`` are optional. When not provided, |
| 52 | +``display_name`` defaults to the ``cluster_id`` value and ``serve_nodes`` |
| 53 | +defaults to the minimum allowed: |
| 54 | +:data:`DEFAULT_SERVE_NODES <gcloud.bigtable.cluster.DEFAULT_SERVE_NODES>`. |
| 55 | + |
| 56 | +Even if this :class:`Cluster <gcloud.bigtable.cluster.Cluster>` already |
| 57 | +has been created with the API, you'll want this object to use as a |
| 58 | +parent of a :class:`Table <gcloud.bigtable.table.Table>` just as the |
| 59 | +:class:`Client <gcloud.bigtable.client.Client>` is used as the parent of |
| 60 | +a :class:`Cluster <gcloud.bigtable.cluster.Cluster>`. |
| 61 | + |
| 62 | +Create a new Cluster |
| 63 | +-------------------- |
| 64 | + |
| 65 | +After creating the cluster object, make a `CreateCluster`_ API request |
| 66 | +with :meth:`create() <gcloud.bigtable.cluster.Cluster.create>`: |
| 67 | + |
| 68 | +.. code:: python |
| 69 | +
|
| 70 | + cluster.display_name = 'My very own cluster' |
| 71 | + cluster.create() |
| 72 | +
|
| 73 | +If you would like more than the minimum number of nodes |
| 74 | +(:data:`DEFAULT_SERVE_NODES <gcloud.bigtable.cluster.DEFAULT_SERVE_NODES>`) |
| 75 | +in your cluster: |
| 76 | + |
| 77 | +.. code:: python |
| 78 | +
|
| 79 | + cluster.serve_nodes = 10 |
| 80 | + cluster.create() |
| 81 | +
|
| 82 | +Check on Current Operation |
| 83 | +-------------------------- |
| 84 | + |
| 85 | +.. note:: |
| 86 | + |
| 87 | + When modifying a cluster (via a `CreateCluster`_, `UpdateCluster`_ or |
| 88 | + `UndeleteCluster`_ request), the Bigtable API will return a long-running |
| 89 | + `Operation`_. This will be stored on the object after each of |
| 90 | + :meth:`create() <gcloud.bigtable.cluster.Cluster.create>`, |
| 91 | + :meth:`update() <gcloud.bigtable.cluster.Cluster.update>` and |
| 92 | + :meth:`undelete() <gcloud.bigtable.cluster.Cluster.undelete>` are called. |
| 93 | + |
| 94 | +You can check if a long-running operation (for a |
| 95 | +:meth:`create() <gcloud.bigtable.cluster.Cluster.create>`, |
| 96 | +:meth:`update() <gcloud.bigtable.cluster.Cluster.update>` or |
| 97 | +:meth:`undelete() <gcloud.bigtable.cluster.Cluster.undelete>`) has finished |
| 98 | +by making a `GetOperation`_ request with |
| 99 | +:meth:`Operation.finished() <gcloud.bigtable.cluster.Operation.finished>`: |
| 100 | + |
| 101 | +.. code:: python |
| 102 | +
|
| 103 | + >>> operation = cluster.create() |
| 104 | + >>> operation.finished() |
| 105 | + True |
| 106 | +
|
| 107 | +.. note:: |
| 108 | + |
| 109 | + Once an :class:`Operation <gcloud.bigtable.cluster.Operation>` object |
| 110 | + has returned :data:`True` from |
| 111 | + :meth:`finished() <gcloud.bigtable.cluster.Operation.finished>`, the |
| 112 | + object should not be re-used. Subsequent calls to |
| 113 | + :meth:`finished() <gcloud.bigtable.cluster.Operation.finished>` |
| 114 | + will result in a :class:`ValueError <exceptions.ValueError>`. |
| 115 | + |
| 116 | +Get metadata for an existing Cluster |
| 117 | +------------------------------------ |
| 118 | + |
| 119 | +After creating the cluster object, make a `GetCluster`_ API request |
| 120 | +with :meth:`reload() <gcloud.bigtable.cluster.Cluster.reload>`: |
| 121 | + |
| 122 | +.. code:: python |
| 123 | +
|
| 124 | + cluster.reload() |
| 125 | +
|
| 126 | +This will load ``serve_nodes`` and ``display_name`` for the existing |
| 127 | +``cluster`` in addition to the ``cluster_id``, ``zone`` and ``project`` |
| 128 | +already set on the :class:`Cluster <gcloud.bigtable.cluster.Cluster>` object. |
| 129 | + |
| 130 | +Update an existing Cluster |
| 131 | +-------------------------- |
| 132 | + |
| 133 | +After creating the cluster object, make an `UpdateCluster`_ API request |
| 134 | +with :meth:`update() <gcloud.bigtable.cluster.Cluster.update>`: |
| 135 | + |
| 136 | +.. code:: python |
| 137 | +
|
| 138 | + client.display_name = 'New display_name' |
| 139 | + cluster.update() |
| 140 | +
|
| 141 | +Delete an existing Cluster |
| 142 | +-------------------------- |
| 143 | + |
| 144 | +Make a `DeleteCluster`_ API request with |
| 145 | +:meth:`delete() <gcloud.bigtable.cluster.Cluster.delete>`: |
| 146 | + |
| 147 | +.. code:: python |
| 148 | +
|
| 149 | + cluster.delete() |
| 150 | +
|
| 151 | +Undelete a deleted Cluster |
| 152 | +-------------------------- |
| 153 | + |
| 154 | +Make an `UndeleteCluster`_ API request with |
| 155 | +:meth:`undelete() <gcloud.bigtable.cluster.Cluster.undelete>`: |
| 156 | + |
| 157 | +.. code:: python |
| 158 | +
|
| 159 | + cluster.undelete() |
| 160 | +
|
| 161 | +Next Step |
| 162 | +--------- |
| 163 | + |
| 164 | +Now we go down the hierarchy from |
| 165 | +:class:`Cluster <gcloud.bigtable.cluster.Cluster>` to a |
| 166 | +:class:`Table <gcloud.bigtable.table.Table>`. |
| 167 | + |
| 168 | +Head next to learn about the :doc:`bigtable-table-api`. |
| 169 | + |
| 170 | +.. _Cluster Admin API: https://cloud.google.com/bigtable/docs/creating-cluster |
| 171 | +.. _CreateCluster: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L66-L68 |
| 172 | +.. _GetCluster: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L38-L40 |
| 173 | +.. _UpdateCluster: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L93-L95 |
| 174 | +.. _DeleteCluster: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L109-L111 |
| 175 | +.. _ListZones: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L33-L35 |
| 176 | +.. _ListClusters: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L44-L46 |
| 177 | +.. _GetOperation: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/longrunning/operations.proto#L43-L45 |
| 178 | +.. _UndeleteCluster: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto#L126-L128 |
| 179 | +.. _Operation: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/longrunning/operations.proto#L73-L102 |
0 commit comments