Instance(
instance_id, client, display_name=None, instance_type=None, labels=None, _state=None
)
Representation of a Google Cloud Bigtable Instance.
We can use an Instance
to:
reload
itselfcreate
itselfupdate
itselfdelete
itself
Parameters
Name | Description |
instance_id |
str
The ID of the instance. |
client |
Client
The client that owns the instance. Provides authorization and a project ID. |
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. |
instance_type |
int
(Optional) The type of the instance. Possible values are represented by the following constants: :data: |
labels |
dict
(Optional) Labels are a flexible and lightweight mechanism for organizing cloud resources into groups that reflect a customer's organizational needs and deployment strategies. They can be used to filter resources and aggregate metrics. Label keys must be between 1 and 63 characters long. Maximum 64 labels can be associated with a given resource. Label values must be between 0 and 63 characters long. Keys and values must both be under 128 bytes. |
_state |
int
( |
Properties
name
Instance name used in requests.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_instance_name] :end-before: [END bigtable_instance_name]
The instance name is of the form
`"projects/{project}/instances/{instance_id}"`
Type | Description |
str | Return a fully-qualified instance string. |
state
google.cloud.bigtable.enums.Instance.State: state of Instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_instance_state] :end-before: [END bigtable_instance_state]
Methods
app_profile
app_profile(
app_profile_id,
routing_policy_type=None,
description=None,
cluster_id=None,
allow_transactional_writes=None,
)
Factory to create AppProfile associated with this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_create_app_profile] :end-before: [END bigtable_create_app_profile]
Name | Description |
app_profile_id |
str
The ID of the AppProfile. Must be of the form |
Type | Description |
AppProfile> | AppProfile for this instance. |
cluster
cluster(cluster_id, location_id=None, serve_nodes=None, default_storage_type=None)
Factory to create a cluster associated with this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_create_cluster] :end-before: [END bigtable_create_cluster]
Name | Description |
cluster_id |
str
The ID of the cluster. |
instance |
Instance
The instance where the cluster resides. |
location_id |
str
(Creation Only) The location where this cluster's nodes and storage reside. For best performance, clients should be located as close as possible to this cluster. For list of supported locations refer to https://cloud.google.com/bigtable/docs/locations |
serve_nodes |
int
(Optional) The number of nodes in the cluster. |
default_storage_type |
int
(Optional) The type of storage Possible values are represented by the following constants: :data: |
Type | Description |
Cluster | a cluster owned by this instance. |
create
create(
location_id=None, serve_nodes=None, default_storage_type=None, clusters=None
)
Create this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_create_prod_instance] :end-before: [END bigtable_create_prod_instance]
Name | Description |
location_id |
str
(Creation Only) The location where nodes and storage of the cluster owned by this instance reside. For best performance, clients should be located as close as possible to cluster's location. For list of supported locations refer to https://cloud.google.com/bigtable/docs/locations |
serve_nodes |
int
(Optional) The number of nodes in the instance's cluster; used to set up the instance's cluster. |
default_storage_type |
int
(Optional) The storage media type for persisting Bigtable data. Possible values are represented by the following constants: :data: |
clusters |
class:``
List of clusters to be created. |
Type | Description |
`ValueErro |
Type | Description |
| The long-running operation corresponding to the create operation. |
delete
delete()
Delete this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_delete_instance] :end-before: [END bigtable_delete_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.
exists
exists()
Check whether the instance already exists.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_check_instance_exists] :end-before: [END bigtable_check_instance_exists]
Type | Description |
bool | True if the table exists, else False. |
from_pb
from_pb(instance_pb, client)
Creates an instance instance from a protobuf.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_instance_from_pb] :end-before: [END bigtable_instance_from_pb]
Name | Description |
instance_pb |
An instance protobuf object. |
client |
Client
The client that owns the instance. |
Type | Description |
`ValueErro |
Type | Description |
| The instance parsed from the protobuf response. |
get_iam_policy
get_iam_policy()
Gets the access control policy for an instance resource.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_get_iam_policy] :end-before: [END bigtable_get_iam_policy]
Type | Description |
Policy | The current IAM policy of this instance |
list_app_profiles
list_app_profiles()
Lists information about AppProfiles in an instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_list_app_profiles] :end-before: [END bigtable_list_app_profiles]
Type | Description |
:list:[ | A :list:[AppProfile ]. By default, this is a list of AppProfile instances. |
list_clusters
list_clusters()
List the clusters in this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_list_clusters_on_instance] :end-before: [END bigtable_list_clusters_on_instance]
Type | Description |
tuple | (clusters, failed_locations), where 'clusters' is list of Cluster, and 'failed_locations' is a list of locations which could not be resolved. |
list_tables
list_tables()
List the tables in this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_list_tables] :end-before: [END bigtable_list_tables]
Type | Description |
`ValueErro |
Type | Description |
list of Table | The list of tables owned by the instance. |
reload
reload()
Reload the metadata for this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_reload_instance] :end-before: [END bigtable_reload_instance]
set_iam_policy
set_iam_policy(policy)
Sets the access control policy on an instance resource. Replaces any existing policy.
For more information about policy, please see documentation of
class google.cloud.bigtable.policy.Policy
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_set_iam_policy] :end-before: [END bigtable_set_iam_policy]
Name | Description |
policy |
Policy
A new IAM policy to replace the current IAM policy of this instance |
Type | Description |
Policy | The current IAM policy of this instance. |
table
table(table_id, mutation_timeout=None, app_profile_id=None)
Factory to create a table associated with this instance.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_create_table] :end-before: [END bigtable_create_table]
Name | Description |
table_id |
str
The ID of the table. |
app_profile_id |
str
(Optional) The unique name of the AppProfile. |
Type | Description |
Table | The table owned by this instance. |
test_iam_permissions
test_iam_permissions(permissions)
Returns permissions that the caller has on the specified instance resource.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_test_iam_permissions] :end-before: [END bigtable_test_iam_permissions]
Name | Description |
permissions |
list
The set of permissions to check for the |
Type | Description |
list | A List(string) of permissions allowed on the instance |
update
update()
Updates an instance within a project.
For example:
.. literalinclude:: snippets.py :start-after: [START bigtable_update_instance] :end-before: [END bigtable_update_instance]
Type | Description |
| The long-running operation corresponding to the update operation. |