After creating a :class:`Client <google.cloud.bigtable.client.Client>`, you can interact with individual instances for a project.
If you want a comprehensive list of all existing instances, make a ListInstances API request with :meth:`Client.list_instances() <google.cloud.bigtable.client.Client.list_instances>`:
instances = client.list_instances()To create an :class:`Instance <google.cloud.bigtable.instance.Instance>` object:
instance = client.instance(instance_id, location_id,
display_name=display_name)location_idis the ID of the location in which the instance's cluster will be hosted, e.g.'us-central1-c'.location_idis required for instances which do not already exist.display_nameis optional. When not provided,display_namedefaults to theinstance_idvalue.
You can also use :meth:`Client.instance` to create a local wrapper for instances that have already been created with the API, or through the web conole:
instance = client.instance(existing_instance_id)
instance.reload()After creating the instance object, make a CreateInstance API request with :meth:`create() <google.cloud.bigtable.instance.Instance.create>`:
instance.display_name = 'My very own instance'
instance.create()Note
When modifying an instance (via a CreateInstance request), the Bigtable API will return a long-running operation and a corresponding :class:`Operation <google.cloud.bigtable.instance.Operation>` object will be returned by :meth:`create() <google.cloud.bigtable.instance.Instance.create>`.
You can check if a long-running operation (for a :meth:`create() <google.cloud.bigtable.instance.Instance.create>` has finished by making a GetOperation request with :meth:`Operation.finished() <google.cloud.bigtable.instance.Operation.finished>`:
>>> operation = instance.create()
>>> operation.finished()
TrueNote
Once an :class:`Operation <google.cloud.bigtable.instance.Operation>` object has returned :data:`True` from :meth:`finished() <google.cloud.bigtable.instance.Operation.finished>`, the object should not be re-used. Subsequent calls to :meth:`finished() <google.cloud.bigtable.instance.Operation.finished>` will result in a :class:`ValueError <exceptions.ValueError>`.
After creating the instance object, make a GetInstance API request with :meth:`reload() <google.cloud.bigtable.instance.Instance.reload>`:
instance.reload()This will load display_name for the existing instance object.
After creating the instance object, make an UpdateInstance API request with :meth:`update() <google.cloud.bigtable.instance.Instance.update>`:
client.display_name = 'New display_name'
instance.update()Make a DeleteInstance API request with :meth:`delete() <google.cloud.bigtable.instance.Instance.delete>`:
instance.delete()Now we go down the hierarchy from :class:`Instance <google.cloud.bigtable.instance.Instance>` to a :class:`Table <google.cloud.bigtable.table.Table>`.
Head next to learn about the :doc:`bigtable-table-api`.