Skip to content

Commit f0e4858

Browse files
committed
Merge pull request #1275 from dhermes/finalize-bigtable-cluster
Put finishing touches on Bigtable Cluster.
2 parents ea97822 + bd5690e commit f0e4858

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

gcloud/bigtable/cluster.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ def finished(self):
227227
class Cluster(object):
228228
"""Representation of a Google Cloud Bigtable Cluster.
229229
230+
We can use a :class:`Cluster` to:
231+
232+
* :meth:`reload` itself
233+
* :meth:`create` itself
234+
* :meth:`update` itself
235+
* :meth:`delete` itself
236+
* :meth:`undelete` itself
237+
238+
.. note::
239+
240+
For now, we leave out the ``default_storage_type`` (an enum)
241+
which if not sent will end up as :data:`.data_pb2.STORAGE_SSD`.
242+
230243
:type zone: str
231244
:param zone: The name of the zone where the cluster resides.
232245
@@ -386,7 +399,7 @@ def create(self):
386399
request_pb, self._client.timeout_seconds)
387400

388401
op_id, op_begin = _process_operation(cluster_pb.current_operation)
389-
return Operation('create', op_id, op_begin)
402+
return Operation('create', op_id, op_begin, cluster=self)
390403

391404
def update(self):
392405
"""Update this cluster.
@@ -417,7 +430,7 @@ def update(self):
417430
request_pb, self._client.timeout_seconds)
418431

419432
op_id, op_begin = _process_operation(cluster_pb.current_operation)
420-
return Operation('update', op_id, op_begin)
433+
return Operation('update', op_id, op_begin, cluster=self)
421434

422435
def delete(self):
423436
"""Delete this cluster.
@@ -480,7 +493,7 @@ def undelete(self):
480493
request_pb, self._client.timeout_seconds)
481494

482495
op_id, op_begin = _process_operation(operation_pb2)
483-
return Operation('undelete', op_id, op_begin)
496+
return Operation('undelete', op_id, op_begin, cluster=self)
484497

485498
def list_tables(self):
486499
"""List the tables in this cluster.

gcloud/bigtable/test_cluster.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ def test_create(self):
384384
client._cluster_stub = stub = _FakeStub(response_pb)
385385

386386
# Create expected_result.
387-
expected_result = MUT.Operation('create', op_id, op_begin)
387+
expected_result = MUT.Operation('create', op_id, op_begin,
388+
cluster=cluster)
388389

389390
# Create the mocks.
390391
prep_create_called = []
@@ -452,7 +453,8 @@ def test_update(self):
452453
# Create expected_result.
453454
op_id = 5678
454455
op_begin = object()
455-
expected_result = MUT.Operation('update', op_id, op_begin)
456+
expected_result = MUT.Operation('update', op_id, op_begin,
457+
cluster=cluster)
456458

457459
# Create mocks
458460
process_operation_called = []
@@ -541,7 +543,8 @@ def test_undelete(self):
541543
# Create expected_result.
542544
op_id = 5678
543545
op_begin = object()
544-
expected_result = MUT.Operation('undelete', op_id, op_begin)
546+
expected_result = MUT.Operation('undelete', op_id, op_begin,
547+
cluster=cluster)
545548

546549
# Create the mocks.
547550
process_operation_called = []

0 commit comments

Comments
 (0)