Instance#

User-friendly container for Google Cloud Bigtable Instance.

class google.cloud.bigtable.instance.Instance(instance_id, client, location_id='see-existing-cluster', display_name=None, serve_nodes=3)[source]#

Bases: object

Representation of a Google Cloud Bigtable Instance.

We can use an Instance to:

Note

For now, we leave out the default_storage_type (an enum) which if not sent will end up as data_v2_pb2.STORAGE_SSD.

Parameters:
  • instance_id (str) – The ID of the instance.
  • client (Client) – The client that owns the instance. Provides authorization and a project ID.
  • location_id (str) – ID of the location in which the instance will be created. Required for instances which do not yet exist.
  • display_name (str) – (Optional) The display name for the instance in the Cloud Console UI. (Must be between 4 and 30 characters.) If this value is not set in the constructor, will fall back to the instance ID.
  • serve_nodes (int) – (Optional) The number of nodes in the instance’s cluster; used to set up the instance’s cluster.
cluster(cluster_id, serve_nodes=3)[source]#

Factory to create a cluster associated with this client.

Parameters:
  • cluster_id (str) – The ID of the cluster.
  • serve_nodes (int) – (Optional) The number of nodes in the cluster. Defaults to 3.
Return type:

Cluster

Returns:

The cluster owned by this client.

copy()[source]#

Make a copy of this instance.

Copies the local data stored as simple types and copies the client attached to this instance.

Return type:Instance
Returns:A copy of the current instance.
create()[source]#

Create this instance.

Note

Uses the project and instance_id on the current Instance in addition to the display_name. To change them before creating, reset the values via

instance.display_name = 'New display name'
instance.instance_id = 'i-changed-my-mind'

before calling create().

Return type:Operation
Returns:The long-running operation corresponding to the create operation.
delete()[source]#

Delete this instance.

Marks an instance and all of its tables for permanent deletion in 7 days.

Immediately upon completion of the request:

  • Billing will cease for all of the instance’s reserved resources.
  • The instance’s delete_time field will be set 7 days in the future.

Soon afterward:

  • All tables within the instance will become unavailable.

At the instance’s delete_time:

  • The instance and all of its tables will immediately and irrevocably disappear from the API, and their data will be permanently deleted.
classmethod from_pb(instance_pb, client)[source]#

Creates an instance instance from a protobuf.

Parameters:
  • instance_pb (instance_pb2.Instance) – An instance protobuf object.
  • client (Client) – The client that owns the instance.
Return type:

Instance

Returns:

The instance parsed from the protobuf response.

Raises:

ValueError if the instance name does not match projects/{project}/instances/{instance_id} or if the parsed project ID does not match the project ID on the client.

list_clusters()[source]#

Lists clusters in this instance.

Return type:tuple
Returns:A pair of results, the first is a list of Cluster s returned and the second is a list of strings (the failed locations in the request).
list_tables()[source]#

List the tables in this instance.

Return type:list of Table
Returns:The list of tables owned by the instance.
Raises:ValueError if one of the returned tables has a name that is not of the expected format.
name#

Instance name used in requests.

Note

This property will not change if instance_id does not, but the return value is not cached.

The instance name is of the form

"projects/{project}/instances/{instance_id}"
Return type:str
Returns:The instance name.
reload()[source]#

Reload the metadata for this instance.

table(table_id)[source]#

Factory to create a table associated with this instance.

Parameters:table_id (str) – The ID of the table.
Return type:Table
Returns:The table owned by this instance.
update()[source]#

Update this instance.

Note

Updates the display_name. To change that value before updating, reset its values via

instance.display_name = 'New display name'

before calling update().