|
| 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 |
0 commit comments