google-cloud-spanner 3.55.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 (119) hide show
  1. google/cloud/spanner.py +47 -0
  2. google/cloud/spanner_admin_database_v1/__init__.py +146 -0
  3. google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
  4. google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
  5. google/cloud/spanner_admin_database_v1/py.typed +2 -0
  6. google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
  7. google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
  8. google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
  9. google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
  10. google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
  11. google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
  12. google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
  13. google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
  14. google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
  15. google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
  16. google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
  17. google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
  18. google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
  19. google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
  20. google/cloud/spanner_admin_database_v1/types/common.py +180 -0
  21. google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
  22. google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
  23. google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
  24. google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
  25. google/cloud/spanner_admin_instance_v1/py.typed +2 -0
  26. google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
  27. google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
  28. google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
  29. google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
  30. google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
  31. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
  32. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
  33. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
  34. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
  35. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
  36. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
  37. google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
  38. google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
  39. google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
  40. google/cloud/spanner_dbapi/__init__.py +93 -0
  41. google/cloud/spanner_dbapi/_helpers.py +113 -0
  42. google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
  43. google/cloud/spanner_dbapi/checksum.py +80 -0
  44. google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
  45. google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
  46. google/cloud/spanner_dbapi/connection.py +818 -0
  47. google/cloud/spanner_dbapi/cursor.py +609 -0
  48. google/cloud/spanner_dbapi/exceptions.py +172 -0
  49. google/cloud/spanner_dbapi/parse_utils.py +392 -0
  50. google/cloud/spanner_dbapi/parsed_statement.py +63 -0
  51. google/cloud/spanner_dbapi/parser.py +258 -0
  52. google/cloud/spanner_dbapi/partition_helper.py +41 -0
  53. google/cloud/spanner_dbapi/transaction_helper.py +294 -0
  54. google/cloud/spanner_dbapi/types.py +106 -0
  55. google/cloud/spanner_dbapi/utils.py +147 -0
  56. google/cloud/spanner_dbapi/version.py +20 -0
  57. google/cloud/spanner_v1/__init__.py +154 -0
  58. google/cloud/spanner_v1/_helpers.py +751 -0
  59. google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
  60. google/cloud/spanner_v1/backup.py +397 -0
  61. google/cloud/spanner_v1/batch.py +433 -0
  62. google/cloud/spanner_v1/client.py +538 -0
  63. google/cloud/spanner_v1/data_types.py +350 -0
  64. google/cloud/spanner_v1/database.py +1968 -0
  65. google/cloud/spanner_v1/database_sessions_manager.py +249 -0
  66. google/cloud/spanner_v1/gapic_metadata.json +268 -0
  67. google/cloud/spanner_v1/gapic_version.py +16 -0
  68. google/cloud/spanner_v1/instance.py +735 -0
  69. google/cloud/spanner_v1/keyset.py +193 -0
  70. google/cloud/spanner_v1/merged_result_set.py +146 -0
  71. google/cloud/spanner_v1/metrics/constants.py +71 -0
  72. google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
  73. google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
  74. google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
  75. google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
  76. google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
  77. google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
  78. google/cloud/spanner_v1/param_types.py +110 -0
  79. google/cloud/spanner_v1/pool.py +813 -0
  80. google/cloud/spanner_v1/py.typed +2 -0
  81. google/cloud/spanner_v1/request_id_header.py +64 -0
  82. google/cloud/spanner_v1/services/__init__.py +15 -0
  83. google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
  84. google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
  85. google/cloud/spanner_v1/services/spanner/client.py +2624 -0
  86. google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
  87. google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
  88. google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
  89. google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
  90. google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
  91. google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
  92. google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
  93. google/cloud/spanner_v1/session.py +631 -0
  94. google/cloud/spanner_v1/session_options.py +133 -0
  95. google/cloud/spanner_v1/snapshot.py +1057 -0
  96. google/cloud/spanner_v1/streamed.py +402 -0
  97. google/cloud/spanner_v1/table.py +181 -0
  98. google/cloud/spanner_v1/testing/__init__.py +0 -0
  99. google/cloud/spanner_v1/testing/database_test.py +121 -0
  100. google/cloud/spanner_v1/testing/interceptors.py +118 -0
  101. google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
  102. google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
  103. google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
  104. google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
  105. google/cloud/spanner_v1/transaction.py +747 -0
  106. google/cloud/spanner_v1/types/__init__.py +118 -0
  107. google/cloud/spanner_v1/types/commit_response.py +94 -0
  108. google/cloud/spanner_v1/types/keys.py +248 -0
  109. google/cloud/spanner_v1/types/mutation.py +201 -0
  110. google/cloud/spanner_v1/types/query_plan.py +220 -0
  111. google/cloud/spanner_v1/types/result_set.py +379 -0
  112. google/cloud/spanner_v1/types/spanner.py +1815 -0
  113. google/cloud/spanner_v1/types/transaction.py +818 -0
  114. google/cloud/spanner_v1/types/type.py +288 -0
  115. google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
  116. google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
  117. google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
  118. google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
  119. google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,981 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 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 json # type: ignore
17
+ from google.api_core import path_template
18
+ from google.api_core import gapic_v1
19
+
20
+ from google.protobuf import json_format
21
+ from .base import SpannerTransport, DEFAULT_CLIENT_INFO
22
+
23
+ import re
24
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
25
+
26
+
27
+ from google.cloud.spanner_v1.types import commit_response
28
+ from google.cloud.spanner_v1.types import result_set
29
+ from google.cloud.spanner_v1.types import spanner
30
+ from google.cloud.spanner_v1.types import transaction
31
+ from google.cloud.spanner_v1.metrics.metrics_interceptor import MetricsInterceptor
32
+ from google.protobuf import empty_pb2 # type: ignore
33
+
34
+
35
+ class _BaseSpannerRestTransport(SpannerTransport):
36
+ """Base REST backend transport for Spanner.
37
+
38
+ Note: This class is not meant to be used directly. Use its sync and
39
+ async sub-classes instead.
40
+
41
+ This class defines the same methods as the primary client, so the
42
+ primary client can load the underlying transport implementation
43
+ and call it.
44
+
45
+ It sends JSON representations of protocol buffers over HTTP/1.1
46
+ """
47
+
48
+ def __init__(
49
+ self,
50
+ *,
51
+ host: str = "spanner.googleapis.com",
52
+ credentials: Optional[Any] = None,
53
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
54
+ always_use_jwt_access: Optional[bool] = False,
55
+ url_scheme: str = "https",
56
+ api_audience: Optional[str] = None,
57
+ metrics_interceptor: Optional[MetricsInterceptor] = None,
58
+ ) -> None:
59
+ """Instantiate the transport.
60
+ Args:
61
+ host (Optional[str]):
62
+ The hostname to connect to (default: 'spanner.googleapis.com').
63
+ credentials (Optional[Any]): The
64
+ authorization credentials to attach to requests. These
65
+ credentials identify the application to the service; if none
66
+ are specified, the client will attempt to ascertain the
67
+ credentials from the environment.
68
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
69
+ The client info used to send a user-agent string along with
70
+ API requests. If ``None``, then default info will be used.
71
+ Generally, you only need to set this if you are developing
72
+ your own client library.
73
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
74
+ be used for service account credentials.
75
+ url_scheme: the protocol scheme for the API endpoint. Normally
76
+ "https", but for testing or local servers,
77
+ "http" can be specified.
78
+ """
79
+ # Run the base constructor
80
+ maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
81
+ if maybe_url_match is None:
82
+ raise ValueError(
83
+ f"Unexpected hostname structure: {host}"
84
+ ) # pragma: NO COVER
85
+
86
+ url_match_items = maybe_url_match.groupdict()
87
+
88
+ host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
89
+
90
+ super().__init__(
91
+ host=host,
92
+ credentials=credentials,
93
+ client_info=client_info,
94
+ always_use_jwt_access=always_use_jwt_access,
95
+ api_audience=api_audience,
96
+ )
97
+
98
+ class _BaseBatchCreateSessions:
99
+ def __hash__(self): # pragma: NO COVER
100
+ return NotImplementedError("__hash__ must be implemented.")
101
+
102
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
103
+
104
+ @classmethod
105
+ def _get_unset_required_fields(cls, message_dict):
106
+ return {
107
+ k: v
108
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
109
+ if k not in message_dict
110
+ }
111
+
112
+ @staticmethod
113
+ def _get_http_options():
114
+ http_options: List[Dict[str, str]] = [
115
+ {
116
+ "method": "post",
117
+ "uri": "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate",
118
+ "body": "*",
119
+ },
120
+ ]
121
+ return http_options
122
+
123
+ @staticmethod
124
+ def _get_transcoded_request(http_options, request):
125
+ pb_request = spanner.BatchCreateSessionsRequest.pb(request)
126
+ transcoded_request = path_template.transcode(http_options, pb_request)
127
+ return transcoded_request
128
+
129
+ @staticmethod
130
+ def _get_request_body_json(transcoded_request):
131
+ # Jsonify the request body
132
+
133
+ body = json_format.MessageToJson(
134
+ transcoded_request["body"], use_integers_for_enums=True
135
+ )
136
+ return body
137
+
138
+ @staticmethod
139
+ def _get_query_params_json(transcoded_request):
140
+ query_params = json.loads(
141
+ json_format.MessageToJson(
142
+ transcoded_request["query_params"],
143
+ use_integers_for_enums=True,
144
+ )
145
+ )
146
+ query_params.update(
147
+ _BaseSpannerRestTransport._BaseBatchCreateSessions._get_unset_required_fields(
148
+ query_params
149
+ )
150
+ )
151
+
152
+ query_params["$alt"] = "json;enum-encoding=int"
153
+ return query_params
154
+
155
+ class _BaseBatchWrite:
156
+ def __hash__(self): # pragma: NO COVER
157
+ return NotImplementedError("__hash__ must be implemented.")
158
+
159
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
160
+
161
+ @classmethod
162
+ def _get_unset_required_fields(cls, message_dict):
163
+ return {
164
+ k: v
165
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
166
+ if k not in message_dict
167
+ }
168
+
169
+ @staticmethod
170
+ def _get_http_options():
171
+ http_options: List[Dict[str, str]] = [
172
+ {
173
+ "method": "post",
174
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite",
175
+ "body": "*",
176
+ },
177
+ ]
178
+ return http_options
179
+
180
+ @staticmethod
181
+ def _get_transcoded_request(http_options, request):
182
+ pb_request = spanner.BatchWriteRequest.pb(request)
183
+ transcoded_request = path_template.transcode(http_options, pb_request)
184
+ return transcoded_request
185
+
186
+ @staticmethod
187
+ def _get_request_body_json(transcoded_request):
188
+ # Jsonify the request body
189
+
190
+ body = json_format.MessageToJson(
191
+ transcoded_request["body"], use_integers_for_enums=True
192
+ )
193
+ return body
194
+
195
+ @staticmethod
196
+ def _get_query_params_json(transcoded_request):
197
+ query_params = json.loads(
198
+ json_format.MessageToJson(
199
+ transcoded_request["query_params"],
200
+ use_integers_for_enums=True,
201
+ )
202
+ )
203
+ query_params.update(
204
+ _BaseSpannerRestTransport._BaseBatchWrite._get_unset_required_fields(
205
+ query_params
206
+ )
207
+ )
208
+
209
+ query_params["$alt"] = "json;enum-encoding=int"
210
+ return query_params
211
+
212
+ class _BaseBeginTransaction:
213
+ def __hash__(self): # pragma: NO COVER
214
+ return NotImplementedError("__hash__ must be implemented.")
215
+
216
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
217
+
218
+ @classmethod
219
+ def _get_unset_required_fields(cls, message_dict):
220
+ return {
221
+ k: v
222
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
223
+ if k not in message_dict
224
+ }
225
+
226
+ @staticmethod
227
+ def _get_http_options():
228
+ http_options: List[Dict[str, str]] = [
229
+ {
230
+ "method": "post",
231
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction",
232
+ "body": "*",
233
+ },
234
+ ]
235
+ return http_options
236
+
237
+ @staticmethod
238
+ def _get_transcoded_request(http_options, request):
239
+ pb_request = spanner.BeginTransactionRequest.pb(request)
240
+ transcoded_request = path_template.transcode(http_options, pb_request)
241
+ return transcoded_request
242
+
243
+ @staticmethod
244
+ def _get_request_body_json(transcoded_request):
245
+ # Jsonify the request body
246
+
247
+ body = json_format.MessageToJson(
248
+ transcoded_request["body"], use_integers_for_enums=True
249
+ )
250
+ return body
251
+
252
+ @staticmethod
253
+ def _get_query_params_json(transcoded_request):
254
+ query_params = json.loads(
255
+ json_format.MessageToJson(
256
+ transcoded_request["query_params"],
257
+ use_integers_for_enums=True,
258
+ )
259
+ )
260
+ query_params.update(
261
+ _BaseSpannerRestTransport._BaseBeginTransaction._get_unset_required_fields(
262
+ query_params
263
+ )
264
+ )
265
+
266
+ query_params["$alt"] = "json;enum-encoding=int"
267
+ return query_params
268
+
269
+ class _BaseCommit:
270
+ def __hash__(self): # pragma: NO COVER
271
+ return NotImplementedError("__hash__ must be implemented.")
272
+
273
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
274
+
275
+ @classmethod
276
+ def _get_unset_required_fields(cls, message_dict):
277
+ return {
278
+ k: v
279
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
280
+ if k not in message_dict
281
+ }
282
+
283
+ @staticmethod
284
+ def _get_http_options():
285
+ http_options: List[Dict[str, str]] = [
286
+ {
287
+ "method": "post",
288
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit",
289
+ "body": "*",
290
+ },
291
+ ]
292
+ return http_options
293
+
294
+ @staticmethod
295
+ def _get_transcoded_request(http_options, request):
296
+ pb_request = spanner.CommitRequest.pb(request)
297
+ transcoded_request = path_template.transcode(http_options, pb_request)
298
+ return transcoded_request
299
+
300
+ @staticmethod
301
+ def _get_request_body_json(transcoded_request):
302
+ # Jsonify the request body
303
+
304
+ body = json_format.MessageToJson(
305
+ transcoded_request["body"], use_integers_for_enums=True
306
+ )
307
+ return body
308
+
309
+ @staticmethod
310
+ def _get_query_params_json(transcoded_request):
311
+ query_params = json.loads(
312
+ json_format.MessageToJson(
313
+ transcoded_request["query_params"],
314
+ use_integers_for_enums=True,
315
+ )
316
+ )
317
+ query_params.update(
318
+ _BaseSpannerRestTransport._BaseCommit._get_unset_required_fields(
319
+ query_params
320
+ )
321
+ )
322
+
323
+ query_params["$alt"] = "json;enum-encoding=int"
324
+ return query_params
325
+
326
+ class _BaseCreateSession:
327
+ def __hash__(self): # pragma: NO COVER
328
+ return NotImplementedError("__hash__ must be implemented.")
329
+
330
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
331
+
332
+ @classmethod
333
+ def _get_unset_required_fields(cls, message_dict):
334
+ return {
335
+ k: v
336
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
337
+ if k not in message_dict
338
+ }
339
+
340
+ @staticmethod
341
+ def _get_http_options():
342
+ http_options: List[Dict[str, str]] = [
343
+ {
344
+ "method": "post",
345
+ "uri": "/v1/{database=projects/*/instances/*/databases/*}/sessions",
346
+ "body": "*",
347
+ },
348
+ ]
349
+ return http_options
350
+
351
+ @staticmethod
352
+ def _get_transcoded_request(http_options, request):
353
+ pb_request = spanner.CreateSessionRequest.pb(request)
354
+ transcoded_request = path_template.transcode(http_options, pb_request)
355
+ return transcoded_request
356
+
357
+ @staticmethod
358
+ def _get_request_body_json(transcoded_request):
359
+ # Jsonify the request body
360
+
361
+ body = json_format.MessageToJson(
362
+ transcoded_request["body"], use_integers_for_enums=True
363
+ )
364
+ return body
365
+
366
+ @staticmethod
367
+ def _get_query_params_json(transcoded_request):
368
+ query_params = json.loads(
369
+ json_format.MessageToJson(
370
+ transcoded_request["query_params"],
371
+ use_integers_for_enums=True,
372
+ )
373
+ )
374
+ query_params.update(
375
+ _BaseSpannerRestTransport._BaseCreateSession._get_unset_required_fields(
376
+ query_params
377
+ )
378
+ )
379
+
380
+ query_params["$alt"] = "json;enum-encoding=int"
381
+ return query_params
382
+
383
+ class _BaseDeleteSession:
384
+ def __hash__(self): # pragma: NO COVER
385
+ return NotImplementedError("__hash__ must be implemented.")
386
+
387
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
388
+
389
+ @classmethod
390
+ def _get_unset_required_fields(cls, message_dict):
391
+ return {
392
+ k: v
393
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
394
+ if k not in message_dict
395
+ }
396
+
397
+ @staticmethod
398
+ def _get_http_options():
399
+ http_options: List[Dict[str, str]] = [
400
+ {
401
+ "method": "delete",
402
+ "uri": "/v1/{name=projects/*/instances/*/databases/*/sessions/*}",
403
+ },
404
+ ]
405
+ return http_options
406
+
407
+ @staticmethod
408
+ def _get_transcoded_request(http_options, request):
409
+ pb_request = spanner.DeleteSessionRequest.pb(request)
410
+ transcoded_request = path_template.transcode(http_options, pb_request)
411
+ return transcoded_request
412
+
413
+ @staticmethod
414
+ def _get_query_params_json(transcoded_request):
415
+ query_params = json.loads(
416
+ json_format.MessageToJson(
417
+ transcoded_request["query_params"],
418
+ use_integers_for_enums=True,
419
+ )
420
+ )
421
+ query_params.update(
422
+ _BaseSpannerRestTransport._BaseDeleteSession._get_unset_required_fields(
423
+ query_params
424
+ )
425
+ )
426
+
427
+ query_params["$alt"] = "json;enum-encoding=int"
428
+ return query_params
429
+
430
+ class _BaseExecuteBatchDml:
431
+ def __hash__(self): # pragma: NO COVER
432
+ return NotImplementedError("__hash__ must be implemented.")
433
+
434
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
435
+
436
+ @classmethod
437
+ def _get_unset_required_fields(cls, message_dict):
438
+ return {
439
+ k: v
440
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
441
+ if k not in message_dict
442
+ }
443
+
444
+ @staticmethod
445
+ def _get_http_options():
446
+ http_options: List[Dict[str, str]] = [
447
+ {
448
+ "method": "post",
449
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml",
450
+ "body": "*",
451
+ },
452
+ ]
453
+ return http_options
454
+
455
+ @staticmethod
456
+ def _get_transcoded_request(http_options, request):
457
+ pb_request = spanner.ExecuteBatchDmlRequest.pb(request)
458
+ transcoded_request = path_template.transcode(http_options, pb_request)
459
+ return transcoded_request
460
+
461
+ @staticmethod
462
+ def _get_request_body_json(transcoded_request):
463
+ # Jsonify the request body
464
+
465
+ body = json_format.MessageToJson(
466
+ transcoded_request["body"], use_integers_for_enums=True
467
+ )
468
+ return body
469
+
470
+ @staticmethod
471
+ def _get_query_params_json(transcoded_request):
472
+ query_params = json.loads(
473
+ json_format.MessageToJson(
474
+ transcoded_request["query_params"],
475
+ use_integers_for_enums=True,
476
+ )
477
+ )
478
+ query_params.update(
479
+ _BaseSpannerRestTransport._BaseExecuteBatchDml._get_unset_required_fields(
480
+ query_params
481
+ )
482
+ )
483
+
484
+ query_params["$alt"] = "json;enum-encoding=int"
485
+ return query_params
486
+
487
+ class _BaseExecuteSql:
488
+ def __hash__(self): # pragma: NO COVER
489
+ return NotImplementedError("__hash__ must be implemented.")
490
+
491
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
492
+
493
+ @classmethod
494
+ def _get_unset_required_fields(cls, message_dict):
495
+ return {
496
+ k: v
497
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
498
+ if k not in message_dict
499
+ }
500
+
501
+ @staticmethod
502
+ def _get_http_options():
503
+ http_options: List[Dict[str, str]] = [
504
+ {
505
+ "method": "post",
506
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql",
507
+ "body": "*",
508
+ },
509
+ ]
510
+ return http_options
511
+
512
+ @staticmethod
513
+ def _get_transcoded_request(http_options, request):
514
+ pb_request = spanner.ExecuteSqlRequest.pb(request)
515
+ transcoded_request = path_template.transcode(http_options, pb_request)
516
+ return transcoded_request
517
+
518
+ @staticmethod
519
+ def _get_request_body_json(transcoded_request):
520
+ # Jsonify the request body
521
+
522
+ body = json_format.MessageToJson(
523
+ transcoded_request["body"], use_integers_for_enums=True
524
+ )
525
+ return body
526
+
527
+ @staticmethod
528
+ def _get_query_params_json(transcoded_request):
529
+ query_params = json.loads(
530
+ json_format.MessageToJson(
531
+ transcoded_request["query_params"],
532
+ use_integers_for_enums=True,
533
+ )
534
+ )
535
+ query_params.update(
536
+ _BaseSpannerRestTransport._BaseExecuteSql._get_unset_required_fields(
537
+ query_params
538
+ )
539
+ )
540
+
541
+ query_params["$alt"] = "json;enum-encoding=int"
542
+ return query_params
543
+
544
+ class _BaseExecuteStreamingSql:
545
+ def __hash__(self): # pragma: NO COVER
546
+ return NotImplementedError("__hash__ must be implemented.")
547
+
548
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
549
+
550
+ @classmethod
551
+ def _get_unset_required_fields(cls, message_dict):
552
+ return {
553
+ k: v
554
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
555
+ if k not in message_dict
556
+ }
557
+
558
+ @staticmethod
559
+ def _get_http_options():
560
+ http_options: List[Dict[str, str]] = [
561
+ {
562
+ "method": "post",
563
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql",
564
+ "body": "*",
565
+ },
566
+ ]
567
+ return http_options
568
+
569
+ @staticmethod
570
+ def _get_transcoded_request(http_options, request):
571
+ pb_request = spanner.ExecuteSqlRequest.pb(request)
572
+ transcoded_request = path_template.transcode(http_options, pb_request)
573
+ return transcoded_request
574
+
575
+ @staticmethod
576
+ def _get_request_body_json(transcoded_request):
577
+ # Jsonify the request body
578
+
579
+ body = json_format.MessageToJson(
580
+ transcoded_request["body"], use_integers_for_enums=True
581
+ )
582
+ return body
583
+
584
+ @staticmethod
585
+ def _get_query_params_json(transcoded_request):
586
+ query_params = json.loads(
587
+ json_format.MessageToJson(
588
+ transcoded_request["query_params"],
589
+ use_integers_for_enums=True,
590
+ )
591
+ )
592
+ query_params.update(
593
+ _BaseSpannerRestTransport._BaseExecuteStreamingSql._get_unset_required_fields(
594
+ query_params
595
+ )
596
+ )
597
+
598
+ query_params["$alt"] = "json;enum-encoding=int"
599
+ return query_params
600
+
601
+ class _BaseGetSession:
602
+ def __hash__(self): # pragma: NO COVER
603
+ return NotImplementedError("__hash__ must be implemented.")
604
+
605
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
606
+
607
+ @classmethod
608
+ def _get_unset_required_fields(cls, message_dict):
609
+ return {
610
+ k: v
611
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
612
+ if k not in message_dict
613
+ }
614
+
615
+ @staticmethod
616
+ def _get_http_options():
617
+ http_options: List[Dict[str, str]] = [
618
+ {
619
+ "method": "get",
620
+ "uri": "/v1/{name=projects/*/instances/*/databases/*/sessions/*}",
621
+ },
622
+ ]
623
+ return http_options
624
+
625
+ @staticmethod
626
+ def _get_transcoded_request(http_options, request):
627
+ pb_request = spanner.GetSessionRequest.pb(request)
628
+ transcoded_request = path_template.transcode(http_options, pb_request)
629
+ return transcoded_request
630
+
631
+ @staticmethod
632
+ def _get_query_params_json(transcoded_request):
633
+ query_params = json.loads(
634
+ json_format.MessageToJson(
635
+ transcoded_request["query_params"],
636
+ use_integers_for_enums=True,
637
+ )
638
+ )
639
+ query_params.update(
640
+ _BaseSpannerRestTransport._BaseGetSession._get_unset_required_fields(
641
+ query_params
642
+ )
643
+ )
644
+
645
+ query_params["$alt"] = "json;enum-encoding=int"
646
+ return query_params
647
+
648
+ class _BaseListSessions:
649
+ def __hash__(self): # pragma: NO COVER
650
+ return NotImplementedError("__hash__ must be implemented.")
651
+
652
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
653
+
654
+ @classmethod
655
+ def _get_unset_required_fields(cls, message_dict):
656
+ return {
657
+ k: v
658
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
659
+ if k not in message_dict
660
+ }
661
+
662
+ @staticmethod
663
+ def _get_http_options():
664
+ http_options: List[Dict[str, str]] = [
665
+ {
666
+ "method": "get",
667
+ "uri": "/v1/{database=projects/*/instances/*/databases/*}/sessions",
668
+ },
669
+ ]
670
+ return http_options
671
+
672
+ @staticmethod
673
+ def _get_transcoded_request(http_options, request):
674
+ pb_request = spanner.ListSessionsRequest.pb(request)
675
+ transcoded_request = path_template.transcode(http_options, pb_request)
676
+ return transcoded_request
677
+
678
+ @staticmethod
679
+ def _get_query_params_json(transcoded_request):
680
+ query_params = json.loads(
681
+ json_format.MessageToJson(
682
+ transcoded_request["query_params"],
683
+ use_integers_for_enums=True,
684
+ )
685
+ )
686
+ query_params.update(
687
+ _BaseSpannerRestTransport._BaseListSessions._get_unset_required_fields(
688
+ query_params
689
+ )
690
+ )
691
+
692
+ query_params["$alt"] = "json;enum-encoding=int"
693
+ return query_params
694
+
695
+ class _BasePartitionQuery:
696
+ def __hash__(self): # pragma: NO COVER
697
+ return NotImplementedError("__hash__ must be implemented.")
698
+
699
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
700
+
701
+ @classmethod
702
+ def _get_unset_required_fields(cls, message_dict):
703
+ return {
704
+ k: v
705
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
706
+ if k not in message_dict
707
+ }
708
+
709
+ @staticmethod
710
+ def _get_http_options():
711
+ http_options: List[Dict[str, str]] = [
712
+ {
713
+ "method": "post",
714
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery",
715
+ "body": "*",
716
+ },
717
+ ]
718
+ return http_options
719
+
720
+ @staticmethod
721
+ def _get_transcoded_request(http_options, request):
722
+ pb_request = spanner.PartitionQueryRequest.pb(request)
723
+ transcoded_request = path_template.transcode(http_options, pb_request)
724
+ return transcoded_request
725
+
726
+ @staticmethod
727
+ def _get_request_body_json(transcoded_request):
728
+ # Jsonify the request body
729
+
730
+ body = json_format.MessageToJson(
731
+ transcoded_request["body"], use_integers_for_enums=True
732
+ )
733
+ return body
734
+
735
+ @staticmethod
736
+ def _get_query_params_json(transcoded_request):
737
+ query_params = json.loads(
738
+ json_format.MessageToJson(
739
+ transcoded_request["query_params"],
740
+ use_integers_for_enums=True,
741
+ )
742
+ )
743
+ query_params.update(
744
+ _BaseSpannerRestTransport._BasePartitionQuery._get_unset_required_fields(
745
+ query_params
746
+ )
747
+ )
748
+
749
+ query_params["$alt"] = "json;enum-encoding=int"
750
+ return query_params
751
+
752
+ class _BasePartitionRead:
753
+ def __hash__(self): # pragma: NO COVER
754
+ return NotImplementedError("__hash__ must be implemented.")
755
+
756
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
757
+
758
+ @classmethod
759
+ def _get_unset_required_fields(cls, message_dict):
760
+ return {
761
+ k: v
762
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
763
+ if k not in message_dict
764
+ }
765
+
766
+ @staticmethod
767
+ def _get_http_options():
768
+ http_options: List[Dict[str, str]] = [
769
+ {
770
+ "method": "post",
771
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead",
772
+ "body": "*",
773
+ },
774
+ ]
775
+ return http_options
776
+
777
+ @staticmethod
778
+ def _get_transcoded_request(http_options, request):
779
+ pb_request = spanner.PartitionReadRequest.pb(request)
780
+ transcoded_request = path_template.transcode(http_options, pb_request)
781
+ return transcoded_request
782
+
783
+ @staticmethod
784
+ def _get_request_body_json(transcoded_request):
785
+ # Jsonify the request body
786
+
787
+ body = json_format.MessageToJson(
788
+ transcoded_request["body"], use_integers_for_enums=True
789
+ )
790
+ return body
791
+
792
+ @staticmethod
793
+ def _get_query_params_json(transcoded_request):
794
+ query_params = json.loads(
795
+ json_format.MessageToJson(
796
+ transcoded_request["query_params"],
797
+ use_integers_for_enums=True,
798
+ )
799
+ )
800
+ query_params.update(
801
+ _BaseSpannerRestTransport._BasePartitionRead._get_unset_required_fields(
802
+ query_params
803
+ )
804
+ )
805
+
806
+ query_params["$alt"] = "json;enum-encoding=int"
807
+ return query_params
808
+
809
+ class _BaseRead:
810
+ def __hash__(self): # pragma: NO COVER
811
+ return NotImplementedError("__hash__ must be implemented.")
812
+
813
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
814
+
815
+ @classmethod
816
+ def _get_unset_required_fields(cls, message_dict):
817
+ return {
818
+ k: v
819
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
820
+ if k not in message_dict
821
+ }
822
+
823
+ @staticmethod
824
+ def _get_http_options():
825
+ http_options: List[Dict[str, str]] = [
826
+ {
827
+ "method": "post",
828
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read",
829
+ "body": "*",
830
+ },
831
+ ]
832
+ return http_options
833
+
834
+ @staticmethod
835
+ def _get_transcoded_request(http_options, request):
836
+ pb_request = spanner.ReadRequest.pb(request)
837
+ transcoded_request = path_template.transcode(http_options, pb_request)
838
+ return transcoded_request
839
+
840
+ @staticmethod
841
+ def _get_request_body_json(transcoded_request):
842
+ # Jsonify the request body
843
+
844
+ body = json_format.MessageToJson(
845
+ transcoded_request["body"], use_integers_for_enums=True
846
+ )
847
+ return body
848
+
849
+ @staticmethod
850
+ def _get_query_params_json(transcoded_request):
851
+ query_params = json.loads(
852
+ json_format.MessageToJson(
853
+ transcoded_request["query_params"],
854
+ use_integers_for_enums=True,
855
+ )
856
+ )
857
+ query_params.update(
858
+ _BaseSpannerRestTransport._BaseRead._get_unset_required_fields(
859
+ query_params
860
+ )
861
+ )
862
+
863
+ query_params["$alt"] = "json;enum-encoding=int"
864
+ return query_params
865
+
866
+ class _BaseRollback:
867
+ def __hash__(self): # pragma: NO COVER
868
+ return NotImplementedError("__hash__ must be implemented.")
869
+
870
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
871
+
872
+ @classmethod
873
+ def _get_unset_required_fields(cls, message_dict):
874
+ return {
875
+ k: v
876
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
877
+ if k not in message_dict
878
+ }
879
+
880
+ @staticmethod
881
+ def _get_http_options():
882
+ http_options: List[Dict[str, str]] = [
883
+ {
884
+ "method": "post",
885
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback",
886
+ "body": "*",
887
+ },
888
+ ]
889
+ return http_options
890
+
891
+ @staticmethod
892
+ def _get_transcoded_request(http_options, request):
893
+ pb_request = spanner.RollbackRequest.pb(request)
894
+ transcoded_request = path_template.transcode(http_options, pb_request)
895
+ return transcoded_request
896
+
897
+ @staticmethod
898
+ def _get_request_body_json(transcoded_request):
899
+ # Jsonify the request body
900
+
901
+ body = json_format.MessageToJson(
902
+ transcoded_request["body"], use_integers_for_enums=True
903
+ )
904
+ return body
905
+
906
+ @staticmethod
907
+ def _get_query_params_json(transcoded_request):
908
+ query_params = json.loads(
909
+ json_format.MessageToJson(
910
+ transcoded_request["query_params"],
911
+ use_integers_for_enums=True,
912
+ )
913
+ )
914
+ query_params.update(
915
+ _BaseSpannerRestTransport._BaseRollback._get_unset_required_fields(
916
+ query_params
917
+ )
918
+ )
919
+
920
+ query_params["$alt"] = "json;enum-encoding=int"
921
+ return query_params
922
+
923
+ class _BaseStreamingRead:
924
+ def __hash__(self): # pragma: NO COVER
925
+ return NotImplementedError("__hash__ must be implemented.")
926
+
927
+ __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
928
+
929
+ @classmethod
930
+ def _get_unset_required_fields(cls, message_dict):
931
+ return {
932
+ k: v
933
+ for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
934
+ if k not in message_dict
935
+ }
936
+
937
+ @staticmethod
938
+ def _get_http_options():
939
+ http_options: List[Dict[str, str]] = [
940
+ {
941
+ "method": "post",
942
+ "uri": "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead",
943
+ "body": "*",
944
+ },
945
+ ]
946
+ return http_options
947
+
948
+ @staticmethod
949
+ def _get_transcoded_request(http_options, request):
950
+ pb_request = spanner.ReadRequest.pb(request)
951
+ transcoded_request = path_template.transcode(http_options, pb_request)
952
+ return transcoded_request
953
+
954
+ @staticmethod
955
+ def _get_request_body_json(transcoded_request):
956
+ # Jsonify the request body
957
+
958
+ body = json_format.MessageToJson(
959
+ transcoded_request["body"], use_integers_for_enums=True
960
+ )
961
+ return body
962
+
963
+ @staticmethod
964
+ def _get_query_params_json(transcoded_request):
965
+ query_params = json.loads(
966
+ json_format.MessageToJson(
967
+ transcoded_request["query_params"],
968
+ use_integers_for_enums=True,
969
+ )
970
+ )
971
+ query_params.update(
972
+ _BaseSpannerRestTransport._BaseStreamingRead._get_unset_required_fields(
973
+ query_params
974
+ )
975
+ )
976
+
977
+ query_params["$alt"] = "json;enum-encoding=int"
978
+ return query_params
979
+
980
+
981
+ __all__ = ("_BaseSpannerRestTransport",)