Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put finishing touches on Bigtable Cluster. #1275

Merged
merged 1 commit into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions gcloud/bigtable/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ def finished(self):
class Cluster(object):
"""Representation of a Google Cloud Bigtable Cluster.

We can use a :class:`Cluster` to:

* :meth:`reload` itself
* :meth:`create` itself
* :meth:`update` itself
* :meth:`delete` itself
* :meth:`undelete` itself

.. note::

For now, we leave out the ``default_storage_type`` (an enum)
which if not sent will end up as :data:`.data_pb2.STORAGE_SSD`.

:type zone: str
:param zone: The name of the zone where the cluster resides.

Expand Down Expand Up @@ -386,7 +399,7 @@ def create(self):
request_pb, self._client.timeout_seconds)

op_id, op_begin = _process_operation(cluster_pb.current_operation)
return Operation('create', op_id, op_begin)
return Operation('create', op_id, op_begin, cluster=self)

def update(self):
"""Update this cluster.
Expand Down Expand Up @@ -417,7 +430,7 @@ def update(self):
request_pb, self._client.timeout_seconds)

op_id, op_begin = _process_operation(cluster_pb.current_operation)
return Operation('update', op_id, op_begin)
return Operation('update', op_id, op_begin, cluster=self)

def delete(self):
"""Delete this cluster.
Expand Down Expand Up @@ -480,7 +493,7 @@ def undelete(self):
request_pb, self._client.timeout_seconds)

op_id, op_begin = _process_operation(operation_pb2)
return Operation('undelete', op_id, op_begin)
return Operation('undelete', op_id, op_begin, cluster=self)

def list_tables(self):
"""List the tables in this cluster.
Expand Down
9 changes: 6 additions & 3 deletions gcloud/bigtable/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ def test_create(self):
client._cluster_stub = stub = _FakeStub(response_pb)

# Create expected_result.
expected_result = MUT.Operation('create', op_id, op_begin)
expected_result = MUT.Operation('create', op_id, op_begin,
cluster=cluster)

# Create the mocks.
prep_create_called = []
Expand Down Expand Up @@ -452,7 +453,8 @@ def test_update(self):
# Create expected_result.
op_id = 5678
op_begin = object()
expected_result = MUT.Operation('update', op_id, op_begin)
expected_result = MUT.Operation('update', op_id, op_begin,
cluster=cluster)

# Create mocks
process_operation_called = []
Expand Down Expand Up @@ -541,7 +543,8 @@ def test_undelete(self):
# Create expected_result.
op_id = 5678
op_begin = object()
expected_result = MUT.Operation('undelete', op_id, op_begin)
expected_result = MUT.Operation('undelete', op_id, op_begin,
cluster=cluster)

# Create the mocks.
process_operation_called = []
Expand Down