def create_table( instance: Instance, table_id: str, initial_split_keys: Optional[List] = None, column_families: Optional[Dict[str, GarbageCollectionRule]] = None ) -> None: """ Creates the specified Cloud Bigtable table. Raises ``google.api_core.exceptions.AlreadyExists`` if the table exists. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the table. :type table_id: str :param table_id: The ID of the table to create in Cloud Bigtable. :type initial_split_keys: list :param initial_split_keys: (Optional) A list of row keys in bytes to use to initially split the table. :type column_families: dict :param column_families: (Optional) A map of columns to create. The key is the column_id str, and the value is a :class:`google.cloud.bigtable.column_family.GarbageCollectionRule`. """ if column_families is None: column_families = {} if initial_split_keys is None: initial_split_keys = [] table = Table(table_id, instance) table.create(initial_split_keys, column_families)
def create_table(instance, table_id, initial_split_keys=None, column_families=None): """ Creates the specified Cloud Bigtable table. Raises ``google.api_core.exceptions.AlreadyExists`` if the table exists. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the table. :type table_id: str :param table_id: The ID of the table to create in Cloud Bigtable. :type initial_split_keys: list :param initial_split_keys: (Optional) A list of row keys in bytes to use to initially split the table. :type column_families: dict :param column_families: (Optional) A map of columns to create. The key is the column_id str, and the value is a :class:`google.cloud.bigtable.column_family.GarbageCollectionRule`. """ if column_families is None: column_families = {} if initial_split_keys is None: initial_split_keys = [] table = Table(table_id, instance) table.create(initial_split_keys, column_families)
def get_column_families_for_table( instance: Instance, table_id: str) -> Dict[str, ColumnFamily]: """ Fetches Column Families for the specified table in Cloud Bigtable. :param instance: The Cloud Bigtable instance that owns the table. :param table_id: The ID of the table in Cloud Bigtable to fetch Column Families from. """ table = Table(table_id, instance) return table.list_column_families()
def get_cluster_states_for_table(instance: Instance, table_id: str) -> Dict[str, ClusterState]: """ Fetches Cluster States for the specified table in Cloud Bigtable. Raises google.api_core.exceptions.NotFound if the table does not exist. :param instance: The Cloud Bigtable instance that owns the table. :param table_id: The ID of the table in Cloud Bigtable to fetch Cluster States from. """ table = Table(table_id, instance) return table.get_cluster_states()
def get_column_families_for_table(instance, table_id): """ Fetches Column Families for the specified table in Cloud Bigtable. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the table. :type table_id: str :param table_id: The ID of the table in Cloud Bigtable to fetch Column Families from. """ table = Table(table_id, instance) return table.list_column_families()
def get_cluster_states_for_table(instance, table_id): """ Fetches Cluster States for the specified table in Cloud Bigtable. Raises google.api_core.exceptions.NotFound if the table does not exist. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the table. :type table_id: str :param table_id: The ID of the table in Cloud Bigtable to fetch Cluster States from. """ table = Table(table_id, instance) return table.get_cluster_states()
def delete_table(self, project_id, instance_id, table_id): """ Deletes the specified table in Cloud Bigtable. Raises google.api_core.exceptions.NotFound if the table does not exist. :type project_id: str :param project_id: The ID of the GCP project. :type instance_id: str :param instance_id: The ID of the Cloud Bigtable instance. :type table_id: str :param table_id: The ID of the table in Cloud Bigtable. """ instance = Instance(instance_id, self.get_client(project_id)) table = Table(table_id, instance) table.delete()
def table(self, 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 :type table_id: str :param table_id: The ID of the table. :type mutation_timeout: int :param mutation_timeout: (Optional) The overriding mutation timeout. :type app_profile_id: str :param app_profile_id: (Optional) The unique name of the AppProfile. :rtype: :class:`Table <google.cloud.bigtable.table.Table>` :returns: The table owned by this instance. """ return Table( table_id, self, app_profile_id=app_profile_id, mutation_timeout=mutation_timeout, )
def create_table(self, instance, table_id, initial_split_keys, column_families): """ Creates the specified Cloud Bigtable table. Raises google.api_core.exceptions.AlreadyExists if the table exists. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the table. :type table_id: str :param table_id: The ID of the table to create in Cloud Bigtable. :type initial_split_keys: list :param initial_split_keys: (Optional) A list of row keys in bytes to use to initially split the table. :type column_families: dict :param column_families: (Optional) A map of columns to create. The key is the column_id str, and the value is a GarbageCollectionRule. """ table = Table(table_id, instance) table.create(initial_split_keys, column_families)
def table(self, table_id): """Factory to create a table associated with this instance. :type table_id: str :param table_id: The ID of the table. :rtype: :class:`Table <google.cloud.bigtable.table.Table>` :returns: The table owned by this instance. """ return Table(table_id, self)
def table(self, table_id, app_profile_id=None): """Factory to create a table associated with this instance. :type table_id: str :param table_id: The ID of the table. :type app_profile_id: str :param app_profile_id: (Optional) The unique name of the AppProfile. :rtype: :class:`Table <google.cloud.bigtable.table.Table>` :returns: The table owned by this instance. """ return Table(table_id, self, app_profile_id=app_profile_id)
def setUp(self): client = MagicMock() instance = Instance(self._INSTANCE_ID, client) self.table = Table(self._TABLE_ID, instance)