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', delegate_to=None, impersonation_chain=None)[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(self, instance_id, project_id)[source]¶
Retrieves and returns the specified Cloud Bigtable instance if it exists. Otherwise, returns None.
- delete_instance(self, instance_id, project_id)[source]¶
Deletes the specified Cloud Bigtable instance. Raises google.api_core.exceptions.NotFound if the Cloud Bigtable instance does not exist.
- create_instance(self, instance_id, main_cluster_id, main_cluster_zone, project_id, replica_clusters=None, instance_display_name=None, instance_type=enums.Instance.Type.TYPE_UNSPECIFIED, instance_labels=None, cluster_nodes=None, cluster_storage_type=enums.StorageType.STORAGE_TYPE_UNSPECIFIED, timeout=None)[source]¶
Creates 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 (Optional[List[Dict[str, str]]]) -- (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_admin_v2.enums.Instance.Type) -- (optional) The type of the instance.
instance_display_name (Optional[str]) -- (optional) Human-readable name of the instance. Defaults to
instance_id
.instance_labels (Optional[Dict]) -- (optional) Dictionary of labels to associate with the instance.
cluster_nodes (Optional[int]) -- (optional) Number of nodes for cluster.
cluster_storage_type (google.cloud.bigtable_admin_v2.enums.StorageType) -- (optional) The type of storage.
timeout (Optional[float]) -- (optional) timeout (in seconds) for instance creation. If None is not specified, Operator will wait indefinitely.
- update_instance(self, 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 (Optional[str]) -- (optional) Human-readable name of the instance.
instance_type (Optional[Union[google.cloud.bigtable_admin_v2.enums.Instance.Type, enum.IntEnum]]) -- (optional) The type of the instance.
instance_labels (Optional[Dict]) -- (optional) Dictionary of labels to associate with the instance.
timeout (Optional[float]) -- (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]¶
Creates 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 (Optional[List]) -- (Optional) A list of row keys in bytes to use to initially split the table.
column_families (Optional[Dict[str, google.cloud.bigtable.column_family.GarbageCollectionRule]]) -- (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(self, instance_id, table_id, project_id)[source]¶
Deletes the specified table in Cloud Bigtable. Raises google.api_core.exceptions.NotFound if the table does not exist.
- Parameters
- static update_cluster(instance, cluster_id, nodes)[source]¶
Updates 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]¶
Fetches 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]¶
Fetches 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.