2.42.0 (latest) 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.1 2.29.0 2.28.1 2.26.0 2.25.0 2.24.0 2.23.1 2.22.0 2.21.0 2.20.0 2.19.0 2.18.1 2.17.0 2.16.0 2.15.0 2.14.1 2.13.2 2.12.0 2.11.3 2.10.1 2.9.0 2.8.1 2.7.1 2.6.0 2.5.2 2.4.0 2.3.3 2.2.0 2.1.0 2.0.0 1.7.3 1.6.1 1.5.1 1.4.0 1.3.0 1.2.1 1.1.0 1.0.0 0.34.0

    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` itself
- `create` itself
- `update` itself
- `delete` itself

> [!NOTE]
> **Note:** For now, we leave out the `default_storage_type` (an enum) which if not sent will end up as :data:`.data_v2_pb2.STORAGE_SSD`.

| ## Parameters ||
|---|---|
| **Name** | **Description** |
| `instance_id` | `str` The ID of the instance. |
| `client` | `https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.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:`google.cloud.bigtable.enums.Instance.Type.PRODUCTION`. :data:`google.cloud.bigtable.enums.Instance.Type.DEVELOPMENT`, Defaults to :data:`google.cloud.bigtable.enums.Instance.Type.UNSPECIFIED`. |
| `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` (`OutputOnly`) The current state of the instance. Possible values are represented by the following constants: :data:`google.cloud.bigtable.enums.Instance.State.STATE_NOT_KNOWN`. :data:`google.cloud.bigtable.enums.Instance.State.READY`. :data:`google.cloud.bigtable.enums.Instance.State.CREATING`. |

## Properties

### name

<br />

Instance name used in requests.

<br />

> [!NOTE]
> **Note:** This property will not change if `instance_id` does not, but the return value is not cached.

For example:

<br />

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_instance_name\]
:end-before: \[END bigtable_api_instance_name\]
:dedent: 4

The instance name is of the form

<br />

    `"projects/{project}/instances/{instance_id}"`

| **Returns** ||
|---|---|
| **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_api_instance_state\]
:end-before: \[END bigtable_api_instance_state\]
:dedent: 4

## Methods

### app_profile

    app_profile(
        app_profile_id,
        routing_policy_type=None,
        description=None,
        cluster_id=None,
        multi_cluster_ids=None,
        allow_transactional_writes=None,
    )

Factory to create AppProfile associated with this instance.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_create_app_profile\]
:end-before: \[END bigtable_api_create_app_profile\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `app_profile_id` | `str` The ID of the AppProfile. Must be of the form `` `<code>_a-zA-Z0-9][-_.a-zA-Z0-9]</code>* ```. :type: routing_policy_type: int :param: routing_policy_type: The type of the routing policy. Possible values are represented by the following constants: :data:`google.cloud.bigtable.enums.RoutingPolicyType.ANY` :data:`google.cloud.bigtable.enums.RoutingPolicyType.SINGLE\` :type: description: str :param: description: (Optional) Long form description of the use case for this AppProfile. :type: cluster_id: str :param: cluster_id: (Optional) Unique cluster_id which is only required when routing_policy_type is ROUTING_POLICY_TYPE_SINGLE. :type: multi_cluster_ids: list :param: multi_cluster_ids: (Optional) The set of clusters to route to. The order is ignored; clusters will be tried in order of distance. If left empty, all clusters are eligible. :type: allow_transactional_writes: bool :param: allow_transactional_writes: (Optional) If true, allow transactional writes for ROUTING_POLICY_TYPE_SINGLE. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.app_profile.AppProfile` | AppProfile for this instance. |

### cluster

    cluster(
        cluster_id,
        location_id=None,
        serve_nodes=None,
        default_storage_type=None,
        kms_key_name=None,
        min_serve_nodes=None,
        max_serve_nodes=None,
        cpu_utilization_percent=None,
    )

Factory to create a cluster associated with this instance.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_create_cluster\]
:end-before: \[END bigtable_api_create_cluster\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `cluster_id` | `str` The ID of the cluster. |
| `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-0google-0com.linkedin.net.nz/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:`google.cloud.bigtable.enums.StorageType.SSD`. :data:`google.cloud.bigtable.enums.StorageType.HDD`, Defaults to :data:`google.cloud.bigtable.enums.StorageType.UNSPECIFIED`. |
| `kms_key_name` | `str` (Optional, Creation Only) The name of the KMS customer managed encryption key (CMEK) to use for at-rest encryption of data in this cluster. If omitted, Google's default encryption will be used. If specified, the requirements for this key are: 1) The Cloud Bigtable service account associated with the project that contains the cluster must be granted the `cloudkms.cryptoKeyEncrypterDecrypter` role on the CMEK. 2) Only regional keys can be used and the region of the CMEK key must match the region of the cluster. 3) All clusters within an instance must use the same CMEK key. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Cluster` | a cluster owned by this instance. |

### create

    create(
        location_id=None,
        serve_nodes=None,
        default_storage_type=None,
        clusters=None,
        min_serve_nodes=None,
        max_serve_nodes=None,
        cpu_utilization_percent=None,
    )

Create this instance.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_create_prod_instance\]
:end-before: \[END bigtable_api_create_prod_instance\]
:dedent: 4

> [!NOTE]
> **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 .. code:: python instance.display_name = 'New display name' instance.instance_id = 'i-changed-my-mind' before calling `create`.

| **Parameters** ||
|---|---|
| **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-0google-0com.linkedin.net.nz/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:`google.cloud.bigtable.enums.StorageType.SSD`. :data:`google.cloud.bigtable.enums.StorageType.HDD`, Defaults to :data:`google.cloud.bigtable.enums.StorageType.UNSPECIFIED`. |
| `clusters` | ```` class:```[``https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.cluster.Cluster]` ```` List of clusters to be created. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `google.api_core.operation.Operation` `` | The long-running operation corresponding to the create operation. |

### delete

    delete()

Delete this instance.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_delete_instance\]
:end-before: \[END bigtable_api_delete_instance\]
:dedent: 4

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_api_check_instance_exists\]
:end-before: \[END bigtable_api_check_instance_exists\]
:dedent: 4

| **Returns** ||
|---|---|
| **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_api_instance_from_pb\]
:end-before: \[END bigtable_api_instance_from_pb\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `instance_pb` | `` `instance.Instance` `` An instance protobuf object. |
| `client` | `https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client` The client that owns the instance. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `Instance` `` | The instance parsed from the protobuf response. |

### get_iam_policy

    get_iam_policy(requested_policy_version=None)

Gets the access control policy for an instance resource.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_get_iam_policy\]
:end-before: \[END bigtable_api_get_iam_policy\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `requested_policy_version` | `` int or `NoneType` `` Optional. The version of IAM policies to request. If a policy with a condition is requested without setting this, the server will return an error. This must be set to a value of 3 to retrieve IAM policies containing conditions. This is to prevent client code that isn't aware of IAM conditions from interpreting and modifying policies incorrectly. The service might return a policy with version lower than the one that was requested, based on the feature syntax in the policy fetched. |

| **Returns** ||
|---|---|
| **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_api_list_app_profiles\]
:end-before: \[END bigtable_api_list_app_profiles\]
:dedent: 4

| **Returns** ||
|---|---|
| **Type** | **Description** |
| ``:list:[`https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.app_profile.AppProfile`]`` | A :list:\[`https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.app_profile.AppProfile`\]. By default, this is a list of [AppProfile](https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.app_profile.AppProfile) instances. |

### list_clusters

    list_clusters()

List the clusters in this instance.

For example:

.. literalinclude:: snippets.py
:start-after: \[START bigtable_api_list_clusters_on_instance\]
:end-before: \[END bigtable_api_list_clusters_on_instance\]
:dedent: 4

| **Returns** ||
|---|---|
| **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_api_list_tables\]
:end-before: \[END bigtable_api_list_tables\]
:dedent: 4

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `list of https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.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_api_reload_instance\]
:end-before: \[END bigtable_api_reload_instance\]
:dedent: 4

### 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_api_set_iam_policy\]
:end-before: \[END bigtable_api_set_iam_policy\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `policy` | `Policy` A new IAM policy to replace the current IAM policy of this instance |

| **Returns** ||
|---|---|
| **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_api_create_table\]
:end-before: \[END bigtable_api_create_table\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `table_id` | `str` The ID of the table. |
| `mutation_timeout` | `int` (Optional) The overriding mutation timeout. |
| `app_profile_id` | `str` (Optional) The unique name of the AppProfile. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs-0cloud-0google-0com.linkedin.net.nz/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.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_api_test_iam_permissions\]
:end-before: \[END bigtable_api_test_iam_permissions\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `permissions` | `list` The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.* ') are not allowed. For more information see `IAM Overview https://cloud-0google-0com.linkedin.net.nz/iam/docs/overview#permissions`*. `Bigtable Permissions https://cloud-0google-0com.linkedin.net.nz/bigtable/docs/access-control`*. |

| **Returns** ||
|---|---|
| **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_api_update_instance\]
:end-before: \[END bigtable_api_update_instance\]
:dedent: 4

> [!NOTE]
> **Note:** Updates any or all of the following values: `display_name` `type` `labels` To change a value before updating, assign that values via .. code:: python instance.display_name = 'New display name' before calling `update`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `google.api_core.operation.Operation` `` | The long-running operation corresponding to the update operation. |