airflow.providers.google.cloud.hooks.bigtable

This module contains a Google Cloud Bigtable Hook.

Module Contents

Classes

BigtableHook

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.

Parameters
  • instance_id (str) -- The ID of the Cloud Bigtable 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.

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.

Parameters
  • 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_id (str) -- The ID of the Cloud Bigtable instance.

create_instance(self, instance_id, main_cluster_id, main_cluster_zone, project_id, replica_clusters=None, replica_cluster_id=None, replica_cluster_zone=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"}]

  • replica_cluster_id (Optional[str]) -- (deprecated) The ID for replica cluster for the new instance.

  • replica_cluster_zone (Optional[str]) -- (deprecated) The zone for replica cluster.

  • 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
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
  • instance_id (str) -- The ID of the Cloud Bigtable instance.

  • table_id (str) -- The ID of the table in Cloud Bigtable.

  • 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.

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
static get_column_families_for_table(instance, table_id)[source]

Fetches Column Families for the specified table in Cloud Bigtable.

Parameters
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

Was this entry helpful?