|
49 | 49 |
|
50 | 50 | _LEGACY_ARGS = frozenset(('host', 'port', 'compat', 'transport', 'protocol')) |
51 | 51 | _WARN = warnings.warn |
| 52 | +_BASE_DISABLE = 'Cloud Bigtable has no concept of enabled / disabled tables.' |
52 | 53 | _DISABLE_DELETE_MSG = ('The disable argument should not be used in ' |
53 | | - 'delete_table(). Cloud Bigtable has no concept ' |
54 | | - 'of enabled / disabled tables.') |
| 54 | + 'delete_table(). ') + _BASE_DISABLE |
| 55 | +_ENABLE_TMPL = 'Connection.enable_table(%r) was called, but ' + _BASE_DISABLE |
| 56 | +_DISABLE_TMPL = 'Connection.disable_table(%r) was called, but ' + _BASE_DISABLE |
| 57 | +_IS_ENABLED_TMPL = ('Connection.is_table_enabled(%r) was called, but ' + |
| 58 | + _BASE_DISABLE) |
| 59 | +_COMPACT_TMPL = ('Connection.compact_table(%r, major=%r) was called, but the ' |
| 60 | + 'Cloud Bigtable API handles table compactions automatically ' |
| 61 | + 'and does not expose an API for it.') |
55 | 62 |
|
56 | 63 |
|
57 | 64 | def _get_instance(timeout=None): |
@@ -378,61 +385,70 @@ def delete_table(self, name, disable=False): |
378 | 385 | name = self._table_name(name) |
379 | 386 | _LowLevelTable(name, self._instance).delete() |
380 | 387 |
|
381 | | - def enable_table(self, name): |
| 388 | + @staticmethod |
| 389 | + def enable_table(name): |
382 | 390 | """Enable the specified table. |
383 | 391 |
|
384 | 392 | .. warning:: |
385 | 393 |
|
386 | 394 | Cloud Bigtable has no concept of enabled / disabled tables so this |
387 | | - method does not work. It is provided simply for compatibility. |
| 395 | + method does nothing. It is provided simply for compatibility. |
388 | 396 |
|
389 | | - :raises: :class:`NotImplementedError <exceptions.NotImplementedError>` |
390 | | - always |
| 397 | + :type name: str |
| 398 | + :param name: The name of the table to be enabled. |
391 | 399 | """ |
392 | | - raise NotImplementedError('The Cloud Bigtable API has no concept of ' |
393 | | - 'enabled or disabled tables.') |
| 400 | + _WARN(_ENABLE_TMPL % (name,)) |
394 | 401 |
|
395 | | - def disable_table(self, name): |
| 402 | + @staticmethod |
| 403 | + def disable_table(name): |
396 | 404 | """Disable the specified table. |
397 | 405 |
|
398 | 406 | .. warning:: |
399 | 407 |
|
400 | 408 | Cloud Bigtable has no concept of enabled / disabled tables so this |
401 | | - method does not work. It is provided simply for compatibility. |
| 409 | + method does nothing. It is provided simply for compatibility. |
402 | 410 |
|
403 | | - :raises: :class:`NotImplementedError <exceptions.NotImplementedError>` |
404 | | - always |
| 411 | + :type name: str |
| 412 | + :param name: The name of the table to be disabled. |
405 | 413 | """ |
406 | | - raise NotImplementedError('The Cloud Bigtable API has no concept of ' |
407 | | - 'enabled or disabled tables.') |
| 414 | + _WARN(_DISABLE_TMPL % (name,)) |
408 | 415 |
|
409 | | - def is_table_enabled(self, name): |
| 416 | + @staticmethod |
| 417 | + def is_table_enabled(name): |
410 | 418 | """Return whether the specified table is enabled. |
411 | 419 |
|
412 | 420 | .. warning:: |
413 | 421 |
|
414 | 422 | Cloud Bigtable has no concept of enabled / disabled tables so this |
415 | | - method does not work. It is provided simply for compatibility. |
| 423 | + method always returns :data:`True`. It is provided simply for |
| 424 | + compatibility. |
416 | 425 |
|
417 | | - :raises: :class:`NotImplementedError <exceptions.NotImplementedError>` |
418 | | - always |
| 426 | + :type name: str |
| 427 | + :param name: The name of the table to check enabled / disabled status. |
| 428 | +
|
| 429 | + :rtype: bool |
| 430 | + :returns: The value :data:`True` always. |
419 | 431 | """ |
420 | | - raise NotImplementedError('The Cloud Bigtable API has no concept of ' |
421 | | - 'enabled or disabled tables.') |
| 432 | + _WARN(_IS_ENABLED_TMPL % (name,)) |
| 433 | + return True |
422 | 434 |
|
423 | | - def compact_table(self, name, major=False): |
| 435 | + @staticmethod |
| 436 | + def compact_table(name, major=False): |
424 | 437 | """Compact the specified table. |
425 | 438 |
|
426 | 439 | .. warning:: |
427 | 440 |
|
428 | | - Cloud Bigtable does not support compacting a table, so this |
429 | | - method does not work. It is provided simply for compatibility. |
| 441 | + Cloud Bigtable supports table compactions, it just doesn't expose |
| 442 | + an API for that feature, so this method does nothing. It is |
| 443 | + provided simply for compatibility. |
| 444 | +
|
| 445 | + :type name: str |
| 446 | + :param name: The name of the table to compact. |
430 | 447 |
|
431 | | - :raises: :class:`NotImplementedError <exceptions.NotImplementedError>` |
432 | | - always |
| 448 | + :type major: bool |
| 449 | + :param major: Whether to perform a major compaction. |
433 | 450 | """ |
434 | | - raise NotImplementedError('The Cloud Bigtable API does not support ' |
435 | | - 'compacting a table.') |
| 451 | + _WARN(_COMPACT_TMPL % (name, major)) |
436 | 452 |
|
437 | 453 |
|
438 | 454 | def _parse_family_option(option): |
|
0 commit comments