-
Notifications
You must be signed in to change notification settings - Fork 65
feat: initializing the new data client #1238
Changes from 5 commits
406ae29
f1e03e6
abc9b51
ca1b715
e534cc2
0afdbf2
39ae646
7f49237
d173efe
225df82
7a7e8e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,9 +34,7 @@ | |
| from google.api_core.gapic_v1 import client_info as client_info_lib | ||
| from google.auth.credentials import AnonymousCredentials # type: ignore | ||
|
|
||
| from google.cloud import bigtable_v2 | ||
| from google.cloud.bigtable import admin | ||
| from google.cloud.bigtable_v2.services.bigtable.transports import BigtableGrpcTransport | ||
| from google.cloud.bigtable.admin.services.bigtable_instance_admin.transports import ( | ||
| BigtableInstanceAdminGrpcTransport, | ||
| ) | ||
|
|
@@ -54,6 +52,11 @@ | |
| from google.cloud.bigtable.cluster import _CLUSTER_NAME_RE | ||
| from google.cloud.environment_vars import BIGTABLE_EMULATOR # type: ignore | ||
|
|
||
| from google.cloud.bigtable.data import BigtableDataClient | ||
| from google.cloud.bigtable.data._helpers import ( | ||
| _DEFAULT_BIGTABLE_EMULATOR_CLIENT, | ||
| ) | ||
|
daniel-sanche marked this conversation as resolved.
|
||
|
|
||
|
|
||
| INSTANCE_TYPE_PRODUCTION = instance.Instance.Type.PRODUCTION | ||
| INSTANCE_TYPE_DEVELOPMENT = instance.Instance.Type.DEVELOPMENT | ||
|
|
@@ -66,7 +69,6 @@ | |
| READ_ONLY_SCOPE = "https://www.googleapis.com/auth/bigtable.data.readonly" | ||
| """Scope for reading table data.""" | ||
|
|
||
| _DEFAULT_BIGTABLE_EMULATOR_CLIENT = "google-cloud-bigtable-emulator" | ||
| _GRPC_CHANNEL_OPTIONS = ( | ||
| ("grpc.max_send_message_length", -1), | ||
| ("grpc.max_receive_message_length", -1), | ||
|
|
@@ -290,18 +292,7 @@ def table_data_client(self): | |
| :rtype: :class:`.bigtable_v2.BigtableClient` | ||
| :returns: A BigtableClient object. | ||
| """ | ||
| if self._table_data_client is None: | ||
| transport = self._create_gapic_client_channel( | ||
| bigtable_v2.BigtableClient, | ||
| BigtableGrpcTransport, | ||
| ) | ||
| klass = _create_gapic_client( | ||
| bigtable_v2.BigtableClient, | ||
| client_options=self._client_options, | ||
| transport=transport, | ||
| ) | ||
| self._table_data_client = klass(self) | ||
| return self._table_data_client | ||
| return self._data_client._gapic_client | ||
|
|
||
| @property | ||
| def table_admin_client(self): | ||
|
|
@@ -369,6 +360,19 @@ def instance_admin_client(self): | |
| self._instance_admin_client = klass(self) | ||
| return self._instance_admin_client | ||
|
|
||
| @property | ||
| def _data_client(self): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: having |
||
| """Getter for the new Data Table API.""" | ||
| if self._table_data_client is None: | ||
| self._table_data_client = BigtableDataClient( | ||
| project=self.project, | ||
| credentials=self._credentials, | ||
| client_options=self._client_options, | ||
| _client_info=self._client_info, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking we should customize the What do you think? (Maybe ping Mattie?) |
||
| _disable_background_channel_refresh=True, | ||
| ) | ||
| return self._table_data_client | ||
|
|
||
| def instance(self, instance_id, display_name=None, instance_type=None, labels=None): | ||
| """Factory to create a instance associated with this client. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,15 @@ def __init__(self, table_id, instance, mutation_timeout=None, app_profile_id=Non | |
| self._app_profile_id = app_profile_id | ||
| self.mutation_timeout = mutation_timeout | ||
|
|
||
| self._table_impl = ( | ||
| self._instance._client._data_client.get_table( | ||
| self._instance.instance_id, | ||
| self.table_id, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing app_profile_id. And maybe |
||
| ) | ||
| if self._instance | ||
| else None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need I don't think we'd ever want this to be None, right? |
||
| ) | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Table name used in requests. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.