Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Implementing Bigtable Cluster.list_tables().#1269
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,8 @@ | ||
| from gcloud.bigtable._generated import bigtable_cluster_data_pb2 as data_pb2 | ||
| from gcloud.bigtable._generated import ( | ||
| bigtable_cluster_service_messages_pb2 as messages_pb2) | ||
| from gcloud.bigtable._generated import ( | ||
| bigtable_table_service_messages_pb2 as table_messages_pb2) | ||
| from gcloud.bigtable.table import Table | ||
| @@ -346,3 +348,27 @@ def delete(self): | ||
| # We expect a `._generated.empty_pb2.Empty` | ||
| self._client._cluster_stub.DeleteCluster( | ||
| request_pb, self._client.timeout_seconds) | ||
| def list_tables(self): | ||
| """List the tables in this cluster. | ||
| :rtype: list of :class:`Table <gcloud.bigtable.table.Table>` | ||
| :returns: The list of tables owned by the cluster. | ||
| :raises: :class:`ValueError <exceptions.ValueError>` if one of the | ||
| returned tables has a name that is not of the expected format. | ||
| """ | ||
| request_pb = table_messages_pb2.ListTablesRequest(name=self.name) | ||
| # We expect a `table_messages_pb2.ListTablesResponse` | ||
| table_list_pb = self._client._table_stub.ListTables( | ||
| request_pb, self._client.timeout_seconds) | ||
| result = [] | ||
| for table_pb in table_list_pb.tables: | ||
| table_prefix = self.name + '/tables/' | ||
| if not table_pb.name.startswith(table_prefix): | ||
| raise ValueError('Table name %s not of expected format' % ( | ||
| table_pb.name,)) | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| table_id = table_pb.name[len(table_prefix):] | ||
| result.append(self.table(table_id)) | ||
| return result | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.