Instance#
Warning
gRPC is required for using the Cloud Bigtable API. As of May 2016,
grpcio is only supported in Python 2.7, so importing
gcloud.bigtable in other versions of Python will fail.
User friendly container for Google Cloud Bigtable Instance.
-
class
gcloud.bigtable.instance.Instance(instance_id, client, location_id='see-existing-cluster', display_name=None, serve_nodes=3)[source]# Bases:
objectRepresentation of a Google Cloud Bigtable Instance.
We can use a
Instanceto:Note
For now, we leave out the
default_storage_type(an enum) which if not sent will end up asdata_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: Return type: 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: InstanceReturns: A copy of the current instance.
-
create()[source]# Create this instance.
Note
Uses the
projectandinstance_idon the currentInstancein addition to thedisplay_name. To change them before creating, reset the values viainstance.display_name = 'New display name' instance.instance_id = 'i-changed-my-mind'
before calling
create().Return type: OperationReturns: The long-running operation corresponding to the create operation.
-
delete()[source]# Delete this instance.
Marks a 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_timefield will be set 7 days in the future.
Soon afterward:
- All tables within the instance will become unavailable.
Prior to the instance’s
delete_time:- The instance can be recovered with a call to
UndeleteInstance. - All other attempts to modify or delete the instance will be rejected.
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 a instance instance from a protobuf.
Parameters: - instance_pb (
instance_pb2.Instance) – A instance protobuf object. - client (
Client) – The client that owns the instance.
Return type: Returns: The instance parsed from the protobuf response.
Raises: ValueErrorif the instance name does not matchprojects/{project}/instances/{instance_id}or if the parsed project ID does not match the project ID on the client.- instance_pb (
-
list_clusters()[source]# Lists clusters in this instance.
Return type: tuple Returns: A pair of results, the first is a list of Clusters 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 TableReturns: The list of tables owned by the instance. Raises: ValueErrorif 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_iddoes 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.
-
class
gcloud.bigtable.instance.Operation(op_type, op_id, begin, location_id, instance=None)[source]# Bases:
objectRepresentation of a Google API Long-Running Operation.
In particular, these will be the result of operations on instances using the Cloud Bigtable API.
Parameters: - op_type (str) – The type of operation being performed. Expect
create,updateorundelete. - op_id (int) – The ID of the operation.
- begin (
datetime.datetime) – The time when the operation was started. - location_id (str) – ID of the location in which the operation is running
- instance (
Instance) – The instance that created the operation.
-
finished()[source]# Check if the operation has finished.
Return type: bool Returns: A boolean indicating if the current operation has completed. Raises: ValueErrorif the operation has already completed.
- op_type (str) – The type of operation being performed. Expect