Skip to content

Commit

Permalink
Moving some code around to stay up-to-date with gcloud-python.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Dec 1, 2015
1 parent 647bcc3 commit d864c3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 2 additions & 0 deletions gcloud_bigtable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
'Python locate the libraries.')
else:
raise

from gcloud_bigtable.client import Client
2 changes: 1 addition & 1 deletion gcloud_bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Client(object):
:class:`OAuth2Credentials <oauth2client.client.OAuth2Credentials>` or
:data:`NoneType <types.NoneType>`
:param credentials: (Optional) The OAuth2 Credentials to use for this
cluster. If not provided, defaulst to the Google
cluster. If not provided, defaults to the Google
Application Default Credentials.
:type read_only: bool
Expand Down
31 changes: 16 additions & 15 deletions gcloud_bigtable/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ def __init__(self, zone, cluster_id, client,
self._operation_id = None
self._operation_begin = None

def table(self, table_id):
"""Factory to create a table associated with this cluster.
:type table_id: str
:param table_id: The ID of the table.
:rtype: :class:`Table <gcloud_bigtable.table.Table>`
:returns: The table owned by this cluster.
"""
return Table(table_id, self)

def _update_from_pb(self, cluster_pb):
self.display_name = _get_pb_property_value(cluster_pb, 'display_name')
self.serve_nodes = _get_pb_property_value(cluster_pb, 'serve_nodes')
Expand Down Expand Up @@ -250,25 +261,15 @@ def name(self):
return (self.client.project_name + '/zones/' + self.zone +
'/clusters/' + self.cluster_id)

def table(self, table_id):
"""Factory to create a table associated with this cluster.
:type table_id: str
:param table_id: The ID of the table.
:rtype: :class:`Table <gcloud_bigtable.table.Table>`
:returns: The table owned by this cluster.
"""
return Table(table_id, self)

def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
# NOTE: This does not compare the configuration values, such as
# the serve_nodes or display_name. This is intentional, since
# the same cluster can be in different states if not
# synchronized. This suggests we should use `project`
# instead of `client` for the third comparison.
# the serve_nodes or display_name. Instead, it only compares
# identifying values zone, cluster ID and client. This is
# intentional, since the same cluster can be in different states
# if not synchronized. Clusters with similar zone/cluster
# settings but different clients can't be used in the same way.
return (other.zone == self.zone and
other.cluster_id == self.cluster_id and
other.client == self.client)
Expand Down

0 comments on commit d864c3e

Please sign in to comment.