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,1741 @@
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 logging as std_logging
17
+ from collections import OrderedDict
18
+ import re
19
+ from typing import (
20
+ Dict,
21
+ Callable,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ AsyncIterable,
27
+ Awaitable,
28
+ Sequence,
29
+ Tuple,
30
+ Type,
31
+ Union,
32
+ )
33
+
34
+ from google.cloud.bigtable_v2 import gapic_version as package_version
35
+
36
+ from google.api_core.client_options import ClientOptions
37
+ from google.api_core import exceptions as core_exceptions
38
+ from google.api_core import gapic_v1
39
+ from google.api_core import retry_async as retries
40
+ from google.auth import credentials as ga_credentials # type: ignore
41
+ from google.oauth2 import service_account # type: ignore
42
+
43
+
44
+ try:
45
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
46
+ except AttributeError: # pragma: NO COVER
47
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
48
+
49
+ from google.cloud.bigtable_v2.types import bigtable
50
+ from google.cloud.bigtable_v2.types import data
51
+ from google.cloud.bigtable_v2.types import request_stats
52
+ from google.protobuf import timestamp_pb2 # type: ignore
53
+ from .transports.base import BigtableTransport, DEFAULT_CLIENT_INFO
54
+ from .transports.grpc_asyncio import BigtableGrpcAsyncIOTransport
55
+ from .client import BigtableClient
56
+
57
+ try:
58
+ from google.api_core import client_logging # type: ignore
59
+
60
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
61
+ except ImportError: # pragma: NO COVER
62
+ CLIENT_LOGGING_SUPPORTED = False
63
+
64
+ _LOGGER = std_logging.getLogger(__name__)
65
+
66
+
67
+ class BigtableAsyncClient:
68
+ """Service for reading from and writing to existing Bigtable
69
+ tables.
70
+ """
71
+
72
+ _client: BigtableClient
73
+
74
+ # Copy defaults from the synchronous client for use here.
75
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
76
+ DEFAULT_ENDPOINT = BigtableClient.DEFAULT_ENDPOINT
77
+ DEFAULT_MTLS_ENDPOINT = BigtableClient.DEFAULT_MTLS_ENDPOINT
78
+ _DEFAULT_ENDPOINT_TEMPLATE = BigtableClient._DEFAULT_ENDPOINT_TEMPLATE
79
+ _DEFAULT_UNIVERSE = BigtableClient._DEFAULT_UNIVERSE
80
+
81
+ authorized_view_path = staticmethod(BigtableClient.authorized_view_path)
82
+ parse_authorized_view_path = staticmethod(BigtableClient.parse_authorized_view_path)
83
+ instance_path = staticmethod(BigtableClient.instance_path)
84
+ parse_instance_path = staticmethod(BigtableClient.parse_instance_path)
85
+ materialized_view_path = staticmethod(BigtableClient.materialized_view_path)
86
+ parse_materialized_view_path = staticmethod(
87
+ BigtableClient.parse_materialized_view_path
88
+ )
89
+ table_path = staticmethod(BigtableClient.table_path)
90
+ parse_table_path = staticmethod(BigtableClient.parse_table_path)
91
+ common_billing_account_path = staticmethod(
92
+ BigtableClient.common_billing_account_path
93
+ )
94
+ parse_common_billing_account_path = staticmethod(
95
+ BigtableClient.parse_common_billing_account_path
96
+ )
97
+ common_folder_path = staticmethod(BigtableClient.common_folder_path)
98
+ parse_common_folder_path = staticmethod(BigtableClient.parse_common_folder_path)
99
+ common_organization_path = staticmethod(BigtableClient.common_organization_path)
100
+ parse_common_organization_path = staticmethod(
101
+ BigtableClient.parse_common_organization_path
102
+ )
103
+ common_project_path = staticmethod(BigtableClient.common_project_path)
104
+ parse_common_project_path = staticmethod(BigtableClient.parse_common_project_path)
105
+ common_location_path = staticmethod(BigtableClient.common_location_path)
106
+ parse_common_location_path = staticmethod(BigtableClient.parse_common_location_path)
107
+
108
+ @classmethod
109
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
110
+ """Creates an instance of this client using the provided credentials
111
+ info.
112
+
113
+ Args:
114
+ info (dict): The service account private key info.
115
+ args: Additional arguments to pass to the constructor.
116
+ kwargs: Additional arguments to pass to the constructor.
117
+
118
+ Returns:
119
+ BigtableAsyncClient: The constructed client.
120
+ """
121
+ return BigtableClient.from_service_account_info.__func__(BigtableAsyncClient, info, *args, **kwargs) # type: ignore
122
+
123
+ @classmethod
124
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
125
+ """Creates an instance of this client using the provided credentials
126
+ file.
127
+
128
+ Args:
129
+ filename (str): The path to the service account private key json
130
+ file.
131
+ args: Additional arguments to pass to the constructor.
132
+ kwargs: Additional arguments to pass to the constructor.
133
+
134
+ Returns:
135
+ BigtableAsyncClient: The constructed client.
136
+ """
137
+ return BigtableClient.from_service_account_file.__func__(BigtableAsyncClient, filename, *args, **kwargs) # type: ignore
138
+
139
+ from_service_account_json = from_service_account_file
140
+
141
+ @classmethod
142
+ def get_mtls_endpoint_and_cert_source(
143
+ cls, client_options: Optional[ClientOptions] = None
144
+ ):
145
+ """Return the API endpoint and client cert source for mutual TLS.
146
+
147
+ The client cert source is determined in the following order:
148
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
149
+ client cert source is None.
150
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
151
+ default client cert source exists, use the default one; otherwise the client cert
152
+ source is None.
153
+
154
+ The API endpoint is determined in the following order:
155
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
156
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
157
+ default mTLS endpoint; if the environment variable is "never", use the default API
158
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
159
+ use the default API endpoint.
160
+
161
+ More details can be found at https://google.aip.dev/auth/4114.
162
+
163
+ Args:
164
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
165
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
166
+ in this method.
167
+
168
+ Returns:
169
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
170
+ client cert source to use.
171
+
172
+ Raises:
173
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
174
+ """
175
+ return BigtableClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
176
+
177
+ @property
178
+ def transport(self) -> BigtableTransport:
179
+ """Returns the transport used by the client instance.
180
+
181
+ Returns:
182
+ BigtableTransport: The transport used by the client instance.
183
+ """
184
+ return self._client.transport
185
+
186
+ @property
187
+ def api_endpoint(self):
188
+ """Return the API endpoint used by the client instance.
189
+
190
+ Returns:
191
+ str: The API endpoint used by the client instance.
192
+ """
193
+ return self._client._api_endpoint
194
+
195
+ @property
196
+ def universe_domain(self) -> str:
197
+ """Return the universe domain used by the client instance.
198
+
199
+ Returns:
200
+ str: The universe domain used
201
+ by the client instance.
202
+ """
203
+ return self._client._universe_domain
204
+
205
+ get_transport_class = BigtableClient.get_transport_class
206
+
207
+ def __init__(
208
+ self,
209
+ *,
210
+ credentials: Optional[ga_credentials.Credentials] = None,
211
+ transport: Optional[
212
+ Union[str, BigtableTransport, Callable[..., BigtableTransport]]
213
+ ] = "grpc_asyncio",
214
+ client_options: Optional[ClientOptions] = None,
215
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
216
+ ) -> None:
217
+ """Instantiates the bigtable async client.
218
+
219
+ Args:
220
+ credentials (Optional[google.auth.credentials.Credentials]): The
221
+ authorization credentials to attach to requests. These
222
+ credentials identify the application to the service; if none
223
+ are specified, the client will attempt to ascertain the
224
+ credentials from the environment.
225
+ transport (Optional[Union[str,BigtableTransport,Callable[..., BigtableTransport]]]):
226
+ The transport to use, or a Callable that constructs and returns a new transport to use.
227
+ If a Callable is given, it will be called with the same set of initialization
228
+ arguments as used in the BigtableTransport constructor.
229
+ If set to None, a transport is chosen automatically.
230
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
231
+ Custom options for the client.
232
+
233
+ 1. The ``api_endpoint`` property can be used to override the
234
+ default endpoint provided by the client when ``transport`` is
235
+ not explicitly provided. Only if this property is not set and
236
+ ``transport`` was not explicitly provided, the endpoint is
237
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
238
+ variable, which have one of the following values:
239
+ "always" (always use the default mTLS endpoint), "never" (always
240
+ use the default regular endpoint) and "auto" (auto-switch to the
241
+ default mTLS endpoint if client certificate is present; this is
242
+ the default value).
243
+
244
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
245
+ is "true", then the ``client_cert_source`` property can be used
246
+ to provide a client certificate for mTLS transport. If
247
+ not provided, the default SSL client certificate will be used if
248
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
249
+ set, no client certificate will be used.
250
+
251
+ 3. The ``universe_domain`` property can be used to override the
252
+ default "googleapis.com" universe. Note that ``api_endpoint``
253
+ property still takes precedence; and ``universe_domain`` is
254
+ currently not supported for mTLS.
255
+
256
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
257
+ The client info used to send a user-agent string along with
258
+ API requests. If ``None``, then default info will be used.
259
+ Generally, you only need to set this if you're developing
260
+ your own client library.
261
+
262
+ Raises:
263
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
264
+ creation failed for any reason.
265
+ """
266
+ self._client = BigtableClient(
267
+ credentials=credentials,
268
+ transport=transport,
269
+ client_options=client_options,
270
+ client_info=client_info,
271
+ )
272
+
273
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
274
+ std_logging.DEBUG
275
+ ): # pragma: NO COVER
276
+ _LOGGER.debug(
277
+ "Created client `google.bigtable_v2.BigtableAsyncClient`.",
278
+ extra={
279
+ "serviceName": "google.bigtable.v2.Bigtable",
280
+ "universeDomain": getattr(
281
+ self._client._transport._credentials, "universe_domain", ""
282
+ ),
283
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
284
+ "credentialsInfo": getattr(
285
+ self.transport._credentials, "get_cred_info", lambda: None
286
+ )(),
287
+ }
288
+ if hasattr(self._client._transport, "_credentials")
289
+ else {
290
+ "serviceName": "google.bigtable.v2.Bigtable",
291
+ "credentialsType": None,
292
+ },
293
+ )
294
+
295
+ def read_rows(
296
+ self,
297
+ request: Optional[Union[bigtable.ReadRowsRequest, dict]] = None,
298
+ *,
299
+ table_name: Optional[str] = None,
300
+ app_profile_id: Optional[str] = None,
301
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
302
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
303
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
304
+ ) -> Awaitable[AsyncIterable[bigtable.ReadRowsResponse]]:
305
+ r"""Streams back the contents of all requested rows in
306
+ key order, optionally applying the same Reader filter to
307
+ each. Depending on their size, rows and cells may be
308
+ broken up across multiple responses, but atomicity of
309
+ each row will still be preserved. See the
310
+ ReadRowsResponse documentation for details.
311
+
312
+ Args:
313
+ request (Optional[Union[google.cloud.bigtable_v2.types.ReadRowsRequest, dict]]):
314
+ The request object. Request message for
315
+ Bigtable.ReadRows.
316
+ table_name (:class:`str`):
317
+ Optional. The unique name of the table from which to
318
+ read.
319
+
320
+ Values are of the form
321
+ ``projects/<project>/instances/<instance>/tables/<table>``.
322
+
323
+ This corresponds to the ``table_name`` field
324
+ on the ``request`` instance; if ``request`` is provided, this
325
+ should not be set.
326
+ app_profile_id (:class:`str`):
327
+ This value specifies routing for
328
+ replication. If not specified, the
329
+ "default" application profile will be
330
+ used.
331
+
332
+ This corresponds to the ``app_profile_id`` field
333
+ on the ``request`` instance; if ``request`` is provided, this
334
+ should not be set.
335
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
336
+ should be retried.
337
+ timeout (float): The timeout for this request.
338
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
339
+ sent along with the request as metadata. Normally, each value must be of type `str`,
340
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
341
+ be of type `bytes`.
342
+
343
+ Returns:
344
+ AsyncIterable[google.cloud.bigtable_v2.types.ReadRowsResponse]:
345
+ Response message for
346
+ Bigtable.ReadRows.
347
+
348
+ """
349
+ # Create or coerce a protobuf request object.
350
+ # - Quick check: If we got a request object, we should *not* have
351
+ # gotten any keyword arguments that map to the request.
352
+ flattened_params = [table_name, app_profile_id]
353
+ has_flattened_params = (
354
+ len([param for param in flattened_params if param is not None]) > 0
355
+ )
356
+ if request is not None and has_flattened_params:
357
+ raise ValueError(
358
+ "If the `request` argument is set, then none of "
359
+ "the individual field arguments should be set."
360
+ )
361
+
362
+ # - Use the request object if provided (there's no risk of modifying the input as
363
+ # there are no flattened fields), or create one.
364
+ if not isinstance(request, bigtable.ReadRowsRequest):
365
+ request = bigtable.ReadRowsRequest(request)
366
+
367
+ # If we have keyword arguments corresponding to fields on the
368
+ # request, apply these.
369
+ if table_name is not None:
370
+ request.table_name = table_name
371
+ if app_profile_id is not None:
372
+ request.app_profile_id = app_profile_id
373
+
374
+ # Wrap the RPC method; this adds retry and timeout information,
375
+ # and friendly error handling.
376
+ rpc = self._client._transport._wrapped_methods[
377
+ self._client._transport.read_rows
378
+ ]
379
+
380
+ header_params = {}
381
+
382
+ routing_param_regex = re.compile(
383
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
384
+ )
385
+ regex_match = routing_param_regex.match(request.table_name)
386
+ if regex_match and regex_match.group("table_name"):
387
+ header_params["table_name"] = regex_match.group("table_name")
388
+
389
+ if request.app_profile_id:
390
+ header_params["app_profile_id"] = request.app_profile_id
391
+
392
+ routing_param_regex = re.compile(
393
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
394
+ )
395
+ regex_match = routing_param_regex.match(request.authorized_view_name)
396
+ if regex_match and regex_match.group("authorized_view_name"):
397
+ header_params["authorized_view_name"] = regex_match.group(
398
+ "authorized_view_name"
399
+ )
400
+
401
+ if header_params:
402
+ metadata = tuple(metadata) + (
403
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
404
+ )
405
+
406
+ # Validate the universe domain.
407
+ self._client._validate_universe_domain()
408
+
409
+ # Send the request.
410
+ response = rpc(
411
+ request,
412
+ retry=retry,
413
+ timeout=timeout,
414
+ metadata=metadata,
415
+ )
416
+
417
+ # Done; return the response.
418
+ return response
419
+
420
+ def sample_row_keys(
421
+ self,
422
+ request: Optional[Union[bigtable.SampleRowKeysRequest, dict]] = None,
423
+ *,
424
+ table_name: Optional[str] = None,
425
+ app_profile_id: Optional[str] = None,
426
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
427
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
428
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
429
+ ) -> Awaitable[AsyncIterable[bigtable.SampleRowKeysResponse]]:
430
+ r"""Returns a sample of row keys in the table. The
431
+ returned row keys will delimit contiguous sections of
432
+ the table of approximately equal size, which can be used
433
+ to break up the data for distributed tasks like
434
+ mapreduces.
435
+
436
+ Args:
437
+ request (Optional[Union[google.cloud.bigtable_v2.types.SampleRowKeysRequest, dict]]):
438
+ The request object. Request message for
439
+ Bigtable.SampleRowKeys.
440
+ table_name (:class:`str`):
441
+ Optional. The unique name of the table from which to
442
+ sample row keys.
443
+
444
+ Values are of the form
445
+ ``projects/<project>/instances/<instance>/tables/<table>``.
446
+
447
+ This corresponds to the ``table_name`` field
448
+ on the ``request`` instance; if ``request`` is provided, this
449
+ should not be set.
450
+ app_profile_id (:class:`str`):
451
+ This value specifies routing for
452
+ replication. If not specified, the
453
+ "default" application profile will be
454
+ used.
455
+
456
+ This corresponds to the ``app_profile_id`` field
457
+ on the ``request`` instance; if ``request`` is provided, this
458
+ should not be set.
459
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
460
+ should be retried.
461
+ timeout (float): The timeout for this request.
462
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
463
+ sent along with the request as metadata. Normally, each value must be of type `str`,
464
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
465
+ be of type `bytes`.
466
+
467
+ Returns:
468
+ AsyncIterable[google.cloud.bigtable_v2.types.SampleRowKeysResponse]:
469
+ Response message for
470
+ Bigtable.SampleRowKeys.
471
+
472
+ """
473
+ # Create or coerce a protobuf request object.
474
+ # - Quick check: If we got a request object, we should *not* have
475
+ # gotten any keyword arguments that map to the request.
476
+ flattened_params = [table_name, app_profile_id]
477
+ has_flattened_params = (
478
+ len([param for param in flattened_params if param is not None]) > 0
479
+ )
480
+ if request is not None and has_flattened_params:
481
+ raise ValueError(
482
+ "If the `request` argument is set, then none of "
483
+ "the individual field arguments should be set."
484
+ )
485
+
486
+ # - Use the request object if provided (there's no risk of modifying the input as
487
+ # there are no flattened fields), or create one.
488
+ if not isinstance(request, bigtable.SampleRowKeysRequest):
489
+ request = bigtable.SampleRowKeysRequest(request)
490
+
491
+ # If we have keyword arguments corresponding to fields on the
492
+ # request, apply these.
493
+ if table_name is not None:
494
+ request.table_name = table_name
495
+ if app_profile_id is not None:
496
+ request.app_profile_id = app_profile_id
497
+
498
+ # Wrap the RPC method; this adds retry and timeout information,
499
+ # and friendly error handling.
500
+ rpc = self._client._transport._wrapped_methods[
501
+ self._client._transport.sample_row_keys
502
+ ]
503
+
504
+ header_params = {}
505
+
506
+ routing_param_regex = re.compile(
507
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
508
+ )
509
+ regex_match = routing_param_regex.match(request.table_name)
510
+ if regex_match and regex_match.group("table_name"):
511
+ header_params["table_name"] = regex_match.group("table_name")
512
+
513
+ if request.app_profile_id:
514
+ header_params["app_profile_id"] = request.app_profile_id
515
+
516
+ routing_param_regex = re.compile(
517
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
518
+ )
519
+ regex_match = routing_param_regex.match(request.authorized_view_name)
520
+ if regex_match and regex_match.group("authorized_view_name"):
521
+ header_params["authorized_view_name"] = regex_match.group(
522
+ "authorized_view_name"
523
+ )
524
+
525
+ if header_params:
526
+ metadata = tuple(metadata) + (
527
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
528
+ )
529
+
530
+ # Validate the universe domain.
531
+ self._client._validate_universe_domain()
532
+
533
+ # Send the request.
534
+ response = rpc(
535
+ request,
536
+ retry=retry,
537
+ timeout=timeout,
538
+ metadata=metadata,
539
+ )
540
+
541
+ # Done; return the response.
542
+ return response
543
+
544
+ async def mutate_row(
545
+ self,
546
+ request: Optional[Union[bigtable.MutateRowRequest, dict]] = None,
547
+ *,
548
+ table_name: Optional[str] = None,
549
+ row_key: Optional[bytes] = None,
550
+ mutations: Optional[MutableSequence[data.Mutation]] = None,
551
+ app_profile_id: Optional[str] = None,
552
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
553
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
554
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
555
+ ) -> bigtable.MutateRowResponse:
556
+ r"""Mutates a row atomically. Cells already present in the row are
557
+ left unchanged unless explicitly changed by ``mutation``.
558
+
559
+ Args:
560
+ request (Optional[Union[google.cloud.bigtable_v2.types.MutateRowRequest, dict]]):
561
+ The request object. Request message for
562
+ Bigtable.MutateRow.
563
+ table_name (:class:`str`):
564
+ Optional. The unique name of the table to which the
565
+ mutation should be applied.
566
+
567
+ Values are of the form
568
+ ``projects/<project>/instances/<instance>/tables/<table>``.
569
+
570
+ This corresponds to the ``table_name`` field
571
+ on the ``request`` instance; if ``request`` is provided, this
572
+ should not be set.
573
+ row_key (:class:`bytes`):
574
+ Required. The key of the row to which
575
+ the mutation should be applied.
576
+
577
+ This corresponds to the ``row_key`` field
578
+ on the ``request`` instance; if ``request`` is provided, this
579
+ should not be set.
580
+ mutations (:class:`MutableSequence[google.cloud.bigtable_v2.types.Mutation]`):
581
+ Required. Changes to be atomically
582
+ applied to the specified row. Entries
583
+ are applied in order, meaning that
584
+ earlier mutations can be masked by later
585
+ ones. Must contain at least one entry
586
+ and at most 100000.
587
+
588
+ This corresponds to the ``mutations`` field
589
+ on the ``request`` instance; if ``request`` is provided, this
590
+ should not be set.
591
+ app_profile_id (:class:`str`):
592
+ This value specifies routing for
593
+ replication. If not specified, the
594
+ "default" application profile will be
595
+ used.
596
+
597
+ This corresponds to the ``app_profile_id`` field
598
+ on the ``request`` instance; if ``request`` is provided, this
599
+ should not be set.
600
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
601
+ should be retried.
602
+ timeout (float): The timeout for this request.
603
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
604
+ sent along with the request as metadata. Normally, each value must be of type `str`,
605
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
606
+ be of type `bytes`.
607
+
608
+ Returns:
609
+ google.cloud.bigtable_v2.types.MutateRowResponse:
610
+ Response message for
611
+ Bigtable.MutateRow.
612
+
613
+ """
614
+ # Create or coerce a protobuf request object.
615
+ # - Quick check: If we got a request object, we should *not* have
616
+ # gotten any keyword arguments that map to the request.
617
+ flattened_params = [table_name, row_key, mutations, app_profile_id]
618
+ has_flattened_params = (
619
+ len([param for param in flattened_params if param is not None]) > 0
620
+ )
621
+ if request is not None and has_flattened_params:
622
+ raise ValueError(
623
+ "If the `request` argument is set, then none of "
624
+ "the individual field arguments should be set."
625
+ )
626
+
627
+ # - Use the request object if provided (there's no risk of modifying the input as
628
+ # there are no flattened fields), or create one.
629
+ if not isinstance(request, bigtable.MutateRowRequest):
630
+ request = bigtable.MutateRowRequest(request)
631
+
632
+ # If we have keyword arguments corresponding to fields on the
633
+ # request, apply these.
634
+ if table_name is not None:
635
+ request.table_name = table_name
636
+ if row_key is not None:
637
+ request.row_key = row_key
638
+ if app_profile_id is not None:
639
+ request.app_profile_id = app_profile_id
640
+ if mutations:
641
+ request.mutations.extend(mutations)
642
+
643
+ # Wrap the RPC method; this adds retry and timeout information,
644
+ # and friendly error handling.
645
+ rpc = self._client._transport._wrapped_methods[
646
+ self._client._transport.mutate_row
647
+ ]
648
+
649
+ header_params = {}
650
+
651
+ routing_param_regex = re.compile(
652
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
653
+ )
654
+ regex_match = routing_param_regex.match(request.table_name)
655
+ if regex_match and regex_match.group("table_name"):
656
+ header_params["table_name"] = regex_match.group("table_name")
657
+
658
+ if request.app_profile_id:
659
+ header_params["app_profile_id"] = request.app_profile_id
660
+
661
+ routing_param_regex = re.compile(
662
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
663
+ )
664
+ regex_match = routing_param_regex.match(request.authorized_view_name)
665
+ if regex_match and regex_match.group("authorized_view_name"):
666
+ header_params["authorized_view_name"] = regex_match.group(
667
+ "authorized_view_name"
668
+ )
669
+
670
+ if header_params:
671
+ metadata = tuple(metadata) + (
672
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
673
+ )
674
+
675
+ # Validate the universe domain.
676
+ self._client._validate_universe_domain()
677
+
678
+ # Send the request.
679
+ response = await rpc(
680
+ request,
681
+ retry=retry,
682
+ timeout=timeout,
683
+ metadata=metadata,
684
+ )
685
+
686
+ # Done; return the response.
687
+ return response
688
+
689
+ def mutate_rows(
690
+ self,
691
+ request: Optional[Union[bigtable.MutateRowsRequest, dict]] = None,
692
+ *,
693
+ table_name: Optional[str] = None,
694
+ entries: Optional[MutableSequence[bigtable.MutateRowsRequest.Entry]] = None,
695
+ app_profile_id: Optional[str] = None,
696
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
697
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
698
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
699
+ ) -> Awaitable[AsyncIterable[bigtable.MutateRowsResponse]]:
700
+ r"""Mutates multiple rows in a batch. Each individual row
701
+ is mutated atomically as in MutateRow, but the entire
702
+ batch is not executed atomically.
703
+
704
+ Args:
705
+ request (Optional[Union[google.cloud.bigtable_v2.types.MutateRowsRequest, dict]]):
706
+ The request object. Request message for
707
+ BigtableService.MutateRows.
708
+ table_name (:class:`str`):
709
+ Optional. The unique name of the table to which the
710
+ mutations should be applied.
711
+
712
+ Values are of the form
713
+ ``projects/<project>/instances/<instance>/tables/<table>``.
714
+
715
+ This corresponds to the ``table_name`` field
716
+ on the ``request`` instance; if ``request`` is provided, this
717
+ should not be set.
718
+ entries (:class:`MutableSequence[google.cloud.bigtable_v2.types.MutateRowsRequest.Entry]`):
719
+ Required. The row keys and
720
+ corresponding mutations to be applied in
721
+ bulk. Each entry is applied as an atomic
722
+ mutation, but the entries may be applied
723
+ in arbitrary order (even between entries
724
+ for the same row). At least one entry
725
+ must be specified, and in total the
726
+ entries can contain at most 100000
727
+ mutations.
728
+
729
+ This corresponds to the ``entries`` field
730
+ on the ``request`` instance; if ``request`` is provided, this
731
+ should not be set.
732
+ app_profile_id (:class:`str`):
733
+ This value specifies routing for
734
+ replication. If not specified, the
735
+ "default" application profile will be
736
+ used.
737
+
738
+ This corresponds to the ``app_profile_id`` field
739
+ on the ``request`` instance; if ``request`` is provided, this
740
+ should not be set.
741
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
742
+ should be retried.
743
+ timeout (float): The timeout for this request.
744
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
745
+ sent along with the request as metadata. Normally, each value must be of type `str`,
746
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
747
+ be of type `bytes`.
748
+
749
+ Returns:
750
+ AsyncIterable[google.cloud.bigtable_v2.types.MutateRowsResponse]:
751
+ Response message for
752
+ BigtableService.MutateRows.
753
+
754
+ """
755
+ # Create or coerce a protobuf request object.
756
+ # - Quick check: If we got a request object, we should *not* have
757
+ # gotten any keyword arguments that map to the request.
758
+ flattened_params = [table_name, entries, app_profile_id]
759
+ has_flattened_params = (
760
+ len([param for param in flattened_params if param is not None]) > 0
761
+ )
762
+ if request is not None and has_flattened_params:
763
+ raise ValueError(
764
+ "If the `request` argument is set, then none of "
765
+ "the individual field arguments should be set."
766
+ )
767
+
768
+ # - Use the request object if provided (there's no risk of modifying the input as
769
+ # there are no flattened fields), or create one.
770
+ if not isinstance(request, bigtable.MutateRowsRequest):
771
+ request = bigtable.MutateRowsRequest(request)
772
+
773
+ # If we have keyword arguments corresponding to fields on the
774
+ # request, apply these.
775
+ if table_name is not None:
776
+ request.table_name = table_name
777
+ if app_profile_id is not None:
778
+ request.app_profile_id = app_profile_id
779
+ if entries:
780
+ request.entries.extend(entries)
781
+
782
+ # Wrap the RPC method; this adds retry and timeout information,
783
+ # and friendly error handling.
784
+ rpc = self._client._transport._wrapped_methods[
785
+ self._client._transport.mutate_rows
786
+ ]
787
+
788
+ header_params = {}
789
+
790
+ routing_param_regex = re.compile(
791
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
792
+ )
793
+ regex_match = routing_param_regex.match(request.table_name)
794
+ if regex_match and regex_match.group("table_name"):
795
+ header_params["table_name"] = regex_match.group("table_name")
796
+
797
+ if request.app_profile_id:
798
+ header_params["app_profile_id"] = request.app_profile_id
799
+
800
+ routing_param_regex = re.compile(
801
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
802
+ )
803
+ regex_match = routing_param_regex.match(request.authorized_view_name)
804
+ if regex_match and regex_match.group("authorized_view_name"):
805
+ header_params["authorized_view_name"] = regex_match.group(
806
+ "authorized_view_name"
807
+ )
808
+
809
+ if header_params:
810
+ metadata = tuple(metadata) + (
811
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
812
+ )
813
+
814
+ # Validate the universe domain.
815
+ self._client._validate_universe_domain()
816
+
817
+ # Send the request.
818
+ response = rpc(
819
+ request,
820
+ retry=retry,
821
+ timeout=timeout,
822
+ metadata=metadata,
823
+ )
824
+
825
+ # Done; return the response.
826
+ return response
827
+
828
+ async def check_and_mutate_row(
829
+ self,
830
+ request: Optional[Union[bigtable.CheckAndMutateRowRequest, dict]] = None,
831
+ *,
832
+ table_name: Optional[str] = None,
833
+ row_key: Optional[bytes] = None,
834
+ predicate_filter: Optional[data.RowFilter] = None,
835
+ true_mutations: Optional[MutableSequence[data.Mutation]] = None,
836
+ false_mutations: Optional[MutableSequence[data.Mutation]] = None,
837
+ app_profile_id: Optional[str] = None,
838
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
839
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
840
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
841
+ ) -> bigtable.CheckAndMutateRowResponse:
842
+ r"""Mutates a row atomically based on the output of a
843
+ predicate Reader filter.
844
+
845
+ Args:
846
+ request (Optional[Union[google.cloud.bigtable_v2.types.CheckAndMutateRowRequest, dict]]):
847
+ The request object. Request message for
848
+ Bigtable.CheckAndMutateRow.
849
+ table_name (:class:`str`):
850
+ Optional. The unique name of the table to which the
851
+ conditional mutation should be applied.
852
+
853
+ Values are of the form
854
+ ``projects/<project>/instances/<instance>/tables/<table>``.
855
+
856
+ This corresponds to the ``table_name`` field
857
+ on the ``request`` instance; if ``request`` is provided, this
858
+ should not be set.
859
+ row_key (:class:`bytes`):
860
+ Required. The key of the row to which
861
+ the conditional mutation should be
862
+ applied.
863
+
864
+ This corresponds to the ``row_key`` field
865
+ on the ``request`` instance; if ``request`` is provided, this
866
+ should not be set.
867
+ predicate_filter (:class:`google.cloud.bigtable_v2.types.RowFilter`):
868
+ The filter to be applied to the contents of the
869
+ specified row. Depending on whether or not any results
870
+ are yielded, either ``true_mutations`` or
871
+ ``false_mutations`` will be executed. If unset, checks
872
+ that the row contains any values at all.
873
+
874
+ This corresponds to the ``predicate_filter`` field
875
+ on the ``request`` instance; if ``request`` is provided, this
876
+ should not be set.
877
+ true_mutations (:class:`MutableSequence[google.cloud.bigtable_v2.types.Mutation]`):
878
+ Changes to be atomically applied to the specified row if
879
+ ``predicate_filter`` yields at least one cell when
880
+ applied to ``row_key``. Entries are applied in order,
881
+ meaning that earlier mutations can be masked by later
882
+ ones. Must contain at least one entry if
883
+ ``false_mutations`` is empty, and at most 100000.
884
+
885
+ This corresponds to the ``true_mutations`` field
886
+ on the ``request`` instance; if ``request`` is provided, this
887
+ should not be set.
888
+ false_mutations (:class:`MutableSequence[google.cloud.bigtable_v2.types.Mutation]`):
889
+ Changes to be atomically applied to the specified row if
890
+ ``predicate_filter`` does not yield any cells when
891
+ applied to ``row_key``. Entries are applied in order,
892
+ meaning that earlier mutations can be masked by later
893
+ ones. Must contain at least one entry if
894
+ ``true_mutations`` is empty, and at most 100000.
895
+
896
+ This corresponds to the ``false_mutations`` field
897
+ on the ``request`` instance; if ``request`` is provided, this
898
+ should not be set.
899
+ app_profile_id (:class:`str`):
900
+ This value specifies routing for
901
+ replication. If not specified, the
902
+ "default" application profile will be
903
+ used.
904
+
905
+ This corresponds to the ``app_profile_id`` field
906
+ on the ``request`` instance; if ``request`` is provided, this
907
+ should not be set.
908
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
909
+ should be retried.
910
+ timeout (float): The timeout for this request.
911
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
912
+ sent along with the request as metadata. Normally, each value must be of type `str`,
913
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
914
+ be of type `bytes`.
915
+
916
+ Returns:
917
+ google.cloud.bigtable_v2.types.CheckAndMutateRowResponse:
918
+ Response message for
919
+ Bigtable.CheckAndMutateRow.
920
+
921
+ """
922
+ # Create or coerce a protobuf request object.
923
+ # - Quick check: If we got a request object, we should *not* have
924
+ # gotten any keyword arguments that map to the request.
925
+ flattened_params = [
926
+ table_name,
927
+ row_key,
928
+ predicate_filter,
929
+ true_mutations,
930
+ false_mutations,
931
+ app_profile_id,
932
+ ]
933
+ has_flattened_params = (
934
+ len([param for param in flattened_params if param is not None]) > 0
935
+ )
936
+ if request is not None and has_flattened_params:
937
+ raise ValueError(
938
+ "If the `request` argument is set, then none of "
939
+ "the individual field arguments should be set."
940
+ )
941
+
942
+ # - Use the request object if provided (there's no risk of modifying the input as
943
+ # there are no flattened fields), or create one.
944
+ if not isinstance(request, bigtable.CheckAndMutateRowRequest):
945
+ request = bigtable.CheckAndMutateRowRequest(request)
946
+
947
+ # If we have keyword arguments corresponding to fields on the
948
+ # request, apply these.
949
+ if table_name is not None:
950
+ request.table_name = table_name
951
+ if row_key is not None:
952
+ request.row_key = row_key
953
+ if predicate_filter is not None:
954
+ request.predicate_filter = predicate_filter
955
+ if app_profile_id is not None:
956
+ request.app_profile_id = app_profile_id
957
+ if true_mutations:
958
+ request.true_mutations.extend(true_mutations)
959
+ if false_mutations:
960
+ request.false_mutations.extend(false_mutations)
961
+
962
+ # Wrap the RPC method; this adds retry and timeout information,
963
+ # and friendly error handling.
964
+ rpc = self._client._transport._wrapped_methods[
965
+ self._client._transport.check_and_mutate_row
966
+ ]
967
+
968
+ header_params = {}
969
+
970
+ routing_param_regex = re.compile(
971
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
972
+ )
973
+ regex_match = routing_param_regex.match(request.table_name)
974
+ if regex_match and regex_match.group("table_name"):
975
+ header_params["table_name"] = regex_match.group("table_name")
976
+
977
+ if request.app_profile_id:
978
+ header_params["app_profile_id"] = request.app_profile_id
979
+
980
+ routing_param_regex = re.compile(
981
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
982
+ )
983
+ regex_match = routing_param_regex.match(request.authorized_view_name)
984
+ if regex_match and regex_match.group("authorized_view_name"):
985
+ header_params["authorized_view_name"] = regex_match.group(
986
+ "authorized_view_name"
987
+ )
988
+
989
+ if header_params:
990
+ metadata = tuple(metadata) + (
991
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
992
+ )
993
+
994
+ # Validate the universe domain.
995
+ self._client._validate_universe_domain()
996
+
997
+ # Send the request.
998
+ response = await rpc(
999
+ request,
1000
+ retry=retry,
1001
+ timeout=timeout,
1002
+ metadata=metadata,
1003
+ )
1004
+
1005
+ # Done; return the response.
1006
+ return response
1007
+
1008
+ async def ping_and_warm(
1009
+ self,
1010
+ request: Optional[Union[bigtable.PingAndWarmRequest, dict]] = None,
1011
+ *,
1012
+ name: Optional[str] = None,
1013
+ app_profile_id: Optional[str] = None,
1014
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1015
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1016
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1017
+ ) -> bigtable.PingAndWarmResponse:
1018
+ r"""Warm up associated instance metadata for this
1019
+ connection. This call is not required but may be useful
1020
+ for connection keep-alive.
1021
+
1022
+ Args:
1023
+ request (Optional[Union[google.cloud.bigtable_v2.types.PingAndWarmRequest, dict]]):
1024
+ The request object. Request message for client connection
1025
+ keep-alive and warming.
1026
+ name (:class:`str`):
1027
+ Required. The unique name of the instance to check
1028
+ permissions for as well as respond. Values are of the
1029
+ form ``projects/<project>/instances/<instance>``.
1030
+
1031
+ This corresponds to the ``name`` field
1032
+ on the ``request`` instance; if ``request`` is provided, this
1033
+ should not be set.
1034
+ app_profile_id (:class:`str`):
1035
+ This value specifies routing for
1036
+ replication. If not specified, the
1037
+ "default" application profile will be
1038
+ used.
1039
+
1040
+ This corresponds to the ``app_profile_id`` field
1041
+ on the ``request`` instance; if ``request`` is provided, this
1042
+ should not be set.
1043
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1044
+ should be retried.
1045
+ timeout (float): The timeout for this request.
1046
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1047
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1048
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1049
+ be of type `bytes`.
1050
+
1051
+ Returns:
1052
+ google.cloud.bigtable_v2.types.PingAndWarmResponse:
1053
+ Response message for
1054
+ Bigtable.PingAndWarm connection
1055
+ keepalive and warming.
1056
+
1057
+ """
1058
+ # Create or coerce a protobuf request object.
1059
+ # - Quick check: If we got a request object, we should *not* have
1060
+ # gotten any keyword arguments that map to the request.
1061
+ flattened_params = [name, app_profile_id]
1062
+ has_flattened_params = (
1063
+ len([param for param in flattened_params if param is not None]) > 0
1064
+ )
1065
+ if request is not None and has_flattened_params:
1066
+ raise ValueError(
1067
+ "If the `request` argument is set, then none of "
1068
+ "the individual field arguments should be set."
1069
+ )
1070
+
1071
+ # - Use the request object if provided (there's no risk of modifying the input as
1072
+ # there are no flattened fields), or create one.
1073
+ if not isinstance(request, bigtable.PingAndWarmRequest):
1074
+ request = bigtable.PingAndWarmRequest(request)
1075
+
1076
+ # If we have keyword arguments corresponding to fields on the
1077
+ # request, apply these.
1078
+ if name is not None:
1079
+ request.name = name
1080
+ if app_profile_id is not None:
1081
+ request.app_profile_id = app_profile_id
1082
+
1083
+ # Wrap the RPC method; this adds retry and timeout information,
1084
+ # and friendly error handling.
1085
+ rpc = self._client._transport._wrapped_methods[
1086
+ self._client._transport.ping_and_warm
1087
+ ]
1088
+
1089
+ header_params = {}
1090
+
1091
+ routing_param_regex = re.compile("^(?P<name>projects/[^/]+/instances/[^/]+)$")
1092
+ regex_match = routing_param_regex.match(request.name)
1093
+ if regex_match and regex_match.group("name"):
1094
+ header_params["name"] = regex_match.group("name")
1095
+
1096
+ if request.app_profile_id:
1097
+ header_params["app_profile_id"] = request.app_profile_id
1098
+
1099
+ if header_params:
1100
+ metadata = tuple(metadata) + (
1101
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
1102
+ )
1103
+
1104
+ # Validate the universe domain.
1105
+ self._client._validate_universe_domain()
1106
+
1107
+ # Send the request.
1108
+ response = await rpc(
1109
+ request,
1110
+ retry=retry,
1111
+ timeout=timeout,
1112
+ metadata=metadata,
1113
+ )
1114
+
1115
+ # Done; return the response.
1116
+ return response
1117
+
1118
+ async def read_modify_write_row(
1119
+ self,
1120
+ request: Optional[Union[bigtable.ReadModifyWriteRowRequest, dict]] = None,
1121
+ *,
1122
+ table_name: Optional[str] = None,
1123
+ row_key: Optional[bytes] = None,
1124
+ rules: Optional[MutableSequence[data.ReadModifyWriteRule]] = None,
1125
+ app_profile_id: Optional[str] = None,
1126
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1127
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1128
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1129
+ ) -> bigtable.ReadModifyWriteRowResponse:
1130
+ r"""Modifies a row atomically on the server. The method
1131
+ reads the latest existing timestamp and value from the
1132
+ specified columns and writes a new entry based on
1133
+ pre-defined read/modify/write rules. The new value for
1134
+ the timestamp is the greater of the existing timestamp
1135
+ or the current server time. The method returns the new
1136
+ contents of all modified cells.
1137
+
1138
+ Args:
1139
+ request (Optional[Union[google.cloud.bigtable_v2.types.ReadModifyWriteRowRequest, dict]]):
1140
+ The request object. Request message for
1141
+ Bigtable.ReadModifyWriteRow.
1142
+ table_name (:class:`str`):
1143
+ Optional. The unique name of the table to which the
1144
+ read/modify/write rules should be applied.
1145
+
1146
+ Values are of the form
1147
+ ``projects/<project>/instances/<instance>/tables/<table>``.
1148
+
1149
+ This corresponds to the ``table_name`` field
1150
+ on the ``request`` instance; if ``request`` is provided, this
1151
+ should not be set.
1152
+ row_key (:class:`bytes`):
1153
+ Required. The key of the row to which
1154
+ the read/modify/write rules should be
1155
+ applied.
1156
+
1157
+ This corresponds to the ``row_key`` field
1158
+ on the ``request`` instance; if ``request`` is provided, this
1159
+ should not be set.
1160
+ rules (:class:`MutableSequence[google.cloud.bigtable_v2.types.ReadModifyWriteRule]`):
1161
+ Required. Rules specifying how the
1162
+ specified row's contents are to be
1163
+ transformed into writes. Entries are
1164
+ applied in order, meaning that earlier
1165
+ rules will affect the results of later
1166
+ ones.
1167
+
1168
+ This corresponds to the ``rules`` field
1169
+ on the ``request`` instance; if ``request`` is provided, this
1170
+ should not be set.
1171
+ app_profile_id (:class:`str`):
1172
+ This value specifies routing for
1173
+ replication. If not specified, the
1174
+ "default" application profile will be
1175
+ used.
1176
+
1177
+ This corresponds to the ``app_profile_id`` field
1178
+ on the ``request`` instance; if ``request`` is provided, this
1179
+ should not be set.
1180
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1181
+ should be retried.
1182
+ timeout (float): The timeout for this request.
1183
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1184
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1185
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1186
+ be of type `bytes`.
1187
+
1188
+ Returns:
1189
+ google.cloud.bigtable_v2.types.ReadModifyWriteRowResponse:
1190
+ Response message for
1191
+ Bigtable.ReadModifyWriteRow.
1192
+
1193
+ """
1194
+ # Create or coerce a protobuf request object.
1195
+ # - Quick check: If we got a request object, we should *not* have
1196
+ # gotten any keyword arguments that map to the request.
1197
+ flattened_params = [table_name, row_key, rules, app_profile_id]
1198
+ has_flattened_params = (
1199
+ len([param for param in flattened_params if param is not None]) > 0
1200
+ )
1201
+ if request is not None and has_flattened_params:
1202
+ raise ValueError(
1203
+ "If the `request` argument is set, then none of "
1204
+ "the individual field arguments should be set."
1205
+ )
1206
+
1207
+ # - Use the request object if provided (there's no risk of modifying the input as
1208
+ # there are no flattened fields), or create one.
1209
+ if not isinstance(request, bigtable.ReadModifyWriteRowRequest):
1210
+ request = bigtable.ReadModifyWriteRowRequest(request)
1211
+
1212
+ # If we have keyword arguments corresponding to fields on the
1213
+ # request, apply these.
1214
+ if table_name is not None:
1215
+ request.table_name = table_name
1216
+ if row_key is not None:
1217
+ request.row_key = row_key
1218
+ if app_profile_id is not None:
1219
+ request.app_profile_id = app_profile_id
1220
+ if rules:
1221
+ request.rules.extend(rules)
1222
+
1223
+ # Wrap the RPC method; this adds retry and timeout information,
1224
+ # and friendly error handling.
1225
+ rpc = self._client._transport._wrapped_methods[
1226
+ self._client._transport.read_modify_write_row
1227
+ ]
1228
+
1229
+ header_params = {}
1230
+
1231
+ routing_param_regex = re.compile(
1232
+ "^(?P<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)$"
1233
+ )
1234
+ regex_match = routing_param_regex.match(request.table_name)
1235
+ if regex_match and regex_match.group("table_name"):
1236
+ header_params["table_name"] = regex_match.group("table_name")
1237
+
1238
+ if request.app_profile_id:
1239
+ header_params["app_profile_id"] = request.app_profile_id
1240
+
1241
+ routing_param_regex = re.compile(
1242
+ "^(?P<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)$"
1243
+ )
1244
+ regex_match = routing_param_regex.match(request.authorized_view_name)
1245
+ if regex_match and regex_match.group("authorized_view_name"):
1246
+ header_params["authorized_view_name"] = regex_match.group(
1247
+ "authorized_view_name"
1248
+ )
1249
+
1250
+ if header_params:
1251
+ metadata = tuple(metadata) + (
1252
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
1253
+ )
1254
+
1255
+ # Validate the universe domain.
1256
+ self._client._validate_universe_domain()
1257
+
1258
+ # Send the request.
1259
+ response = await rpc(
1260
+ request,
1261
+ retry=retry,
1262
+ timeout=timeout,
1263
+ metadata=metadata,
1264
+ )
1265
+
1266
+ # Done; return the response.
1267
+ return response
1268
+
1269
+ def generate_initial_change_stream_partitions(
1270
+ self,
1271
+ request: Optional[
1272
+ Union[bigtable.GenerateInitialChangeStreamPartitionsRequest, dict]
1273
+ ] = None,
1274
+ *,
1275
+ table_name: Optional[str] = None,
1276
+ app_profile_id: Optional[str] = None,
1277
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1278
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1279
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1280
+ ) -> Awaitable[
1281
+ AsyncIterable[bigtable.GenerateInitialChangeStreamPartitionsResponse]
1282
+ ]:
1283
+ r"""NOTE: This API is intended to be used by Apache Beam BigtableIO.
1284
+ Returns the current list of partitions that make up the table's
1285
+ change stream. The union of partitions will cover the entire
1286
+ keyspace. Partitions can be read with ``ReadChangeStream``.
1287
+
1288
+ Args:
1289
+ request (Optional[Union[google.cloud.bigtable_v2.types.GenerateInitialChangeStreamPartitionsRequest, dict]]):
1290
+ The request object. NOTE: This API is intended to be used
1291
+ by Apache Beam BigtableIO. Request
1292
+ message for
1293
+ Bigtable.GenerateInitialChangeStreamPartitions.
1294
+ table_name (:class:`str`):
1295
+ Required. The unique name of the table from which to get
1296
+ change stream partitions. Values are of the form
1297
+ ``projects/<project>/instances/<instance>/tables/<table>``.
1298
+ Change streaming must be enabled on the table.
1299
+
1300
+ This corresponds to the ``table_name`` field
1301
+ on the ``request`` instance; if ``request`` is provided, this
1302
+ should not be set.
1303
+ app_profile_id (:class:`str`):
1304
+ This value specifies routing for
1305
+ replication. If not specified, the
1306
+ "default" application profile will be
1307
+ used. Single cluster routing must be
1308
+ configured on the profile.
1309
+
1310
+ This corresponds to the ``app_profile_id`` field
1311
+ on the ``request`` instance; if ``request`` is provided, this
1312
+ should not be set.
1313
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1314
+ should be retried.
1315
+ timeout (float): The timeout for this request.
1316
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1317
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1318
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1319
+ be of type `bytes`.
1320
+
1321
+ Returns:
1322
+ AsyncIterable[google.cloud.bigtable_v2.types.GenerateInitialChangeStreamPartitionsResponse]:
1323
+ NOTE: This API is intended to be used
1324
+ by Apache Beam BigtableIO. Response
1325
+ message for
1326
+ Bigtable.GenerateInitialChangeStreamPartitions.
1327
+
1328
+ """
1329
+ # Create or coerce a protobuf request object.
1330
+ # - Quick check: If we got a request object, we should *not* have
1331
+ # gotten any keyword arguments that map to the request.
1332
+ flattened_params = [table_name, app_profile_id]
1333
+ has_flattened_params = (
1334
+ len([param for param in flattened_params if param is not None]) > 0
1335
+ )
1336
+ if request is not None and has_flattened_params:
1337
+ raise ValueError(
1338
+ "If the `request` argument is set, then none of "
1339
+ "the individual field arguments should be set."
1340
+ )
1341
+
1342
+ # - Use the request object if provided (there's no risk of modifying the input as
1343
+ # there are no flattened fields), or create one.
1344
+ if not isinstance(
1345
+ request, bigtable.GenerateInitialChangeStreamPartitionsRequest
1346
+ ):
1347
+ request = bigtable.GenerateInitialChangeStreamPartitionsRequest(request)
1348
+
1349
+ # If we have keyword arguments corresponding to fields on the
1350
+ # request, apply these.
1351
+ if table_name is not None:
1352
+ request.table_name = table_name
1353
+ if app_profile_id is not None:
1354
+ request.app_profile_id = app_profile_id
1355
+
1356
+ # Wrap the RPC method; this adds retry and timeout information,
1357
+ # and friendly error handling.
1358
+ rpc = self._client._transport._wrapped_methods[
1359
+ self._client._transport.generate_initial_change_stream_partitions
1360
+ ]
1361
+
1362
+ # Certain fields should be provided within the metadata header;
1363
+ # add these here.
1364
+ metadata = tuple(metadata) + (
1365
+ gapic_v1.routing_header.to_grpc_metadata(
1366
+ (("table_name", request.table_name),)
1367
+ ),
1368
+ )
1369
+
1370
+ # Validate the universe domain.
1371
+ self._client._validate_universe_domain()
1372
+
1373
+ # Send the request.
1374
+ response = rpc(
1375
+ request,
1376
+ retry=retry,
1377
+ timeout=timeout,
1378
+ metadata=metadata,
1379
+ )
1380
+
1381
+ # Done; return the response.
1382
+ return response
1383
+
1384
+ def read_change_stream(
1385
+ self,
1386
+ request: Optional[Union[bigtable.ReadChangeStreamRequest, dict]] = None,
1387
+ *,
1388
+ table_name: Optional[str] = None,
1389
+ app_profile_id: Optional[str] = None,
1390
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1391
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1392
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1393
+ ) -> Awaitable[AsyncIterable[bigtable.ReadChangeStreamResponse]]:
1394
+ r"""NOTE: This API is intended to be used by Apache Beam
1395
+ BigtableIO. Reads changes from a table's change stream.
1396
+ Changes will reflect both user-initiated mutations and
1397
+ mutations that are caused by garbage collection.
1398
+
1399
+ Args:
1400
+ request (Optional[Union[google.cloud.bigtable_v2.types.ReadChangeStreamRequest, dict]]):
1401
+ The request object. NOTE: This API is intended to be used
1402
+ by Apache Beam BigtableIO. Request
1403
+ message for Bigtable.ReadChangeStream.
1404
+ table_name (:class:`str`):
1405
+ Required. The unique name of the table from which to
1406
+ read a change stream. Values are of the form
1407
+ ``projects/<project>/instances/<instance>/tables/<table>``.
1408
+ Change streaming must be enabled on the table.
1409
+
1410
+ This corresponds to the ``table_name`` field
1411
+ on the ``request`` instance; if ``request`` is provided, this
1412
+ should not be set.
1413
+ app_profile_id (:class:`str`):
1414
+ This value specifies routing for
1415
+ replication. If not specified, the
1416
+ "default" application profile will be
1417
+ used. Single cluster routing must be
1418
+ configured on the profile.
1419
+
1420
+ This corresponds to the ``app_profile_id`` field
1421
+ on the ``request`` instance; if ``request`` is provided, this
1422
+ should not be set.
1423
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1424
+ should be retried.
1425
+ timeout (float): The timeout for this request.
1426
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1427
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1428
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1429
+ be of type `bytes`.
1430
+
1431
+ Returns:
1432
+ AsyncIterable[google.cloud.bigtable_v2.types.ReadChangeStreamResponse]:
1433
+ NOTE: This API is intended to be used
1434
+ by Apache Beam BigtableIO. Response
1435
+ message for Bigtable.ReadChangeStream.
1436
+
1437
+ """
1438
+ # Create or coerce a protobuf request object.
1439
+ # - Quick check: If we got a request object, we should *not* have
1440
+ # gotten any keyword arguments that map to the request.
1441
+ flattened_params = [table_name, app_profile_id]
1442
+ has_flattened_params = (
1443
+ len([param for param in flattened_params if param is not None]) > 0
1444
+ )
1445
+ if request is not None and has_flattened_params:
1446
+ raise ValueError(
1447
+ "If the `request` argument is set, then none of "
1448
+ "the individual field arguments should be set."
1449
+ )
1450
+
1451
+ # - Use the request object if provided (there's no risk of modifying the input as
1452
+ # there are no flattened fields), or create one.
1453
+ if not isinstance(request, bigtable.ReadChangeStreamRequest):
1454
+ request = bigtable.ReadChangeStreamRequest(request)
1455
+
1456
+ # If we have keyword arguments corresponding to fields on the
1457
+ # request, apply these.
1458
+ if table_name is not None:
1459
+ request.table_name = table_name
1460
+ if app_profile_id is not None:
1461
+ request.app_profile_id = app_profile_id
1462
+
1463
+ # Wrap the RPC method; this adds retry and timeout information,
1464
+ # and friendly error handling.
1465
+ rpc = self._client._transport._wrapped_methods[
1466
+ self._client._transport.read_change_stream
1467
+ ]
1468
+
1469
+ # Certain fields should be provided within the metadata header;
1470
+ # add these here.
1471
+ metadata = tuple(metadata) + (
1472
+ gapic_v1.routing_header.to_grpc_metadata(
1473
+ (("table_name", request.table_name),)
1474
+ ),
1475
+ )
1476
+
1477
+ # Validate the universe domain.
1478
+ self._client._validate_universe_domain()
1479
+
1480
+ # Send the request.
1481
+ response = rpc(
1482
+ request,
1483
+ retry=retry,
1484
+ timeout=timeout,
1485
+ metadata=metadata,
1486
+ )
1487
+
1488
+ # Done; return the response.
1489
+ return response
1490
+
1491
+ async def prepare_query(
1492
+ self,
1493
+ request: Optional[Union[bigtable.PrepareQueryRequest, dict]] = None,
1494
+ *,
1495
+ instance_name: Optional[str] = None,
1496
+ query: Optional[str] = None,
1497
+ app_profile_id: Optional[str] = None,
1498
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1499
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1500
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1501
+ ) -> bigtable.PrepareQueryResponse:
1502
+ r"""Prepares a GoogleSQL query for execution on a
1503
+ particular Bigtable instance.
1504
+
1505
+ Args:
1506
+ request (Optional[Union[google.cloud.bigtable_v2.types.PrepareQueryRequest, dict]]):
1507
+ The request object. Request message for
1508
+ Bigtable.PrepareQuery
1509
+ instance_name (:class:`str`):
1510
+ Required. The unique name of the instance against which
1511
+ the query should be executed. Values are of the form
1512
+ ``projects/<project>/instances/<instance>``
1513
+
1514
+ This corresponds to the ``instance_name`` field
1515
+ on the ``request`` instance; if ``request`` is provided, this
1516
+ should not be set.
1517
+ query (:class:`str`):
1518
+ Required. The query string.
1519
+ This corresponds to the ``query`` field
1520
+ on the ``request`` instance; if ``request`` is provided, this
1521
+ should not be set.
1522
+ app_profile_id (:class:`str`):
1523
+ Optional. This value specifies routing for preparing the
1524
+ query. Note that this ``app_profile_id`` is only used
1525
+ for preparing the query. The actual query execution will
1526
+ use the app profile specified in the
1527
+ ``ExecuteQueryRequest``. If not specified, the
1528
+ ``default`` application profile will be used.
1529
+
1530
+ This corresponds to the ``app_profile_id`` field
1531
+ on the ``request`` instance; if ``request`` is provided, this
1532
+ should not be set.
1533
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1534
+ should be retried.
1535
+ timeout (float): The timeout for this request.
1536
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1537
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1538
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1539
+ be of type `bytes`.
1540
+
1541
+ Returns:
1542
+ google.cloud.bigtable_v2.types.PrepareQueryResponse:
1543
+ Response message for
1544
+ Bigtable.PrepareQueryResponse
1545
+
1546
+ """
1547
+ # Create or coerce a protobuf request object.
1548
+ # - Quick check: If we got a request object, we should *not* have
1549
+ # gotten any keyword arguments that map to the request.
1550
+ flattened_params = [instance_name, query, app_profile_id]
1551
+ has_flattened_params = (
1552
+ len([param for param in flattened_params if param is not None]) > 0
1553
+ )
1554
+ if request is not None and has_flattened_params:
1555
+ raise ValueError(
1556
+ "If the `request` argument is set, then none of "
1557
+ "the individual field arguments should be set."
1558
+ )
1559
+
1560
+ # - Use the request object if provided (there's no risk of modifying the input as
1561
+ # there are no flattened fields), or create one.
1562
+ if not isinstance(request, bigtable.PrepareQueryRequest):
1563
+ request = bigtable.PrepareQueryRequest(request)
1564
+
1565
+ # If we have keyword arguments corresponding to fields on the
1566
+ # request, apply these.
1567
+ if instance_name is not None:
1568
+ request.instance_name = instance_name
1569
+ if query is not None:
1570
+ request.query = query
1571
+ if app_profile_id is not None:
1572
+ request.app_profile_id = app_profile_id
1573
+
1574
+ # Wrap the RPC method; this adds retry and timeout information,
1575
+ # and friendly error handling.
1576
+ rpc = self._client._transport._wrapped_methods[
1577
+ self._client._transport.prepare_query
1578
+ ]
1579
+
1580
+ header_params = {}
1581
+
1582
+ routing_param_regex = re.compile("^(?P<name>projects/[^/]+/instances/[^/]+)$")
1583
+ regex_match = routing_param_regex.match(request.instance_name)
1584
+ if regex_match and regex_match.group("name"):
1585
+ header_params["name"] = regex_match.group("name")
1586
+
1587
+ if request.app_profile_id:
1588
+ header_params["app_profile_id"] = request.app_profile_id
1589
+
1590
+ if header_params:
1591
+ metadata = tuple(metadata) + (
1592
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
1593
+ )
1594
+
1595
+ # Validate the universe domain.
1596
+ self._client._validate_universe_domain()
1597
+
1598
+ # Send the request.
1599
+ response = await rpc(
1600
+ request,
1601
+ retry=retry,
1602
+ timeout=timeout,
1603
+ metadata=metadata,
1604
+ )
1605
+
1606
+ # Done; return the response.
1607
+ return response
1608
+
1609
+ def execute_query(
1610
+ self,
1611
+ request: Optional[Union[bigtable.ExecuteQueryRequest, dict]] = None,
1612
+ *,
1613
+ instance_name: Optional[str] = None,
1614
+ query: Optional[str] = None,
1615
+ app_profile_id: Optional[str] = None,
1616
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1617
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1618
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1619
+ ) -> Awaitable[AsyncIterable[bigtable.ExecuteQueryResponse]]:
1620
+ r"""Executes a SQL query against a particular Bigtable
1621
+ instance.
1622
+
1623
+ Args:
1624
+ request (Optional[Union[google.cloud.bigtable_v2.types.ExecuteQueryRequest, dict]]):
1625
+ The request object. Request message for
1626
+ Bigtable.ExecuteQuery
1627
+ instance_name (:class:`str`):
1628
+ Required. The unique name of the instance against which
1629
+ the query should be executed. Values are of the form
1630
+ ``projects/<project>/instances/<instance>``
1631
+
1632
+ This corresponds to the ``instance_name`` field
1633
+ on the ``request`` instance; if ``request`` is provided, this
1634
+ should not be set.
1635
+ query (:class:`str`):
1636
+ Required. The query string.
1637
+
1638
+ Exactly one of ``query`` and ``prepared_query`` is
1639
+ required. Setting both or neither is an
1640
+ ``INVALID_ARGUMENT``.
1641
+
1642
+ This corresponds to the ``query`` field
1643
+ on the ``request`` instance; if ``request`` is provided, this
1644
+ should not be set.
1645
+ app_profile_id (:class:`str`):
1646
+ Optional. This value specifies routing for replication.
1647
+ If not specified, the ``default`` application profile
1648
+ will be used.
1649
+
1650
+ This corresponds to the ``app_profile_id`` field
1651
+ on the ``request`` instance; if ``request`` is provided, this
1652
+ should not be set.
1653
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1654
+ should be retried.
1655
+ timeout (float): The timeout for this request.
1656
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1657
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1658
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1659
+ be of type `bytes`.
1660
+
1661
+ Returns:
1662
+ AsyncIterable[google.cloud.bigtable_v2.types.ExecuteQueryResponse]:
1663
+ Response message for
1664
+ Bigtable.ExecuteQuery
1665
+
1666
+ """
1667
+ # Create or coerce a protobuf request object.
1668
+ # - Quick check: If we got a request object, we should *not* have
1669
+ # gotten any keyword arguments that map to the request.
1670
+ flattened_params = [instance_name, query, app_profile_id]
1671
+ has_flattened_params = (
1672
+ len([param for param in flattened_params if param is not None]) > 0
1673
+ )
1674
+ if request is not None and has_flattened_params:
1675
+ raise ValueError(
1676
+ "If the `request` argument is set, then none of "
1677
+ "the individual field arguments should be set."
1678
+ )
1679
+
1680
+ # - Use the request object if provided (there's no risk of modifying the input as
1681
+ # there are no flattened fields), or create one.
1682
+ if not isinstance(request, bigtable.ExecuteQueryRequest):
1683
+ request = bigtable.ExecuteQueryRequest(request)
1684
+
1685
+ # If we have keyword arguments corresponding to fields on the
1686
+ # request, apply these.
1687
+ if instance_name is not None:
1688
+ request.instance_name = instance_name
1689
+ if query is not None:
1690
+ request.query = query
1691
+ if app_profile_id is not None:
1692
+ request.app_profile_id = app_profile_id
1693
+
1694
+ # Wrap the RPC method; this adds retry and timeout information,
1695
+ # and friendly error handling.
1696
+ rpc = self._client._transport._wrapped_methods[
1697
+ self._client._transport.execute_query
1698
+ ]
1699
+
1700
+ header_params = {}
1701
+
1702
+ routing_param_regex = re.compile("^(?P<name>projects/[^/]+/instances/[^/]+)$")
1703
+ regex_match = routing_param_regex.match(request.instance_name)
1704
+ if regex_match and regex_match.group("name"):
1705
+ header_params["name"] = regex_match.group("name")
1706
+
1707
+ if request.app_profile_id:
1708
+ header_params["app_profile_id"] = request.app_profile_id
1709
+
1710
+ if header_params:
1711
+ metadata = tuple(metadata) + (
1712
+ gapic_v1.routing_header.to_grpc_metadata(header_params),
1713
+ )
1714
+
1715
+ # Validate the universe domain.
1716
+ self._client._validate_universe_domain()
1717
+
1718
+ # Send the request.
1719
+ response = rpc(
1720
+ request,
1721
+ retry=retry,
1722
+ timeout=timeout,
1723
+ metadata=metadata,
1724
+ )
1725
+
1726
+ # Done; return the response.
1727
+ return response
1728
+
1729
+ async def __aenter__(self) -> "BigtableAsyncClient":
1730
+ return self
1731
+
1732
+ async def __aexit__(self, exc_type, exc, tb):
1733
+ await self.transport.close()
1734
+
1735
+
1736
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1737
+ gapic_version=package_version.__version__
1738
+ )
1739
+
1740
+
1741
+ __all__ = ("BigtableAsyncClient",)