5454 'of enabled / disabled tables.' )
5555
5656
57- def _get_cluster (timeout = None ):
58- """Gets cluster for the default project.
57+ def _get_instance (timeout = None ):
58+ """Gets instance for the default project.
5959
6060 Creates a client with the inferred credentials and project ID from
6161 the local environment. Then uses
62- :meth:`.bigtable.client.Client.list_clusters ` to
63- get the unique cluster owned by the project.
62+ :meth:`.bigtable.client.Client.list_instances ` to
63+ get the unique instance owned by the project.
6464
65- If the request fails for any reason, or if there isn't exactly one cluster
65+ If the request fails for any reason, or if there isn't exactly one instance
6666 owned by the project, then this function will fail.
6767
6868 :type timeout: int
6969 :param timeout: (Optional) The socket timeout in milliseconds.
7070
71- :rtype: :class:`gcloud.bigtable.cluster.Cluster `
72- :returns: The unique cluster owned by the project inferred from
71+ :rtype: :class:`gcloud.bigtable.instance.Instance `
72+ :returns: The unique instance owned by the project inferred from
7373 the environment.
7474 :raises: :class:`ValueError <exceptions.ValueError>` if there is a failed
75- zone or any number of clusters other than one.
75+ location or any number of instances other than one.
7676 """
7777 client_kwargs = {'admin' : True }
7878 if timeout is not None :
7979 client_kwargs ['timeout_seconds' ] = timeout / 1000.0
8080 client = Client (** client_kwargs )
8181 try :
8282 client .start ()
83- clusters , failed_zones = client .list_clusters ()
83+ instances , failed_locations = client .list_instances ()
8484 finally :
8585 client .stop ()
8686
87- if len (failed_zones ) != 0 :
88- raise ValueError ('Determining cluster via ListClusters encountered '
89- 'failed zones .' )
90- if len (clusters ) == 0 :
91- raise ValueError ('This client doesn\' t have access to any clusters .' )
92- if len (clusters ) > 1 :
93- raise ValueError ('This client has access to more than one cluster . '
94- 'Please directly pass the cluster you\' d '
87+ if len (failed_locations ) != 0 :
88+ raise ValueError ('Determining instance via ListInstances encountered '
89+ 'failed locations .' )
90+ if len (instances ) == 0 :
91+ raise ValueError ('This client doesn\' t have access to any instances .' )
92+ if len (instances ) > 1 :
93+ raise ValueError ('This client has access to more than one instance . '
94+ 'Please directly pass the instance you\' d '
9595 'like to use.' )
96- return clusters [0 ]
96+ return instances [0 ]
9797
9898
9999class Connection (object ):
100100 """Connection to Cloud Bigtable backend.
101101
102102 .. note::
103103
104- If you pass a ``cluster ``, it will be :meth:`.Cluster .copy`-ed before
104+ If you pass a ``instance ``, it will be :meth:`.Instance .copy`-ed before
105105 being stored on the new connection. This also copies the
106106 :class:`Client <gcloud.bigtable.client.Client>` that created the
107- :class:`Cluster <gcloud.bigtable.cluster.Cluster >` instance and the
107+ :class:`Instance <gcloud.bigtable.instance.Instance >` instance and the
108108 :class:`Credentials <oauth2client.client.Credentials>` stored on the
109109 client.
110110
@@ -127,27 +127,27 @@ class Connection(object):
127127 :param table_prefix_separator: (Optional) Separator used with
128128 ``table_prefix``. Defaults to ``_``.
129129
130- :type cluster : :class:`Cluster <gcloud.bigtable.cluster.Cluster >`
131- :param cluster : (Optional) A Cloud Bigtable cluster . The instance also
130+ :type instance : :class:`Instance <gcloud.bigtable.instance.Instance >`
131+ :param instance : (Optional) A Cloud Bigtable instance . The instance also
132132 owns a client for making gRPC requests to the Cloud
133133 Bigtable API. If not passed in, defaults to creating client
134134 with ``admin=True`` and using the ``timeout`` here for the
135135 ``timeout_seconds`` argument to the
136136 :class:`Client <gcloud.bigtable.client.Client>`
137137 constructor. The credentials for the client
138138 will be the implicit ones loaded from the environment.
139- Then that client is used to retrieve all the clusters
139+ Then that client is used to retrieve all the instances
140140 owned by the client's project.
141141
142142 :type kwargs: dict
143143 :param kwargs: Remaining keyword arguments. Provided for HappyBase
144144 compatibility.
145145 """
146146
147- _cluster = None
147+ _instance = None
148148
149149 def __init__ (self , timeout = None , autoconnect = True , table_prefix = None ,
150- table_prefix_separator = '_' , cluster = None , ** kwargs ):
150+ table_prefix_separator = '_' , instance = None , ** kwargs ):
151151 self ._handle_legacy_args (kwargs )
152152 if table_prefix is not None :
153153 if not isinstance (table_prefix , six .string_types ):
@@ -162,13 +162,13 @@ def __init__(self, timeout=None, autoconnect=True, table_prefix=None,
162162 self .table_prefix = table_prefix
163163 self .table_prefix_separator = table_prefix_separator
164164
165- if cluster is None :
166- self ._cluster = _get_cluster (timeout = timeout )
165+ if instance is None :
166+ self ._instance = _get_instance (timeout = timeout )
167167 else :
168168 if timeout is not None :
169169 raise ValueError ('Timeout cannot be used when an existing '
170- 'cluster is passed' )
171- self ._cluster = cluster .copy ()
170+ 'instance is passed' )
171+ self ._instance = instance .copy ()
172172
173173 if autoconnect :
174174 self .open ()
@@ -203,23 +203,23 @@ def open(self):
203203
204204 This method opens the underlying HTTP/2 gRPC connection using a
205205 :class:`Client <gcloud.bigtable.client.Client>` bound to the
206- :class:`Cluster <gcloud.bigtable.cluster.Cluster >` owned by
206+ :class:`Instance <gcloud.bigtable.instance.Instance >` owned by
207207 this connection.
208208 """
209- self ._cluster ._client .start ()
209+ self ._instance ._client .start ()
210210
211211 def close (self ):
212212 """Close the underlying transport to Cloud Bigtable.
213213
214214 This method closes the underlying HTTP/2 gRPC connection using a
215215 :class:`Client <gcloud.bigtable.client.Client>` bound to the
216- :class:`Cluster <gcloud.bigtable.cluster.Cluster >` owned by
216+ :class:`Instance <gcloud.bigtable.instance.Instance >` owned by
217217 this connection.
218218 """
219- self ._cluster ._client .stop ()
219+ self ._instance ._client .stop ()
220220
221221 def __del__ (self ):
222- if self ._cluster is not None :
222+ if self ._instance is not None :
223223 self .close ()
224224
225225 def _table_name (self , name ):
@@ -258,7 +258,7 @@ def tables(self):
258258
259259 .. note::
260260
261- This lists every table in the cluster owned by this connection,
261+ This lists every table in the instance owned by this connection,
262262 **not** every table that a given user may have access to.
263263
264264 .. note::
@@ -269,7 +269,7 @@ def tables(self):
269269 :rtype: list
270270 :returns: List of string table names.
271271 """
272- low_level_table_instances = self ._cluster .list_tables ()
272+ low_level_table_instances = self ._instance .list_tables ()
273273 table_names = [table_instance .table_id
274274 for table_instance in low_level_table_instances ]
275275
@@ -345,7 +345,7 @@ def create_table(self, name, families):
345345
346346 # Create table instance and then make API calls.
347347 name = self ._table_name (name )
348- low_level_table = _LowLevelTable (name , self ._cluster )
348+ low_level_table = _LowLevelTable (name , self ._instance )
349349 try :
350350 low_level_table .create ()
351351 except face .NetworkError as network_err :
@@ -376,7 +376,7 @@ def delete_table(self, name, disable=False):
376376 _WARN (_DISABLE_DELETE_MSG )
377377
378378 name = self ._table_name (name )
379- _LowLevelTable (name , self ._cluster ).delete ()
379+ _LowLevelTable (name , self ._instance ).delete ()
380380
381381 def enable_table (self , name ):
382382 """Enable the specified table.
0 commit comments