def row(self, row_key, filter_=None, append=False): """Factory to create a row associated with this table. .. warning:: At most one of ``filter_`` and ``append`` can be used in a :class:`Row`. :type row_key: bytes :param row_key: The key for the row being created. :type filter_: :class:`.RowFilter` :param filter_: (Optional) Filter to be used for conditional mutations. See :class:`.DirectRow` for more details. :type append: bool :param append: (Optional) Flag to determine if the row should be used for append mutations. :rtype: :class:`.DirectRow` :returns: A row owned by this table. :raises: :class:`ValueError <exceptions.ValueError>` if both ``filter_`` and ``append`` are used. """ if append and filter_ is not None: raise ValueError('At most one of filter_ and append can be set') if append: return AppendRow(row_key, self) elif filter_ is not None: return ConditionalRow(row_key, self, filter_=filter_) else: return DirectRow(row_key, self)
def row(self, row_key, filter_=None, append=False): """Factory to create a row associated with this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_table_row] :end-before: [END bigtable_table_row] .. warning:: At most one of ``filter_`` and ``append`` can be used in a :class:`~google.cloud.bigtable.row.Row`. :type row_key: bytes :param row_key: The key for the row being created. :type filter_: :class:`.RowFilter` :param filter_: (Optional) Filter to be used for conditional mutations. See :class:`.ConditionalRow` for more details. :type append: bool :param append: (Optional) Flag to determine if the row should be used for append mutations. :rtype: :class:`~google.cloud.bigtable.row.Row` :returns: A row owned by this table. :raises: :class:`ValueError <exceptions.ValueError>` if both ``filter_`` and ``append`` are used. """ warnings.warn( "This method will be deprecated in future versions. Please " "use Table.append_row(), Table.conditional_row() " "and Table.direct_row() methods instead.", PendingDeprecationWarning, stacklevel=2, ) if append and filter_ is not None: raise ValueError("At most one of filter_ and append can be set") if append: return AppendRow(row_key, self) elif filter_ is not None: return ConditionalRow(row_key, self, filter_=filter_) else: return DirectRow(row_key, self)
def conditional_row(self, row_key, filter_): """Create a :class:`~google.cloud.bigtable.row.ConditionalRow` associated with this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_table_conditional_row] :end-before: [END bigtable_table_conditional_row] Args: row_key (bytes): The key for the row being created. filter_ (:class:`.RowFilter`): (Optional) Filter to be used for conditional mutations. See :class:`.ConditionalRow` for more details. Returns: A row owned by this table. """ return ConditionalRow(row_key, self, filter_=filter_)
def test_test_wrong_row_type(self): from google.cloud.bigtable.row import ConditionalRow row = ConditionalRow(row_key=b'row_key', table='table', filter_=None) with self.assertRaises(TypeError): self._call_fut(row)
def _make_conditional_row(*args, **kwargs): from google.cloud.bigtable.row import ConditionalRow return ConditionalRow(*args, **kwargs)