Exemplo n.º 1
0
    def list_column_families(self, timeout_seconds=None):
        """Check if this table exists.

        :type timeout_seconds: int
        :param timeout_seconds: Number of seconds for request time-out.
                                If not passed, defaults to value set on table.

        :rtype: dictionary with string as keys and
                :class:`.column_family.ColumnFamily` as values
        :returns: List of column families attached to this table.
        :raises: :class:`ValueError <exceptions.ValueError>` if the column
                 family name from the response does not agree with the computed
                 name from the column family ID.
        """
        request_pb = messages_pb2.GetTableRequest(name=self.name)
        timeout_seconds = timeout_seconds or self.timeout_seconds
        response = self.client.table_stub.GetTable.async(request_pb,
                                                         timeout_seconds)
        # We expect a `._generated.bigtable_table_data_pb2.Table`
        table_pb = response.result()

        result = {}
        for column_family_id, value_pb in table_pb.column_families.items():
            gc_rule = _gc_rule_from_pb(value_pb.gc_rule)
            column_family = self.column_family(column_family_id,
                                               gc_rule=gc_rule)
            if column_family.name != value_pb.name:
                raise ValueError('Column family name %s does not agree with '
                                 'name from request: %s.' % (
                                     column_family.name, value_pb.name))
            result[column_family_id] = column_family
        return result
    def _callFUT(self, gc_rule_pb):
        from gcloud_bigtable.column_family import _gc_rule_from_pb

        return _gc_rule_from_pb(gc_rule_pb)