airflow.providers.google.cloud.hooks.bigtable
¶
This module contains a Google Cloud Bigtable Hook.
Module Contents¶
Classes¶
Hook for Google Cloud Bigtable APIs. |
- class airflow.providers.google.cloud.hooks.bigtable.BigtableHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]¶
Bases:
airflow.providers.google.common.hooks.base_google.GoogleBaseHook
Hook for Google Cloud Bigtable APIs.
All the methods in the hook where project_id is used must be called with keyword arguments rather than positional.
- get_instance(instance_id, project_id)[source]¶
Retrieve and returns the specified Cloud Bigtable instance if it exists, otherwise returns None.
- delete_instance(instance_id, project_id)[source]¶
Delete the specified Cloud Bigtable instance.
Raises google.api_core.exceptions.NotFound if the Cloud Bigtable instance does not exist.
- create_instance(instance_id, main_cluster_id, main_cluster_zone, project_id, replica_clusters=None, instance_display_name=None, instance_type=enums.Instance.Type.UNSPECIFIED, instance_labels=None, cluster_nodes=None, cluster_storage_type=enums.StorageType.UNSPECIFIED, timeout=None)[source]¶
Create new instance.
- Parameters
instance_id (str) – The ID for the new instance.
main_cluster_id (str) – The ID for main cluster for the new instance.
main_cluster_zone (str) – The zone for main cluster. See https://cloud.google.com/bigtable/docs/locations for more details.
project_id (str) – Optional, Google Cloud project ID where the BigTable exists. If set to None or missing, the default project_id from the Google Cloud connection is used.
replica_clusters (list[dict[str, str]] | None) – (optional) A list of replica clusters for the new instance. Each cluster dictionary contains an id and a zone. Example: [{“id”: “replica-1”, “zone”: “us-west1-a”}]
instance_type (google.cloud.bigtable.enums.Instance.Type) – (optional) The type of the instance.
instance_display_name (str | None) – (optional) Human-readable name of the instance. Defaults to
instance_id
.instance_labels (dict | None) – (optional) Dictionary of labels to associate with the instance.
cluster_nodes (int | None) – (optional) Number of nodes for cluster.
cluster_storage_type (google.cloud.bigtable.enums.StorageType) – (optional) The type of storage.
timeout (float | None) – (optional) timeout (in seconds) for instance creation. If None is not specified, Operator will wait indefinitely.
- update_instance(instance_id, project_id, instance_display_name=None, instance_type=None, instance_labels=None, timeout=None)[source]¶
Update an existing instance.
- Parameters
instance_id (str) – The ID for the existing instance.
project_id (str) – Optional, Google Cloud project ID where the BigTable exists. If set to None or missing, the default project_id from the Google Cloud connection is used.
instance_display_name (str | None) – (optional) Human-readable name of the instance.
instance_type (google.cloud.bigtable.enums.Instance.Type | enum.IntEnum | None) – (optional) The type of the instance.
instance_labels (dict | None) – (optional) Dictionary of labels to associate with the instance.
timeout (float | None) – (optional) timeout (in seconds) for instance update. If None is not specified, Operator will wait indefinitely.
- static create_table(instance, table_id, initial_split_keys=None, column_families=None)[source]¶
Create the specified Cloud Bigtable table.
Raises
google.api_core.exceptions.AlreadyExists
if the table exists.- Parameters
instance (google.cloud.bigtable.instance.Instance) – The Cloud Bigtable instance that owns the table.
table_id (str) – The ID of the table to create in Cloud Bigtable.
initial_split_keys (list | None) – (Optional) A list of row keys in bytes to use to initially split the table.
column_families (dict[str, google.cloud.bigtable.column_family.GarbageCollectionRule] | None) – (Optional) A map of columns to create. The key is the column_id str, and the value is a
google.cloud.bigtable.column_family.GarbageCollectionRule
.
- delete_table(instance_id, table_id, project_id)[source]¶
Delete the specified table in Cloud Bigtable.
Raises google.api_core.exceptions.NotFound if the table does not exist.
- static update_cluster(instance, cluster_id, nodes)[source]¶
Update number of nodes in the specified Cloud Bigtable cluster.
Raises google.api_core.exceptions.NotFound if the cluster does not exist.
- Parameters
instance (google.cloud.bigtable.instance.Instance) – The Cloud Bigtable instance that owns the cluster.
cluster_id (str) – The ID of the cluster.
nodes (int) – The desired number of nodes.
- static get_column_families_for_table(instance, table_id)[source]¶
Fetch Column Families for the specified table in Cloud Bigtable.
- Parameters
instance (google.cloud.bigtable.instance.Instance) – The Cloud Bigtable instance that owns the table.
table_id (str) – The ID of the table in Cloud Bigtable to fetch Column Families from.
- static get_cluster_states_for_table(instance, table_id)[source]¶
Fetch Cluster States for the specified table in Cloud Bigtable.
Raises google.api_core.exceptions.NotFound if the table does not exist.
- Parameters
instance (google.cloud.bigtable.instance.Instance) – The Cloud Bigtable instance that owns the table.
table_id (str) – The ID of the table in Cloud Bigtable to fetch Cluster States from.