Skip to content

Latest commit

 

History

History
130 lines (88 loc) · 5.01 KB

instance-api.rst

File metadata and controls

130 lines (88 loc) · 5.01 KB

Instance Admin API

After creating a Client <google.cloud.bigtable.client.Client>, you can interact with individual instances for a project.

List Instances

If you want a comprehensive list of all existing instances, make a ListInstances API request with Client.list_instances() <google.cloud.bigtable.client.Client.list_instances>:

instances = client.list_instances()

Instance Factory

To create an Instance <google.cloud.bigtable.instance.Instance> object:

instance = client.instance(instance_id, display_name=display_name)
  • display_name is optional. When not provided, display_name defaults to the instance_id value.

You can also use Client.instance to create a local wrapper for instances that have already been created with the API, or through the web console:

instance = client.instance(existing_instance_id)
instance.reload()

Create a new Instance

After creating the instance object, make a CreateInstance API request with create() <google.cloud.bigtable.instance.Instance.create>:

instance.display_name = 'My very own instance'
instance.create()

Check on Current Operation

Note

When modifying an instance (via a CreateInstance request), the Bigtable API will return a long-running operation and a corresponding Operation <google.cloud.bigtable.instance.Operation> object will be returned by create() <google.cloud.bigtable.instance.Instance.create>.

You can check if a long-running operation (for a create() <google.cloud.bigtable.instance.Instance.create> has finished by making a GetOperation request with Operation.finished() <google.cloud.bigtable.instance.Operation.finished>:

>>> operation = instance.create()
>>> operation.finished()
True

Note

Once an Operation <google.cloud.bigtable.instance.Operation> object has returned True from finished() <google.cloud.bigtable.instance.Operation.finished>, the object should not be re-used. Subsequent calls to finished() <google.cloud.bigtable.instance.Operation.finished> will result in a ValueError <exceptions.ValueError>.

Get metadata for an existing Instance

After creating the instance object, make a GetInstance API request with reload() <google.cloud.bigtable.instance.Instance.reload>:

instance.reload()

This will load display_name for the existing instance object.

Update an existing Instance

After creating the instance object, make an UpdateInstance API request with update() <google.cloud.bigtable.instance.Instance.update>:

instance.display_name = 'New display_name'
instance.update()

Delete an existing Instance

Make a DeleteInstance API request with delete() <google.cloud.bigtable.instance.Instance.delete>:

instance.delete()

Next Step

Now we go down the hierarchy from Instance <google.cloud.bigtable.instance.Instance> to a Table <google.cloud.bigtable.table.Table>.

Head next to learn about the table-api.