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,2489 @@
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
17
+ import json # type: ignore
18
+
19
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
20
+ from google.auth import credentials as ga_credentials # type: ignore
21
+ from google.api_core import exceptions as core_exceptions
22
+ from google.api_core import retry as retries
23
+ from google.api_core import rest_helpers
24
+ from google.api_core import rest_streaming
25
+ from google.api_core import gapic_v1
26
+
27
+ from google.protobuf import json_format
28
+
29
+ from requests import __version__ as requests_version
30
+ import dataclasses
31
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
32
+ import warnings
33
+
34
+
35
+ from google.cloud.bigtable_v2.types import bigtable
36
+
37
+
38
+ from .rest_base import _BaseBigtableRestTransport
39
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
40
+
41
+ try:
42
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
43
+ except AttributeError: # pragma: NO COVER
44
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
45
+
46
+ try:
47
+ from google.api_core import client_logging # type: ignore
48
+
49
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
50
+ except ImportError: # pragma: NO COVER
51
+ CLIENT_LOGGING_SUPPORTED = False
52
+
53
+ _LOGGER = logging.getLogger(__name__)
54
+
55
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
56
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
57
+ grpc_version=None,
58
+ rest_version=f"requests@{requests_version}",
59
+ )
60
+
61
+
62
+ class BigtableRestInterceptor:
63
+ """Interceptor for Bigtable.
64
+
65
+ Interceptors are used to manipulate requests, request metadata, and responses
66
+ in arbitrary ways.
67
+ Example use cases include:
68
+ * Logging
69
+ * Verifying requests according to service or custom semantics
70
+ * Stripping extraneous information from responses
71
+
72
+ These use cases and more can be enabled by injecting an
73
+ instance of a custom subclass when constructing the BigtableRestTransport.
74
+
75
+ .. code-block:: python
76
+ class MyCustomBigtableInterceptor(BigtableRestInterceptor):
77
+ def pre_check_and_mutate_row(self, request, metadata):
78
+ logging.log(f"Received request: {request}")
79
+ return request, metadata
80
+
81
+ def post_check_and_mutate_row(self, response):
82
+ logging.log(f"Received response: {response}")
83
+ return response
84
+
85
+ def pre_execute_query(self, request, metadata):
86
+ logging.log(f"Received request: {request}")
87
+ return request, metadata
88
+
89
+ def post_execute_query(self, response):
90
+ logging.log(f"Received response: {response}")
91
+ return response
92
+
93
+ def pre_generate_initial_change_stream_partitions(self, request, metadata):
94
+ logging.log(f"Received request: {request}")
95
+ return request, metadata
96
+
97
+ def post_generate_initial_change_stream_partitions(self, response):
98
+ logging.log(f"Received response: {response}")
99
+ return response
100
+
101
+ def pre_mutate_row(self, request, metadata):
102
+ logging.log(f"Received request: {request}")
103
+ return request, metadata
104
+
105
+ def post_mutate_row(self, response):
106
+ logging.log(f"Received response: {response}")
107
+ return response
108
+
109
+ def pre_mutate_rows(self, request, metadata):
110
+ logging.log(f"Received request: {request}")
111
+ return request, metadata
112
+
113
+ def post_mutate_rows(self, response):
114
+ logging.log(f"Received response: {response}")
115
+ return response
116
+
117
+ def pre_ping_and_warm(self, request, metadata):
118
+ logging.log(f"Received request: {request}")
119
+ return request, metadata
120
+
121
+ def post_ping_and_warm(self, response):
122
+ logging.log(f"Received response: {response}")
123
+ return response
124
+
125
+ def pre_prepare_query(self, request, metadata):
126
+ logging.log(f"Received request: {request}")
127
+ return request, metadata
128
+
129
+ def post_prepare_query(self, response):
130
+ logging.log(f"Received response: {response}")
131
+ return response
132
+
133
+ def pre_read_change_stream(self, request, metadata):
134
+ logging.log(f"Received request: {request}")
135
+ return request, metadata
136
+
137
+ def post_read_change_stream(self, response):
138
+ logging.log(f"Received response: {response}")
139
+ return response
140
+
141
+ def pre_read_modify_write_row(self, request, metadata):
142
+ logging.log(f"Received request: {request}")
143
+ return request, metadata
144
+
145
+ def post_read_modify_write_row(self, response):
146
+ logging.log(f"Received response: {response}")
147
+ return response
148
+
149
+ def pre_read_rows(self, request, metadata):
150
+ logging.log(f"Received request: {request}")
151
+ return request, metadata
152
+
153
+ def post_read_rows(self, response):
154
+ logging.log(f"Received response: {response}")
155
+ return response
156
+
157
+ def pre_sample_row_keys(self, request, metadata):
158
+ logging.log(f"Received request: {request}")
159
+ return request, metadata
160
+
161
+ def post_sample_row_keys(self, response):
162
+ logging.log(f"Received response: {response}")
163
+ return response
164
+
165
+ transport = BigtableRestTransport(interceptor=MyCustomBigtableInterceptor())
166
+ client = BigtableClient(transport=transport)
167
+
168
+
169
+ """
170
+
171
+ def pre_check_and_mutate_row(
172
+ self,
173
+ request: bigtable.CheckAndMutateRowRequest,
174
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
175
+ ) -> Tuple[
176
+ bigtable.CheckAndMutateRowRequest, Sequence[Tuple[str, Union[str, bytes]]]
177
+ ]:
178
+ """Pre-rpc interceptor for check_and_mutate_row
179
+
180
+ Override in a subclass to manipulate the request or metadata
181
+ before they are sent to the Bigtable server.
182
+ """
183
+ return request, metadata
184
+
185
+ def post_check_and_mutate_row(
186
+ self, response: bigtable.CheckAndMutateRowResponse
187
+ ) -> bigtable.CheckAndMutateRowResponse:
188
+ """Post-rpc interceptor for check_and_mutate_row
189
+
190
+ DEPRECATED. Please use the `post_check_and_mutate_row_with_metadata`
191
+ interceptor instead.
192
+
193
+ Override in a subclass to read or manipulate the response
194
+ after it is returned by the Bigtable server but before
195
+ it is returned to user code. This `post_check_and_mutate_row` interceptor runs
196
+ before the `post_check_and_mutate_row_with_metadata` interceptor.
197
+ """
198
+ return response
199
+
200
+ def post_check_and_mutate_row_with_metadata(
201
+ self,
202
+ response: bigtable.CheckAndMutateRowResponse,
203
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
204
+ ) -> Tuple[
205
+ bigtable.CheckAndMutateRowResponse, Sequence[Tuple[str, Union[str, bytes]]]
206
+ ]:
207
+ """Post-rpc interceptor for check_and_mutate_row
208
+
209
+ Override in a subclass to read or manipulate the response or metadata after it
210
+ is returned by the Bigtable server but before it is returned to user code.
211
+
212
+ We recommend only using this `post_check_and_mutate_row_with_metadata`
213
+ interceptor in new development instead of the `post_check_and_mutate_row` interceptor.
214
+ When both interceptors are used, this `post_check_and_mutate_row_with_metadata` interceptor runs after the
215
+ `post_check_and_mutate_row` interceptor. The (possibly modified) response returned by
216
+ `post_check_and_mutate_row` will be passed to
217
+ `post_check_and_mutate_row_with_metadata`.
218
+ """
219
+ return response, metadata
220
+
221
+ def pre_execute_query(
222
+ self,
223
+ request: bigtable.ExecuteQueryRequest,
224
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
225
+ ) -> Tuple[bigtable.ExecuteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
226
+ """Pre-rpc interceptor for execute_query
227
+
228
+ Override in a subclass to manipulate the request or metadata
229
+ before they are sent to the Bigtable server.
230
+ """
231
+ return request, metadata
232
+
233
+ def post_execute_query(
234
+ self, response: rest_streaming.ResponseIterator
235
+ ) -> rest_streaming.ResponseIterator:
236
+ """Post-rpc interceptor for execute_query
237
+
238
+ DEPRECATED. Please use the `post_execute_query_with_metadata`
239
+ interceptor instead.
240
+
241
+ Override in a subclass to read or manipulate the response
242
+ after it is returned by the Bigtable server but before
243
+ it is returned to user code. This `post_execute_query` interceptor runs
244
+ before the `post_execute_query_with_metadata` interceptor.
245
+ """
246
+ return response
247
+
248
+ def post_execute_query_with_metadata(
249
+ self,
250
+ response: rest_streaming.ResponseIterator,
251
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
252
+ ) -> Tuple[
253
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
254
+ ]:
255
+ """Post-rpc interceptor for execute_query
256
+
257
+ Override in a subclass to read or manipulate the response or metadata after it
258
+ is returned by the Bigtable server but before it is returned to user code.
259
+
260
+ We recommend only using this `post_execute_query_with_metadata`
261
+ interceptor in new development instead of the `post_execute_query` interceptor.
262
+ When both interceptors are used, this `post_execute_query_with_metadata` interceptor runs after the
263
+ `post_execute_query` interceptor. The (possibly modified) response returned by
264
+ `post_execute_query` will be passed to
265
+ `post_execute_query_with_metadata`.
266
+ """
267
+ return response, metadata
268
+
269
+ def pre_generate_initial_change_stream_partitions(
270
+ self,
271
+ request: bigtable.GenerateInitialChangeStreamPartitionsRequest,
272
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
273
+ ) -> Tuple[
274
+ bigtable.GenerateInitialChangeStreamPartitionsRequest,
275
+ Sequence[Tuple[str, Union[str, bytes]]],
276
+ ]:
277
+ """Pre-rpc interceptor for generate_initial_change_stream_partitions
278
+
279
+ Override in a subclass to manipulate the request or metadata
280
+ before they are sent to the Bigtable server.
281
+ """
282
+ return request, metadata
283
+
284
+ def post_generate_initial_change_stream_partitions(
285
+ self, response: rest_streaming.ResponseIterator
286
+ ) -> rest_streaming.ResponseIterator:
287
+ """Post-rpc interceptor for generate_initial_change_stream_partitions
288
+
289
+ DEPRECATED. Please use the `post_generate_initial_change_stream_partitions_with_metadata`
290
+ interceptor instead.
291
+
292
+ Override in a subclass to read or manipulate the response
293
+ after it is returned by the Bigtable server but before
294
+ it is returned to user code. This `post_generate_initial_change_stream_partitions` interceptor runs
295
+ before the `post_generate_initial_change_stream_partitions_with_metadata` interceptor.
296
+ """
297
+ return response
298
+
299
+ def post_generate_initial_change_stream_partitions_with_metadata(
300
+ self,
301
+ response: rest_streaming.ResponseIterator,
302
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
303
+ ) -> Tuple[
304
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
305
+ ]:
306
+ """Post-rpc interceptor for generate_initial_change_stream_partitions
307
+
308
+ Override in a subclass to read or manipulate the response or metadata after it
309
+ is returned by the Bigtable server but before it is returned to user code.
310
+
311
+ We recommend only using this `post_generate_initial_change_stream_partitions_with_metadata`
312
+ interceptor in new development instead of the `post_generate_initial_change_stream_partitions` interceptor.
313
+ When both interceptors are used, this `post_generate_initial_change_stream_partitions_with_metadata` interceptor runs after the
314
+ `post_generate_initial_change_stream_partitions` interceptor. The (possibly modified) response returned by
315
+ `post_generate_initial_change_stream_partitions` will be passed to
316
+ `post_generate_initial_change_stream_partitions_with_metadata`.
317
+ """
318
+ return response, metadata
319
+
320
+ def pre_mutate_row(
321
+ self,
322
+ request: bigtable.MutateRowRequest,
323
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
324
+ ) -> Tuple[bigtable.MutateRowRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
325
+ """Pre-rpc interceptor for mutate_row
326
+
327
+ Override in a subclass to manipulate the request or metadata
328
+ before they are sent to the Bigtable server.
329
+ """
330
+ return request, metadata
331
+
332
+ def post_mutate_row(
333
+ self, response: bigtable.MutateRowResponse
334
+ ) -> bigtable.MutateRowResponse:
335
+ """Post-rpc interceptor for mutate_row
336
+
337
+ DEPRECATED. Please use the `post_mutate_row_with_metadata`
338
+ interceptor instead.
339
+
340
+ Override in a subclass to read or manipulate the response
341
+ after it is returned by the Bigtable server but before
342
+ it is returned to user code. This `post_mutate_row` interceptor runs
343
+ before the `post_mutate_row_with_metadata` interceptor.
344
+ """
345
+ return response
346
+
347
+ def post_mutate_row_with_metadata(
348
+ self,
349
+ response: bigtable.MutateRowResponse,
350
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
351
+ ) -> Tuple[bigtable.MutateRowResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
352
+ """Post-rpc interceptor for mutate_row
353
+
354
+ Override in a subclass to read or manipulate the response or metadata after it
355
+ is returned by the Bigtable server but before it is returned to user code.
356
+
357
+ We recommend only using this `post_mutate_row_with_metadata`
358
+ interceptor in new development instead of the `post_mutate_row` interceptor.
359
+ When both interceptors are used, this `post_mutate_row_with_metadata` interceptor runs after the
360
+ `post_mutate_row` interceptor. The (possibly modified) response returned by
361
+ `post_mutate_row` will be passed to
362
+ `post_mutate_row_with_metadata`.
363
+ """
364
+ return response, metadata
365
+
366
+ def pre_mutate_rows(
367
+ self,
368
+ request: bigtable.MutateRowsRequest,
369
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
370
+ ) -> Tuple[bigtable.MutateRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
371
+ """Pre-rpc interceptor for mutate_rows
372
+
373
+ Override in a subclass to manipulate the request or metadata
374
+ before they are sent to the Bigtable server.
375
+ """
376
+ return request, metadata
377
+
378
+ def post_mutate_rows(
379
+ self, response: rest_streaming.ResponseIterator
380
+ ) -> rest_streaming.ResponseIterator:
381
+ """Post-rpc interceptor for mutate_rows
382
+
383
+ DEPRECATED. Please use the `post_mutate_rows_with_metadata`
384
+ interceptor instead.
385
+
386
+ Override in a subclass to read or manipulate the response
387
+ after it is returned by the Bigtable server but before
388
+ it is returned to user code. This `post_mutate_rows` interceptor runs
389
+ before the `post_mutate_rows_with_metadata` interceptor.
390
+ """
391
+ return response
392
+
393
+ def post_mutate_rows_with_metadata(
394
+ self,
395
+ response: rest_streaming.ResponseIterator,
396
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
397
+ ) -> Tuple[
398
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
399
+ ]:
400
+ """Post-rpc interceptor for mutate_rows
401
+
402
+ Override in a subclass to read or manipulate the response or metadata after it
403
+ is returned by the Bigtable server but before it is returned to user code.
404
+
405
+ We recommend only using this `post_mutate_rows_with_metadata`
406
+ interceptor in new development instead of the `post_mutate_rows` interceptor.
407
+ When both interceptors are used, this `post_mutate_rows_with_metadata` interceptor runs after the
408
+ `post_mutate_rows` interceptor. The (possibly modified) response returned by
409
+ `post_mutate_rows` will be passed to
410
+ `post_mutate_rows_with_metadata`.
411
+ """
412
+ return response, metadata
413
+
414
+ def pre_ping_and_warm(
415
+ self,
416
+ request: bigtable.PingAndWarmRequest,
417
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
418
+ ) -> Tuple[bigtable.PingAndWarmRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
419
+ """Pre-rpc interceptor for ping_and_warm
420
+
421
+ Override in a subclass to manipulate the request or metadata
422
+ before they are sent to the Bigtable server.
423
+ """
424
+ return request, metadata
425
+
426
+ def post_ping_and_warm(
427
+ self, response: bigtable.PingAndWarmResponse
428
+ ) -> bigtable.PingAndWarmResponse:
429
+ """Post-rpc interceptor for ping_and_warm
430
+
431
+ DEPRECATED. Please use the `post_ping_and_warm_with_metadata`
432
+ interceptor instead.
433
+
434
+ Override in a subclass to read or manipulate the response
435
+ after it is returned by the Bigtable server but before
436
+ it is returned to user code. This `post_ping_and_warm` interceptor runs
437
+ before the `post_ping_and_warm_with_metadata` interceptor.
438
+ """
439
+ return response
440
+
441
+ def post_ping_and_warm_with_metadata(
442
+ self,
443
+ response: bigtable.PingAndWarmResponse,
444
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
445
+ ) -> Tuple[bigtable.PingAndWarmResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
446
+ """Post-rpc interceptor for ping_and_warm
447
+
448
+ Override in a subclass to read or manipulate the response or metadata after it
449
+ is returned by the Bigtable server but before it is returned to user code.
450
+
451
+ We recommend only using this `post_ping_and_warm_with_metadata`
452
+ interceptor in new development instead of the `post_ping_and_warm` interceptor.
453
+ When both interceptors are used, this `post_ping_and_warm_with_metadata` interceptor runs after the
454
+ `post_ping_and_warm` interceptor. The (possibly modified) response returned by
455
+ `post_ping_and_warm` will be passed to
456
+ `post_ping_and_warm_with_metadata`.
457
+ """
458
+ return response, metadata
459
+
460
+ def pre_prepare_query(
461
+ self,
462
+ request: bigtable.PrepareQueryRequest,
463
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
464
+ ) -> Tuple[bigtable.PrepareQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
465
+ """Pre-rpc interceptor for prepare_query
466
+
467
+ Override in a subclass to manipulate the request or metadata
468
+ before they are sent to the Bigtable server.
469
+ """
470
+ return request, metadata
471
+
472
+ def post_prepare_query(
473
+ self, response: bigtable.PrepareQueryResponse
474
+ ) -> bigtable.PrepareQueryResponse:
475
+ """Post-rpc interceptor for prepare_query
476
+
477
+ DEPRECATED. Please use the `post_prepare_query_with_metadata`
478
+ interceptor instead.
479
+
480
+ Override in a subclass to read or manipulate the response
481
+ after it is returned by the Bigtable server but before
482
+ it is returned to user code. This `post_prepare_query` interceptor runs
483
+ before the `post_prepare_query_with_metadata` interceptor.
484
+ """
485
+ return response
486
+
487
+ def post_prepare_query_with_metadata(
488
+ self,
489
+ response: bigtable.PrepareQueryResponse,
490
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
491
+ ) -> Tuple[bigtable.PrepareQueryResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
492
+ """Post-rpc interceptor for prepare_query
493
+
494
+ Override in a subclass to read or manipulate the response or metadata after it
495
+ is returned by the Bigtable server but before it is returned to user code.
496
+
497
+ We recommend only using this `post_prepare_query_with_metadata`
498
+ interceptor in new development instead of the `post_prepare_query` interceptor.
499
+ When both interceptors are used, this `post_prepare_query_with_metadata` interceptor runs after the
500
+ `post_prepare_query` interceptor. The (possibly modified) response returned by
501
+ `post_prepare_query` will be passed to
502
+ `post_prepare_query_with_metadata`.
503
+ """
504
+ return response, metadata
505
+
506
+ def pre_read_change_stream(
507
+ self,
508
+ request: bigtable.ReadChangeStreamRequest,
509
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
510
+ ) -> Tuple[
511
+ bigtable.ReadChangeStreamRequest, Sequence[Tuple[str, Union[str, bytes]]]
512
+ ]:
513
+ """Pre-rpc interceptor for read_change_stream
514
+
515
+ Override in a subclass to manipulate the request or metadata
516
+ before they are sent to the Bigtable server.
517
+ """
518
+ return request, metadata
519
+
520
+ def post_read_change_stream(
521
+ self, response: rest_streaming.ResponseIterator
522
+ ) -> rest_streaming.ResponseIterator:
523
+ """Post-rpc interceptor for read_change_stream
524
+
525
+ DEPRECATED. Please use the `post_read_change_stream_with_metadata`
526
+ interceptor instead.
527
+
528
+ Override in a subclass to read or manipulate the response
529
+ after it is returned by the Bigtable server but before
530
+ it is returned to user code. This `post_read_change_stream` interceptor runs
531
+ before the `post_read_change_stream_with_metadata` interceptor.
532
+ """
533
+ return response
534
+
535
+ def post_read_change_stream_with_metadata(
536
+ self,
537
+ response: rest_streaming.ResponseIterator,
538
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
539
+ ) -> Tuple[
540
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
541
+ ]:
542
+ """Post-rpc interceptor for read_change_stream
543
+
544
+ Override in a subclass to read or manipulate the response or metadata after it
545
+ is returned by the Bigtable server but before it is returned to user code.
546
+
547
+ We recommend only using this `post_read_change_stream_with_metadata`
548
+ interceptor in new development instead of the `post_read_change_stream` interceptor.
549
+ When both interceptors are used, this `post_read_change_stream_with_metadata` interceptor runs after the
550
+ `post_read_change_stream` interceptor. The (possibly modified) response returned by
551
+ `post_read_change_stream` will be passed to
552
+ `post_read_change_stream_with_metadata`.
553
+ """
554
+ return response, metadata
555
+
556
+ def pre_read_modify_write_row(
557
+ self,
558
+ request: bigtable.ReadModifyWriteRowRequest,
559
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
560
+ ) -> Tuple[
561
+ bigtable.ReadModifyWriteRowRequest, Sequence[Tuple[str, Union[str, bytes]]]
562
+ ]:
563
+ """Pre-rpc interceptor for read_modify_write_row
564
+
565
+ Override in a subclass to manipulate the request or metadata
566
+ before they are sent to the Bigtable server.
567
+ """
568
+ return request, metadata
569
+
570
+ def post_read_modify_write_row(
571
+ self, response: bigtable.ReadModifyWriteRowResponse
572
+ ) -> bigtable.ReadModifyWriteRowResponse:
573
+ """Post-rpc interceptor for read_modify_write_row
574
+
575
+ DEPRECATED. Please use the `post_read_modify_write_row_with_metadata`
576
+ interceptor instead.
577
+
578
+ Override in a subclass to read or manipulate the response
579
+ after it is returned by the Bigtable server but before
580
+ it is returned to user code. This `post_read_modify_write_row` interceptor runs
581
+ before the `post_read_modify_write_row_with_metadata` interceptor.
582
+ """
583
+ return response
584
+
585
+ def post_read_modify_write_row_with_metadata(
586
+ self,
587
+ response: bigtable.ReadModifyWriteRowResponse,
588
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
589
+ ) -> Tuple[
590
+ bigtable.ReadModifyWriteRowResponse, Sequence[Tuple[str, Union[str, bytes]]]
591
+ ]:
592
+ """Post-rpc interceptor for read_modify_write_row
593
+
594
+ Override in a subclass to read or manipulate the response or metadata after it
595
+ is returned by the Bigtable server but before it is returned to user code.
596
+
597
+ We recommend only using this `post_read_modify_write_row_with_metadata`
598
+ interceptor in new development instead of the `post_read_modify_write_row` interceptor.
599
+ When both interceptors are used, this `post_read_modify_write_row_with_metadata` interceptor runs after the
600
+ `post_read_modify_write_row` interceptor. The (possibly modified) response returned by
601
+ `post_read_modify_write_row` will be passed to
602
+ `post_read_modify_write_row_with_metadata`.
603
+ """
604
+ return response, metadata
605
+
606
+ def pre_read_rows(
607
+ self,
608
+ request: bigtable.ReadRowsRequest,
609
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
610
+ ) -> Tuple[bigtable.ReadRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
611
+ """Pre-rpc interceptor for read_rows
612
+
613
+ Override in a subclass to manipulate the request or metadata
614
+ before they are sent to the Bigtable server.
615
+ """
616
+ return request, metadata
617
+
618
+ def post_read_rows(
619
+ self, response: rest_streaming.ResponseIterator
620
+ ) -> rest_streaming.ResponseIterator:
621
+ """Post-rpc interceptor for read_rows
622
+
623
+ DEPRECATED. Please use the `post_read_rows_with_metadata`
624
+ interceptor instead.
625
+
626
+ Override in a subclass to read or manipulate the response
627
+ after it is returned by the Bigtable server but before
628
+ it is returned to user code. This `post_read_rows` interceptor runs
629
+ before the `post_read_rows_with_metadata` interceptor.
630
+ """
631
+ return response
632
+
633
+ def post_read_rows_with_metadata(
634
+ self,
635
+ response: rest_streaming.ResponseIterator,
636
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
637
+ ) -> Tuple[
638
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
639
+ ]:
640
+ """Post-rpc interceptor for read_rows
641
+
642
+ Override in a subclass to read or manipulate the response or metadata after it
643
+ is returned by the Bigtable server but before it is returned to user code.
644
+
645
+ We recommend only using this `post_read_rows_with_metadata`
646
+ interceptor in new development instead of the `post_read_rows` interceptor.
647
+ When both interceptors are used, this `post_read_rows_with_metadata` interceptor runs after the
648
+ `post_read_rows` interceptor. The (possibly modified) response returned by
649
+ `post_read_rows` will be passed to
650
+ `post_read_rows_with_metadata`.
651
+ """
652
+ return response, metadata
653
+
654
+ def pre_sample_row_keys(
655
+ self,
656
+ request: bigtable.SampleRowKeysRequest,
657
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
658
+ ) -> Tuple[bigtable.SampleRowKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
659
+ """Pre-rpc interceptor for sample_row_keys
660
+
661
+ Override in a subclass to manipulate the request or metadata
662
+ before they are sent to the Bigtable server.
663
+ """
664
+ return request, metadata
665
+
666
+ def post_sample_row_keys(
667
+ self, response: rest_streaming.ResponseIterator
668
+ ) -> rest_streaming.ResponseIterator:
669
+ """Post-rpc interceptor for sample_row_keys
670
+
671
+ DEPRECATED. Please use the `post_sample_row_keys_with_metadata`
672
+ interceptor instead.
673
+
674
+ Override in a subclass to read or manipulate the response
675
+ after it is returned by the Bigtable server but before
676
+ it is returned to user code. This `post_sample_row_keys` interceptor runs
677
+ before the `post_sample_row_keys_with_metadata` interceptor.
678
+ """
679
+ return response
680
+
681
+ def post_sample_row_keys_with_metadata(
682
+ self,
683
+ response: rest_streaming.ResponseIterator,
684
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
685
+ ) -> Tuple[
686
+ rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
687
+ ]:
688
+ """Post-rpc interceptor for sample_row_keys
689
+
690
+ Override in a subclass to read or manipulate the response or metadata after it
691
+ is returned by the Bigtable server but before it is returned to user code.
692
+
693
+ We recommend only using this `post_sample_row_keys_with_metadata`
694
+ interceptor in new development instead of the `post_sample_row_keys` interceptor.
695
+ When both interceptors are used, this `post_sample_row_keys_with_metadata` interceptor runs after the
696
+ `post_sample_row_keys` interceptor. The (possibly modified) response returned by
697
+ `post_sample_row_keys` will be passed to
698
+ `post_sample_row_keys_with_metadata`.
699
+ """
700
+ return response, metadata
701
+
702
+
703
+ @dataclasses.dataclass
704
+ class BigtableRestStub:
705
+ _session: AuthorizedSession
706
+ _host: str
707
+ _interceptor: BigtableRestInterceptor
708
+
709
+
710
+ class BigtableRestTransport(_BaseBigtableRestTransport):
711
+ """REST backend synchronous transport for Bigtable.
712
+
713
+ Service for reading from and writing to existing Bigtable
714
+ tables.
715
+
716
+ This class defines the same methods as the primary client, so the
717
+ primary client can load the underlying transport implementation
718
+ and call it.
719
+
720
+ It sends JSON representations of protocol buffers over HTTP/1.1
721
+ """
722
+
723
+ def __init__(
724
+ self,
725
+ *,
726
+ host: str = "bigtable.googleapis.com",
727
+ credentials: Optional[ga_credentials.Credentials] = None,
728
+ credentials_file: Optional[str] = None,
729
+ scopes: Optional[Sequence[str]] = None,
730
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
731
+ quota_project_id: Optional[str] = None,
732
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
733
+ always_use_jwt_access: Optional[bool] = False,
734
+ url_scheme: str = "https",
735
+ interceptor: Optional[BigtableRestInterceptor] = None,
736
+ api_audience: Optional[str] = None,
737
+ ) -> None:
738
+ """Instantiate the transport.
739
+
740
+ Args:
741
+ host (Optional[str]):
742
+ The hostname to connect to (default: 'bigtable.googleapis.com').
743
+ credentials (Optional[google.auth.credentials.Credentials]): The
744
+ authorization credentials to attach to requests. These
745
+ credentials identify the application to the service; if none
746
+ are specified, the client will attempt to ascertain the
747
+ credentials from the environment.
748
+
749
+ credentials_file (Optional[str]): A file with credentials that can
750
+ be loaded with :func:`google.auth.load_credentials_from_file`.
751
+ This argument is ignored if ``channel`` is provided.
752
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
753
+ ignored if ``channel`` is provided.
754
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
755
+ certificate to configure mutual TLS HTTP channel. It is ignored
756
+ if ``channel`` is provided.
757
+ quota_project_id (Optional[str]): An optional project to use for billing
758
+ and quota.
759
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
760
+ The client info used to send a user-agent string along with
761
+ API requests. If ``None``, then default info will be used.
762
+ Generally, you only need to set this if you are developing
763
+ your own client library.
764
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
765
+ be used for service account credentials.
766
+ url_scheme: the protocol scheme for the API endpoint. Normally
767
+ "https", but for testing or local servers,
768
+ "http" can be specified.
769
+ """
770
+ # Run the base constructor
771
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
772
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
773
+ # credentials object
774
+ super().__init__(
775
+ host=host,
776
+ credentials=credentials,
777
+ client_info=client_info,
778
+ always_use_jwt_access=always_use_jwt_access,
779
+ url_scheme=url_scheme,
780
+ api_audience=api_audience,
781
+ )
782
+ self._session = AuthorizedSession(
783
+ self._credentials, default_host=self.DEFAULT_HOST
784
+ )
785
+ if client_cert_source_for_mtls:
786
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
787
+ self._interceptor = interceptor or BigtableRestInterceptor()
788
+ self._prep_wrapped_messages(client_info)
789
+
790
+ class _CheckAndMutateRow(
791
+ _BaseBigtableRestTransport._BaseCheckAndMutateRow, BigtableRestStub
792
+ ):
793
+ def __hash__(self):
794
+ return hash("BigtableRestTransport.CheckAndMutateRow")
795
+
796
+ @staticmethod
797
+ def _get_response(
798
+ host,
799
+ metadata,
800
+ query_params,
801
+ session,
802
+ timeout,
803
+ transcoded_request,
804
+ body=None,
805
+ ):
806
+ uri = transcoded_request["uri"]
807
+ method = transcoded_request["method"]
808
+ headers = dict(metadata)
809
+ headers["Content-Type"] = "application/json"
810
+ response = getattr(session, method)(
811
+ "{host}{uri}".format(host=host, uri=uri),
812
+ timeout=timeout,
813
+ headers=headers,
814
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
815
+ data=body,
816
+ )
817
+ return response
818
+
819
+ def __call__(
820
+ self,
821
+ request: bigtable.CheckAndMutateRowRequest,
822
+ *,
823
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
824
+ timeout: Optional[float] = None,
825
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
826
+ ) -> bigtable.CheckAndMutateRowResponse:
827
+ r"""Call the check and mutate row method over HTTP.
828
+
829
+ Args:
830
+ request (~.bigtable.CheckAndMutateRowRequest):
831
+ The request object. Request message for
832
+ Bigtable.CheckAndMutateRow.
833
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
834
+ should be retried.
835
+ timeout (float): The timeout for this request.
836
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
837
+ sent along with the request as metadata. Normally, each value must be of type `str`,
838
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
839
+ be of type `bytes`.
840
+
841
+ Returns:
842
+ ~.bigtable.CheckAndMutateRowResponse:
843
+ Response message for
844
+ Bigtable.CheckAndMutateRow.
845
+
846
+ """
847
+
848
+ http_options = (
849
+ _BaseBigtableRestTransport._BaseCheckAndMutateRow._get_http_options()
850
+ )
851
+
852
+ request, metadata = self._interceptor.pre_check_and_mutate_row(
853
+ request, metadata
854
+ )
855
+ transcoded_request = _BaseBigtableRestTransport._BaseCheckAndMutateRow._get_transcoded_request(
856
+ http_options, request
857
+ )
858
+
859
+ body = _BaseBigtableRestTransport._BaseCheckAndMutateRow._get_request_body_json(
860
+ transcoded_request
861
+ )
862
+
863
+ # Jsonify the query params
864
+ query_params = _BaseBigtableRestTransport._BaseCheckAndMutateRow._get_query_params_json(
865
+ transcoded_request
866
+ )
867
+
868
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
869
+ logging.DEBUG
870
+ ): # pragma: NO COVER
871
+ request_url = "{host}{uri}".format(
872
+ host=self._host, uri=transcoded_request["uri"]
873
+ )
874
+ method = transcoded_request["method"]
875
+ try:
876
+ request_payload = type(request).to_json(request)
877
+ except:
878
+ request_payload = None
879
+ http_request = {
880
+ "payload": request_payload,
881
+ "requestMethod": method,
882
+ "requestUrl": request_url,
883
+ "headers": dict(metadata),
884
+ }
885
+ _LOGGER.debug(
886
+ f"Sending request for google.bigtable_v2.BigtableClient.CheckAndMutateRow",
887
+ extra={
888
+ "serviceName": "google.bigtable.v2.Bigtable",
889
+ "rpcName": "CheckAndMutateRow",
890
+ "httpRequest": http_request,
891
+ "metadata": http_request["headers"],
892
+ },
893
+ )
894
+
895
+ # Send the request
896
+ response = BigtableRestTransport._CheckAndMutateRow._get_response(
897
+ self._host,
898
+ metadata,
899
+ query_params,
900
+ self._session,
901
+ timeout,
902
+ transcoded_request,
903
+ body,
904
+ )
905
+
906
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
907
+ # subclass.
908
+ if response.status_code >= 400:
909
+ raise core_exceptions.from_http_response(response)
910
+
911
+ # Return the response
912
+ resp = bigtable.CheckAndMutateRowResponse()
913
+ pb_resp = bigtable.CheckAndMutateRowResponse.pb(resp)
914
+
915
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
916
+
917
+ resp = self._interceptor.post_check_and_mutate_row(resp)
918
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
919
+ resp, _ = self._interceptor.post_check_and_mutate_row_with_metadata(
920
+ resp, response_metadata
921
+ )
922
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
923
+ logging.DEBUG
924
+ ): # pragma: NO COVER
925
+ try:
926
+ response_payload = bigtable.CheckAndMutateRowResponse.to_json(
927
+ response
928
+ )
929
+ except:
930
+ response_payload = None
931
+ http_response = {
932
+ "payload": response_payload,
933
+ "headers": dict(response.headers),
934
+ "status": response.status_code,
935
+ }
936
+ _LOGGER.debug(
937
+ "Received response for google.bigtable_v2.BigtableClient.check_and_mutate_row",
938
+ extra={
939
+ "serviceName": "google.bigtable.v2.Bigtable",
940
+ "rpcName": "CheckAndMutateRow",
941
+ "metadata": http_response["headers"],
942
+ "httpResponse": http_response,
943
+ },
944
+ )
945
+ return resp
946
+
947
+ class _ExecuteQuery(_BaseBigtableRestTransport._BaseExecuteQuery, BigtableRestStub):
948
+ def __hash__(self):
949
+ return hash("BigtableRestTransport.ExecuteQuery")
950
+
951
+ @staticmethod
952
+ def _get_response(
953
+ host,
954
+ metadata,
955
+ query_params,
956
+ session,
957
+ timeout,
958
+ transcoded_request,
959
+ body=None,
960
+ ):
961
+ uri = transcoded_request["uri"]
962
+ method = transcoded_request["method"]
963
+ headers = dict(metadata)
964
+ headers["Content-Type"] = "application/json"
965
+ response = getattr(session, method)(
966
+ "{host}{uri}".format(host=host, uri=uri),
967
+ timeout=timeout,
968
+ headers=headers,
969
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
970
+ data=body,
971
+ stream=True,
972
+ )
973
+ return response
974
+
975
+ def __call__(
976
+ self,
977
+ request: bigtable.ExecuteQueryRequest,
978
+ *,
979
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
980
+ timeout: Optional[float] = None,
981
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
982
+ ) -> rest_streaming.ResponseIterator:
983
+ r"""Call the execute query method over HTTP.
984
+
985
+ Args:
986
+ request (~.bigtable.ExecuteQueryRequest):
987
+ The request object. Request message for
988
+ Bigtable.ExecuteQuery
989
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
990
+ should be retried.
991
+ timeout (float): The timeout for this request.
992
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
993
+ sent along with the request as metadata. Normally, each value must be of type `str`,
994
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
995
+ be of type `bytes`.
996
+
997
+ Returns:
998
+ ~.bigtable.ExecuteQueryResponse:
999
+ Response message for
1000
+ Bigtable.ExecuteQuery
1001
+
1002
+ """
1003
+
1004
+ http_options = (
1005
+ _BaseBigtableRestTransport._BaseExecuteQuery._get_http_options()
1006
+ )
1007
+
1008
+ request, metadata = self._interceptor.pre_execute_query(request, metadata)
1009
+ transcoded_request = (
1010
+ _BaseBigtableRestTransport._BaseExecuteQuery._get_transcoded_request(
1011
+ http_options, request
1012
+ )
1013
+ )
1014
+
1015
+ body = _BaseBigtableRestTransport._BaseExecuteQuery._get_request_body_json(
1016
+ transcoded_request
1017
+ )
1018
+
1019
+ # Jsonify the query params
1020
+ query_params = (
1021
+ _BaseBigtableRestTransport._BaseExecuteQuery._get_query_params_json(
1022
+ transcoded_request
1023
+ )
1024
+ )
1025
+
1026
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1027
+ logging.DEBUG
1028
+ ): # pragma: NO COVER
1029
+ request_url = "{host}{uri}".format(
1030
+ host=self._host, uri=transcoded_request["uri"]
1031
+ )
1032
+ method = transcoded_request["method"]
1033
+ try:
1034
+ request_payload = type(request).to_json(request)
1035
+ except:
1036
+ request_payload = None
1037
+ http_request = {
1038
+ "payload": request_payload,
1039
+ "requestMethod": method,
1040
+ "requestUrl": request_url,
1041
+ "headers": dict(metadata),
1042
+ }
1043
+ _LOGGER.debug(
1044
+ f"Sending request for google.bigtable_v2.BigtableClient.ExecuteQuery",
1045
+ extra={
1046
+ "serviceName": "google.bigtable.v2.Bigtable",
1047
+ "rpcName": "ExecuteQuery",
1048
+ "httpRequest": http_request,
1049
+ "metadata": http_request["headers"],
1050
+ },
1051
+ )
1052
+
1053
+ # Send the request
1054
+ response = BigtableRestTransport._ExecuteQuery._get_response(
1055
+ self._host,
1056
+ metadata,
1057
+ query_params,
1058
+ self._session,
1059
+ timeout,
1060
+ transcoded_request,
1061
+ body,
1062
+ )
1063
+
1064
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1065
+ # subclass.
1066
+ if response.status_code >= 400:
1067
+ raise core_exceptions.from_http_response(response)
1068
+
1069
+ # Return the response
1070
+ resp = rest_streaming.ResponseIterator(
1071
+ response, bigtable.ExecuteQueryResponse
1072
+ )
1073
+
1074
+ resp = self._interceptor.post_execute_query(resp)
1075
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1076
+ resp, _ = self._interceptor.post_execute_query_with_metadata(
1077
+ resp, response_metadata
1078
+ )
1079
+ return resp
1080
+
1081
+ class _GenerateInitialChangeStreamPartitions(
1082
+ _BaseBigtableRestTransport._BaseGenerateInitialChangeStreamPartitions,
1083
+ BigtableRestStub,
1084
+ ):
1085
+ def __hash__(self):
1086
+ return hash("BigtableRestTransport.GenerateInitialChangeStreamPartitions")
1087
+
1088
+ @staticmethod
1089
+ def _get_response(
1090
+ host,
1091
+ metadata,
1092
+ query_params,
1093
+ session,
1094
+ timeout,
1095
+ transcoded_request,
1096
+ body=None,
1097
+ ):
1098
+ uri = transcoded_request["uri"]
1099
+ method = transcoded_request["method"]
1100
+ headers = dict(metadata)
1101
+ headers["Content-Type"] = "application/json"
1102
+ response = getattr(session, method)(
1103
+ "{host}{uri}".format(host=host, uri=uri),
1104
+ timeout=timeout,
1105
+ headers=headers,
1106
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1107
+ data=body,
1108
+ stream=True,
1109
+ )
1110
+ return response
1111
+
1112
+ def __call__(
1113
+ self,
1114
+ request: bigtable.GenerateInitialChangeStreamPartitionsRequest,
1115
+ *,
1116
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1117
+ timeout: Optional[float] = None,
1118
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1119
+ ) -> rest_streaming.ResponseIterator:
1120
+ r"""Call the generate initial change
1121
+ stream partitions method over HTTP.
1122
+
1123
+ Args:
1124
+ request (~.bigtable.GenerateInitialChangeStreamPartitionsRequest):
1125
+ The request object. NOTE: This API is intended to be used
1126
+ by Apache Beam BigtableIO. Request
1127
+ message for
1128
+ Bigtable.GenerateInitialChangeStreamPartitions.
1129
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1130
+ should be retried.
1131
+ timeout (float): The timeout for this request.
1132
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1133
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1134
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1135
+ be of type `bytes`.
1136
+
1137
+ Returns:
1138
+ ~.bigtable.GenerateInitialChangeStreamPartitionsResponse:
1139
+ NOTE: This API is intended to be used
1140
+ by Apache Beam BigtableIO. Response
1141
+ message for
1142
+ Bigtable.GenerateInitialChangeStreamPartitions.
1143
+
1144
+ """
1145
+
1146
+ http_options = (
1147
+ _BaseBigtableRestTransport._BaseGenerateInitialChangeStreamPartitions._get_http_options()
1148
+ )
1149
+
1150
+ (
1151
+ request,
1152
+ metadata,
1153
+ ) = self._interceptor.pre_generate_initial_change_stream_partitions(
1154
+ request, metadata
1155
+ )
1156
+ transcoded_request = _BaseBigtableRestTransport._BaseGenerateInitialChangeStreamPartitions._get_transcoded_request(
1157
+ http_options, request
1158
+ )
1159
+
1160
+ body = _BaseBigtableRestTransport._BaseGenerateInitialChangeStreamPartitions._get_request_body_json(
1161
+ transcoded_request
1162
+ )
1163
+
1164
+ # Jsonify the query params
1165
+ query_params = _BaseBigtableRestTransport._BaseGenerateInitialChangeStreamPartitions._get_query_params_json(
1166
+ transcoded_request
1167
+ )
1168
+
1169
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1170
+ logging.DEBUG
1171
+ ): # pragma: NO COVER
1172
+ request_url = "{host}{uri}".format(
1173
+ host=self._host, uri=transcoded_request["uri"]
1174
+ )
1175
+ method = transcoded_request["method"]
1176
+ try:
1177
+ request_payload = type(request).to_json(request)
1178
+ except:
1179
+ request_payload = None
1180
+ http_request = {
1181
+ "payload": request_payload,
1182
+ "requestMethod": method,
1183
+ "requestUrl": request_url,
1184
+ "headers": dict(metadata),
1185
+ }
1186
+ _LOGGER.debug(
1187
+ f"Sending request for google.bigtable_v2.BigtableClient.GenerateInitialChangeStreamPartitions",
1188
+ extra={
1189
+ "serviceName": "google.bigtable.v2.Bigtable",
1190
+ "rpcName": "GenerateInitialChangeStreamPartitions",
1191
+ "httpRequest": http_request,
1192
+ "metadata": http_request["headers"],
1193
+ },
1194
+ )
1195
+
1196
+ # Send the request
1197
+ response = BigtableRestTransport._GenerateInitialChangeStreamPartitions._get_response(
1198
+ self._host,
1199
+ metadata,
1200
+ query_params,
1201
+ self._session,
1202
+ timeout,
1203
+ transcoded_request,
1204
+ body,
1205
+ )
1206
+
1207
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1208
+ # subclass.
1209
+ if response.status_code >= 400:
1210
+ raise core_exceptions.from_http_response(response)
1211
+
1212
+ # Return the response
1213
+ resp = rest_streaming.ResponseIterator(
1214
+ response, bigtable.GenerateInitialChangeStreamPartitionsResponse
1215
+ )
1216
+
1217
+ resp = self._interceptor.post_generate_initial_change_stream_partitions(
1218
+ resp
1219
+ )
1220
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1221
+ (
1222
+ resp,
1223
+ _,
1224
+ ) = self._interceptor.post_generate_initial_change_stream_partitions_with_metadata(
1225
+ resp, response_metadata
1226
+ )
1227
+ return resp
1228
+
1229
+ class _MutateRow(_BaseBigtableRestTransport._BaseMutateRow, BigtableRestStub):
1230
+ def __hash__(self):
1231
+ return hash("BigtableRestTransport.MutateRow")
1232
+
1233
+ @staticmethod
1234
+ def _get_response(
1235
+ host,
1236
+ metadata,
1237
+ query_params,
1238
+ session,
1239
+ timeout,
1240
+ transcoded_request,
1241
+ body=None,
1242
+ ):
1243
+ uri = transcoded_request["uri"]
1244
+ method = transcoded_request["method"]
1245
+ headers = dict(metadata)
1246
+ headers["Content-Type"] = "application/json"
1247
+ response = getattr(session, method)(
1248
+ "{host}{uri}".format(host=host, uri=uri),
1249
+ timeout=timeout,
1250
+ headers=headers,
1251
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1252
+ data=body,
1253
+ )
1254
+ return response
1255
+
1256
+ def __call__(
1257
+ self,
1258
+ request: bigtable.MutateRowRequest,
1259
+ *,
1260
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1261
+ timeout: Optional[float] = None,
1262
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1263
+ ) -> bigtable.MutateRowResponse:
1264
+ r"""Call the mutate row method over HTTP.
1265
+
1266
+ Args:
1267
+ request (~.bigtable.MutateRowRequest):
1268
+ The request object. Request message for
1269
+ Bigtable.MutateRow.
1270
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1271
+ should be retried.
1272
+ timeout (float): The timeout for this request.
1273
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1274
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1275
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1276
+ be of type `bytes`.
1277
+
1278
+ Returns:
1279
+ ~.bigtable.MutateRowResponse:
1280
+ Response message for
1281
+ Bigtable.MutateRow.
1282
+
1283
+ """
1284
+
1285
+ http_options = _BaseBigtableRestTransport._BaseMutateRow._get_http_options()
1286
+
1287
+ request, metadata = self._interceptor.pre_mutate_row(request, metadata)
1288
+ transcoded_request = (
1289
+ _BaseBigtableRestTransport._BaseMutateRow._get_transcoded_request(
1290
+ http_options, request
1291
+ )
1292
+ )
1293
+
1294
+ body = _BaseBigtableRestTransport._BaseMutateRow._get_request_body_json(
1295
+ transcoded_request
1296
+ )
1297
+
1298
+ # Jsonify the query params
1299
+ query_params = (
1300
+ _BaseBigtableRestTransport._BaseMutateRow._get_query_params_json(
1301
+ transcoded_request
1302
+ )
1303
+ )
1304
+
1305
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1306
+ logging.DEBUG
1307
+ ): # pragma: NO COVER
1308
+ request_url = "{host}{uri}".format(
1309
+ host=self._host, uri=transcoded_request["uri"]
1310
+ )
1311
+ method = transcoded_request["method"]
1312
+ try:
1313
+ request_payload = type(request).to_json(request)
1314
+ except:
1315
+ request_payload = None
1316
+ http_request = {
1317
+ "payload": request_payload,
1318
+ "requestMethod": method,
1319
+ "requestUrl": request_url,
1320
+ "headers": dict(metadata),
1321
+ }
1322
+ _LOGGER.debug(
1323
+ f"Sending request for google.bigtable_v2.BigtableClient.MutateRow",
1324
+ extra={
1325
+ "serviceName": "google.bigtable.v2.Bigtable",
1326
+ "rpcName": "MutateRow",
1327
+ "httpRequest": http_request,
1328
+ "metadata": http_request["headers"],
1329
+ },
1330
+ )
1331
+
1332
+ # Send the request
1333
+ response = BigtableRestTransport._MutateRow._get_response(
1334
+ self._host,
1335
+ metadata,
1336
+ query_params,
1337
+ self._session,
1338
+ timeout,
1339
+ transcoded_request,
1340
+ body,
1341
+ )
1342
+
1343
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1344
+ # subclass.
1345
+ if response.status_code >= 400:
1346
+ raise core_exceptions.from_http_response(response)
1347
+
1348
+ # Return the response
1349
+ resp = bigtable.MutateRowResponse()
1350
+ pb_resp = bigtable.MutateRowResponse.pb(resp)
1351
+
1352
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1353
+
1354
+ resp = self._interceptor.post_mutate_row(resp)
1355
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1356
+ resp, _ = self._interceptor.post_mutate_row_with_metadata(
1357
+ resp, response_metadata
1358
+ )
1359
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1360
+ logging.DEBUG
1361
+ ): # pragma: NO COVER
1362
+ try:
1363
+ response_payload = bigtable.MutateRowResponse.to_json(response)
1364
+ except:
1365
+ response_payload = None
1366
+ http_response = {
1367
+ "payload": response_payload,
1368
+ "headers": dict(response.headers),
1369
+ "status": response.status_code,
1370
+ }
1371
+ _LOGGER.debug(
1372
+ "Received response for google.bigtable_v2.BigtableClient.mutate_row",
1373
+ extra={
1374
+ "serviceName": "google.bigtable.v2.Bigtable",
1375
+ "rpcName": "MutateRow",
1376
+ "metadata": http_response["headers"],
1377
+ "httpResponse": http_response,
1378
+ },
1379
+ )
1380
+ return resp
1381
+
1382
+ class _MutateRows(_BaseBigtableRestTransport._BaseMutateRows, BigtableRestStub):
1383
+ def __hash__(self):
1384
+ return hash("BigtableRestTransport.MutateRows")
1385
+
1386
+ @staticmethod
1387
+ def _get_response(
1388
+ host,
1389
+ metadata,
1390
+ query_params,
1391
+ session,
1392
+ timeout,
1393
+ transcoded_request,
1394
+ body=None,
1395
+ ):
1396
+ uri = transcoded_request["uri"]
1397
+ method = transcoded_request["method"]
1398
+ headers = dict(metadata)
1399
+ headers["Content-Type"] = "application/json"
1400
+ response = getattr(session, method)(
1401
+ "{host}{uri}".format(host=host, uri=uri),
1402
+ timeout=timeout,
1403
+ headers=headers,
1404
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1405
+ data=body,
1406
+ stream=True,
1407
+ )
1408
+ return response
1409
+
1410
+ def __call__(
1411
+ self,
1412
+ request: bigtable.MutateRowsRequest,
1413
+ *,
1414
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1415
+ timeout: Optional[float] = None,
1416
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1417
+ ) -> rest_streaming.ResponseIterator:
1418
+ r"""Call the mutate rows method over HTTP.
1419
+
1420
+ Args:
1421
+ request (~.bigtable.MutateRowsRequest):
1422
+ The request object. Request message for
1423
+ BigtableService.MutateRows.
1424
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1425
+ should be retried.
1426
+ timeout (float): The timeout for this request.
1427
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1428
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1429
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1430
+ be of type `bytes`.
1431
+
1432
+ Returns:
1433
+ ~.bigtable.MutateRowsResponse:
1434
+ Response message for
1435
+ BigtableService.MutateRows.
1436
+
1437
+ """
1438
+
1439
+ http_options = (
1440
+ _BaseBigtableRestTransport._BaseMutateRows._get_http_options()
1441
+ )
1442
+
1443
+ request, metadata = self._interceptor.pre_mutate_rows(request, metadata)
1444
+ transcoded_request = (
1445
+ _BaseBigtableRestTransport._BaseMutateRows._get_transcoded_request(
1446
+ http_options, request
1447
+ )
1448
+ )
1449
+
1450
+ body = _BaseBigtableRestTransport._BaseMutateRows._get_request_body_json(
1451
+ transcoded_request
1452
+ )
1453
+
1454
+ # Jsonify the query params
1455
+ query_params = (
1456
+ _BaseBigtableRestTransport._BaseMutateRows._get_query_params_json(
1457
+ transcoded_request
1458
+ )
1459
+ )
1460
+
1461
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1462
+ logging.DEBUG
1463
+ ): # pragma: NO COVER
1464
+ request_url = "{host}{uri}".format(
1465
+ host=self._host, uri=transcoded_request["uri"]
1466
+ )
1467
+ method = transcoded_request["method"]
1468
+ try:
1469
+ request_payload = type(request).to_json(request)
1470
+ except:
1471
+ request_payload = None
1472
+ http_request = {
1473
+ "payload": request_payload,
1474
+ "requestMethod": method,
1475
+ "requestUrl": request_url,
1476
+ "headers": dict(metadata),
1477
+ }
1478
+ _LOGGER.debug(
1479
+ f"Sending request for google.bigtable_v2.BigtableClient.MutateRows",
1480
+ extra={
1481
+ "serviceName": "google.bigtable.v2.Bigtable",
1482
+ "rpcName": "MutateRows",
1483
+ "httpRequest": http_request,
1484
+ "metadata": http_request["headers"],
1485
+ },
1486
+ )
1487
+
1488
+ # Send the request
1489
+ response = BigtableRestTransport._MutateRows._get_response(
1490
+ self._host,
1491
+ metadata,
1492
+ query_params,
1493
+ self._session,
1494
+ timeout,
1495
+ transcoded_request,
1496
+ body,
1497
+ )
1498
+
1499
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1500
+ # subclass.
1501
+ if response.status_code >= 400:
1502
+ raise core_exceptions.from_http_response(response)
1503
+
1504
+ # Return the response
1505
+ resp = rest_streaming.ResponseIterator(
1506
+ response, bigtable.MutateRowsResponse
1507
+ )
1508
+
1509
+ resp = self._interceptor.post_mutate_rows(resp)
1510
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1511
+ resp, _ = self._interceptor.post_mutate_rows_with_metadata(
1512
+ resp, response_metadata
1513
+ )
1514
+ return resp
1515
+
1516
+ class _PingAndWarm(_BaseBigtableRestTransport._BasePingAndWarm, BigtableRestStub):
1517
+ def __hash__(self):
1518
+ return hash("BigtableRestTransport.PingAndWarm")
1519
+
1520
+ @staticmethod
1521
+ def _get_response(
1522
+ host,
1523
+ metadata,
1524
+ query_params,
1525
+ session,
1526
+ timeout,
1527
+ transcoded_request,
1528
+ body=None,
1529
+ ):
1530
+ uri = transcoded_request["uri"]
1531
+ method = transcoded_request["method"]
1532
+ headers = dict(metadata)
1533
+ headers["Content-Type"] = "application/json"
1534
+ response = getattr(session, method)(
1535
+ "{host}{uri}".format(host=host, uri=uri),
1536
+ timeout=timeout,
1537
+ headers=headers,
1538
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1539
+ data=body,
1540
+ )
1541
+ return response
1542
+
1543
+ def __call__(
1544
+ self,
1545
+ request: bigtable.PingAndWarmRequest,
1546
+ *,
1547
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1548
+ timeout: Optional[float] = None,
1549
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1550
+ ) -> bigtable.PingAndWarmResponse:
1551
+ r"""Call the ping and warm method over HTTP.
1552
+
1553
+ Args:
1554
+ request (~.bigtable.PingAndWarmRequest):
1555
+ The request object. Request message for client connection
1556
+ keep-alive and warming.
1557
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1558
+ should be retried.
1559
+ timeout (float): The timeout for this request.
1560
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1561
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1562
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1563
+ be of type `bytes`.
1564
+
1565
+ Returns:
1566
+ ~.bigtable.PingAndWarmResponse:
1567
+ Response message for
1568
+ Bigtable.PingAndWarm connection
1569
+ keepalive and warming.
1570
+
1571
+ """
1572
+
1573
+ http_options = (
1574
+ _BaseBigtableRestTransport._BasePingAndWarm._get_http_options()
1575
+ )
1576
+
1577
+ request, metadata = self._interceptor.pre_ping_and_warm(request, metadata)
1578
+ transcoded_request = (
1579
+ _BaseBigtableRestTransport._BasePingAndWarm._get_transcoded_request(
1580
+ http_options, request
1581
+ )
1582
+ )
1583
+
1584
+ body = _BaseBigtableRestTransport._BasePingAndWarm._get_request_body_json(
1585
+ transcoded_request
1586
+ )
1587
+
1588
+ # Jsonify the query params
1589
+ query_params = (
1590
+ _BaseBigtableRestTransport._BasePingAndWarm._get_query_params_json(
1591
+ transcoded_request
1592
+ )
1593
+ )
1594
+
1595
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1596
+ logging.DEBUG
1597
+ ): # pragma: NO COVER
1598
+ request_url = "{host}{uri}".format(
1599
+ host=self._host, uri=transcoded_request["uri"]
1600
+ )
1601
+ method = transcoded_request["method"]
1602
+ try:
1603
+ request_payload = type(request).to_json(request)
1604
+ except:
1605
+ request_payload = None
1606
+ http_request = {
1607
+ "payload": request_payload,
1608
+ "requestMethod": method,
1609
+ "requestUrl": request_url,
1610
+ "headers": dict(metadata),
1611
+ }
1612
+ _LOGGER.debug(
1613
+ f"Sending request for google.bigtable_v2.BigtableClient.PingAndWarm",
1614
+ extra={
1615
+ "serviceName": "google.bigtable.v2.Bigtable",
1616
+ "rpcName": "PingAndWarm",
1617
+ "httpRequest": http_request,
1618
+ "metadata": http_request["headers"],
1619
+ },
1620
+ )
1621
+
1622
+ # Send the request
1623
+ response = BigtableRestTransport._PingAndWarm._get_response(
1624
+ self._host,
1625
+ metadata,
1626
+ query_params,
1627
+ self._session,
1628
+ timeout,
1629
+ transcoded_request,
1630
+ body,
1631
+ )
1632
+
1633
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1634
+ # subclass.
1635
+ if response.status_code >= 400:
1636
+ raise core_exceptions.from_http_response(response)
1637
+
1638
+ # Return the response
1639
+ resp = bigtable.PingAndWarmResponse()
1640
+ pb_resp = bigtable.PingAndWarmResponse.pb(resp)
1641
+
1642
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1643
+
1644
+ resp = self._interceptor.post_ping_and_warm(resp)
1645
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1646
+ resp, _ = self._interceptor.post_ping_and_warm_with_metadata(
1647
+ resp, response_metadata
1648
+ )
1649
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1650
+ logging.DEBUG
1651
+ ): # pragma: NO COVER
1652
+ try:
1653
+ response_payload = bigtable.PingAndWarmResponse.to_json(response)
1654
+ except:
1655
+ response_payload = None
1656
+ http_response = {
1657
+ "payload": response_payload,
1658
+ "headers": dict(response.headers),
1659
+ "status": response.status_code,
1660
+ }
1661
+ _LOGGER.debug(
1662
+ "Received response for google.bigtable_v2.BigtableClient.ping_and_warm",
1663
+ extra={
1664
+ "serviceName": "google.bigtable.v2.Bigtable",
1665
+ "rpcName": "PingAndWarm",
1666
+ "metadata": http_response["headers"],
1667
+ "httpResponse": http_response,
1668
+ },
1669
+ )
1670
+ return resp
1671
+
1672
+ class _PrepareQuery(_BaseBigtableRestTransport._BasePrepareQuery, BigtableRestStub):
1673
+ def __hash__(self):
1674
+ return hash("BigtableRestTransport.PrepareQuery")
1675
+
1676
+ @staticmethod
1677
+ def _get_response(
1678
+ host,
1679
+ metadata,
1680
+ query_params,
1681
+ session,
1682
+ timeout,
1683
+ transcoded_request,
1684
+ body=None,
1685
+ ):
1686
+ uri = transcoded_request["uri"]
1687
+ method = transcoded_request["method"]
1688
+ headers = dict(metadata)
1689
+ headers["Content-Type"] = "application/json"
1690
+ response = getattr(session, method)(
1691
+ "{host}{uri}".format(host=host, uri=uri),
1692
+ timeout=timeout,
1693
+ headers=headers,
1694
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1695
+ data=body,
1696
+ )
1697
+ return response
1698
+
1699
+ def __call__(
1700
+ self,
1701
+ request: bigtable.PrepareQueryRequest,
1702
+ *,
1703
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1704
+ timeout: Optional[float] = None,
1705
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1706
+ ) -> bigtable.PrepareQueryResponse:
1707
+ r"""Call the prepare query method over HTTP.
1708
+
1709
+ Args:
1710
+ request (~.bigtable.PrepareQueryRequest):
1711
+ The request object. Request message for
1712
+ Bigtable.PrepareQuery
1713
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1714
+ should be retried.
1715
+ timeout (float): The timeout for this request.
1716
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1717
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1718
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1719
+ be of type `bytes`.
1720
+
1721
+ Returns:
1722
+ ~.bigtable.PrepareQueryResponse:
1723
+ Response message for
1724
+ Bigtable.PrepareQueryResponse
1725
+
1726
+ """
1727
+
1728
+ http_options = (
1729
+ _BaseBigtableRestTransport._BasePrepareQuery._get_http_options()
1730
+ )
1731
+
1732
+ request, metadata = self._interceptor.pre_prepare_query(request, metadata)
1733
+ transcoded_request = (
1734
+ _BaseBigtableRestTransport._BasePrepareQuery._get_transcoded_request(
1735
+ http_options, request
1736
+ )
1737
+ )
1738
+
1739
+ body = _BaseBigtableRestTransport._BasePrepareQuery._get_request_body_json(
1740
+ transcoded_request
1741
+ )
1742
+
1743
+ # Jsonify the query params
1744
+ query_params = (
1745
+ _BaseBigtableRestTransport._BasePrepareQuery._get_query_params_json(
1746
+ transcoded_request
1747
+ )
1748
+ )
1749
+
1750
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1751
+ logging.DEBUG
1752
+ ): # pragma: NO COVER
1753
+ request_url = "{host}{uri}".format(
1754
+ host=self._host, uri=transcoded_request["uri"]
1755
+ )
1756
+ method = transcoded_request["method"]
1757
+ try:
1758
+ request_payload = type(request).to_json(request)
1759
+ except:
1760
+ request_payload = None
1761
+ http_request = {
1762
+ "payload": request_payload,
1763
+ "requestMethod": method,
1764
+ "requestUrl": request_url,
1765
+ "headers": dict(metadata),
1766
+ }
1767
+ _LOGGER.debug(
1768
+ f"Sending request for google.bigtable_v2.BigtableClient.PrepareQuery",
1769
+ extra={
1770
+ "serviceName": "google.bigtable.v2.Bigtable",
1771
+ "rpcName": "PrepareQuery",
1772
+ "httpRequest": http_request,
1773
+ "metadata": http_request["headers"],
1774
+ },
1775
+ )
1776
+
1777
+ # Send the request
1778
+ response = BigtableRestTransport._PrepareQuery._get_response(
1779
+ self._host,
1780
+ metadata,
1781
+ query_params,
1782
+ self._session,
1783
+ timeout,
1784
+ transcoded_request,
1785
+ body,
1786
+ )
1787
+
1788
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1789
+ # subclass.
1790
+ if response.status_code >= 400:
1791
+ raise core_exceptions.from_http_response(response)
1792
+
1793
+ # Return the response
1794
+ resp = bigtable.PrepareQueryResponse()
1795
+ pb_resp = bigtable.PrepareQueryResponse.pb(resp)
1796
+
1797
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1798
+
1799
+ resp = self._interceptor.post_prepare_query(resp)
1800
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1801
+ resp, _ = self._interceptor.post_prepare_query_with_metadata(
1802
+ resp, response_metadata
1803
+ )
1804
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1805
+ logging.DEBUG
1806
+ ): # pragma: NO COVER
1807
+ try:
1808
+ response_payload = bigtable.PrepareQueryResponse.to_json(response)
1809
+ except:
1810
+ response_payload = None
1811
+ http_response = {
1812
+ "payload": response_payload,
1813
+ "headers": dict(response.headers),
1814
+ "status": response.status_code,
1815
+ }
1816
+ _LOGGER.debug(
1817
+ "Received response for google.bigtable_v2.BigtableClient.prepare_query",
1818
+ extra={
1819
+ "serviceName": "google.bigtable.v2.Bigtable",
1820
+ "rpcName": "PrepareQuery",
1821
+ "metadata": http_response["headers"],
1822
+ "httpResponse": http_response,
1823
+ },
1824
+ )
1825
+ return resp
1826
+
1827
+ class _ReadChangeStream(
1828
+ _BaseBigtableRestTransport._BaseReadChangeStream, BigtableRestStub
1829
+ ):
1830
+ def __hash__(self):
1831
+ return hash("BigtableRestTransport.ReadChangeStream")
1832
+
1833
+ @staticmethod
1834
+ def _get_response(
1835
+ host,
1836
+ metadata,
1837
+ query_params,
1838
+ session,
1839
+ timeout,
1840
+ transcoded_request,
1841
+ body=None,
1842
+ ):
1843
+ uri = transcoded_request["uri"]
1844
+ method = transcoded_request["method"]
1845
+ headers = dict(metadata)
1846
+ headers["Content-Type"] = "application/json"
1847
+ response = getattr(session, method)(
1848
+ "{host}{uri}".format(host=host, uri=uri),
1849
+ timeout=timeout,
1850
+ headers=headers,
1851
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1852
+ data=body,
1853
+ stream=True,
1854
+ )
1855
+ return response
1856
+
1857
+ def __call__(
1858
+ self,
1859
+ request: bigtable.ReadChangeStreamRequest,
1860
+ *,
1861
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1862
+ timeout: Optional[float] = None,
1863
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1864
+ ) -> rest_streaming.ResponseIterator:
1865
+ r"""Call the read change stream method over HTTP.
1866
+
1867
+ Args:
1868
+ request (~.bigtable.ReadChangeStreamRequest):
1869
+ The request object. NOTE: This API is intended to be used
1870
+ by Apache Beam BigtableIO. Request
1871
+ message for Bigtable.ReadChangeStream.
1872
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1873
+ should be retried.
1874
+ timeout (float): The timeout for this request.
1875
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1876
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1877
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1878
+ be of type `bytes`.
1879
+
1880
+ Returns:
1881
+ ~.bigtable.ReadChangeStreamResponse:
1882
+ NOTE: This API is intended to be used
1883
+ by Apache Beam BigtableIO. Response
1884
+ message for Bigtable.ReadChangeStream.
1885
+
1886
+ """
1887
+
1888
+ http_options = (
1889
+ _BaseBigtableRestTransport._BaseReadChangeStream._get_http_options()
1890
+ )
1891
+
1892
+ request, metadata = self._interceptor.pre_read_change_stream(
1893
+ request, metadata
1894
+ )
1895
+ transcoded_request = _BaseBigtableRestTransport._BaseReadChangeStream._get_transcoded_request(
1896
+ http_options, request
1897
+ )
1898
+
1899
+ body = (
1900
+ _BaseBigtableRestTransport._BaseReadChangeStream._get_request_body_json(
1901
+ transcoded_request
1902
+ )
1903
+ )
1904
+
1905
+ # Jsonify the query params
1906
+ query_params = (
1907
+ _BaseBigtableRestTransport._BaseReadChangeStream._get_query_params_json(
1908
+ transcoded_request
1909
+ )
1910
+ )
1911
+
1912
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1913
+ logging.DEBUG
1914
+ ): # pragma: NO COVER
1915
+ request_url = "{host}{uri}".format(
1916
+ host=self._host, uri=transcoded_request["uri"]
1917
+ )
1918
+ method = transcoded_request["method"]
1919
+ try:
1920
+ request_payload = type(request).to_json(request)
1921
+ except:
1922
+ request_payload = None
1923
+ http_request = {
1924
+ "payload": request_payload,
1925
+ "requestMethod": method,
1926
+ "requestUrl": request_url,
1927
+ "headers": dict(metadata),
1928
+ }
1929
+ _LOGGER.debug(
1930
+ f"Sending request for google.bigtable_v2.BigtableClient.ReadChangeStream",
1931
+ extra={
1932
+ "serviceName": "google.bigtable.v2.Bigtable",
1933
+ "rpcName": "ReadChangeStream",
1934
+ "httpRequest": http_request,
1935
+ "metadata": http_request["headers"],
1936
+ },
1937
+ )
1938
+
1939
+ # Send the request
1940
+ response = BigtableRestTransport._ReadChangeStream._get_response(
1941
+ self._host,
1942
+ metadata,
1943
+ query_params,
1944
+ self._session,
1945
+ timeout,
1946
+ transcoded_request,
1947
+ body,
1948
+ )
1949
+
1950
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1951
+ # subclass.
1952
+ if response.status_code >= 400:
1953
+ raise core_exceptions.from_http_response(response)
1954
+
1955
+ # Return the response
1956
+ resp = rest_streaming.ResponseIterator(
1957
+ response, bigtable.ReadChangeStreamResponse
1958
+ )
1959
+
1960
+ resp = self._interceptor.post_read_change_stream(resp)
1961
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1962
+ resp, _ = self._interceptor.post_read_change_stream_with_metadata(
1963
+ resp, response_metadata
1964
+ )
1965
+ return resp
1966
+
1967
+ class _ReadModifyWriteRow(
1968
+ _BaseBigtableRestTransport._BaseReadModifyWriteRow, BigtableRestStub
1969
+ ):
1970
+ def __hash__(self):
1971
+ return hash("BigtableRestTransport.ReadModifyWriteRow")
1972
+
1973
+ @staticmethod
1974
+ def _get_response(
1975
+ host,
1976
+ metadata,
1977
+ query_params,
1978
+ session,
1979
+ timeout,
1980
+ transcoded_request,
1981
+ body=None,
1982
+ ):
1983
+ uri = transcoded_request["uri"]
1984
+ method = transcoded_request["method"]
1985
+ headers = dict(metadata)
1986
+ headers["Content-Type"] = "application/json"
1987
+ response = getattr(session, method)(
1988
+ "{host}{uri}".format(host=host, uri=uri),
1989
+ timeout=timeout,
1990
+ headers=headers,
1991
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1992
+ data=body,
1993
+ )
1994
+ return response
1995
+
1996
+ def __call__(
1997
+ self,
1998
+ request: bigtable.ReadModifyWriteRowRequest,
1999
+ *,
2000
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2001
+ timeout: Optional[float] = None,
2002
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2003
+ ) -> bigtable.ReadModifyWriteRowResponse:
2004
+ r"""Call the read modify write row method over HTTP.
2005
+
2006
+ Args:
2007
+ request (~.bigtable.ReadModifyWriteRowRequest):
2008
+ The request object. Request message for
2009
+ Bigtable.ReadModifyWriteRow.
2010
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2011
+ should be retried.
2012
+ timeout (float): The timeout for this request.
2013
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2014
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2015
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2016
+ be of type `bytes`.
2017
+
2018
+ Returns:
2019
+ ~.bigtable.ReadModifyWriteRowResponse:
2020
+ Response message for
2021
+ Bigtable.ReadModifyWriteRow.
2022
+
2023
+ """
2024
+
2025
+ http_options = (
2026
+ _BaseBigtableRestTransport._BaseReadModifyWriteRow._get_http_options()
2027
+ )
2028
+
2029
+ request, metadata = self._interceptor.pre_read_modify_write_row(
2030
+ request, metadata
2031
+ )
2032
+ transcoded_request = _BaseBigtableRestTransport._BaseReadModifyWriteRow._get_transcoded_request(
2033
+ http_options, request
2034
+ )
2035
+
2036
+ body = _BaseBigtableRestTransport._BaseReadModifyWriteRow._get_request_body_json(
2037
+ transcoded_request
2038
+ )
2039
+
2040
+ # Jsonify the query params
2041
+ query_params = _BaseBigtableRestTransport._BaseReadModifyWriteRow._get_query_params_json(
2042
+ transcoded_request
2043
+ )
2044
+
2045
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2046
+ logging.DEBUG
2047
+ ): # pragma: NO COVER
2048
+ request_url = "{host}{uri}".format(
2049
+ host=self._host, uri=transcoded_request["uri"]
2050
+ )
2051
+ method = transcoded_request["method"]
2052
+ try:
2053
+ request_payload = type(request).to_json(request)
2054
+ except:
2055
+ request_payload = None
2056
+ http_request = {
2057
+ "payload": request_payload,
2058
+ "requestMethod": method,
2059
+ "requestUrl": request_url,
2060
+ "headers": dict(metadata),
2061
+ }
2062
+ _LOGGER.debug(
2063
+ f"Sending request for google.bigtable_v2.BigtableClient.ReadModifyWriteRow",
2064
+ extra={
2065
+ "serviceName": "google.bigtable.v2.Bigtable",
2066
+ "rpcName": "ReadModifyWriteRow",
2067
+ "httpRequest": http_request,
2068
+ "metadata": http_request["headers"],
2069
+ },
2070
+ )
2071
+
2072
+ # Send the request
2073
+ response = BigtableRestTransport._ReadModifyWriteRow._get_response(
2074
+ self._host,
2075
+ metadata,
2076
+ query_params,
2077
+ self._session,
2078
+ timeout,
2079
+ transcoded_request,
2080
+ body,
2081
+ )
2082
+
2083
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2084
+ # subclass.
2085
+ if response.status_code >= 400:
2086
+ raise core_exceptions.from_http_response(response)
2087
+
2088
+ # Return the response
2089
+ resp = bigtable.ReadModifyWriteRowResponse()
2090
+ pb_resp = bigtable.ReadModifyWriteRowResponse.pb(resp)
2091
+
2092
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
2093
+
2094
+ resp = self._interceptor.post_read_modify_write_row(resp)
2095
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
2096
+ resp, _ = self._interceptor.post_read_modify_write_row_with_metadata(
2097
+ resp, response_metadata
2098
+ )
2099
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2100
+ logging.DEBUG
2101
+ ): # pragma: NO COVER
2102
+ try:
2103
+ response_payload = bigtable.ReadModifyWriteRowResponse.to_json(
2104
+ response
2105
+ )
2106
+ except:
2107
+ response_payload = None
2108
+ http_response = {
2109
+ "payload": response_payload,
2110
+ "headers": dict(response.headers),
2111
+ "status": response.status_code,
2112
+ }
2113
+ _LOGGER.debug(
2114
+ "Received response for google.bigtable_v2.BigtableClient.read_modify_write_row",
2115
+ extra={
2116
+ "serviceName": "google.bigtable.v2.Bigtable",
2117
+ "rpcName": "ReadModifyWriteRow",
2118
+ "metadata": http_response["headers"],
2119
+ "httpResponse": http_response,
2120
+ },
2121
+ )
2122
+ return resp
2123
+
2124
+ class _ReadRows(_BaseBigtableRestTransport._BaseReadRows, BigtableRestStub):
2125
+ def __hash__(self):
2126
+ return hash("BigtableRestTransport.ReadRows")
2127
+
2128
+ @staticmethod
2129
+ def _get_response(
2130
+ host,
2131
+ metadata,
2132
+ query_params,
2133
+ session,
2134
+ timeout,
2135
+ transcoded_request,
2136
+ body=None,
2137
+ ):
2138
+ uri = transcoded_request["uri"]
2139
+ method = transcoded_request["method"]
2140
+ headers = dict(metadata)
2141
+ headers["Content-Type"] = "application/json"
2142
+ response = getattr(session, method)(
2143
+ "{host}{uri}".format(host=host, uri=uri),
2144
+ timeout=timeout,
2145
+ headers=headers,
2146
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2147
+ data=body,
2148
+ stream=True,
2149
+ )
2150
+ return response
2151
+
2152
+ def __call__(
2153
+ self,
2154
+ request: bigtable.ReadRowsRequest,
2155
+ *,
2156
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2157
+ timeout: Optional[float] = None,
2158
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2159
+ ) -> rest_streaming.ResponseIterator:
2160
+ r"""Call the read rows method over HTTP.
2161
+
2162
+ Args:
2163
+ request (~.bigtable.ReadRowsRequest):
2164
+ The request object. Request message for
2165
+ Bigtable.ReadRows.
2166
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2167
+ should be retried.
2168
+ timeout (float): The timeout for this request.
2169
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2170
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2171
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2172
+ be of type `bytes`.
2173
+
2174
+ Returns:
2175
+ ~.bigtable.ReadRowsResponse:
2176
+ Response message for
2177
+ Bigtable.ReadRows.
2178
+
2179
+ """
2180
+
2181
+ http_options = _BaseBigtableRestTransport._BaseReadRows._get_http_options()
2182
+
2183
+ request, metadata = self._interceptor.pre_read_rows(request, metadata)
2184
+ transcoded_request = (
2185
+ _BaseBigtableRestTransport._BaseReadRows._get_transcoded_request(
2186
+ http_options, request
2187
+ )
2188
+ )
2189
+
2190
+ body = _BaseBigtableRestTransport._BaseReadRows._get_request_body_json(
2191
+ transcoded_request
2192
+ )
2193
+
2194
+ # Jsonify the query params
2195
+ query_params = (
2196
+ _BaseBigtableRestTransport._BaseReadRows._get_query_params_json(
2197
+ transcoded_request
2198
+ )
2199
+ )
2200
+
2201
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2202
+ logging.DEBUG
2203
+ ): # pragma: NO COVER
2204
+ request_url = "{host}{uri}".format(
2205
+ host=self._host, uri=transcoded_request["uri"]
2206
+ )
2207
+ method = transcoded_request["method"]
2208
+ try:
2209
+ request_payload = type(request).to_json(request)
2210
+ except:
2211
+ request_payload = None
2212
+ http_request = {
2213
+ "payload": request_payload,
2214
+ "requestMethod": method,
2215
+ "requestUrl": request_url,
2216
+ "headers": dict(metadata),
2217
+ }
2218
+ _LOGGER.debug(
2219
+ f"Sending request for google.bigtable_v2.BigtableClient.ReadRows",
2220
+ extra={
2221
+ "serviceName": "google.bigtable.v2.Bigtable",
2222
+ "rpcName": "ReadRows",
2223
+ "httpRequest": http_request,
2224
+ "metadata": http_request["headers"],
2225
+ },
2226
+ )
2227
+
2228
+ # Send the request
2229
+ response = BigtableRestTransport._ReadRows._get_response(
2230
+ self._host,
2231
+ metadata,
2232
+ query_params,
2233
+ self._session,
2234
+ timeout,
2235
+ transcoded_request,
2236
+ body,
2237
+ )
2238
+
2239
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2240
+ # subclass.
2241
+ if response.status_code >= 400:
2242
+ raise core_exceptions.from_http_response(response)
2243
+
2244
+ # Return the response
2245
+ resp = rest_streaming.ResponseIterator(response, bigtable.ReadRowsResponse)
2246
+
2247
+ resp = self._interceptor.post_read_rows(resp)
2248
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
2249
+ resp, _ = self._interceptor.post_read_rows_with_metadata(
2250
+ resp, response_metadata
2251
+ )
2252
+ return resp
2253
+
2254
+ class _SampleRowKeys(
2255
+ _BaseBigtableRestTransport._BaseSampleRowKeys, BigtableRestStub
2256
+ ):
2257
+ def __hash__(self):
2258
+ return hash("BigtableRestTransport.SampleRowKeys")
2259
+
2260
+ @staticmethod
2261
+ def _get_response(
2262
+ host,
2263
+ metadata,
2264
+ query_params,
2265
+ session,
2266
+ timeout,
2267
+ transcoded_request,
2268
+ body=None,
2269
+ ):
2270
+ uri = transcoded_request["uri"]
2271
+ method = transcoded_request["method"]
2272
+ headers = dict(metadata)
2273
+ headers["Content-Type"] = "application/json"
2274
+ response = getattr(session, method)(
2275
+ "{host}{uri}".format(host=host, uri=uri),
2276
+ timeout=timeout,
2277
+ headers=headers,
2278
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2279
+ stream=True,
2280
+ )
2281
+ return response
2282
+
2283
+ def __call__(
2284
+ self,
2285
+ request: bigtable.SampleRowKeysRequest,
2286
+ *,
2287
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2288
+ timeout: Optional[float] = None,
2289
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2290
+ ) -> rest_streaming.ResponseIterator:
2291
+ r"""Call the sample row keys method over HTTP.
2292
+
2293
+ Args:
2294
+ request (~.bigtable.SampleRowKeysRequest):
2295
+ The request object. Request message for
2296
+ Bigtable.SampleRowKeys.
2297
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2298
+ should be retried.
2299
+ timeout (float): The timeout for this request.
2300
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2301
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2302
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2303
+ be of type `bytes`.
2304
+
2305
+ Returns:
2306
+ ~.bigtable.SampleRowKeysResponse:
2307
+ Response message for
2308
+ Bigtable.SampleRowKeys.
2309
+
2310
+ """
2311
+
2312
+ http_options = (
2313
+ _BaseBigtableRestTransport._BaseSampleRowKeys._get_http_options()
2314
+ )
2315
+
2316
+ request, metadata = self._interceptor.pre_sample_row_keys(request, metadata)
2317
+ transcoded_request = (
2318
+ _BaseBigtableRestTransport._BaseSampleRowKeys._get_transcoded_request(
2319
+ http_options, request
2320
+ )
2321
+ )
2322
+
2323
+ # Jsonify the query params
2324
+ query_params = (
2325
+ _BaseBigtableRestTransport._BaseSampleRowKeys._get_query_params_json(
2326
+ transcoded_request
2327
+ )
2328
+ )
2329
+
2330
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2331
+ logging.DEBUG
2332
+ ): # pragma: NO COVER
2333
+ request_url = "{host}{uri}".format(
2334
+ host=self._host, uri=transcoded_request["uri"]
2335
+ )
2336
+ method = transcoded_request["method"]
2337
+ try:
2338
+ request_payload = type(request).to_json(request)
2339
+ except:
2340
+ request_payload = None
2341
+ http_request = {
2342
+ "payload": request_payload,
2343
+ "requestMethod": method,
2344
+ "requestUrl": request_url,
2345
+ "headers": dict(metadata),
2346
+ }
2347
+ _LOGGER.debug(
2348
+ f"Sending request for google.bigtable_v2.BigtableClient.SampleRowKeys",
2349
+ extra={
2350
+ "serviceName": "google.bigtable.v2.Bigtable",
2351
+ "rpcName": "SampleRowKeys",
2352
+ "httpRequest": http_request,
2353
+ "metadata": http_request["headers"],
2354
+ },
2355
+ )
2356
+
2357
+ # Send the request
2358
+ response = BigtableRestTransport._SampleRowKeys._get_response(
2359
+ self._host,
2360
+ metadata,
2361
+ query_params,
2362
+ self._session,
2363
+ timeout,
2364
+ transcoded_request,
2365
+ )
2366
+
2367
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2368
+ # subclass.
2369
+ if response.status_code >= 400:
2370
+ raise core_exceptions.from_http_response(response)
2371
+
2372
+ # Return the response
2373
+ resp = rest_streaming.ResponseIterator(
2374
+ response, bigtable.SampleRowKeysResponse
2375
+ )
2376
+
2377
+ resp = self._interceptor.post_sample_row_keys(resp)
2378
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
2379
+ resp, _ = self._interceptor.post_sample_row_keys_with_metadata(
2380
+ resp, response_metadata
2381
+ )
2382
+ return resp
2383
+
2384
+ @property
2385
+ def check_and_mutate_row(
2386
+ self,
2387
+ ) -> Callable[
2388
+ [bigtable.CheckAndMutateRowRequest], bigtable.CheckAndMutateRowResponse
2389
+ ]:
2390
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2391
+ # In C++ this would require a dynamic_cast
2392
+ return self._CheckAndMutateRow(self._session, self._host, self._interceptor) # type: ignore
2393
+
2394
+ @property
2395
+ def execute_query(
2396
+ self,
2397
+ ) -> Callable[[bigtable.ExecuteQueryRequest], bigtable.ExecuteQueryResponse]:
2398
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2399
+ # In C++ this would require a dynamic_cast
2400
+ return self._ExecuteQuery(self._session, self._host, self._interceptor) # type: ignore
2401
+
2402
+ @property
2403
+ def generate_initial_change_stream_partitions(
2404
+ self,
2405
+ ) -> Callable[
2406
+ [bigtable.GenerateInitialChangeStreamPartitionsRequest],
2407
+ bigtable.GenerateInitialChangeStreamPartitionsResponse,
2408
+ ]:
2409
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2410
+ # In C++ this would require a dynamic_cast
2411
+ return self._GenerateInitialChangeStreamPartitions(self._session, self._host, self._interceptor) # type: ignore
2412
+
2413
+ @property
2414
+ def mutate_row(
2415
+ self,
2416
+ ) -> Callable[[bigtable.MutateRowRequest], bigtable.MutateRowResponse]:
2417
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2418
+ # In C++ this would require a dynamic_cast
2419
+ return self._MutateRow(self._session, self._host, self._interceptor) # type: ignore
2420
+
2421
+ @property
2422
+ def mutate_rows(
2423
+ self,
2424
+ ) -> Callable[[bigtable.MutateRowsRequest], bigtable.MutateRowsResponse]:
2425
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2426
+ # In C++ this would require a dynamic_cast
2427
+ return self._MutateRows(self._session, self._host, self._interceptor) # type: ignore
2428
+
2429
+ @property
2430
+ def ping_and_warm(
2431
+ self,
2432
+ ) -> Callable[[bigtable.PingAndWarmRequest], bigtable.PingAndWarmResponse]:
2433
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2434
+ # In C++ this would require a dynamic_cast
2435
+ return self._PingAndWarm(self._session, self._host, self._interceptor) # type: ignore
2436
+
2437
+ @property
2438
+ def prepare_query(
2439
+ self,
2440
+ ) -> Callable[[bigtable.PrepareQueryRequest], bigtable.PrepareQueryResponse]:
2441
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2442
+ # In C++ this would require a dynamic_cast
2443
+ return self._PrepareQuery(self._session, self._host, self._interceptor) # type: ignore
2444
+
2445
+ @property
2446
+ def read_change_stream(
2447
+ self,
2448
+ ) -> Callable[
2449
+ [bigtable.ReadChangeStreamRequest], bigtable.ReadChangeStreamResponse
2450
+ ]:
2451
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2452
+ # In C++ this would require a dynamic_cast
2453
+ return self._ReadChangeStream(self._session, self._host, self._interceptor) # type: ignore
2454
+
2455
+ @property
2456
+ def read_modify_write_row(
2457
+ self,
2458
+ ) -> Callable[
2459
+ [bigtable.ReadModifyWriteRowRequest], bigtable.ReadModifyWriteRowResponse
2460
+ ]:
2461
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2462
+ # In C++ this would require a dynamic_cast
2463
+ return self._ReadModifyWriteRow(self._session, self._host, self._interceptor) # type: ignore
2464
+
2465
+ @property
2466
+ def read_rows(
2467
+ self,
2468
+ ) -> Callable[[bigtable.ReadRowsRequest], bigtable.ReadRowsResponse]:
2469
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2470
+ # In C++ this would require a dynamic_cast
2471
+ return self._ReadRows(self._session, self._host, self._interceptor) # type: ignore
2472
+
2473
+ @property
2474
+ def sample_row_keys(
2475
+ self,
2476
+ ) -> Callable[[bigtable.SampleRowKeysRequest], bigtable.SampleRowKeysResponse]:
2477
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
2478
+ # In C++ this would require a dynamic_cast
2479
+ return self._SampleRowKeys(self._session, self._host, self._interceptor) # type: ignore
2480
+
2481
+ @property
2482
+ def kind(self) -> str:
2483
+ return "rest"
2484
+
2485
+ def close(self):
2486
+ self._session.close()
2487
+
2488
+
2489
+ __all__ = ("BigtableRestTransport",)