Skip to content

Commit 90cd2e7

Browse files
authored
Merge pull request #1923 from tseaver/bigtable-v2-instance_admin
Support V2 instance admin
2 parents 3b48e0f + 9880a42 commit 90cd2e7

17 files changed

+2248
-1265
lines changed

docs/bigtable-client-intro.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Configuration
6363
Admin API Access
6464
----------------
6565

66-
If you'll be using your client to make `Cluster Admin`_ and `Table Admin`_
66+
If you'll be using your client to make `Instance Admin`_ and `Table Admin`_
6767
API requests, you'll need to pass the ``admin`` argument:
6868

6969
.. code:: python
@@ -89,10 +89,10 @@ Next Step
8989
---------
9090

9191
After a :class:`Client <gcloud.bigtable.client.Client>`, the next highest-level
92-
object is a :class:`Cluster <gcloud.bigtable.cluster.Cluster>`. You'll need
92+
object is a :class:`Instance <gcloud.bigtable.instance.Instance>`. You'll need
9393
one before you can interact with tables or data.
9494

95-
Head next to learn about the :doc:`bigtable-cluster-api`.
95+
Head next to learn about the :doc:`bigtable-instance-api`.
9696

97-
.. _Cluster Admin: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/tree/master/bigtable-protos/src/main/proto/google/bigtable/admin/cluster/v1
97+
.. _Instance Admin: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/tree/master/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1
9898
.. _Table Admin: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/tree/master/bigtable-protos/src/main/proto/google/bigtable/admin/table/v1

docs/bigtable-cluster-api.rst

Lines changed: 0 additions & 187 deletions
This file was deleted.

docs/bigtable-instance-api.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
Instance Admin API
2+
==================
3+
4+
.. warning::
5+
6+
gRPC is required for using the Cloud Bigtable API. As of May 2016,
7+
``grpcio`` is only supported in Python 2.7, so importing
8+
:mod:`gcloud.bigtable` in other versions of Python will fail.
9+
10+
After creating a :class:`Client <gcloud.bigtable.client.Client>`, you can
11+
interact with individual instances for a project.
12+
13+
List Intances
14+
-------------
15+
16+
If you want a comprehensive list of all existing intances, make a
17+
`ListInstances`_ API request with
18+
:meth:`Client.list_intances() <gcloud.bigtable.client.Client.list_intances>`:
19+
20+
.. code:: python
21+
22+
intances = client.list_intances()
23+
24+
Instance Factory
25+
----------------
26+
27+
To create a :class:`Instance <gcloud.bigtable.instance.Instance>` object:
28+
29+
.. code:: python
30+
31+
instance = client.instance(instance_id, display_name=display_name)
32+
33+
``display_name`` is optional. When not provided,
34+
``display_name`` defaults to the ``instance_id`` value.
35+
36+
Even if this :class:`Instance <gcloud.bigtable.instance.Instance>` already
37+
has been created with the API, you'll want this object to use as a
38+
parent of a :class:`Table <gcloud.bigtable.table.Table>` just as the
39+
:class:`Client <gcloud.bigtable.client.Client>` is used as the parent of
40+
a :class:`Instance <gcloud.bigtable.instance.Instance>`.
41+
42+
Create a new Instance
43+
---------------------
44+
45+
After creating the instance object, make a `CreateInstance`_ API request
46+
with :meth:`create() <gcloud.bigtable.instance.Instance.create>`:
47+
48+
.. code:: python
49+
50+
instance.display_name = 'My very own instance'
51+
instance.create()
52+
53+
Check on Current Operation
54+
--------------------------
55+
56+
.. note::
57+
58+
When modifying a instance (via a `CreateInstance`_ request), the Bigtable
59+
API will return a `long-running operation`_ and a corresponding
60+
:class:`Operation <gcloud.bigtable.instance.Operation>` object
61+
will be returned by
62+
:meth:`create() <gcloud.bigtable.instance.Instance.create>``.
63+
64+
You can check if a long-running operation (for a
65+
:meth:`create() <gcloud.bigtable.instance.Instance.create>` has finished
66+
by making a `GetOperation`_ request with
67+
:meth:`Operation.finished() <gcloud.bigtable.instance.Operation.finished>`:
68+
69+
.. code:: python
70+
71+
>>> operation = instance.create()
72+
>>> operation.finished()
73+
True
74+
75+
.. note::
76+
77+
Once an :class:`Operation <gcloud.bigtable.instance.Operation>` object
78+
has returned :data:`True` from
79+
:meth:`finished() <gcloud.bigtable.instance.Operation.finished>`, the
80+
object should not be re-used. Subsequent calls to
81+
:meth:`finished() <gcloud.bigtable.instance.Operation.finished>`
82+
will result in a :class:`ValueError <exceptions.ValueError>`.
83+
84+
Get metadata for an existing Instance
85+
-------------------------------------
86+
87+
After creating the instance object, make a `GetInstance`_ API request
88+
with :meth:`reload() <gcloud.bigtable.instance.Instance.reload>`:
89+
90+
.. code:: python
91+
92+
instance.reload()
93+
94+
This will load ``display_name`` for the existing ``instance`` object.
95+
96+
Update an existing Instance
97+
---------------------------
98+
99+
After creating the instance object, make an `UpdateInstance`_ API request
100+
with :meth:`update() <gcloud.bigtable.instance.Instance.update>`:
101+
102+
.. code:: python
103+
104+
client.display_name = 'New display_name'
105+
instance.update()
106+
107+
Delete an existing Instance
108+
---------------------------
109+
110+
Make a `DeleteInstance`_ API request with
111+
:meth:`delete() <gcloud.bigtable.instance.Instance.delete>`:
112+
113+
.. code:: python
114+
115+
instance.delete()
116+
117+
Next Step
118+
---------
119+
120+
Now we go down the hierarchy from
121+
:class:`Instance <gcloud.bigtable.instance.Instance>` to a
122+
:class:`Table <gcloud.bigtable.table.Table>`.
123+
124+
Head next to learn about the :doc:`bigtable-table-api`.
125+
126+
.. _Instance Admin API: https://cloud.google.com/bigtable/docs/creating-instance
127+
.. _CreateInstance: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1/bigtable_instance_service.proto#L66-L68
128+
.. _GetInstance: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1/bigtable_instance_service.proto#L38-L40
129+
.. _UpdateInstance: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1/bigtable_instance_service.proto#L93-L95
130+
.. _DeleteInstance: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1/bigtable_instance_service.proto#L109-L111
131+
.. _ListInstances: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/bigtable/admin/instance/v1/bigtable_instance_service.proto#L44-L46
132+
.. _GetOperation: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/longrunning/operations.proto#L43-L45
133+
.. _long-running operation: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/2aae624081f652427052fb652d3ae43d8ac5bf5a/bigtable-protos/src/main/proto/google/longrunning/operations.proto#L73-L102

docs/bigtable-instance.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Instance
2+
~~~~~~~~
3+
4+
.. warning::
5+
6+
gRPC is required for using the Cloud Bigtable API. As of May 2016,
7+
``grpcio`` is only supported in Python 2.7, so importing
8+
:mod:`gcloud.bigtable` in other versions of Python will fail.
9+
10+
.. automodule:: gcloud.bigtable.instance
11+
:members:
12+
:show-inheritance:

docs/bigtable-table-api.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Table Admin API
77
``grpcio`` is only supported in Python 2.7, so importing
88
:mod:`gcloud.bigtable` in other versions of Python will fail.
99

10-
After creating a :class:`Cluster <gcloud.bigtable.cluster.Cluster>`, you can
10+
After creating a :class:`Instance <gcloud.bigtable.instance.Instance>`, you can
1111
interact with individual tables, groups of tables or column families within
1212
a table.
1313

1414
List Tables
1515
-----------
1616

17-
If you want a comprehensive list of all existing tables in a cluster, make a
17+
If you want a comprehensive list of all existing tables in a instance, make a
1818
`ListTables`_ API request with
19-
:meth:`Cluster.list_tables() <gcloud.bigtable.cluster.Cluster.list_tables>`:
19+
:meth:`Instance.list_tables() <gcloud.bigtable.instance.Instance.list_tables>`:
2020

2121
.. code:: python
2222
23-
>>> cluster.list_tables()
23+
>>> instance.list_tables()
2424
[<gcloud.bigtable.table.Table at 0x7ff6a1de8f50>,
2525
<gcloud.bigtable.table.Table at 0x7ff6a1de8350>]
2626
@@ -31,7 +31,7 @@ To create a :class:`Table <gcloud.bigtable.table.Table>` object:
3131

3232
.. code:: python
3333
34-
table = cluster.table(table_id)
34+
table = instance.table(table_id)
3535
3636
Even if this :class:`Table <gcloud.bigtable.table.Table>` already
3737
has been created with the API, you'll want this object to use as a

0 commit comments

Comments
 (0)