airflow.providers.google.cloud.hooks.bigtable¶
此模組包含 Google Cloud Bigtable Hook。
類¶
Google Cloud Bigtable API 的 Hook。 |
模組內容¶
- class airflow.providers.google.cloud.hooks.bigtable.BigtableHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]¶
基類:
airflow.providers.google.common.hooks.base_google.GoogleBaseHookGoogle Cloud Bigtable API 的 Hook。
Hook 中所有使用 project_id 的方法必須使用關鍵字引數呼叫,而非位置引數。
- delete_instance(instance_id, project_id)[source]¶
刪除指定的 Cloud Bigtable 例項。
如果 Cloud Bigtable 例項不存在,則引發 google.api_core.exceptions.NotFound 異常。
- 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]¶
建立新例項。
- 引數:
instance_id (str) – 新例項的 ID。
main_cluster_id (str) – 新例項主叢集的 ID。
main_cluster_zone (str) – 主叢集的區域。更多詳情請參見 https://cloud.google.com/bigtable/docs/locations。
project_id (str) – 可選,BigTable 所在的 Google Cloud 專案 ID。如果設定為 None 或缺失,將使用 Google Cloud 連線中的預設 project_id。
replica_clusters (list[dict[str, str]] | None) – (可選)新例項的副本叢集列表。每個叢集字典包含一個 id 和一個 zone。示例:[{“id”: “replica-1”, “zone”: “us-west1-a”}]
instance_type (google.cloud.bigtable.enums.Instance.Type) – (可選)例項的型別。
instance_display_name (str | None) – (可選)例項的人類可讀名稱。預設為
instance_id。instance_labels (dict | None) – (可選)與例項關聯的標籤字典。
cluster_nodes (int | None) – (可選)叢集的節點數。
cluster_storage_type (google.cloud.bigtable.enums.StorageType) – (可選)儲存型別。
timeout (float | None) – (可選)例項建立的超時時間(秒)。如果未指定 None,Operator 將無限期等待。
- update_instance(instance_id, project_id, instance_display_name=None, instance_type=None, instance_labels=None, timeout=None)[source]¶
更新現有例項。
- 引數:
instance_id (str) – 現有例項的 ID。
project_id (str) – 可選,BigTable 所在的 Google Cloud 專案 ID。如果設定為 None 或缺失,將使用 Google Cloud 連線中的預設 project_id。
instance_display_name (str | None) – (可選)例項的人類可讀名稱。
instance_type (google.cloud.bigtable.enums.Instance.Type | enum.IntEnum | None) – (可選)例項的型別。
instance_labels (dict | None) – (可選)與例項關聯的標籤字典。
timeout (float | None) – (可選)例項更新的超時時間(秒)。如果未指定 None,Operator 將無限期等待。
- static create_table(instance, table_id, initial_split_keys=None, column_families=None)[source]¶
建立指定的 Cloud Bigtable 表。
如果表已存在,則引發
google.api_core.exceptions.AlreadyExists異常。- 引數:
instance (google.cloud.bigtable.instance.Instance) – 擁有該表的 Cloud Bigtable 例項。
table_id (str) – 要在 Cloud Bigtable 中建立的表的 ID。
initial_split_keys (list | None) – (可選)用於初始拆分表的行鍵(位元組)列表。
column_families (dict[str, google.cloud.bigtable.column_family.GarbageCollectionRule] | None) – (可選)要建立的列的對映。鍵是 column_id 字串,值是
google.cloud.bigtable.column_family.GarbageCollectionRule。
- delete_table(instance_id, table_id, project_id)[source]¶
刪除 Cloud Bigtable 中指定的表。
如果表不存在,則引發 google.api_core.exceptions.NotFound 異常。
- static update_cluster(instance, cluster_id, nodes)[source]¶
更新指定的 Cloud Bigtable 叢集中的節點數。
如果叢集不存在,則引發 google.api_core.exceptions.NotFound 異常。
- 引數:
instance (google.cloud.bigtable.instance.Instance) – 擁有該叢集的 Cloud Bigtable 例項。
cluster_id (str) – 叢集的 ID。
nodes (int) – 所需的節點數。
- static get_column_families_for_table(instance, table_id)[source]¶
獲取 Cloud Bigtable 中指定表的列族。
- 引數:
instance (google.cloud.bigtable.instance.Instance) – 擁有該表的 Cloud Bigtable 例項。
table_id (str) – 要獲取列族的 Cloud Bigtable 中表的 ID。
- static get_cluster_states_for_table(instance, table_id)[source]¶
獲取 Cloud Bigtable 中指定表的叢集狀態。
如果表不存在,則引發 google.api_core.exceptions.NotFound 異常。
- 引數:
instance (google.cloud.bigtable.instance.Instance) – 擁有該表的 Cloud Bigtable 例項。
table_id (str) – 要獲取叢集狀態的 Cloud Bigtable 中表的 ID。