google-cloud-bigtable 2.30.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. google/cloud/bigtable/__init__.py +25 -0
  2. google/cloud/bigtable/app_profile.py +377 -0
  3. google/cloud/bigtable/backup.py +490 -0
  4. google/cloud/bigtable/batcher.py +414 -0
  5. google/cloud/bigtable/client.py +475 -0
  6. google/cloud/bigtable/cluster.py +541 -0
  7. google/cloud/bigtable/column_family.py +362 -0
  8. google/cloud/bigtable/data/__init__.py +103 -0
  9. google/cloud/bigtable/data/_async/__init__.py +25 -0
  10. google/cloud/bigtable/data/_async/_mutate_rows.py +226 -0
  11. google/cloud/bigtable/data/_async/_read_rows.py +363 -0
  12. google/cloud/bigtable/data/_async/client.py +1522 -0
  13. google/cloud/bigtable/data/_async/mutations_batcher.py +534 -0
  14. google/cloud/bigtable/data/_cross_sync/__init__.py +20 -0
  15. google/cloud/bigtable/data/_cross_sync/_decorators.py +441 -0
  16. google/cloud/bigtable/data/_cross_sync/_mapping_meta.py +64 -0
  17. google/cloud/bigtable/data/_cross_sync/cross_sync.py +334 -0
  18. google/cloud/bigtable/data/_helpers.py +249 -0
  19. google/cloud/bigtable/data/_sync_autogen/_mutate_rows.py +182 -0
  20. google/cloud/bigtable/data/_sync_autogen/_read_rows.py +304 -0
  21. google/cloud/bigtable/data/_sync_autogen/client.py +1293 -0
  22. google/cloud/bigtable/data/_sync_autogen/mutations_batcher.py +449 -0
  23. google/cloud/bigtable/data/exceptions.py +340 -0
  24. google/cloud/bigtable/data/execute_query/__init__.py +43 -0
  25. google/cloud/bigtable/data/execute_query/_async/__init__.py +13 -0
  26. google/cloud/bigtable/data/execute_query/_async/execute_query_iterator.py +291 -0
  27. google/cloud/bigtable/data/execute_query/_byte_cursor.py +123 -0
  28. google/cloud/bigtable/data/execute_query/_checksum.py +43 -0
  29. google/cloud/bigtable/data/execute_query/_parameters_formatting.py +155 -0
  30. google/cloud/bigtable/data/execute_query/_query_result_parsing_utils.py +134 -0
  31. google/cloud/bigtable/data/execute_query/_reader.py +122 -0
  32. google/cloud/bigtable/data/execute_query/_sync_autogen/execute_query_iterator.py +239 -0
  33. google/cloud/bigtable/data/execute_query/metadata.py +399 -0
  34. google/cloud/bigtable/data/execute_query/values.py +123 -0
  35. google/cloud/bigtable/data/mutations.py +380 -0
  36. google/cloud/bigtable/data/read_modify_write_rules.py +112 -0
  37. google/cloud/bigtable/data/read_rows_query.py +536 -0
  38. google/cloud/bigtable/data/row.py +535 -0
  39. google/cloud/bigtable/data/row_filters.py +968 -0
  40. google/cloud/bigtable/encryption_info.py +64 -0
  41. google/cloud/bigtable/enums.py +223 -0
  42. google/cloud/bigtable/error.py +64 -0
  43. google/cloud/bigtable/gapic_version.py +16 -0
  44. google/cloud/bigtable/helpers.py +31 -0
  45. google/cloud/bigtable/instance.py +789 -0
  46. google/cloud/bigtable/policy.py +255 -0
  47. google/cloud/bigtable/row.py +1267 -0
  48. google/cloud/bigtable/row_data.py +380 -0
  49. google/cloud/bigtable/row_filters.py +838 -0
  50. google/cloud/bigtable/row_merger.py +250 -0
  51. google/cloud/bigtable/row_set.py +213 -0
  52. google/cloud/bigtable/table.py +1409 -0
  53. google/cloud/bigtable_admin/__init__.py +410 -0
  54. google/cloud/bigtable_admin/gapic_version.py +16 -0
  55. google/cloud/bigtable_admin/py.typed +2 -0
  56. google/cloud/bigtable_admin_v2/__init__.py +250 -0
  57. google/cloud/bigtable_admin_v2/gapic_metadata.json +962 -0
  58. google/cloud/bigtable_admin_v2/gapic_version.py +16 -0
  59. google/cloud/bigtable_admin_v2/py.typed +2 -0
  60. google/cloud/bigtable_admin_v2/services/__init__.py +15 -0
  61. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/__init__.py +22 -0
  62. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py +3465 -0
  63. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py +3944 -0
  64. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/pagers.py +681 -0
  65. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/__init__.py +40 -0
  66. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/base.py +751 -0
  67. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc.py +1249 -0
  68. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc_asyncio.py +1579 -0
  69. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest.py +6820 -0
  70. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest_base.py +1746 -0
  71. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/__init__.py +22 -0
  72. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/async_client.py +3472 -0
  73. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py +3949 -0
  74. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/pagers.py +669 -0
  75. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/__init__.py +40 -0
  76. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py +708 -0
  77. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc.py +1257 -0
  78. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc_asyncio.py +1549 -0
  79. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest.py +6609 -0
  80. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest_base.py +1714 -0
  81. google/cloud/bigtable_admin_v2/types/__init__.py +248 -0
  82. google/cloud/bigtable_admin_v2/types/bigtable_instance_admin.py +1364 -0
  83. google/cloud/bigtable_admin_v2/types/bigtable_table_admin.py +1715 -0
  84. google/cloud/bigtable_admin_v2/types/common.py +81 -0
  85. google/cloud/bigtable_admin_v2/types/instance.py +819 -0
  86. google/cloud/bigtable_admin_v2/types/table.py +1028 -0
  87. google/cloud/bigtable_admin_v2/types/types.py +776 -0
  88. google/cloud/bigtable_v2/__init__.py +136 -0
  89. google/cloud/bigtable_v2/gapic_metadata.json +193 -0
  90. google/cloud/bigtable_v2/gapic_version.py +16 -0
  91. google/cloud/bigtable_v2/py.typed +2 -0
  92. google/cloud/bigtable_v2/services/__init__.py +15 -0
  93. google/cloud/bigtable_v2/services/bigtable/__init__.py +22 -0
  94. google/cloud/bigtable_v2/services/bigtable/async_client.py +1741 -0
  95. google/cloud/bigtable_v2/services/bigtable/client.py +2194 -0
  96. google/cloud/bigtable_v2/services/bigtable/transports/__init__.py +38 -0
  97. google/cloud/bigtable_v2/services/bigtable/transports/base.py +343 -0
  98. google/cloud/bigtable_v2/services/bigtable/transports/grpc.py +660 -0
  99. google/cloud/bigtable_v2/services/bigtable/transports/grpc_asyncio.py +762 -0
  100. google/cloud/bigtable_v2/services/bigtable/transports/rest.py +2489 -0
  101. google/cloud/bigtable_v2/services/bigtable/transports/rest_base.py +711 -0
  102. google/cloud/bigtable_v2/types/__init__.py +138 -0
  103. google/cloud/bigtable_v2/types/bigtable.py +1531 -0
  104. google/cloud/bigtable_v2/types/data.py +1612 -0
  105. google/cloud/bigtable_v2/types/feature_flags.py +119 -0
  106. google/cloud/bigtable_v2/types/request_stats.py +171 -0
  107. google/cloud/bigtable_v2/types/response_params.py +64 -0
  108. google/cloud/bigtable_v2/types/types.py +579 -0
  109. google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_admin_v2_keywords.py +233 -0
  110. google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_v2_keywords.py +186 -0
  111. google_cloud_bigtable-2.30.0.dist-info/LICENSE +202 -0
  112. google_cloud_bigtable-2.30.0.dist-info/METADATA +154 -0
  113. google_cloud_bigtable-2.30.0.dist-info/RECORD +115 -0
  114. google_cloud_bigtable-2.30.0.dist-info/WHEEL +5 -0
  115. google_cloud_bigtable-2.30.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,762 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import inspect
17
+ import json
18
+ import pickle
19
+ import logging as std_logging
20
+ import warnings
21
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
22
+
23
+ from google.api_core import gapic_v1
24
+ from google.api_core import grpc_helpers_async
25
+ from google.api_core import exceptions as core_exceptions
26
+ from google.api_core import retry_async as retries
27
+ from google.auth import credentials as ga_credentials # type: ignore
28
+ from google.auth.transport.grpc import SslCredentials # type: ignore
29
+ from google.protobuf.json_format import MessageToJson
30
+ import google.protobuf.message
31
+
32
+ import grpc # type: ignore
33
+ import proto # type: ignore
34
+ from grpc.experimental import aio # type: ignore
35
+
36
+ from google.cloud.bigtable_v2.types import bigtable
37
+ from .base import BigtableTransport, DEFAULT_CLIENT_INFO
38
+ from .grpc import BigtableGrpcTransport
39
+
40
+ try:
41
+ from google.api_core import client_logging # type: ignore
42
+
43
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
44
+ except ImportError: # pragma: NO COVER
45
+ CLIENT_LOGGING_SUPPORTED = False
46
+
47
+ _LOGGER = std_logging.getLogger(__name__)
48
+
49
+
50
+ class _LoggingClientAIOInterceptor(
51
+ grpc.aio.UnaryUnaryClientInterceptor
52
+ ): # pragma: NO COVER
53
+ async def intercept_unary_unary(self, continuation, client_call_details, request):
54
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
55
+ std_logging.DEBUG
56
+ )
57
+ if logging_enabled: # pragma: NO COVER
58
+ request_metadata = client_call_details.metadata
59
+ if isinstance(request, proto.Message):
60
+ request_payload = type(request).to_json(request)
61
+ elif isinstance(request, google.protobuf.message.Message):
62
+ request_payload = MessageToJson(request)
63
+ else:
64
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
65
+
66
+ request_metadata = {
67
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
68
+ for key, value in request_metadata
69
+ }
70
+ grpc_request = {
71
+ "payload": request_payload,
72
+ "requestMethod": "grpc",
73
+ "metadata": dict(request_metadata),
74
+ }
75
+ _LOGGER.debug(
76
+ f"Sending request for {client_call_details.method}",
77
+ extra={
78
+ "serviceName": "google.bigtable.v2.Bigtable",
79
+ "rpcName": str(client_call_details.method),
80
+ "request": grpc_request,
81
+ "metadata": grpc_request["metadata"],
82
+ },
83
+ )
84
+ response = await continuation(client_call_details, request)
85
+ if logging_enabled: # pragma: NO COVER
86
+ response_metadata = await response.trailing_metadata()
87
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
88
+ metadata = (
89
+ dict([(k, str(v)) for k, v in response_metadata])
90
+ if response_metadata
91
+ else None
92
+ )
93
+ result = await response
94
+ if isinstance(result, proto.Message):
95
+ response_payload = type(result).to_json(result)
96
+ elif isinstance(result, google.protobuf.message.Message):
97
+ response_payload = MessageToJson(result)
98
+ else:
99
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
100
+ grpc_response = {
101
+ "payload": response_payload,
102
+ "metadata": metadata,
103
+ "status": "OK",
104
+ }
105
+ _LOGGER.debug(
106
+ f"Received response to rpc {client_call_details.method}.",
107
+ extra={
108
+ "serviceName": "google.bigtable.v2.Bigtable",
109
+ "rpcName": str(client_call_details.method),
110
+ "response": grpc_response,
111
+ "metadata": grpc_response["metadata"],
112
+ },
113
+ )
114
+ return response
115
+
116
+
117
+ class BigtableGrpcAsyncIOTransport(BigtableTransport):
118
+ """gRPC AsyncIO backend transport for Bigtable.
119
+
120
+ Service for reading from and writing to existing Bigtable
121
+ tables.
122
+
123
+ This class defines the same methods as the primary client, so the
124
+ primary client can load the underlying transport implementation
125
+ and call it.
126
+
127
+ It sends protocol buffers over the wire using gRPC (which is built on
128
+ top of HTTP/2); the ``grpcio`` package must be installed.
129
+ """
130
+
131
+ _grpc_channel: aio.Channel
132
+ _stubs: Dict[str, Callable] = {}
133
+
134
+ @classmethod
135
+ def create_channel(
136
+ cls,
137
+ host: str = "bigtable.googleapis.com",
138
+ credentials: Optional[ga_credentials.Credentials] = None,
139
+ credentials_file: Optional[str] = None,
140
+ scopes: Optional[Sequence[str]] = None,
141
+ quota_project_id: Optional[str] = None,
142
+ **kwargs,
143
+ ) -> aio.Channel:
144
+ """Create and return a gRPC AsyncIO channel object.
145
+ Args:
146
+ host (Optional[str]): The host for the channel to use.
147
+ credentials (Optional[~.Credentials]): The
148
+ authorization credentials to attach to requests. These
149
+ credentials identify this application to the service. If
150
+ none are specified, the client will attempt to ascertain
151
+ the credentials from the environment.
152
+ credentials_file (Optional[str]): A file with credentials that can
153
+ be loaded with :func:`google.auth.load_credentials_from_file`.
154
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
155
+ service. These are only used when credentials are not specified and
156
+ are passed to :func:`google.auth.default`.
157
+ quota_project_id (Optional[str]): An optional project to use for billing
158
+ and quota.
159
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
160
+ channel creation.
161
+ Returns:
162
+ aio.Channel: A gRPC AsyncIO channel object.
163
+ """
164
+
165
+ return grpc_helpers_async.create_channel(
166
+ host,
167
+ credentials=credentials,
168
+ credentials_file=credentials_file,
169
+ quota_project_id=quota_project_id,
170
+ default_scopes=cls.AUTH_SCOPES,
171
+ scopes=scopes,
172
+ default_host=cls.DEFAULT_HOST,
173
+ **kwargs,
174
+ )
175
+
176
+ def __init__(
177
+ self,
178
+ *,
179
+ host: str = "bigtable.googleapis.com",
180
+ credentials: Optional[ga_credentials.Credentials] = None,
181
+ credentials_file: Optional[str] = None,
182
+ scopes: Optional[Sequence[str]] = None,
183
+ channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
184
+ api_mtls_endpoint: Optional[str] = None,
185
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
186
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
187
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
188
+ quota_project_id: Optional[str] = None,
189
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
190
+ always_use_jwt_access: Optional[bool] = False,
191
+ api_audience: Optional[str] = None,
192
+ ) -> None:
193
+ """Instantiate the transport.
194
+
195
+ Args:
196
+ host (Optional[str]):
197
+ The hostname to connect to (default: 'bigtable.googleapis.com').
198
+ credentials (Optional[google.auth.credentials.Credentials]): The
199
+ authorization credentials to attach to requests. These
200
+ credentials identify the application to the service; if none
201
+ are specified, the client will attempt to ascertain the
202
+ credentials from the environment.
203
+ This argument is ignored if a ``channel`` instance is provided.
204
+ credentials_file (Optional[str]): A file with credentials that can
205
+ be loaded with :func:`google.auth.load_credentials_from_file`.
206
+ This argument is ignored if a ``channel`` instance is provided.
207
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
208
+ service. These are only used when credentials are not specified and
209
+ are passed to :func:`google.auth.default`.
210
+ channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
211
+ A ``Channel`` instance through which to make calls, or a Callable
212
+ that constructs and returns one. If set to None, ``self.create_channel``
213
+ is used to create the channel. If a Callable is given, it will be called
214
+ with the same arguments as used in ``self.create_channel``.
215
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
216
+ If provided, it overrides the ``host`` argument and tries to create
217
+ a mutual TLS channel with client SSL credentials from
218
+ ``client_cert_source`` or application default SSL credentials.
219
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
220
+ Deprecated. A callback to provide client SSL certificate bytes and
221
+ private key bytes, both in PEM format. It is ignored if
222
+ ``api_mtls_endpoint`` is None.
223
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
224
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
225
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
226
+ A callback to provide client certificate bytes and private key bytes,
227
+ both in PEM format. It is used to configure a mutual TLS channel. It is
228
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
229
+ quota_project_id (Optional[str]): An optional project to use for billing
230
+ and quota.
231
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
232
+ The client info used to send a user-agent string along with
233
+ API requests. If ``None``, then default info will be used.
234
+ Generally, you only need to set this if you're developing
235
+ your own client library.
236
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
237
+ be used for service account credentials.
238
+
239
+ Raises:
240
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
241
+ creation failed for any reason.
242
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
243
+ and ``credentials_file`` are passed.
244
+ """
245
+ self._grpc_channel = None
246
+ self._ssl_channel_credentials = ssl_channel_credentials
247
+ self._stubs: Dict[str, Callable] = {}
248
+
249
+ if api_mtls_endpoint:
250
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
251
+ if client_cert_source:
252
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
253
+
254
+ if isinstance(channel, aio.Channel):
255
+ # Ignore credentials if a channel was passed.
256
+ credentials = None
257
+ self._ignore_credentials = True
258
+ # If a channel was explicitly provided, set it.
259
+ self._grpc_channel = channel
260
+ self._ssl_channel_credentials = None
261
+ else:
262
+ if api_mtls_endpoint:
263
+ host = api_mtls_endpoint
264
+
265
+ # Create SSL credentials with client_cert_source or application
266
+ # default SSL credentials.
267
+ if client_cert_source:
268
+ cert, key = client_cert_source()
269
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
270
+ certificate_chain=cert, private_key=key
271
+ )
272
+ else:
273
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
274
+
275
+ else:
276
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
277
+ cert, key = client_cert_source_for_mtls()
278
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
279
+ certificate_chain=cert, private_key=key
280
+ )
281
+
282
+ # The base transport sets the host, credentials and scopes
283
+ super().__init__(
284
+ host=host,
285
+ credentials=credentials,
286
+ credentials_file=credentials_file,
287
+ scopes=scopes,
288
+ quota_project_id=quota_project_id,
289
+ client_info=client_info,
290
+ always_use_jwt_access=always_use_jwt_access,
291
+ api_audience=api_audience,
292
+ )
293
+
294
+ if not self._grpc_channel:
295
+ # initialize with the provided callable or the default channel
296
+ channel_init = channel or type(self).create_channel
297
+ self._grpc_channel = channel_init(
298
+ self._host,
299
+ # use the credentials which are saved
300
+ credentials=self._credentials,
301
+ # Set ``credentials_file`` to ``None`` here as
302
+ # the credentials that we saved earlier should be used.
303
+ credentials_file=None,
304
+ scopes=self._scopes,
305
+ ssl_credentials=self._ssl_channel_credentials,
306
+ quota_project_id=quota_project_id,
307
+ options=[
308
+ ("grpc.max_send_message_length", -1),
309
+ ("grpc.max_receive_message_length", -1),
310
+ ],
311
+ )
312
+
313
+ self._interceptor = _LoggingClientAIOInterceptor()
314
+ self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
315
+ self._logged_channel = self._grpc_channel
316
+ self._wrap_with_kind = (
317
+ "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
318
+ )
319
+ # Wrap messages. This must be done after self._logged_channel exists
320
+ self._prep_wrapped_messages(client_info)
321
+
322
+ @property
323
+ def grpc_channel(self) -> aio.Channel:
324
+ """Create the channel designed to connect to this service.
325
+
326
+ This property caches on the instance; repeated calls return
327
+ the same channel.
328
+ """
329
+ # Return the channel from cache.
330
+ return self._grpc_channel
331
+
332
+ @property
333
+ def read_rows(
334
+ self,
335
+ ) -> Callable[[bigtable.ReadRowsRequest], Awaitable[bigtable.ReadRowsResponse]]:
336
+ r"""Return a callable for the read rows method over gRPC.
337
+
338
+ Streams back the contents of all requested rows in
339
+ key order, optionally applying the same Reader filter to
340
+ each. Depending on their size, rows and cells may be
341
+ broken up across multiple responses, but atomicity of
342
+ each row will still be preserved. See the
343
+ ReadRowsResponse documentation for details.
344
+
345
+ Returns:
346
+ Callable[[~.ReadRowsRequest],
347
+ Awaitable[~.ReadRowsResponse]]:
348
+ A function that, when called, will call the underlying RPC
349
+ on the server.
350
+ """
351
+ # Generate a "stub function" on-the-fly which will actually make
352
+ # the request.
353
+ # gRPC handles serialization and deserialization, so we just need
354
+ # to pass in the functions for each.
355
+ if "read_rows" not in self._stubs:
356
+ self._stubs["read_rows"] = self._logged_channel.unary_stream(
357
+ "/google.bigtable.v2.Bigtable/ReadRows",
358
+ request_serializer=bigtable.ReadRowsRequest.serialize,
359
+ response_deserializer=bigtable.ReadRowsResponse.deserialize,
360
+ )
361
+ return self._stubs["read_rows"]
362
+
363
+ @property
364
+ def sample_row_keys(
365
+ self,
366
+ ) -> Callable[
367
+ [bigtable.SampleRowKeysRequest], Awaitable[bigtable.SampleRowKeysResponse]
368
+ ]:
369
+ r"""Return a callable for the sample row keys method over gRPC.
370
+
371
+ Returns a sample of row keys in the table. The
372
+ returned row keys will delimit contiguous sections of
373
+ the table of approximately equal size, which can be used
374
+ to break up the data for distributed tasks like
375
+ mapreduces.
376
+
377
+ Returns:
378
+ Callable[[~.SampleRowKeysRequest],
379
+ Awaitable[~.SampleRowKeysResponse]]:
380
+ A function that, when called, will call the underlying RPC
381
+ on the server.
382
+ """
383
+ # Generate a "stub function" on-the-fly which will actually make
384
+ # the request.
385
+ # gRPC handles serialization and deserialization, so we just need
386
+ # to pass in the functions for each.
387
+ if "sample_row_keys" not in self._stubs:
388
+ self._stubs["sample_row_keys"] = self._logged_channel.unary_stream(
389
+ "/google.bigtable.v2.Bigtable/SampleRowKeys",
390
+ request_serializer=bigtable.SampleRowKeysRequest.serialize,
391
+ response_deserializer=bigtable.SampleRowKeysResponse.deserialize,
392
+ )
393
+ return self._stubs["sample_row_keys"]
394
+
395
+ @property
396
+ def mutate_row(
397
+ self,
398
+ ) -> Callable[[bigtable.MutateRowRequest], Awaitable[bigtable.MutateRowResponse]]:
399
+ r"""Return a callable for the mutate row method over gRPC.
400
+
401
+ Mutates a row atomically. Cells already present in the row are
402
+ left unchanged unless explicitly changed by ``mutation``.
403
+
404
+ Returns:
405
+ Callable[[~.MutateRowRequest],
406
+ Awaitable[~.MutateRowResponse]]:
407
+ A function that, when called, will call the underlying RPC
408
+ on the server.
409
+ """
410
+ # Generate a "stub function" on-the-fly which will actually make
411
+ # the request.
412
+ # gRPC handles serialization and deserialization, so we just need
413
+ # to pass in the functions for each.
414
+ if "mutate_row" not in self._stubs:
415
+ self._stubs["mutate_row"] = self._logged_channel.unary_unary(
416
+ "/google.bigtable.v2.Bigtable/MutateRow",
417
+ request_serializer=bigtable.MutateRowRequest.serialize,
418
+ response_deserializer=bigtable.MutateRowResponse.deserialize,
419
+ )
420
+ return self._stubs["mutate_row"]
421
+
422
+ @property
423
+ def mutate_rows(
424
+ self,
425
+ ) -> Callable[[bigtable.MutateRowsRequest], Awaitable[bigtable.MutateRowsResponse]]:
426
+ r"""Return a callable for the mutate rows method over gRPC.
427
+
428
+ Mutates multiple rows in a batch. Each individual row
429
+ is mutated atomically as in MutateRow, but the entire
430
+ batch is not executed atomically.
431
+
432
+ Returns:
433
+ Callable[[~.MutateRowsRequest],
434
+ Awaitable[~.MutateRowsResponse]]:
435
+ A function that, when called, will call the underlying RPC
436
+ on the server.
437
+ """
438
+ # Generate a "stub function" on-the-fly which will actually make
439
+ # the request.
440
+ # gRPC handles serialization and deserialization, so we just need
441
+ # to pass in the functions for each.
442
+ if "mutate_rows" not in self._stubs:
443
+ self._stubs["mutate_rows"] = self._logged_channel.unary_stream(
444
+ "/google.bigtable.v2.Bigtable/MutateRows",
445
+ request_serializer=bigtable.MutateRowsRequest.serialize,
446
+ response_deserializer=bigtable.MutateRowsResponse.deserialize,
447
+ )
448
+ return self._stubs["mutate_rows"]
449
+
450
+ @property
451
+ def check_and_mutate_row(
452
+ self,
453
+ ) -> Callable[
454
+ [bigtable.CheckAndMutateRowRequest],
455
+ Awaitable[bigtable.CheckAndMutateRowResponse],
456
+ ]:
457
+ r"""Return a callable for the check and mutate row method over gRPC.
458
+
459
+ Mutates a row atomically based on the output of a
460
+ predicate Reader filter.
461
+
462
+ Returns:
463
+ Callable[[~.CheckAndMutateRowRequest],
464
+ Awaitable[~.CheckAndMutateRowResponse]]:
465
+ A function that, when called, will call the underlying RPC
466
+ on the server.
467
+ """
468
+ # Generate a "stub function" on-the-fly which will actually make
469
+ # the request.
470
+ # gRPC handles serialization and deserialization, so we just need
471
+ # to pass in the functions for each.
472
+ if "check_and_mutate_row" not in self._stubs:
473
+ self._stubs["check_and_mutate_row"] = self._logged_channel.unary_unary(
474
+ "/google.bigtable.v2.Bigtable/CheckAndMutateRow",
475
+ request_serializer=bigtable.CheckAndMutateRowRequest.serialize,
476
+ response_deserializer=bigtable.CheckAndMutateRowResponse.deserialize,
477
+ )
478
+ return self._stubs["check_and_mutate_row"]
479
+
480
+ @property
481
+ def ping_and_warm(
482
+ self,
483
+ ) -> Callable[
484
+ [bigtable.PingAndWarmRequest], Awaitable[bigtable.PingAndWarmResponse]
485
+ ]:
486
+ r"""Return a callable for the ping and warm method over gRPC.
487
+
488
+ Warm up associated instance metadata for this
489
+ connection. This call is not required but may be useful
490
+ for connection keep-alive.
491
+
492
+ Returns:
493
+ Callable[[~.PingAndWarmRequest],
494
+ Awaitable[~.PingAndWarmResponse]]:
495
+ A function that, when called, will call the underlying RPC
496
+ on the server.
497
+ """
498
+ # Generate a "stub function" on-the-fly which will actually make
499
+ # the request.
500
+ # gRPC handles serialization and deserialization, so we just need
501
+ # to pass in the functions for each.
502
+ if "ping_and_warm" not in self._stubs:
503
+ self._stubs["ping_and_warm"] = self._logged_channel.unary_unary(
504
+ "/google.bigtable.v2.Bigtable/PingAndWarm",
505
+ request_serializer=bigtable.PingAndWarmRequest.serialize,
506
+ response_deserializer=bigtable.PingAndWarmResponse.deserialize,
507
+ )
508
+ return self._stubs["ping_and_warm"]
509
+
510
+ @property
511
+ def read_modify_write_row(
512
+ self,
513
+ ) -> Callable[
514
+ [bigtable.ReadModifyWriteRowRequest],
515
+ Awaitable[bigtable.ReadModifyWriteRowResponse],
516
+ ]:
517
+ r"""Return a callable for the read modify write row method over gRPC.
518
+
519
+ Modifies a row atomically on the server. The method
520
+ reads the latest existing timestamp and value from the
521
+ specified columns and writes a new entry based on
522
+ pre-defined read/modify/write rules. The new value for
523
+ the timestamp is the greater of the existing timestamp
524
+ or the current server time. The method returns the new
525
+ contents of all modified cells.
526
+
527
+ Returns:
528
+ Callable[[~.ReadModifyWriteRowRequest],
529
+ Awaitable[~.ReadModifyWriteRowResponse]]:
530
+ A function that, when called, will call the underlying RPC
531
+ on the server.
532
+ """
533
+ # Generate a "stub function" on-the-fly which will actually make
534
+ # the request.
535
+ # gRPC handles serialization and deserialization, so we just need
536
+ # to pass in the functions for each.
537
+ if "read_modify_write_row" not in self._stubs:
538
+ self._stubs["read_modify_write_row"] = self._logged_channel.unary_unary(
539
+ "/google.bigtable.v2.Bigtable/ReadModifyWriteRow",
540
+ request_serializer=bigtable.ReadModifyWriteRowRequest.serialize,
541
+ response_deserializer=bigtable.ReadModifyWriteRowResponse.deserialize,
542
+ )
543
+ return self._stubs["read_modify_write_row"]
544
+
545
+ @property
546
+ def generate_initial_change_stream_partitions(
547
+ self,
548
+ ) -> Callable[
549
+ [bigtable.GenerateInitialChangeStreamPartitionsRequest],
550
+ Awaitable[bigtable.GenerateInitialChangeStreamPartitionsResponse],
551
+ ]:
552
+ r"""Return a callable for the generate initial change stream
553
+ partitions method over gRPC.
554
+
555
+ NOTE: This API is intended to be used by Apache Beam BigtableIO.
556
+ Returns the current list of partitions that make up the table's
557
+ change stream. The union of partitions will cover the entire
558
+ keyspace. Partitions can be read with ``ReadChangeStream``.
559
+
560
+ Returns:
561
+ Callable[[~.GenerateInitialChangeStreamPartitionsRequest],
562
+ Awaitable[~.GenerateInitialChangeStreamPartitionsResponse]]:
563
+ A function that, when called, will call the underlying RPC
564
+ on the server.
565
+ """
566
+ # Generate a "stub function" on-the-fly which will actually make
567
+ # the request.
568
+ # gRPC handles serialization and deserialization, so we just need
569
+ # to pass in the functions for each.
570
+ if "generate_initial_change_stream_partitions" not in self._stubs:
571
+ self._stubs[
572
+ "generate_initial_change_stream_partitions"
573
+ ] = self._logged_channel.unary_stream(
574
+ "/google.bigtable.v2.Bigtable/GenerateInitialChangeStreamPartitions",
575
+ request_serializer=bigtable.GenerateInitialChangeStreamPartitionsRequest.serialize,
576
+ response_deserializer=bigtable.GenerateInitialChangeStreamPartitionsResponse.deserialize,
577
+ )
578
+ return self._stubs["generate_initial_change_stream_partitions"]
579
+
580
+ @property
581
+ def read_change_stream(
582
+ self,
583
+ ) -> Callable[
584
+ [bigtable.ReadChangeStreamRequest], Awaitable[bigtable.ReadChangeStreamResponse]
585
+ ]:
586
+ r"""Return a callable for the read change stream method over gRPC.
587
+
588
+ NOTE: This API is intended to be used by Apache Beam
589
+ BigtableIO. Reads changes from a table's change stream.
590
+ Changes will reflect both user-initiated mutations and
591
+ mutations that are caused by garbage collection.
592
+
593
+ Returns:
594
+ Callable[[~.ReadChangeStreamRequest],
595
+ Awaitable[~.ReadChangeStreamResponse]]:
596
+ A function that, when called, will call the underlying RPC
597
+ on the server.
598
+ """
599
+ # Generate a "stub function" on-the-fly which will actually make
600
+ # the request.
601
+ # gRPC handles serialization and deserialization, so we just need
602
+ # to pass in the functions for each.
603
+ if "read_change_stream" not in self._stubs:
604
+ self._stubs["read_change_stream"] = self._logged_channel.unary_stream(
605
+ "/google.bigtable.v2.Bigtable/ReadChangeStream",
606
+ request_serializer=bigtable.ReadChangeStreamRequest.serialize,
607
+ response_deserializer=bigtable.ReadChangeStreamResponse.deserialize,
608
+ )
609
+ return self._stubs["read_change_stream"]
610
+
611
+ @property
612
+ def prepare_query(
613
+ self,
614
+ ) -> Callable[
615
+ [bigtable.PrepareQueryRequest], Awaitable[bigtable.PrepareQueryResponse]
616
+ ]:
617
+ r"""Return a callable for the prepare query method over gRPC.
618
+
619
+ Prepares a GoogleSQL query for execution on a
620
+ particular Bigtable instance.
621
+
622
+ Returns:
623
+ Callable[[~.PrepareQueryRequest],
624
+ Awaitable[~.PrepareQueryResponse]]:
625
+ A function that, when called, will call the underlying RPC
626
+ on the server.
627
+ """
628
+ # Generate a "stub function" on-the-fly which will actually make
629
+ # the request.
630
+ # gRPC handles serialization and deserialization, so we just need
631
+ # to pass in the functions for each.
632
+ if "prepare_query" not in self._stubs:
633
+ self._stubs["prepare_query"] = self._logged_channel.unary_unary(
634
+ "/google.bigtable.v2.Bigtable/PrepareQuery",
635
+ request_serializer=bigtable.PrepareQueryRequest.serialize,
636
+ response_deserializer=bigtable.PrepareQueryResponse.deserialize,
637
+ )
638
+ return self._stubs["prepare_query"]
639
+
640
+ @property
641
+ def execute_query(
642
+ self,
643
+ ) -> Callable[
644
+ [bigtable.ExecuteQueryRequest], Awaitable[bigtable.ExecuteQueryResponse]
645
+ ]:
646
+ r"""Return a callable for the execute query method over gRPC.
647
+
648
+ Executes a SQL query against a particular Bigtable
649
+ instance.
650
+
651
+ Returns:
652
+ Callable[[~.ExecuteQueryRequest],
653
+ Awaitable[~.ExecuteQueryResponse]]:
654
+ A function that, when called, will call the underlying RPC
655
+ on the server.
656
+ """
657
+ # Generate a "stub function" on-the-fly which will actually make
658
+ # the request.
659
+ # gRPC handles serialization and deserialization, so we just need
660
+ # to pass in the functions for each.
661
+ if "execute_query" not in self._stubs:
662
+ self._stubs["execute_query"] = self._logged_channel.unary_stream(
663
+ "/google.bigtable.v2.Bigtable/ExecuteQuery",
664
+ request_serializer=bigtable.ExecuteQueryRequest.serialize,
665
+ response_deserializer=bigtable.ExecuteQueryResponse.deserialize,
666
+ )
667
+ return self._stubs["execute_query"]
668
+
669
+ def _prep_wrapped_messages(self, client_info):
670
+ """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
671
+ self._wrapped_methods = {
672
+ self.read_rows: self._wrap_method(
673
+ self.read_rows,
674
+ default_timeout=43200.0,
675
+ client_info=client_info,
676
+ ),
677
+ self.sample_row_keys: self._wrap_method(
678
+ self.sample_row_keys,
679
+ default_timeout=60.0,
680
+ client_info=client_info,
681
+ ),
682
+ self.mutate_row: self._wrap_method(
683
+ self.mutate_row,
684
+ default_retry=retries.AsyncRetry(
685
+ initial=0.01,
686
+ maximum=60.0,
687
+ multiplier=2,
688
+ predicate=retries.if_exception_type(
689
+ core_exceptions.DeadlineExceeded,
690
+ core_exceptions.ServiceUnavailable,
691
+ ),
692
+ deadline=60.0,
693
+ ),
694
+ default_timeout=60.0,
695
+ client_info=client_info,
696
+ ),
697
+ self.mutate_rows: self._wrap_method(
698
+ self.mutate_rows,
699
+ default_timeout=600.0,
700
+ client_info=client_info,
701
+ ),
702
+ self.check_and_mutate_row: self._wrap_method(
703
+ self.check_and_mutate_row,
704
+ default_timeout=20.0,
705
+ client_info=client_info,
706
+ ),
707
+ self.ping_and_warm: self._wrap_method(
708
+ self.ping_and_warm,
709
+ default_timeout=None,
710
+ client_info=client_info,
711
+ ),
712
+ self.read_modify_write_row: self._wrap_method(
713
+ self.read_modify_write_row,
714
+ default_timeout=20.0,
715
+ client_info=client_info,
716
+ ),
717
+ self.generate_initial_change_stream_partitions: self._wrap_method(
718
+ self.generate_initial_change_stream_partitions,
719
+ default_timeout=60.0,
720
+ client_info=client_info,
721
+ ),
722
+ self.read_change_stream: self._wrap_method(
723
+ self.read_change_stream,
724
+ default_timeout=43200.0,
725
+ client_info=client_info,
726
+ ),
727
+ self.prepare_query: self._wrap_method(
728
+ self.prepare_query,
729
+ default_timeout=None,
730
+ client_info=client_info,
731
+ ),
732
+ self.execute_query: self._wrap_method(
733
+ self.execute_query,
734
+ default_retry=retries.AsyncRetry(
735
+ initial=0.01,
736
+ maximum=60.0,
737
+ multiplier=2,
738
+ predicate=retries.if_exception_type(
739
+ core_exceptions.DeadlineExceeded,
740
+ core_exceptions.ServiceUnavailable,
741
+ ),
742
+ deadline=43200.0,
743
+ ),
744
+ default_timeout=43200.0,
745
+ client_info=client_info,
746
+ ),
747
+ }
748
+
749
+ def _wrap_method(self, func, *args, **kwargs):
750
+ if self._wrap_with_kind: # pragma: NO COVER
751
+ kwargs["kind"] = self.kind
752
+ return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
753
+
754
+ def close(self):
755
+ return self._logged_channel.close()
756
+
757
+ @property
758
+ def kind(self) -> str:
759
+ return "grpc_asyncio"
760
+
761
+
762
+ __all__ = ("BigtableGrpcAsyncIOTransport",)