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.
- google/cloud/spanner.py +47 -0
- google/cloud/spanner_admin_database_v1/__init__.py +146 -0
- google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
- google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_database_v1/py.typed +2 -0
- google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
- google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
- google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
- google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
- google/cloud/spanner_admin_database_v1/types/common.py +180 -0
- google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
- google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
- google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
- google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_instance_v1/py.typed +2 -0
- google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
- google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
- google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
- google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
- google/cloud/spanner_dbapi/__init__.py +93 -0
- google/cloud/spanner_dbapi/_helpers.py +113 -0
- google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
- google/cloud/spanner_dbapi/checksum.py +80 -0
- google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
- google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
- google/cloud/spanner_dbapi/connection.py +818 -0
- google/cloud/spanner_dbapi/cursor.py +609 -0
- google/cloud/spanner_dbapi/exceptions.py +172 -0
- google/cloud/spanner_dbapi/parse_utils.py +392 -0
- google/cloud/spanner_dbapi/parsed_statement.py +63 -0
- google/cloud/spanner_dbapi/parser.py +258 -0
- google/cloud/spanner_dbapi/partition_helper.py +41 -0
- google/cloud/spanner_dbapi/transaction_helper.py +294 -0
- google/cloud/spanner_dbapi/types.py +106 -0
- google/cloud/spanner_dbapi/utils.py +147 -0
- google/cloud/spanner_dbapi/version.py +20 -0
- google/cloud/spanner_v1/__init__.py +154 -0
- google/cloud/spanner_v1/_helpers.py +751 -0
- google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
- google/cloud/spanner_v1/backup.py +397 -0
- google/cloud/spanner_v1/batch.py +433 -0
- google/cloud/spanner_v1/client.py +538 -0
- google/cloud/spanner_v1/data_types.py +350 -0
- google/cloud/spanner_v1/database.py +1968 -0
- google/cloud/spanner_v1/database_sessions_manager.py +249 -0
- google/cloud/spanner_v1/gapic_metadata.json +268 -0
- google/cloud/spanner_v1/gapic_version.py +16 -0
- google/cloud/spanner_v1/instance.py +735 -0
- google/cloud/spanner_v1/keyset.py +193 -0
- google/cloud/spanner_v1/merged_result_set.py +146 -0
- google/cloud/spanner_v1/metrics/constants.py +71 -0
- google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
- google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
- google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
- google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
- google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
- google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
- google/cloud/spanner_v1/param_types.py +110 -0
- google/cloud/spanner_v1/pool.py +813 -0
- google/cloud/spanner_v1/py.typed +2 -0
- google/cloud/spanner_v1/request_id_header.py +64 -0
- google/cloud/spanner_v1/services/__init__.py +15 -0
- google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
- google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
- google/cloud/spanner_v1/services/spanner/client.py +2624 -0
- google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
- google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
- google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
- google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
- google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
- google/cloud/spanner_v1/session.py +631 -0
- google/cloud/spanner_v1/session_options.py +133 -0
- google/cloud/spanner_v1/snapshot.py +1057 -0
- google/cloud/spanner_v1/streamed.py +402 -0
- google/cloud/spanner_v1/table.py +181 -0
- google/cloud/spanner_v1/testing/__init__.py +0 -0
- google/cloud/spanner_v1/testing/database_test.py +121 -0
- google/cloud/spanner_v1/testing/interceptors.py +118 -0
- google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
- google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
- google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
- google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
- google/cloud/spanner_v1/transaction.py +747 -0
- google/cloud/spanner_v1/types/__init__.py +118 -0
- google/cloud/spanner_v1/types/commit_response.py +94 -0
- google/cloud/spanner_v1/types/keys.py +248 -0
- google/cloud/spanner_v1/types/mutation.py +201 -0
- google/cloud/spanner_v1/types/query_plan.py +220 -0
- google/cloud/spanner_v1/types/result_set.py +379 -0
- google/cloud/spanner_v1/types/spanner.py +1815 -0
- google/cloud/spanner_v1/types/transaction.py +818 -0
- google/cloud/spanner_v1/types/type.py +288 -0
- google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
- google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
- google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
- google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
- google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,3468 @@
|
|
|
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 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
|
+
import google.protobuf
|
|
27
|
+
|
|
28
|
+
from google.protobuf import json_format
|
|
29
|
+
|
|
30
|
+
from requests import __version__ as requests_version
|
|
31
|
+
import dataclasses
|
|
32
|
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
|
33
|
+
import warnings
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
from google.cloud.spanner_v1.types import commit_response
|
|
37
|
+
from google.cloud.spanner_v1.types import result_set
|
|
38
|
+
from google.cloud.spanner_v1.types import spanner
|
|
39
|
+
from google.cloud.spanner_v1.types import transaction
|
|
40
|
+
from google.cloud.spanner_v1.metrics.metrics_interceptor import MetricsInterceptor
|
|
41
|
+
from google.protobuf import empty_pb2 # type: ignore
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
from .rest_base import _BaseSpannerRestTransport
|
|
45
|
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
49
|
+
except AttributeError: # pragma: NO COVER
|
|
50
|
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
from google.api_core import client_logging # type: ignore
|
|
54
|
+
|
|
55
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
56
|
+
except ImportError: # pragma: NO COVER
|
|
57
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
58
|
+
|
|
59
|
+
_LOGGER = logging.getLogger(__name__)
|
|
60
|
+
|
|
61
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
62
|
+
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
|
63
|
+
grpc_version=None,
|
|
64
|
+
rest_version=f"requests@{requests_version}",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
68
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class SpannerRestInterceptor:
|
|
72
|
+
"""Interceptor for Spanner.
|
|
73
|
+
|
|
74
|
+
Interceptors are used to manipulate requests, request metadata, and responses
|
|
75
|
+
in arbitrary ways.
|
|
76
|
+
Example use cases include:
|
|
77
|
+
* Logging
|
|
78
|
+
* Verifying requests according to service or custom semantics
|
|
79
|
+
* Stripping extraneous information from responses
|
|
80
|
+
|
|
81
|
+
These use cases and more can be enabled by injecting an
|
|
82
|
+
instance of a custom subclass when constructing the SpannerRestTransport.
|
|
83
|
+
|
|
84
|
+
.. code-block:: python
|
|
85
|
+
class MyCustomSpannerInterceptor(SpannerRestInterceptor):
|
|
86
|
+
def pre_batch_create_sessions(self, request, metadata):
|
|
87
|
+
logging.log(f"Received request: {request}")
|
|
88
|
+
return request, metadata
|
|
89
|
+
|
|
90
|
+
def post_batch_create_sessions(self, response):
|
|
91
|
+
logging.log(f"Received response: {response}")
|
|
92
|
+
return response
|
|
93
|
+
|
|
94
|
+
def pre_batch_write(self, request, metadata):
|
|
95
|
+
logging.log(f"Received request: {request}")
|
|
96
|
+
return request, metadata
|
|
97
|
+
|
|
98
|
+
def post_batch_write(self, response):
|
|
99
|
+
logging.log(f"Received response: {response}")
|
|
100
|
+
return response
|
|
101
|
+
|
|
102
|
+
def pre_begin_transaction(self, request, metadata):
|
|
103
|
+
logging.log(f"Received request: {request}")
|
|
104
|
+
return request, metadata
|
|
105
|
+
|
|
106
|
+
def post_begin_transaction(self, response):
|
|
107
|
+
logging.log(f"Received response: {response}")
|
|
108
|
+
return response
|
|
109
|
+
|
|
110
|
+
def pre_commit(self, request, metadata):
|
|
111
|
+
logging.log(f"Received request: {request}")
|
|
112
|
+
return request, metadata
|
|
113
|
+
|
|
114
|
+
def post_commit(self, response):
|
|
115
|
+
logging.log(f"Received response: {response}")
|
|
116
|
+
return response
|
|
117
|
+
|
|
118
|
+
def pre_create_session(self, request, metadata):
|
|
119
|
+
logging.log(f"Received request: {request}")
|
|
120
|
+
return request, metadata
|
|
121
|
+
|
|
122
|
+
def post_create_session(self, response):
|
|
123
|
+
logging.log(f"Received response: {response}")
|
|
124
|
+
return response
|
|
125
|
+
|
|
126
|
+
def pre_delete_session(self, request, metadata):
|
|
127
|
+
logging.log(f"Received request: {request}")
|
|
128
|
+
return request, metadata
|
|
129
|
+
|
|
130
|
+
def pre_execute_batch_dml(self, request, metadata):
|
|
131
|
+
logging.log(f"Received request: {request}")
|
|
132
|
+
return request, metadata
|
|
133
|
+
|
|
134
|
+
def post_execute_batch_dml(self, response):
|
|
135
|
+
logging.log(f"Received response: {response}")
|
|
136
|
+
return response
|
|
137
|
+
|
|
138
|
+
def pre_execute_sql(self, request, metadata):
|
|
139
|
+
logging.log(f"Received request: {request}")
|
|
140
|
+
return request, metadata
|
|
141
|
+
|
|
142
|
+
def post_execute_sql(self, response):
|
|
143
|
+
logging.log(f"Received response: {response}")
|
|
144
|
+
return response
|
|
145
|
+
|
|
146
|
+
def pre_execute_streaming_sql(self, request, metadata):
|
|
147
|
+
logging.log(f"Received request: {request}")
|
|
148
|
+
return request, metadata
|
|
149
|
+
|
|
150
|
+
def post_execute_streaming_sql(self, response):
|
|
151
|
+
logging.log(f"Received response: {response}")
|
|
152
|
+
return response
|
|
153
|
+
|
|
154
|
+
def pre_get_session(self, request, metadata):
|
|
155
|
+
logging.log(f"Received request: {request}")
|
|
156
|
+
return request, metadata
|
|
157
|
+
|
|
158
|
+
def post_get_session(self, response):
|
|
159
|
+
logging.log(f"Received response: {response}")
|
|
160
|
+
return response
|
|
161
|
+
|
|
162
|
+
def pre_list_sessions(self, request, metadata):
|
|
163
|
+
logging.log(f"Received request: {request}")
|
|
164
|
+
return request, metadata
|
|
165
|
+
|
|
166
|
+
def post_list_sessions(self, response):
|
|
167
|
+
logging.log(f"Received response: {response}")
|
|
168
|
+
return response
|
|
169
|
+
|
|
170
|
+
def pre_partition_query(self, request, metadata):
|
|
171
|
+
logging.log(f"Received request: {request}")
|
|
172
|
+
return request, metadata
|
|
173
|
+
|
|
174
|
+
def post_partition_query(self, response):
|
|
175
|
+
logging.log(f"Received response: {response}")
|
|
176
|
+
return response
|
|
177
|
+
|
|
178
|
+
def pre_partition_read(self, request, metadata):
|
|
179
|
+
logging.log(f"Received request: {request}")
|
|
180
|
+
return request, metadata
|
|
181
|
+
|
|
182
|
+
def post_partition_read(self, response):
|
|
183
|
+
logging.log(f"Received response: {response}")
|
|
184
|
+
return response
|
|
185
|
+
|
|
186
|
+
def pre_read(self, request, metadata):
|
|
187
|
+
logging.log(f"Received request: {request}")
|
|
188
|
+
return request, metadata
|
|
189
|
+
|
|
190
|
+
def post_read(self, response):
|
|
191
|
+
logging.log(f"Received response: {response}")
|
|
192
|
+
return response
|
|
193
|
+
|
|
194
|
+
def pre_rollback(self, request, metadata):
|
|
195
|
+
logging.log(f"Received request: {request}")
|
|
196
|
+
return request, metadata
|
|
197
|
+
|
|
198
|
+
def pre_streaming_read(self, request, metadata):
|
|
199
|
+
logging.log(f"Received request: {request}")
|
|
200
|
+
return request, metadata
|
|
201
|
+
|
|
202
|
+
def post_streaming_read(self, response):
|
|
203
|
+
logging.log(f"Received response: {response}")
|
|
204
|
+
return response
|
|
205
|
+
|
|
206
|
+
transport = SpannerRestTransport(interceptor=MyCustomSpannerInterceptor())
|
|
207
|
+
client = SpannerClient(transport=transport)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
def pre_batch_create_sessions(
|
|
213
|
+
self,
|
|
214
|
+
request: spanner.BatchCreateSessionsRequest,
|
|
215
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
216
|
+
) -> Tuple[
|
|
217
|
+
spanner.BatchCreateSessionsRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
218
|
+
]:
|
|
219
|
+
"""Pre-rpc interceptor for batch_create_sessions
|
|
220
|
+
|
|
221
|
+
Override in a subclass to manipulate the request or metadata
|
|
222
|
+
before they are sent to the Spanner server.
|
|
223
|
+
"""
|
|
224
|
+
return request, metadata
|
|
225
|
+
|
|
226
|
+
def post_batch_create_sessions(
|
|
227
|
+
self, response: spanner.BatchCreateSessionsResponse
|
|
228
|
+
) -> spanner.BatchCreateSessionsResponse:
|
|
229
|
+
"""Post-rpc interceptor for batch_create_sessions
|
|
230
|
+
|
|
231
|
+
DEPRECATED. Please use the `post_batch_create_sessions_with_metadata`
|
|
232
|
+
interceptor instead.
|
|
233
|
+
|
|
234
|
+
Override in a subclass to read or manipulate the response
|
|
235
|
+
after it is returned by the Spanner server but before
|
|
236
|
+
it is returned to user code. This `post_batch_create_sessions` interceptor runs
|
|
237
|
+
before the `post_batch_create_sessions_with_metadata` interceptor.
|
|
238
|
+
"""
|
|
239
|
+
return response
|
|
240
|
+
|
|
241
|
+
def post_batch_create_sessions_with_metadata(
|
|
242
|
+
self,
|
|
243
|
+
response: spanner.BatchCreateSessionsResponse,
|
|
244
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
245
|
+
) -> Tuple[
|
|
246
|
+
spanner.BatchCreateSessionsResponse, Sequence[Tuple[str, Union[str, bytes]]]
|
|
247
|
+
]:
|
|
248
|
+
"""Post-rpc interceptor for batch_create_sessions
|
|
249
|
+
|
|
250
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
251
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
252
|
+
|
|
253
|
+
We recommend only using this `post_batch_create_sessions_with_metadata`
|
|
254
|
+
interceptor in new development instead of the `post_batch_create_sessions` interceptor.
|
|
255
|
+
When both interceptors are used, this `post_batch_create_sessions_with_metadata` interceptor runs after the
|
|
256
|
+
`post_batch_create_sessions` interceptor. The (possibly modified) response returned by
|
|
257
|
+
`post_batch_create_sessions` will be passed to
|
|
258
|
+
`post_batch_create_sessions_with_metadata`.
|
|
259
|
+
"""
|
|
260
|
+
return response, metadata
|
|
261
|
+
|
|
262
|
+
def pre_batch_write(
|
|
263
|
+
self,
|
|
264
|
+
request: spanner.BatchWriteRequest,
|
|
265
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
266
|
+
) -> Tuple[spanner.BatchWriteRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
267
|
+
"""Pre-rpc interceptor for batch_write
|
|
268
|
+
|
|
269
|
+
Override in a subclass to manipulate the request or metadata
|
|
270
|
+
before they are sent to the Spanner server.
|
|
271
|
+
"""
|
|
272
|
+
return request, metadata
|
|
273
|
+
|
|
274
|
+
def post_batch_write(
|
|
275
|
+
self, response: rest_streaming.ResponseIterator
|
|
276
|
+
) -> rest_streaming.ResponseIterator:
|
|
277
|
+
"""Post-rpc interceptor for batch_write
|
|
278
|
+
|
|
279
|
+
DEPRECATED. Please use the `post_batch_write_with_metadata`
|
|
280
|
+
interceptor instead.
|
|
281
|
+
|
|
282
|
+
Override in a subclass to read or manipulate the response
|
|
283
|
+
after it is returned by the Spanner server but before
|
|
284
|
+
it is returned to user code. This `post_batch_write` interceptor runs
|
|
285
|
+
before the `post_batch_write_with_metadata` interceptor.
|
|
286
|
+
"""
|
|
287
|
+
return response
|
|
288
|
+
|
|
289
|
+
def post_batch_write_with_metadata(
|
|
290
|
+
self,
|
|
291
|
+
response: rest_streaming.ResponseIterator,
|
|
292
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
293
|
+
) -> Tuple[
|
|
294
|
+
rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
|
|
295
|
+
]:
|
|
296
|
+
"""Post-rpc interceptor for batch_write
|
|
297
|
+
|
|
298
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
299
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
300
|
+
|
|
301
|
+
We recommend only using this `post_batch_write_with_metadata`
|
|
302
|
+
interceptor in new development instead of the `post_batch_write` interceptor.
|
|
303
|
+
When both interceptors are used, this `post_batch_write_with_metadata` interceptor runs after the
|
|
304
|
+
`post_batch_write` interceptor. The (possibly modified) response returned by
|
|
305
|
+
`post_batch_write` will be passed to
|
|
306
|
+
`post_batch_write_with_metadata`.
|
|
307
|
+
"""
|
|
308
|
+
return response, metadata
|
|
309
|
+
|
|
310
|
+
def pre_begin_transaction(
|
|
311
|
+
self,
|
|
312
|
+
request: spanner.BeginTransactionRequest,
|
|
313
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
314
|
+
) -> Tuple[
|
|
315
|
+
spanner.BeginTransactionRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
316
|
+
]:
|
|
317
|
+
"""Pre-rpc interceptor for begin_transaction
|
|
318
|
+
|
|
319
|
+
Override in a subclass to manipulate the request or metadata
|
|
320
|
+
before they are sent to the Spanner server.
|
|
321
|
+
"""
|
|
322
|
+
return request, metadata
|
|
323
|
+
|
|
324
|
+
def post_begin_transaction(
|
|
325
|
+
self, response: transaction.Transaction
|
|
326
|
+
) -> transaction.Transaction:
|
|
327
|
+
"""Post-rpc interceptor for begin_transaction
|
|
328
|
+
|
|
329
|
+
DEPRECATED. Please use the `post_begin_transaction_with_metadata`
|
|
330
|
+
interceptor instead.
|
|
331
|
+
|
|
332
|
+
Override in a subclass to read or manipulate the response
|
|
333
|
+
after it is returned by the Spanner server but before
|
|
334
|
+
it is returned to user code. This `post_begin_transaction` interceptor runs
|
|
335
|
+
before the `post_begin_transaction_with_metadata` interceptor.
|
|
336
|
+
"""
|
|
337
|
+
return response
|
|
338
|
+
|
|
339
|
+
def post_begin_transaction_with_metadata(
|
|
340
|
+
self,
|
|
341
|
+
response: transaction.Transaction,
|
|
342
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
343
|
+
) -> Tuple[transaction.Transaction, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
344
|
+
"""Post-rpc interceptor for begin_transaction
|
|
345
|
+
|
|
346
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
347
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
348
|
+
|
|
349
|
+
We recommend only using this `post_begin_transaction_with_metadata`
|
|
350
|
+
interceptor in new development instead of the `post_begin_transaction` interceptor.
|
|
351
|
+
When both interceptors are used, this `post_begin_transaction_with_metadata` interceptor runs after the
|
|
352
|
+
`post_begin_transaction` interceptor. The (possibly modified) response returned by
|
|
353
|
+
`post_begin_transaction` will be passed to
|
|
354
|
+
`post_begin_transaction_with_metadata`.
|
|
355
|
+
"""
|
|
356
|
+
return response, metadata
|
|
357
|
+
|
|
358
|
+
def pre_commit(
|
|
359
|
+
self,
|
|
360
|
+
request: spanner.CommitRequest,
|
|
361
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
362
|
+
) -> Tuple[spanner.CommitRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
363
|
+
"""Pre-rpc interceptor for commit
|
|
364
|
+
|
|
365
|
+
Override in a subclass to manipulate the request or metadata
|
|
366
|
+
before they are sent to the Spanner server.
|
|
367
|
+
"""
|
|
368
|
+
return request, metadata
|
|
369
|
+
|
|
370
|
+
def post_commit(
|
|
371
|
+
self, response: commit_response.CommitResponse
|
|
372
|
+
) -> commit_response.CommitResponse:
|
|
373
|
+
"""Post-rpc interceptor for commit
|
|
374
|
+
|
|
375
|
+
DEPRECATED. Please use the `post_commit_with_metadata`
|
|
376
|
+
interceptor instead.
|
|
377
|
+
|
|
378
|
+
Override in a subclass to read or manipulate the response
|
|
379
|
+
after it is returned by the Spanner server but before
|
|
380
|
+
it is returned to user code. This `post_commit` interceptor runs
|
|
381
|
+
before the `post_commit_with_metadata` interceptor.
|
|
382
|
+
"""
|
|
383
|
+
return response
|
|
384
|
+
|
|
385
|
+
def post_commit_with_metadata(
|
|
386
|
+
self,
|
|
387
|
+
response: commit_response.CommitResponse,
|
|
388
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
389
|
+
) -> Tuple[commit_response.CommitResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
390
|
+
"""Post-rpc interceptor for commit
|
|
391
|
+
|
|
392
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
393
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
394
|
+
|
|
395
|
+
We recommend only using this `post_commit_with_metadata`
|
|
396
|
+
interceptor in new development instead of the `post_commit` interceptor.
|
|
397
|
+
When both interceptors are used, this `post_commit_with_metadata` interceptor runs after the
|
|
398
|
+
`post_commit` interceptor. The (possibly modified) response returned by
|
|
399
|
+
`post_commit` will be passed to
|
|
400
|
+
`post_commit_with_metadata`.
|
|
401
|
+
"""
|
|
402
|
+
return response, metadata
|
|
403
|
+
|
|
404
|
+
def pre_create_session(
|
|
405
|
+
self,
|
|
406
|
+
request: spanner.CreateSessionRequest,
|
|
407
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
408
|
+
) -> Tuple[spanner.CreateSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
409
|
+
"""Pre-rpc interceptor for create_session
|
|
410
|
+
|
|
411
|
+
Override in a subclass to manipulate the request or metadata
|
|
412
|
+
before they are sent to the Spanner server.
|
|
413
|
+
"""
|
|
414
|
+
return request, metadata
|
|
415
|
+
|
|
416
|
+
def post_create_session(self, response: spanner.Session) -> spanner.Session:
|
|
417
|
+
"""Post-rpc interceptor for create_session
|
|
418
|
+
|
|
419
|
+
DEPRECATED. Please use the `post_create_session_with_metadata`
|
|
420
|
+
interceptor instead.
|
|
421
|
+
|
|
422
|
+
Override in a subclass to read or manipulate the response
|
|
423
|
+
after it is returned by the Spanner server but before
|
|
424
|
+
it is returned to user code. This `post_create_session` interceptor runs
|
|
425
|
+
before the `post_create_session_with_metadata` interceptor.
|
|
426
|
+
"""
|
|
427
|
+
return response
|
|
428
|
+
|
|
429
|
+
def post_create_session_with_metadata(
|
|
430
|
+
self,
|
|
431
|
+
response: spanner.Session,
|
|
432
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
433
|
+
) -> Tuple[spanner.Session, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
434
|
+
"""Post-rpc interceptor for create_session
|
|
435
|
+
|
|
436
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
437
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
438
|
+
|
|
439
|
+
We recommend only using this `post_create_session_with_metadata`
|
|
440
|
+
interceptor in new development instead of the `post_create_session` interceptor.
|
|
441
|
+
When both interceptors are used, this `post_create_session_with_metadata` interceptor runs after the
|
|
442
|
+
`post_create_session` interceptor. The (possibly modified) response returned by
|
|
443
|
+
`post_create_session` will be passed to
|
|
444
|
+
`post_create_session_with_metadata`.
|
|
445
|
+
"""
|
|
446
|
+
return response, metadata
|
|
447
|
+
|
|
448
|
+
def pre_delete_session(
|
|
449
|
+
self,
|
|
450
|
+
request: spanner.DeleteSessionRequest,
|
|
451
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
452
|
+
) -> Tuple[spanner.DeleteSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
453
|
+
"""Pre-rpc interceptor for delete_session
|
|
454
|
+
|
|
455
|
+
Override in a subclass to manipulate the request or metadata
|
|
456
|
+
before they are sent to the Spanner server.
|
|
457
|
+
"""
|
|
458
|
+
return request, metadata
|
|
459
|
+
|
|
460
|
+
def pre_execute_batch_dml(
|
|
461
|
+
self,
|
|
462
|
+
request: spanner.ExecuteBatchDmlRequest,
|
|
463
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
464
|
+
) -> Tuple[spanner.ExecuteBatchDmlRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
465
|
+
"""Pre-rpc interceptor for execute_batch_dml
|
|
466
|
+
|
|
467
|
+
Override in a subclass to manipulate the request or metadata
|
|
468
|
+
before they are sent to the Spanner server.
|
|
469
|
+
"""
|
|
470
|
+
return request, metadata
|
|
471
|
+
|
|
472
|
+
def post_execute_batch_dml(
|
|
473
|
+
self, response: spanner.ExecuteBatchDmlResponse
|
|
474
|
+
) -> spanner.ExecuteBatchDmlResponse:
|
|
475
|
+
"""Post-rpc interceptor for execute_batch_dml
|
|
476
|
+
|
|
477
|
+
DEPRECATED. Please use the `post_execute_batch_dml_with_metadata`
|
|
478
|
+
interceptor instead.
|
|
479
|
+
|
|
480
|
+
Override in a subclass to read or manipulate the response
|
|
481
|
+
after it is returned by the Spanner server but before
|
|
482
|
+
it is returned to user code. This `post_execute_batch_dml` interceptor runs
|
|
483
|
+
before the `post_execute_batch_dml_with_metadata` interceptor.
|
|
484
|
+
"""
|
|
485
|
+
return response
|
|
486
|
+
|
|
487
|
+
def post_execute_batch_dml_with_metadata(
|
|
488
|
+
self,
|
|
489
|
+
response: spanner.ExecuteBatchDmlResponse,
|
|
490
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
491
|
+
) -> Tuple[
|
|
492
|
+
spanner.ExecuteBatchDmlResponse, Sequence[Tuple[str, Union[str, bytes]]]
|
|
493
|
+
]:
|
|
494
|
+
"""Post-rpc interceptor for execute_batch_dml
|
|
495
|
+
|
|
496
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
497
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
498
|
+
|
|
499
|
+
We recommend only using this `post_execute_batch_dml_with_metadata`
|
|
500
|
+
interceptor in new development instead of the `post_execute_batch_dml` interceptor.
|
|
501
|
+
When both interceptors are used, this `post_execute_batch_dml_with_metadata` interceptor runs after the
|
|
502
|
+
`post_execute_batch_dml` interceptor. The (possibly modified) response returned by
|
|
503
|
+
`post_execute_batch_dml` will be passed to
|
|
504
|
+
`post_execute_batch_dml_with_metadata`.
|
|
505
|
+
"""
|
|
506
|
+
return response, metadata
|
|
507
|
+
|
|
508
|
+
def pre_execute_sql(
|
|
509
|
+
self,
|
|
510
|
+
request: spanner.ExecuteSqlRequest,
|
|
511
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
512
|
+
) -> Tuple[spanner.ExecuteSqlRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
513
|
+
"""Pre-rpc interceptor for execute_sql
|
|
514
|
+
|
|
515
|
+
Override in a subclass to manipulate the request or metadata
|
|
516
|
+
before they are sent to the Spanner server.
|
|
517
|
+
"""
|
|
518
|
+
return request, metadata
|
|
519
|
+
|
|
520
|
+
def post_execute_sql(self, response: result_set.ResultSet) -> result_set.ResultSet:
|
|
521
|
+
"""Post-rpc interceptor for execute_sql
|
|
522
|
+
|
|
523
|
+
DEPRECATED. Please use the `post_execute_sql_with_metadata`
|
|
524
|
+
interceptor instead.
|
|
525
|
+
|
|
526
|
+
Override in a subclass to read or manipulate the response
|
|
527
|
+
after it is returned by the Spanner server but before
|
|
528
|
+
it is returned to user code. This `post_execute_sql` interceptor runs
|
|
529
|
+
before the `post_execute_sql_with_metadata` interceptor.
|
|
530
|
+
"""
|
|
531
|
+
return response
|
|
532
|
+
|
|
533
|
+
def post_execute_sql_with_metadata(
|
|
534
|
+
self,
|
|
535
|
+
response: result_set.ResultSet,
|
|
536
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
537
|
+
) -> Tuple[result_set.ResultSet, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
538
|
+
"""Post-rpc interceptor for execute_sql
|
|
539
|
+
|
|
540
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
541
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
542
|
+
|
|
543
|
+
We recommend only using this `post_execute_sql_with_metadata`
|
|
544
|
+
interceptor in new development instead of the `post_execute_sql` interceptor.
|
|
545
|
+
When both interceptors are used, this `post_execute_sql_with_metadata` interceptor runs after the
|
|
546
|
+
`post_execute_sql` interceptor. The (possibly modified) response returned by
|
|
547
|
+
`post_execute_sql` will be passed to
|
|
548
|
+
`post_execute_sql_with_metadata`.
|
|
549
|
+
"""
|
|
550
|
+
return response, metadata
|
|
551
|
+
|
|
552
|
+
def pre_execute_streaming_sql(
|
|
553
|
+
self,
|
|
554
|
+
request: spanner.ExecuteSqlRequest,
|
|
555
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
556
|
+
) -> Tuple[spanner.ExecuteSqlRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
557
|
+
"""Pre-rpc interceptor for execute_streaming_sql
|
|
558
|
+
|
|
559
|
+
Override in a subclass to manipulate the request or metadata
|
|
560
|
+
before they are sent to the Spanner server.
|
|
561
|
+
"""
|
|
562
|
+
return request, metadata
|
|
563
|
+
|
|
564
|
+
def post_execute_streaming_sql(
|
|
565
|
+
self, response: rest_streaming.ResponseIterator
|
|
566
|
+
) -> rest_streaming.ResponseIterator:
|
|
567
|
+
"""Post-rpc interceptor for execute_streaming_sql
|
|
568
|
+
|
|
569
|
+
DEPRECATED. Please use the `post_execute_streaming_sql_with_metadata`
|
|
570
|
+
interceptor instead.
|
|
571
|
+
|
|
572
|
+
Override in a subclass to read or manipulate the response
|
|
573
|
+
after it is returned by the Spanner server but before
|
|
574
|
+
it is returned to user code. This `post_execute_streaming_sql` interceptor runs
|
|
575
|
+
before the `post_execute_streaming_sql_with_metadata` interceptor.
|
|
576
|
+
"""
|
|
577
|
+
return response
|
|
578
|
+
|
|
579
|
+
def post_execute_streaming_sql_with_metadata(
|
|
580
|
+
self,
|
|
581
|
+
response: rest_streaming.ResponseIterator,
|
|
582
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
583
|
+
) -> Tuple[
|
|
584
|
+
rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
|
|
585
|
+
]:
|
|
586
|
+
"""Post-rpc interceptor for execute_streaming_sql
|
|
587
|
+
|
|
588
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
589
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
590
|
+
|
|
591
|
+
We recommend only using this `post_execute_streaming_sql_with_metadata`
|
|
592
|
+
interceptor in new development instead of the `post_execute_streaming_sql` interceptor.
|
|
593
|
+
When both interceptors are used, this `post_execute_streaming_sql_with_metadata` interceptor runs after the
|
|
594
|
+
`post_execute_streaming_sql` interceptor. The (possibly modified) response returned by
|
|
595
|
+
`post_execute_streaming_sql` will be passed to
|
|
596
|
+
`post_execute_streaming_sql_with_metadata`.
|
|
597
|
+
"""
|
|
598
|
+
return response, metadata
|
|
599
|
+
|
|
600
|
+
def pre_get_session(
|
|
601
|
+
self,
|
|
602
|
+
request: spanner.GetSessionRequest,
|
|
603
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
604
|
+
) -> Tuple[spanner.GetSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
605
|
+
"""Pre-rpc interceptor for get_session
|
|
606
|
+
|
|
607
|
+
Override in a subclass to manipulate the request or metadata
|
|
608
|
+
before they are sent to the Spanner server.
|
|
609
|
+
"""
|
|
610
|
+
return request, metadata
|
|
611
|
+
|
|
612
|
+
def post_get_session(self, response: spanner.Session) -> spanner.Session:
|
|
613
|
+
"""Post-rpc interceptor for get_session
|
|
614
|
+
|
|
615
|
+
DEPRECATED. Please use the `post_get_session_with_metadata`
|
|
616
|
+
interceptor instead.
|
|
617
|
+
|
|
618
|
+
Override in a subclass to read or manipulate the response
|
|
619
|
+
after it is returned by the Spanner server but before
|
|
620
|
+
it is returned to user code. This `post_get_session` interceptor runs
|
|
621
|
+
before the `post_get_session_with_metadata` interceptor.
|
|
622
|
+
"""
|
|
623
|
+
return response
|
|
624
|
+
|
|
625
|
+
def post_get_session_with_metadata(
|
|
626
|
+
self,
|
|
627
|
+
response: spanner.Session,
|
|
628
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
629
|
+
) -> Tuple[spanner.Session, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
630
|
+
"""Post-rpc interceptor for get_session
|
|
631
|
+
|
|
632
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
633
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
634
|
+
|
|
635
|
+
We recommend only using this `post_get_session_with_metadata`
|
|
636
|
+
interceptor in new development instead of the `post_get_session` interceptor.
|
|
637
|
+
When both interceptors are used, this `post_get_session_with_metadata` interceptor runs after the
|
|
638
|
+
`post_get_session` interceptor. The (possibly modified) response returned by
|
|
639
|
+
`post_get_session` will be passed to
|
|
640
|
+
`post_get_session_with_metadata`.
|
|
641
|
+
"""
|
|
642
|
+
return response, metadata
|
|
643
|
+
|
|
644
|
+
def pre_list_sessions(
|
|
645
|
+
self,
|
|
646
|
+
request: spanner.ListSessionsRequest,
|
|
647
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
648
|
+
) -> Tuple[spanner.ListSessionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
649
|
+
"""Pre-rpc interceptor for list_sessions
|
|
650
|
+
|
|
651
|
+
Override in a subclass to manipulate the request or metadata
|
|
652
|
+
before they are sent to the Spanner server.
|
|
653
|
+
"""
|
|
654
|
+
return request, metadata
|
|
655
|
+
|
|
656
|
+
def post_list_sessions(
|
|
657
|
+
self, response: spanner.ListSessionsResponse
|
|
658
|
+
) -> spanner.ListSessionsResponse:
|
|
659
|
+
"""Post-rpc interceptor for list_sessions
|
|
660
|
+
|
|
661
|
+
DEPRECATED. Please use the `post_list_sessions_with_metadata`
|
|
662
|
+
interceptor instead.
|
|
663
|
+
|
|
664
|
+
Override in a subclass to read or manipulate the response
|
|
665
|
+
after it is returned by the Spanner server but before
|
|
666
|
+
it is returned to user code. This `post_list_sessions` interceptor runs
|
|
667
|
+
before the `post_list_sessions_with_metadata` interceptor.
|
|
668
|
+
"""
|
|
669
|
+
return response
|
|
670
|
+
|
|
671
|
+
def post_list_sessions_with_metadata(
|
|
672
|
+
self,
|
|
673
|
+
response: spanner.ListSessionsResponse,
|
|
674
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
675
|
+
) -> Tuple[spanner.ListSessionsResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
676
|
+
"""Post-rpc interceptor for list_sessions
|
|
677
|
+
|
|
678
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
679
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
680
|
+
|
|
681
|
+
We recommend only using this `post_list_sessions_with_metadata`
|
|
682
|
+
interceptor in new development instead of the `post_list_sessions` interceptor.
|
|
683
|
+
When both interceptors are used, this `post_list_sessions_with_metadata` interceptor runs after the
|
|
684
|
+
`post_list_sessions` interceptor. The (possibly modified) response returned by
|
|
685
|
+
`post_list_sessions` will be passed to
|
|
686
|
+
`post_list_sessions_with_metadata`.
|
|
687
|
+
"""
|
|
688
|
+
return response, metadata
|
|
689
|
+
|
|
690
|
+
def pre_partition_query(
|
|
691
|
+
self,
|
|
692
|
+
request: spanner.PartitionQueryRequest,
|
|
693
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
694
|
+
) -> Tuple[spanner.PartitionQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
695
|
+
"""Pre-rpc interceptor for partition_query
|
|
696
|
+
|
|
697
|
+
Override in a subclass to manipulate the request or metadata
|
|
698
|
+
before they are sent to the Spanner server.
|
|
699
|
+
"""
|
|
700
|
+
return request, metadata
|
|
701
|
+
|
|
702
|
+
def post_partition_query(
|
|
703
|
+
self, response: spanner.PartitionResponse
|
|
704
|
+
) -> spanner.PartitionResponse:
|
|
705
|
+
"""Post-rpc interceptor for partition_query
|
|
706
|
+
|
|
707
|
+
DEPRECATED. Please use the `post_partition_query_with_metadata`
|
|
708
|
+
interceptor instead.
|
|
709
|
+
|
|
710
|
+
Override in a subclass to read or manipulate the response
|
|
711
|
+
after it is returned by the Spanner server but before
|
|
712
|
+
it is returned to user code. This `post_partition_query` interceptor runs
|
|
713
|
+
before the `post_partition_query_with_metadata` interceptor.
|
|
714
|
+
"""
|
|
715
|
+
return response
|
|
716
|
+
|
|
717
|
+
def post_partition_query_with_metadata(
|
|
718
|
+
self,
|
|
719
|
+
response: spanner.PartitionResponse,
|
|
720
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
721
|
+
) -> Tuple[spanner.PartitionResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
722
|
+
"""Post-rpc interceptor for partition_query
|
|
723
|
+
|
|
724
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
725
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
726
|
+
|
|
727
|
+
We recommend only using this `post_partition_query_with_metadata`
|
|
728
|
+
interceptor in new development instead of the `post_partition_query` interceptor.
|
|
729
|
+
When both interceptors are used, this `post_partition_query_with_metadata` interceptor runs after the
|
|
730
|
+
`post_partition_query` interceptor. The (possibly modified) response returned by
|
|
731
|
+
`post_partition_query` will be passed to
|
|
732
|
+
`post_partition_query_with_metadata`.
|
|
733
|
+
"""
|
|
734
|
+
return response, metadata
|
|
735
|
+
|
|
736
|
+
def pre_partition_read(
|
|
737
|
+
self,
|
|
738
|
+
request: spanner.PartitionReadRequest,
|
|
739
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
740
|
+
) -> Tuple[spanner.PartitionReadRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
741
|
+
"""Pre-rpc interceptor for partition_read
|
|
742
|
+
|
|
743
|
+
Override in a subclass to manipulate the request or metadata
|
|
744
|
+
before they are sent to the Spanner server.
|
|
745
|
+
"""
|
|
746
|
+
return request, metadata
|
|
747
|
+
|
|
748
|
+
def post_partition_read(
|
|
749
|
+
self, response: spanner.PartitionResponse
|
|
750
|
+
) -> spanner.PartitionResponse:
|
|
751
|
+
"""Post-rpc interceptor for partition_read
|
|
752
|
+
|
|
753
|
+
DEPRECATED. Please use the `post_partition_read_with_metadata`
|
|
754
|
+
interceptor instead.
|
|
755
|
+
|
|
756
|
+
Override in a subclass to read or manipulate the response
|
|
757
|
+
after it is returned by the Spanner server but before
|
|
758
|
+
it is returned to user code. This `post_partition_read` interceptor runs
|
|
759
|
+
before the `post_partition_read_with_metadata` interceptor.
|
|
760
|
+
"""
|
|
761
|
+
return response
|
|
762
|
+
|
|
763
|
+
def post_partition_read_with_metadata(
|
|
764
|
+
self,
|
|
765
|
+
response: spanner.PartitionResponse,
|
|
766
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
767
|
+
) -> Tuple[spanner.PartitionResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
768
|
+
"""Post-rpc interceptor for partition_read
|
|
769
|
+
|
|
770
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
771
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
772
|
+
|
|
773
|
+
We recommend only using this `post_partition_read_with_metadata`
|
|
774
|
+
interceptor in new development instead of the `post_partition_read` interceptor.
|
|
775
|
+
When both interceptors are used, this `post_partition_read_with_metadata` interceptor runs after the
|
|
776
|
+
`post_partition_read` interceptor. The (possibly modified) response returned by
|
|
777
|
+
`post_partition_read` will be passed to
|
|
778
|
+
`post_partition_read_with_metadata`.
|
|
779
|
+
"""
|
|
780
|
+
return response, metadata
|
|
781
|
+
|
|
782
|
+
def pre_read(
|
|
783
|
+
self,
|
|
784
|
+
request: spanner.ReadRequest,
|
|
785
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
786
|
+
) -> Tuple[spanner.ReadRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
787
|
+
"""Pre-rpc interceptor for read
|
|
788
|
+
|
|
789
|
+
Override in a subclass to manipulate the request or metadata
|
|
790
|
+
before they are sent to the Spanner server.
|
|
791
|
+
"""
|
|
792
|
+
return request, metadata
|
|
793
|
+
|
|
794
|
+
def post_read(self, response: result_set.ResultSet) -> result_set.ResultSet:
|
|
795
|
+
"""Post-rpc interceptor for read
|
|
796
|
+
|
|
797
|
+
DEPRECATED. Please use the `post_read_with_metadata`
|
|
798
|
+
interceptor instead.
|
|
799
|
+
|
|
800
|
+
Override in a subclass to read or manipulate the response
|
|
801
|
+
after it is returned by the Spanner server but before
|
|
802
|
+
it is returned to user code. This `post_read` interceptor runs
|
|
803
|
+
before the `post_read_with_metadata` interceptor.
|
|
804
|
+
"""
|
|
805
|
+
return response
|
|
806
|
+
|
|
807
|
+
def post_read_with_metadata(
|
|
808
|
+
self,
|
|
809
|
+
response: result_set.ResultSet,
|
|
810
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
811
|
+
) -> Tuple[result_set.ResultSet, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
812
|
+
"""Post-rpc interceptor for read
|
|
813
|
+
|
|
814
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
815
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
816
|
+
|
|
817
|
+
We recommend only using this `post_read_with_metadata`
|
|
818
|
+
interceptor in new development instead of the `post_read` interceptor.
|
|
819
|
+
When both interceptors are used, this `post_read_with_metadata` interceptor runs after the
|
|
820
|
+
`post_read` interceptor. The (possibly modified) response returned by
|
|
821
|
+
`post_read` will be passed to
|
|
822
|
+
`post_read_with_metadata`.
|
|
823
|
+
"""
|
|
824
|
+
return response, metadata
|
|
825
|
+
|
|
826
|
+
def pre_rollback(
|
|
827
|
+
self,
|
|
828
|
+
request: spanner.RollbackRequest,
|
|
829
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
830
|
+
) -> Tuple[spanner.RollbackRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
831
|
+
"""Pre-rpc interceptor for rollback
|
|
832
|
+
|
|
833
|
+
Override in a subclass to manipulate the request or metadata
|
|
834
|
+
before they are sent to the Spanner server.
|
|
835
|
+
"""
|
|
836
|
+
return request, metadata
|
|
837
|
+
|
|
838
|
+
def pre_streaming_read(
|
|
839
|
+
self,
|
|
840
|
+
request: spanner.ReadRequest,
|
|
841
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
842
|
+
) -> Tuple[spanner.ReadRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
843
|
+
"""Pre-rpc interceptor for streaming_read
|
|
844
|
+
|
|
845
|
+
Override in a subclass to manipulate the request or metadata
|
|
846
|
+
before they are sent to the Spanner server.
|
|
847
|
+
"""
|
|
848
|
+
return request, metadata
|
|
849
|
+
|
|
850
|
+
def post_streaming_read(
|
|
851
|
+
self, response: rest_streaming.ResponseIterator
|
|
852
|
+
) -> rest_streaming.ResponseIterator:
|
|
853
|
+
"""Post-rpc interceptor for streaming_read
|
|
854
|
+
|
|
855
|
+
DEPRECATED. Please use the `post_streaming_read_with_metadata`
|
|
856
|
+
interceptor instead.
|
|
857
|
+
|
|
858
|
+
Override in a subclass to read or manipulate the response
|
|
859
|
+
after it is returned by the Spanner server but before
|
|
860
|
+
it is returned to user code. This `post_streaming_read` interceptor runs
|
|
861
|
+
before the `post_streaming_read_with_metadata` interceptor.
|
|
862
|
+
"""
|
|
863
|
+
return response
|
|
864
|
+
|
|
865
|
+
def post_streaming_read_with_metadata(
|
|
866
|
+
self,
|
|
867
|
+
response: rest_streaming.ResponseIterator,
|
|
868
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
869
|
+
) -> Tuple[
|
|
870
|
+
rest_streaming.ResponseIterator, Sequence[Tuple[str, Union[str, bytes]]]
|
|
871
|
+
]:
|
|
872
|
+
"""Post-rpc interceptor for streaming_read
|
|
873
|
+
|
|
874
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
875
|
+
is returned by the Spanner server but before it is returned to user code.
|
|
876
|
+
|
|
877
|
+
We recommend only using this `post_streaming_read_with_metadata`
|
|
878
|
+
interceptor in new development instead of the `post_streaming_read` interceptor.
|
|
879
|
+
When both interceptors are used, this `post_streaming_read_with_metadata` interceptor runs after the
|
|
880
|
+
`post_streaming_read` interceptor. The (possibly modified) response returned by
|
|
881
|
+
`post_streaming_read` will be passed to
|
|
882
|
+
`post_streaming_read_with_metadata`.
|
|
883
|
+
"""
|
|
884
|
+
return response, metadata
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
@dataclasses.dataclass
|
|
888
|
+
class SpannerRestStub:
|
|
889
|
+
_session: AuthorizedSession
|
|
890
|
+
_host: str
|
|
891
|
+
_interceptor: SpannerRestInterceptor
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
class SpannerRestTransport(_BaseSpannerRestTransport):
|
|
895
|
+
"""REST backend synchronous transport for Spanner.
|
|
896
|
+
|
|
897
|
+
Cloud Spanner API
|
|
898
|
+
|
|
899
|
+
The Cloud Spanner API can be used to manage sessions and execute
|
|
900
|
+
transactions on data stored in Cloud Spanner databases.
|
|
901
|
+
|
|
902
|
+
This class defines the same methods as the primary client, so the
|
|
903
|
+
primary client can load the underlying transport implementation
|
|
904
|
+
and call it.
|
|
905
|
+
|
|
906
|
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
|
907
|
+
"""
|
|
908
|
+
|
|
909
|
+
def __init__(
|
|
910
|
+
self,
|
|
911
|
+
*,
|
|
912
|
+
host: str = "spanner.googleapis.com",
|
|
913
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
914
|
+
credentials_file: Optional[str] = None,
|
|
915
|
+
scopes: Optional[Sequence[str]] = None,
|
|
916
|
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
|
917
|
+
quota_project_id: Optional[str] = None,
|
|
918
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
919
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
920
|
+
url_scheme: str = "https",
|
|
921
|
+
interceptor: Optional[SpannerRestInterceptor] = None,
|
|
922
|
+
api_audience: Optional[str] = None,
|
|
923
|
+
metrics_interceptor: Optional[MetricsInterceptor] = None,
|
|
924
|
+
) -> None:
|
|
925
|
+
"""Instantiate the transport.
|
|
926
|
+
|
|
927
|
+
Args:
|
|
928
|
+
host (Optional[str]):
|
|
929
|
+
The hostname to connect to (default: 'spanner.googleapis.com').
|
|
930
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
931
|
+
authorization credentials to attach to requests. These
|
|
932
|
+
credentials identify the application to the service; if none
|
|
933
|
+
are specified, the client will attempt to ascertain the
|
|
934
|
+
credentials from the environment.
|
|
935
|
+
|
|
936
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
937
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
938
|
+
This argument is ignored if ``channel`` is provided.
|
|
939
|
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
|
940
|
+
ignored if ``channel`` is provided.
|
|
941
|
+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
|
|
942
|
+
certificate to configure mutual TLS HTTP channel. It is ignored
|
|
943
|
+
if ``channel`` is provided.
|
|
944
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
945
|
+
and quota.
|
|
946
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
947
|
+
The client info used to send a user-agent string along with
|
|
948
|
+
API requests. If ``None``, then default info will be used.
|
|
949
|
+
Generally, you only need to set this if you are developing
|
|
950
|
+
your own client library.
|
|
951
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
952
|
+
be used for service account credentials.
|
|
953
|
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
|
954
|
+
"https", but for testing or local servers,
|
|
955
|
+
"http" can be specified.
|
|
956
|
+
"""
|
|
957
|
+
# Run the base constructor
|
|
958
|
+
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
|
959
|
+
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
|
960
|
+
# credentials object
|
|
961
|
+
super().__init__(
|
|
962
|
+
host=host,
|
|
963
|
+
credentials=credentials,
|
|
964
|
+
client_info=client_info,
|
|
965
|
+
always_use_jwt_access=always_use_jwt_access,
|
|
966
|
+
url_scheme=url_scheme,
|
|
967
|
+
api_audience=api_audience,
|
|
968
|
+
)
|
|
969
|
+
self._session = AuthorizedSession(
|
|
970
|
+
self._credentials, default_host=self.DEFAULT_HOST
|
|
971
|
+
)
|
|
972
|
+
if client_cert_source_for_mtls:
|
|
973
|
+
self._session.configure_mtls_channel(client_cert_source_for_mtls)
|
|
974
|
+
self._interceptor = interceptor or SpannerRestInterceptor()
|
|
975
|
+
self._prep_wrapped_messages(client_info)
|
|
976
|
+
|
|
977
|
+
class _BatchCreateSessions(
|
|
978
|
+
_BaseSpannerRestTransport._BaseBatchCreateSessions, SpannerRestStub
|
|
979
|
+
):
|
|
980
|
+
def __hash__(self):
|
|
981
|
+
return hash("SpannerRestTransport.BatchCreateSessions")
|
|
982
|
+
|
|
983
|
+
@staticmethod
|
|
984
|
+
def _get_response(
|
|
985
|
+
host,
|
|
986
|
+
metadata,
|
|
987
|
+
query_params,
|
|
988
|
+
session,
|
|
989
|
+
timeout,
|
|
990
|
+
transcoded_request,
|
|
991
|
+
body=None,
|
|
992
|
+
):
|
|
993
|
+
uri = transcoded_request["uri"]
|
|
994
|
+
method = transcoded_request["method"]
|
|
995
|
+
headers = dict(metadata)
|
|
996
|
+
headers["Content-Type"] = "application/json"
|
|
997
|
+
response = getattr(session, method)(
|
|
998
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
999
|
+
timeout=timeout,
|
|
1000
|
+
headers=headers,
|
|
1001
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1002
|
+
data=body,
|
|
1003
|
+
)
|
|
1004
|
+
return response
|
|
1005
|
+
|
|
1006
|
+
def __call__(
|
|
1007
|
+
self,
|
|
1008
|
+
request: spanner.BatchCreateSessionsRequest,
|
|
1009
|
+
*,
|
|
1010
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1011
|
+
timeout: Optional[float] = None,
|
|
1012
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1013
|
+
) -> spanner.BatchCreateSessionsResponse:
|
|
1014
|
+
r"""Call the batch create sessions method over HTTP.
|
|
1015
|
+
|
|
1016
|
+
Args:
|
|
1017
|
+
request (~.spanner.BatchCreateSessionsRequest):
|
|
1018
|
+
The request object. The request for
|
|
1019
|
+
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
|
|
1020
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1021
|
+
should be retried.
|
|
1022
|
+
timeout (float): The timeout for this request.
|
|
1023
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1024
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1025
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1026
|
+
be of type `bytes`.
|
|
1027
|
+
|
|
1028
|
+
Returns:
|
|
1029
|
+
~.spanner.BatchCreateSessionsResponse:
|
|
1030
|
+
The response for
|
|
1031
|
+
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
|
|
1032
|
+
|
|
1033
|
+
"""
|
|
1034
|
+
|
|
1035
|
+
http_options = (
|
|
1036
|
+
_BaseSpannerRestTransport._BaseBatchCreateSessions._get_http_options()
|
|
1037
|
+
)
|
|
1038
|
+
|
|
1039
|
+
request, metadata = self._interceptor.pre_batch_create_sessions(
|
|
1040
|
+
request, metadata
|
|
1041
|
+
)
|
|
1042
|
+
transcoded_request = _BaseSpannerRestTransport._BaseBatchCreateSessions._get_transcoded_request(
|
|
1043
|
+
http_options, request
|
|
1044
|
+
)
|
|
1045
|
+
|
|
1046
|
+
body = _BaseSpannerRestTransport._BaseBatchCreateSessions._get_request_body_json(
|
|
1047
|
+
transcoded_request
|
|
1048
|
+
)
|
|
1049
|
+
|
|
1050
|
+
# Jsonify the query params
|
|
1051
|
+
query_params = _BaseSpannerRestTransport._BaseBatchCreateSessions._get_query_params_json(
|
|
1052
|
+
transcoded_request
|
|
1053
|
+
)
|
|
1054
|
+
|
|
1055
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1056
|
+
logging.DEBUG
|
|
1057
|
+
): # pragma: NO COVER
|
|
1058
|
+
request_url = "{host}{uri}".format(
|
|
1059
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1060
|
+
)
|
|
1061
|
+
method = transcoded_request["method"]
|
|
1062
|
+
try:
|
|
1063
|
+
request_payload = type(request).to_json(request)
|
|
1064
|
+
except:
|
|
1065
|
+
request_payload = None
|
|
1066
|
+
http_request = {
|
|
1067
|
+
"payload": request_payload,
|
|
1068
|
+
"requestMethod": method,
|
|
1069
|
+
"requestUrl": request_url,
|
|
1070
|
+
"headers": dict(metadata),
|
|
1071
|
+
}
|
|
1072
|
+
_LOGGER.debug(
|
|
1073
|
+
f"Sending request for google.spanner_v1.SpannerClient.BatchCreateSessions",
|
|
1074
|
+
extra={
|
|
1075
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1076
|
+
"rpcName": "BatchCreateSessions",
|
|
1077
|
+
"httpRequest": http_request,
|
|
1078
|
+
"metadata": http_request["headers"],
|
|
1079
|
+
},
|
|
1080
|
+
)
|
|
1081
|
+
|
|
1082
|
+
# Send the request
|
|
1083
|
+
response = SpannerRestTransport._BatchCreateSessions._get_response(
|
|
1084
|
+
self._host,
|
|
1085
|
+
metadata,
|
|
1086
|
+
query_params,
|
|
1087
|
+
self._session,
|
|
1088
|
+
timeout,
|
|
1089
|
+
transcoded_request,
|
|
1090
|
+
body,
|
|
1091
|
+
)
|
|
1092
|
+
|
|
1093
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1094
|
+
# subclass.
|
|
1095
|
+
if response.status_code >= 400:
|
|
1096
|
+
raise core_exceptions.from_http_response(response)
|
|
1097
|
+
|
|
1098
|
+
# Return the response
|
|
1099
|
+
resp = spanner.BatchCreateSessionsResponse()
|
|
1100
|
+
pb_resp = spanner.BatchCreateSessionsResponse.pb(resp)
|
|
1101
|
+
|
|
1102
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
1103
|
+
|
|
1104
|
+
resp = self._interceptor.post_batch_create_sessions(resp)
|
|
1105
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1106
|
+
resp, _ = self._interceptor.post_batch_create_sessions_with_metadata(
|
|
1107
|
+
resp, response_metadata
|
|
1108
|
+
)
|
|
1109
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1110
|
+
logging.DEBUG
|
|
1111
|
+
): # pragma: NO COVER
|
|
1112
|
+
try:
|
|
1113
|
+
response_payload = spanner.BatchCreateSessionsResponse.to_json(
|
|
1114
|
+
response
|
|
1115
|
+
)
|
|
1116
|
+
except:
|
|
1117
|
+
response_payload = None
|
|
1118
|
+
http_response = {
|
|
1119
|
+
"payload": response_payload,
|
|
1120
|
+
"headers": dict(response.headers),
|
|
1121
|
+
"status": response.status_code,
|
|
1122
|
+
}
|
|
1123
|
+
_LOGGER.debug(
|
|
1124
|
+
"Received response for google.spanner_v1.SpannerClient.batch_create_sessions",
|
|
1125
|
+
extra={
|
|
1126
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1127
|
+
"rpcName": "BatchCreateSessions",
|
|
1128
|
+
"metadata": http_response["headers"],
|
|
1129
|
+
"httpResponse": http_response,
|
|
1130
|
+
},
|
|
1131
|
+
)
|
|
1132
|
+
return resp
|
|
1133
|
+
|
|
1134
|
+
class _BatchWrite(_BaseSpannerRestTransport._BaseBatchWrite, SpannerRestStub):
|
|
1135
|
+
def __hash__(self):
|
|
1136
|
+
return hash("SpannerRestTransport.BatchWrite")
|
|
1137
|
+
|
|
1138
|
+
@staticmethod
|
|
1139
|
+
def _get_response(
|
|
1140
|
+
host,
|
|
1141
|
+
metadata,
|
|
1142
|
+
query_params,
|
|
1143
|
+
session,
|
|
1144
|
+
timeout,
|
|
1145
|
+
transcoded_request,
|
|
1146
|
+
body=None,
|
|
1147
|
+
):
|
|
1148
|
+
uri = transcoded_request["uri"]
|
|
1149
|
+
method = transcoded_request["method"]
|
|
1150
|
+
headers = dict(metadata)
|
|
1151
|
+
headers["Content-Type"] = "application/json"
|
|
1152
|
+
response = getattr(session, method)(
|
|
1153
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1154
|
+
timeout=timeout,
|
|
1155
|
+
headers=headers,
|
|
1156
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1157
|
+
data=body,
|
|
1158
|
+
stream=True,
|
|
1159
|
+
)
|
|
1160
|
+
return response
|
|
1161
|
+
|
|
1162
|
+
def __call__(
|
|
1163
|
+
self,
|
|
1164
|
+
request: spanner.BatchWriteRequest,
|
|
1165
|
+
*,
|
|
1166
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1167
|
+
timeout: Optional[float] = None,
|
|
1168
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1169
|
+
) -> rest_streaming.ResponseIterator:
|
|
1170
|
+
r"""Call the batch write method over HTTP.
|
|
1171
|
+
|
|
1172
|
+
Args:
|
|
1173
|
+
request (~.spanner.BatchWriteRequest):
|
|
1174
|
+
The request object. The request for
|
|
1175
|
+
[BatchWrite][google.spanner.v1.Spanner.BatchWrite].
|
|
1176
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1177
|
+
should be retried.
|
|
1178
|
+
timeout (float): The timeout for this request.
|
|
1179
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1180
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1181
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1182
|
+
be of type `bytes`.
|
|
1183
|
+
|
|
1184
|
+
Returns:
|
|
1185
|
+
~.spanner.BatchWriteResponse:
|
|
1186
|
+
The result of applying a batch of
|
|
1187
|
+
mutations.
|
|
1188
|
+
|
|
1189
|
+
"""
|
|
1190
|
+
|
|
1191
|
+
http_options = _BaseSpannerRestTransport._BaseBatchWrite._get_http_options()
|
|
1192
|
+
|
|
1193
|
+
request, metadata = self._interceptor.pre_batch_write(request, metadata)
|
|
1194
|
+
transcoded_request = (
|
|
1195
|
+
_BaseSpannerRestTransport._BaseBatchWrite._get_transcoded_request(
|
|
1196
|
+
http_options, request
|
|
1197
|
+
)
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
body = _BaseSpannerRestTransport._BaseBatchWrite._get_request_body_json(
|
|
1201
|
+
transcoded_request
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
# Jsonify the query params
|
|
1205
|
+
query_params = (
|
|
1206
|
+
_BaseSpannerRestTransport._BaseBatchWrite._get_query_params_json(
|
|
1207
|
+
transcoded_request
|
|
1208
|
+
)
|
|
1209
|
+
)
|
|
1210
|
+
|
|
1211
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1212
|
+
logging.DEBUG
|
|
1213
|
+
): # pragma: NO COVER
|
|
1214
|
+
request_url = "{host}{uri}".format(
|
|
1215
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1216
|
+
)
|
|
1217
|
+
method = transcoded_request["method"]
|
|
1218
|
+
try:
|
|
1219
|
+
request_payload = type(request).to_json(request)
|
|
1220
|
+
except:
|
|
1221
|
+
request_payload = None
|
|
1222
|
+
http_request = {
|
|
1223
|
+
"payload": request_payload,
|
|
1224
|
+
"requestMethod": method,
|
|
1225
|
+
"requestUrl": request_url,
|
|
1226
|
+
"headers": dict(metadata),
|
|
1227
|
+
}
|
|
1228
|
+
_LOGGER.debug(
|
|
1229
|
+
f"Sending request for google.spanner_v1.SpannerClient.BatchWrite",
|
|
1230
|
+
extra={
|
|
1231
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1232
|
+
"rpcName": "BatchWrite",
|
|
1233
|
+
"httpRequest": http_request,
|
|
1234
|
+
"metadata": http_request["headers"],
|
|
1235
|
+
},
|
|
1236
|
+
)
|
|
1237
|
+
|
|
1238
|
+
# Send the request
|
|
1239
|
+
response = SpannerRestTransport._BatchWrite._get_response(
|
|
1240
|
+
self._host,
|
|
1241
|
+
metadata,
|
|
1242
|
+
query_params,
|
|
1243
|
+
self._session,
|
|
1244
|
+
timeout,
|
|
1245
|
+
transcoded_request,
|
|
1246
|
+
body,
|
|
1247
|
+
)
|
|
1248
|
+
|
|
1249
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1250
|
+
# subclass.
|
|
1251
|
+
if response.status_code >= 400:
|
|
1252
|
+
raise core_exceptions.from_http_response(response)
|
|
1253
|
+
|
|
1254
|
+
# Return the response
|
|
1255
|
+
resp = rest_streaming.ResponseIterator(response, spanner.BatchWriteResponse)
|
|
1256
|
+
|
|
1257
|
+
resp = self._interceptor.post_batch_write(resp)
|
|
1258
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1259
|
+
resp, _ = self._interceptor.post_batch_write_with_metadata(
|
|
1260
|
+
resp, response_metadata
|
|
1261
|
+
)
|
|
1262
|
+
return resp
|
|
1263
|
+
|
|
1264
|
+
class _BeginTransaction(
|
|
1265
|
+
_BaseSpannerRestTransport._BaseBeginTransaction, SpannerRestStub
|
|
1266
|
+
):
|
|
1267
|
+
def __hash__(self):
|
|
1268
|
+
return hash("SpannerRestTransport.BeginTransaction")
|
|
1269
|
+
|
|
1270
|
+
@staticmethod
|
|
1271
|
+
def _get_response(
|
|
1272
|
+
host,
|
|
1273
|
+
metadata,
|
|
1274
|
+
query_params,
|
|
1275
|
+
session,
|
|
1276
|
+
timeout,
|
|
1277
|
+
transcoded_request,
|
|
1278
|
+
body=None,
|
|
1279
|
+
):
|
|
1280
|
+
uri = transcoded_request["uri"]
|
|
1281
|
+
method = transcoded_request["method"]
|
|
1282
|
+
headers = dict(metadata)
|
|
1283
|
+
headers["Content-Type"] = "application/json"
|
|
1284
|
+
response = getattr(session, method)(
|
|
1285
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1286
|
+
timeout=timeout,
|
|
1287
|
+
headers=headers,
|
|
1288
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1289
|
+
data=body,
|
|
1290
|
+
)
|
|
1291
|
+
return response
|
|
1292
|
+
|
|
1293
|
+
def __call__(
|
|
1294
|
+
self,
|
|
1295
|
+
request: spanner.BeginTransactionRequest,
|
|
1296
|
+
*,
|
|
1297
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1298
|
+
timeout: Optional[float] = None,
|
|
1299
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1300
|
+
) -> transaction.Transaction:
|
|
1301
|
+
r"""Call the begin transaction method over HTTP.
|
|
1302
|
+
|
|
1303
|
+
Args:
|
|
1304
|
+
request (~.spanner.BeginTransactionRequest):
|
|
1305
|
+
The request object. The request for
|
|
1306
|
+
[BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
|
|
1307
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1308
|
+
should be retried.
|
|
1309
|
+
timeout (float): The timeout for this request.
|
|
1310
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1311
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1312
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1313
|
+
be of type `bytes`.
|
|
1314
|
+
|
|
1315
|
+
Returns:
|
|
1316
|
+
~.transaction.Transaction:
|
|
1317
|
+
A transaction.
|
|
1318
|
+
"""
|
|
1319
|
+
|
|
1320
|
+
http_options = (
|
|
1321
|
+
_BaseSpannerRestTransport._BaseBeginTransaction._get_http_options()
|
|
1322
|
+
)
|
|
1323
|
+
|
|
1324
|
+
request, metadata = self._interceptor.pre_begin_transaction(
|
|
1325
|
+
request, metadata
|
|
1326
|
+
)
|
|
1327
|
+
transcoded_request = (
|
|
1328
|
+
_BaseSpannerRestTransport._BaseBeginTransaction._get_transcoded_request(
|
|
1329
|
+
http_options, request
|
|
1330
|
+
)
|
|
1331
|
+
)
|
|
1332
|
+
|
|
1333
|
+
body = (
|
|
1334
|
+
_BaseSpannerRestTransport._BaseBeginTransaction._get_request_body_json(
|
|
1335
|
+
transcoded_request
|
|
1336
|
+
)
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
# Jsonify the query params
|
|
1340
|
+
query_params = (
|
|
1341
|
+
_BaseSpannerRestTransport._BaseBeginTransaction._get_query_params_json(
|
|
1342
|
+
transcoded_request
|
|
1343
|
+
)
|
|
1344
|
+
)
|
|
1345
|
+
|
|
1346
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1347
|
+
logging.DEBUG
|
|
1348
|
+
): # pragma: NO COVER
|
|
1349
|
+
request_url = "{host}{uri}".format(
|
|
1350
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1351
|
+
)
|
|
1352
|
+
method = transcoded_request["method"]
|
|
1353
|
+
try:
|
|
1354
|
+
request_payload = type(request).to_json(request)
|
|
1355
|
+
except:
|
|
1356
|
+
request_payload = None
|
|
1357
|
+
http_request = {
|
|
1358
|
+
"payload": request_payload,
|
|
1359
|
+
"requestMethod": method,
|
|
1360
|
+
"requestUrl": request_url,
|
|
1361
|
+
"headers": dict(metadata),
|
|
1362
|
+
}
|
|
1363
|
+
_LOGGER.debug(
|
|
1364
|
+
f"Sending request for google.spanner_v1.SpannerClient.BeginTransaction",
|
|
1365
|
+
extra={
|
|
1366
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1367
|
+
"rpcName": "BeginTransaction",
|
|
1368
|
+
"httpRequest": http_request,
|
|
1369
|
+
"metadata": http_request["headers"],
|
|
1370
|
+
},
|
|
1371
|
+
)
|
|
1372
|
+
|
|
1373
|
+
# Send the request
|
|
1374
|
+
response = SpannerRestTransport._BeginTransaction._get_response(
|
|
1375
|
+
self._host,
|
|
1376
|
+
metadata,
|
|
1377
|
+
query_params,
|
|
1378
|
+
self._session,
|
|
1379
|
+
timeout,
|
|
1380
|
+
transcoded_request,
|
|
1381
|
+
body,
|
|
1382
|
+
)
|
|
1383
|
+
|
|
1384
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1385
|
+
# subclass.
|
|
1386
|
+
if response.status_code >= 400:
|
|
1387
|
+
raise core_exceptions.from_http_response(response)
|
|
1388
|
+
|
|
1389
|
+
# Return the response
|
|
1390
|
+
resp = transaction.Transaction()
|
|
1391
|
+
pb_resp = transaction.Transaction.pb(resp)
|
|
1392
|
+
|
|
1393
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
1394
|
+
|
|
1395
|
+
resp = self._interceptor.post_begin_transaction(resp)
|
|
1396
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1397
|
+
resp, _ = self._interceptor.post_begin_transaction_with_metadata(
|
|
1398
|
+
resp, response_metadata
|
|
1399
|
+
)
|
|
1400
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1401
|
+
logging.DEBUG
|
|
1402
|
+
): # pragma: NO COVER
|
|
1403
|
+
try:
|
|
1404
|
+
response_payload = transaction.Transaction.to_json(response)
|
|
1405
|
+
except:
|
|
1406
|
+
response_payload = None
|
|
1407
|
+
http_response = {
|
|
1408
|
+
"payload": response_payload,
|
|
1409
|
+
"headers": dict(response.headers),
|
|
1410
|
+
"status": response.status_code,
|
|
1411
|
+
}
|
|
1412
|
+
_LOGGER.debug(
|
|
1413
|
+
"Received response for google.spanner_v1.SpannerClient.begin_transaction",
|
|
1414
|
+
extra={
|
|
1415
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1416
|
+
"rpcName": "BeginTransaction",
|
|
1417
|
+
"metadata": http_response["headers"],
|
|
1418
|
+
"httpResponse": http_response,
|
|
1419
|
+
},
|
|
1420
|
+
)
|
|
1421
|
+
return resp
|
|
1422
|
+
|
|
1423
|
+
class _Commit(_BaseSpannerRestTransport._BaseCommit, SpannerRestStub):
|
|
1424
|
+
def __hash__(self):
|
|
1425
|
+
return hash("SpannerRestTransport.Commit")
|
|
1426
|
+
|
|
1427
|
+
@staticmethod
|
|
1428
|
+
def _get_response(
|
|
1429
|
+
host,
|
|
1430
|
+
metadata,
|
|
1431
|
+
query_params,
|
|
1432
|
+
session,
|
|
1433
|
+
timeout,
|
|
1434
|
+
transcoded_request,
|
|
1435
|
+
body=None,
|
|
1436
|
+
):
|
|
1437
|
+
uri = transcoded_request["uri"]
|
|
1438
|
+
method = transcoded_request["method"]
|
|
1439
|
+
headers = dict(metadata)
|
|
1440
|
+
headers["Content-Type"] = "application/json"
|
|
1441
|
+
response = getattr(session, method)(
|
|
1442
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1443
|
+
timeout=timeout,
|
|
1444
|
+
headers=headers,
|
|
1445
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1446
|
+
data=body,
|
|
1447
|
+
)
|
|
1448
|
+
return response
|
|
1449
|
+
|
|
1450
|
+
def __call__(
|
|
1451
|
+
self,
|
|
1452
|
+
request: spanner.CommitRequest,
|
|
1453
|
+
*,
|
|
1454
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1455
|
+
timeout: Optional[float] = None,
|
|
1456
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1457
|
+
) -> commit_response.CommitResponse:
|
|
1458
|
+
r"""Call the commit method over HTTP.
|
|
1459
|
+
|
|
1460
|
+
Args:
|
|
1461
|
+
request (~.spanner.CommitRequest):
|
|
1462
|
+
The request object. The request for
|
|
1463
|
+
[Commit][google.spanner.v1.Spanner.Commit].
|
|
1464
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1465
|
+
should be retried.
|
|
1466
|
+
timeout (float): The timeout for this request.
|
|
1467
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1468
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1469
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1470
|
+
be of type `bytes`.
|
|
1471
|
+
|
|
1472
|
+
Returns:
|
|
1473
|
+
~.commit_response.CommitResponse:
|
|
1474
|
+
The response for
|
|
1475
|
+
[Commit][google.spanner.v1.Spanner.Commit].
|
|
1476
|
+
|
|
1477
|
+
"""
|
|
1478
|
+
|
|
1479
|
+
http_options = _BaseSpannerRestTransport._BaseCommit._get_http_options()
|
|
1480
|
+
|
|
1481
|
+
request, metadata = self._interceptor.pre_commit(request, metadata)
|
|
1482
|
+
transcoded_request = (
|
|
1483
|
+
_BaseSpannerRestTransport._BaseCommit._get_transcoded_request(
|
|
1484
|
+
http_options, request
|
|
1485
|
+
)
|
|
1486
|
+
)
|
|
1487
|
+
|
|
1488
|
+
body = _BaseSpannerRestTransport._BaseCommit._get_request_body_json(
|
|
1489
|
+
transcoded_request
|
|
1490
|
+
)
|
|
1491
|
+
|
|
1492
|
+
# Jsonify the query params
|
|
1493
|
+
query_params = _BaseSpannerRestTransport._BaseCommit._get_query_params_json(
|
|
1494
|
+
transcoded_request
|
|
1495
|
+
)
|
|
1496
|
+
|
|
1497
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1498
|
+
logging.DEBUG
|
|
1499
|
+
): # pragma: NO COVER
|
|
1500
|
+
request_url = "{host}{uri}".format(
|
|
1501
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1502
|
+
)
|
|
1503
|
+
method = transcoded_request["method"]
|
|
1504
|
+
try:
|
|
1505
|
+
request_payload = type(request).to_json(request)
|
|
1506
|
+
except:
|
|
1507
|
+
request_payload = None
|
|
1508
|
+
http_request = {
|
|
1509
|
+
"payload": request_payload,
|
|
1510
|
+
"requestMethod": method,
|
|
1511
|
+
"requestUrl": request_url,
|
|
1512
|
+
"headers": dict(metadata),
|
|
1513
|
+
}
|
|
1514
|
+
_LOGGER.debug(
|
|
1515
|
+
f"Sending request for google.spanner_v1.SpannerClient.Commit",
|
|
1516
|
+
extra={
|
|
1517
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1518
|
+
"rpcName": "Commit",
|
|
1519
|
+
"httpRequest": http_request,
|
|
1520
|
+
"metadata": http_request["headers"],
|
|
1521
|
+
},
|
|
1522
|
+
)
|
|
1523
|
+
|
|
1524
|
+
# Send the request
|
|
1525
|
+
response = SpannerRestTransport._Commit._get_response(
|
|
1526
|
+
self._host,
|
|
1527
|
+
metadata,
|
|
1528
|
+
query_params,
|
|
1529
|
+
self._session,
|
|
1530
|
+
timeout,
|
|
1531
|
+
transcoded_request,
|
|
1532
|
+
body,
|
|
1533
|
+
)
|
|
1534
|
+
|
|
1535
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1536
|
+
# subclass.
|
|
1537
|
+
if response.status_code >= 400:
|
|
1538
|
+
raise core_exceptions.from_http_response(response)
|
|
1539
|
+
|
|
1540
|
+
# Return the response
|
|
1541
|
+
resp = commit_response.CommitResponse()
|
|
1542
|
+
pb_resp = commit_response.CommitResponse.pb(resp)
|
|
1543
|
+
|
|
1544
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
1545
|
+
|
|
1546
|
+
resp = self._interceptor.post_commit(resp)
|
|
1547
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1548
|
+
resp, _ = self._interceptor.post_commit_with_metadata(
|
|
1549
|
+
resp, response_metadata
|
|
1550
|
+
)
|
|
1551
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1552
|
+
logging.DEBUG
|
|
1553
|
+
): # pragma: NO COVER
|
|
1554
|
+
try:
|
|
1555
|
+
response_payload = commit_response.CommitResponse.to_json(response)
|
|
1556
|
+
except:
|
|
1557
|
+
response_payload = None
|
|
1558
|
+
http_response = {
|
|
1559
|
+
"payload": response_payload,
|
|
1560
|
+
"headers": dict(response.headers),
|
|
1561
|
+
"status": response.status_code,
|
|
1562
|
+
}
|
|
1563
|
+
_LOGGER.debug(
|
|
1564
|
+
"Received response for google.spanner_v1.SpannerClient.commit",
|
|
1565
|
+
extra={
|
|
1566
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1567
|
+
"rpcName": "Commit",
|
|
1568
|
+
"metadata": http_response["headers"],
|
|
1569
|
+
"httpResponse": http_response,
|
|
1570
|
+
},
|
|
1571
|
+
)
|
|
1572
|
+
return resp
|
|
1573
|
+
|
|
1574
|
+
class _CreateSession(_BaseSpannerRestTransport._BaseCreateSession, SpannerRestStub):
|
|
1575
|
+
def __hash__(self):
|
|
1576
|
+
return hash("SpannerRestTransport.CreateSession")
|
|
1577
|
+
|
|
1578
|
+
@staticmethod
|
|
1579
|
+
def _get_response(
|
|
1580
|
+
host,
|
|
1581
|
+
metadata,
|
|
1582
|
+
query_params,
|
|
1583
|
+
session,
|
|
1584
|
+
timeout,
|
|
1585
|
+
transcoded_request,
|
|
1586
|
+
body=None,
|
|
1587
|
+
):
|
|
1588
|
+
uri = transcoded_request["uri"]
|
|
1589
|
+
method = transcoded_request["method"]
|
|
1590
|
+
headers = dict(metadata)
|
|
1591
|
+
headers["Content-Type"] = "application/json"
|
|
1592
|
+
response = getattr(session, method)(
|
|
1593
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1594
|
+
timeout=timeout,
|
|
1595
|
+
headers=headers,
|
|
1596
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1597
|
+
data=body,
|
|
1598
|
+
)
|
|
1599
|
+
return response
|
|
1600
|
+
|
|
1601
|
+
def __call__(
|
|
1602
|
+
self,
|
|
1603
|
+
request: spanner.CreateSessionRequest,
|
|
1604
|
+
*,
|
|
1605
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1606
|
+
timeout: Optional[float] = None,
|
|
1607
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1608
|
+
) -> spanner.Session:
|
|
1609
|
+
r"""Call the create session method over HTTP.
|
|
1610
|
+
|
|
1611
|
+
Args:
|
|
1612
|
+
request (~.spanner.CreateSessionRequest):
|
|
1613
|
+
The request object. The request for
|
|
1614
|
+
[CreateSession][google.spanner.v1.Spanner.CreateSession].
|
|
1615
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1616
|
+
should be retried.
|
|
1617
|
+
timeout (float): The timeout for this request.
|
|
1618
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1619
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1620
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1621
|
+
be of type `bytes`.
|
|
1622
|
+
|
|
1623
|
+
Returns:
|
|
1624
|
+
~.spanner.Session:
|
|
1625
|
+
A session in the Cloud Spanner API.
|
|
1626
|
+
"""
|
|
1627
|
+
|
|
1628
|
+
http_options = (
|
|
1629
|
+
_BaseSpannerRestTransport._BaseCreateSession._get_http_options()
|
|
1630
|
+
)
|
|
1631
|
+
|
|
1632
|
+
request, metadata = self._interceptor.pre_create_session(request, metadata)
|
|
1633
|
+
transcoded_request = (
|
|
1634
|
+
_BaseSpannerRestTransport._BaseCreateSession._get_transcoded_request(
|
|
1635
|
+
http_options, request
|
|
1636
|
+
)
|
|
1637
|
+
)
|
|
1638
|
+
|
|
1639
|
+
body = _BaseSpannerRestTransport._BaseCreateSession._get_request_body_json(
|
|
1640
|
+
transcoded_request
|
|
1641
|
+
)
|
|
1642
|
+
|
|
1643
|
+
# Jsonify the query params
|
|
1644
|
+
query_params = (
|
|
1645
|
+
_BaseSpannerRestTransport._BaseCreateSession._get_query_params_json(
|
|
1646
|
+
transcoded_request
|
|
1647
|
+
)
|
|
1648
|
+
)
|
|
1649
|
+
|
|
1650
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1651
|
+
logging.DEBUG
|
|
1652
|
+
): # pragma: NO COVER
|
|
1653
|
+
request_url = "{host}{uri}".format(
|
|
1654
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1655
|
+
)
|
|
1656
|
+
method = transcoded_request["method"]
|
|
1657
|
+
try:
|
|
1658
|
+
request_payload = type(request).to_json(request)
|
|
1659
|
+
except:
|
|
1660
|
+
request_payload = None
|
|
1661
|
+
http_request = {
|
|
1662
|
+
"payload": request_payload,
|
|
1663
|
+
"requestMethod": method,
|
|
1664
|
+
"requestUrl": request_url,
|
|
1665
|
+
"headers": dict(metadata),
|
|
1666
|
+
}
|
|
1667
|
+
_LOGGER.debug(
|
|
1668
|
+
f"Sending request for google.spanner_v1.SpannerClient.CreateSession",
|
|
1669
|
+
extra={
|
|
1670
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1671
|
+
"rpcName": "CreateSession",
|
|
1672
|
+
"httpRequest": http_request,
|
|
1673
|
+
"metadata": http_request["headers"],
|
|
1674
|
+
},
|
|
1675
|
+
)
|
|
1676
|
+
|
|
1677
|
+
# Send the request
|
|
1678
|
+
response = SpannerRestTransport._CreateSession._get_response(
|
|
1679
|
+
self._host,
|
|
1680
|
+
metadata,
|
|
1681
|
+
query_params,
|
|
1682
|
+
self._session,
|
|
1683
|
+
timeout,
|
|
1684
|
+
transcoded_request,
|
|
1685
|
+
body,
|
|
1686
|
+
)
|
|
1687
|
+
|
|
1688
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1689
|
+
# subclass.
|
|
1690
|
+
if response.status_code >= 400:
|
|
1691
|
+
raise core_exceptions.from_http_response(response)
|
|
1692
|
+
|
|
1693
|
+
# Return the response
|
|
1694
|
+
resp = spanner.Session()
|
|
1695
|
+
pb_resp = spanner.Session.pb(resp)
|
|
1696
|
+
|
|
1697
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
1698
|
+
|
|
1699
|
+
resp = self._interceptor.post_create_session(resp)
|
|
1700
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1701
|
+
resp, _ = self._interceptor.post_create_session_with_metadata(
|
|
1702
|
+
resp, response_metadata
|
|
1703
|
+
)
|
|
1704
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1705
|
+
logging.DEBUG
|
|
1706
|
+
): # pragma: NO COVER
|
|
1707
|
+
try:
|
|
1708
|
+
response_payload = spanner.Session.to_json(response)
|
|
1709
|
+
except:
|
|
1710
|
+
response_payload = None
|
|
1711
|
+
http_response = {
|
|
1712
|
+
"payload": response_payload,
|
|
1713
|
+
"headers": dict(response.headers),
|
|
1714
|
+
"status": response.status_code,
|
|
1715
|
+
}
|
|
1716
|
+
_LOGGER.debug(
|
|
1717
|
+
"Received response for google.spanner_v1.SpannerClient.create_session",
|
|
1718
|
+
extra={
|
|
1719
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1720
|
+
"rpcName": "CreateSession",
|
|
1721
|
+
"metadata": http_response["headers"],
|
|
1722
|
+
"httpResponse": http_response,
|
|
1723
|
+
},
|
|
1724
|
+
)
|
|
1725
|
+
return resp
|
|
1726
|
+
|
|
1727
|
+
class _DeleteSession(_BaseSpannerRestTransport._BaseDeleteSession, SpannerRestStub):
|
|
1728
|
+
def __hash__(self):
|
|
1729
|
+
return hash("SpannerRestTransport.DeleteSession")
|
|
1730
|
+
|
|
1731
|
+
@staticmethod
|
|
1732
|
+
def _get_response(
|
|
1733
|
+
host,
|
|
1734
|
+
metadata,
|
|
1735
|
+
query_params,
|
|
1736
|
+
session,
|
|
1737
|
+
timeout,
|
|
1738
|
+
transcoded_request,
|
|
1739
|
+
body=None,
|
|
1740
|
+
):
|
|
1741
|
+
uri = transcoded_request["uri"]
|
|
1742
|
+
method = transcoded_request["method"]
|
|
1743
|
+
headers = dict(metadata)
|
|
1744
|
+
headers["Content-Type"] = "application/json"
|
|
1745
|
+
response = getattr(session, method)(
|
|
1746
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1747
|
+
timeout=timeout,
|
|
1748
|
+
headers=headers,
|
|
1749
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1750
|
+
)
|
|
1751
|
+
return response
|
|
1752
|
+
|
|
1753
|
+
def __call__(
|
|
1754
|
+
self,
|
|
1755
|
+
request: spanner.DeleteSessionRequest,
|
|
1756
|
+
*,
|
|
1757
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1758
|
+
timeout: Optional[float] = None,
|
|
1759
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1760
|
+
):
|
|
1761
|
+
r"""Call the delete session method over HTTP.
|
|
1762
|
+
|
|
1763
|
+
Args:
|
|
1764
|
+
request (~.spanner.DeleteSessionRequest):
|
|
1765
|
+
The request object. The request for
|
|
1766
|
+
[DeleteSession][google.spanner.v1.Spanner.DeleteSession].
|
|
1767
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1768
|
+
should be retried.
|
|
1769
|
+
timeout (float): The timeout for this request.
|
|
1770
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1771
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1772
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1773
|
+
be of type `bytes`.
|
|
1774
|
+
"""
|
|
1775
|
+
|
|
1776
|
+
http_options = (
|
|
1777
|
+
_BaseSpannerRestTransport._BaseDeleteSession._get_http_options()
|
|
1778
|
+
)
|
|
1779
|
+
|
|
1780
|
+
request, metadata = self._interceptor.pre_delete_session(request, metadata)
|
|
1781
|
+
transcoded_request = (
|
|
1782
|
+
_BaseSpannerRestTransport._BaseDeleteSession._get_transcoded_request(
|
|
1783
|
+
http_options, request
|
|
1784
|
+
)
|
|
1785
|
+
)
|
|
1786
|
+
|
|
1787
|
+
# Jsonify the query params
|
|
1788
|
+
query_params = (
|
|
1789
|
+
_BaseSpannerRestTransport._BaseDeleteSession._get_query_params_json(
|
|
1790
|
+
transcoded_request
|
|
1791
|
+
)
|
|
1792
|
+
)
|
|
1793
|
+
|
|
1794
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1795
|
+
logging.DEBUG
|
|
1796
|
+
): # pragma: NO COVER
|
|
1797
|
+
request_url = "{host}{uri}".format(
|
|
1798
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1799
|
+
)
|
|
1800
|
+
method = transcoded_request["method"]
|
|
1801
|
+
try:
|
|
1802
|
+
request_payload = json_format.MessageToJson(request)
|
|
1803
|
+
except:
|
|
1804
|
+
request_payload = None
|
|
1805
|
+
http_request = {
|
|
1806
|
+
"payload": request_payload,
|
|
1807
|
+
"requestMethod": method,
|
|
1808
|
+
"requestUrl": request_url,
|
|
1809
|
+
"headers": dict(metadata),
|
|
1810
|
+
}
|
|
1811
|
+
_LOGGER.debug(
|
|
1812
|
+
f"Sending request for google.spanner_v1.SpannerClient.DeleteSession",
|
|
1813
|
+
extra={
|
|
1814
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1815
|
+
"rpcName": "DeleteSession",
|
|
1816
|
+
"httpRequest": http_request,
|
|
1817
|
+
"metadata": http_request["headers"],
|
|
1818
|
+
},
|
|
1819
|
+
)
|
|
1820
|
+
|
|
1821
|
+
# Send the request
|
|
1822
|
+
response = SpannerRestTransport._DeleteSession._get_response(
|
|
1823
|
+
self._host,
|
|
1824
|
+
metadata,
|
|
1825
|
+
query_params,
|
|
1826
|
+
self._session,
|
|
1827
|
+
timeout,
|
|
1828
|
+
transcoded_request,
|
|
1829
|
+
)
|
|
1830
|
+
|
|
1831
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1832
|
+
# subclass.
|
|
1833
|
+
if response.status_code >= 400:
|
|
1834
|
+
raise core_exceptions.from_http_response(response)
|
|
1835
|
+
|
|
1836
|
+
class _ExecuteBatchDml(
|
|
1837
|
+
_BaseSpannerRestTransport._BaseExecuteBatchDml, SpannerRestStub
|
|
1838
|
+
):
|
|
1839
|
+
def __hash__(self):
|
|
1840
|
+
return hash("SpannerRestTransport.ExecuteBatchDml")
|
|
1841
|
+
|
|
1842
|
+
@staticmethod
|
|
1843
|
+
def _get_response(
|
|
1844
|
+
host,
|
|
1845
|
+
metadata,
|
|
1846
|
+
query_params,
|
|
1847
|
+
session,
|
|
1848
|
+
timeout,
|
|
1849
|
+
transcoded_request,
|
|
1850
|
+
body=None,
|
|
1851
|
+
):
|
|
1852
|
+
uri = transcoded_request["uri"]
|
|
1853
|
+
method = transcoded_request["method"]
|
|
1854
|
+
headers = dict(metadata)
|
|
1855
|
+
headers["Content-Type"] = "application/json"
|
|
1856
|
+
response = getattr(session, method)(
|
|
1857
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1858
|
+
timeout=timeout,
|
|
1859
|
+
headers=headers,
|
|
1860
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1861
|
+
data=body,
|
|
1862
|
+
)
|
|
1863
|
+
return response
|
|
1864
|
+
|
|
1865
|
+
def __call__(
|
|
1866
|
+
self,
|
|
1867
|
+
request: spanner.ExecuteBatchDmlRequest,
|
|
1868
|
+
*,
|
|
1869
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1870
|
+
timeout: Optional[float] = None,
|
|
1871
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1872
|
+
) -> spanner.ExecuteBatchDmlResponse:
|
|
1873
|
+
r"""Call the execute batch dml method over HTTP.
|
|
1874
|
+
|
|
1875
|
+
Args:
|
|
1876
|
+
request (~.spanner.ExecuteBatchDmlRequest):
|
|
1877
|
+
The request object. The request for
|
|
1878
|
+
[ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
|
|
1879
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1880
|
+
should be retried.
|
|
1881
|
+
timeout (float): The timeout for this request.
|
|
1882
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1883
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1884
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1885
|
+
be of type `bytes`.
|
|
1886
|
+
|
|
1887
|
+
Returns:
|
|
1888
|
+
~.spanner.ExecuteBatchDmlResponse:
|
|
1889
|
+
The response for
|
|
1890
|
+
[ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
|
|
1891
|
+
Contains a list of
|
|
1892
|
+
[ResultSet][google.spanner.v1.ResultSet] messages, one
|
|
1893
|
+
for each DML statement that has successfully executed,
|
|
1894
|
+
in the same order as the statements in the request. If a
|
|
1895
|
+
statement fails, the status in the response body
|
|
1896
|
+
identifies the cause of the failure.
|
|
1897
|
+
|
|
1898
|
+
To check for DML statements that failed, use the
|
|
1899
|
+
following approach:
|
|
1900
|
+
|
|
1901
|
+
1. Check the status in the response message. The
|
|
1902
|
+
[google.rpc.Code][google.rpc.Code] enum value ``OK``
|
|
1903
|
+
indicates that all statements were executed
|
|
1904
|
+
successfully.
|
|
1905
|
+
2. If the status was not ``OK``, check the number of
|
|
1906
|
+
result sets in the response. If the response contains
|
|
1907
|
+
``N`` [ResultSet][google.spanner.v1.ResultSet]
|
|
1908
|
+
messages, then statement ``N+1`` in the request
|
|
1909
|
+
failed.
|
|
1910
|
+
|
|
1911
|
+
Example 1:
|
|
1912
|
+
|
|
1913
|
+
- Request: 5 DML statements, all executed successfully.
|
|
1914
|
+
- Response: 5 [ResultSet][google.spanner.v1.ResultSet]
|
|
1915
|
+
messages, with the status ``OK``.
|
|
1916
|
+
|
|
1917
|
+
Example 2:
|
|
1918
|
+
|
|
1919
|
+
- Request: 5 DML statements. The third statement has a
|
|
1920
|
+
syntax error.
|
|
1921
|
+
- Response: 2 [ResultSet][google.spanner.v1.ResultSet]
|
|
1922
|
+
messages, and a syntax error (``INVALID_ARGUMENT``)
|
|
1923
|
+
status. The number of
|
|
1924
|
+
[ResultSet][google.spanner.v1.ResultSet] messages
|
|
1925
|
+
indicates that the third statement failed, and the
|
|
1926
|
+
fourth and fifth statements were not executed.
|
|
1927
|
+
|
|
1928
|
+
"""
|
|
1929
|
+
|
|
1930
|
+
http_options = (
|
|
1931
|
+
_BaseSpannerRestTransport._BaseExecuteBatchDml._get_http_options()
|
|
1932
|
+
)
|
|
1933
|
+
|
|
1934
|
+
request, metadata = self._interceptor.pre_execute_batch_dml(
|
|
1935
|
+
request, metadata
|
|
1936
|
+
)
|
|
1937
|
+
transcoded_request = (
|
|
1938
|
+
_BaseSpannerRestTransport._BaseExecuteBatchDml._get_transcoded_request(
|
|
1939
|
+
http_options, request
|
|
1940
|
+
)
|
|
1941
|
+
)
|
|
1942
|
+
|
|
1943
|
+
body = (
|
|
1944
|
+
_BaseSpannerRestTransport._BaseExecuteBatchDml._get_request_body_json(
|
|
1945
|
+
transcoded_request
|
|
1946
|
+
)
|
|
1947
|
+
)
|
|
1948
|
+
|
|
1949
|
+
# Jsonify the query params
|
|
1950
|
+
query_params = (
|
|
1951
|
+
_BaseSpannerRestTransport._BaseExecuteBatchDml._get_query_params_json(
|
|
1952
|
+
transcoded_request
|
|
1953
|
+
)
|
|
1954
|
+
)
|
|
1955
|
+
|
|
1956
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1957
|
+
logging.DEBUG
|
|
1958
|
+
): # pragma: NO COVER
|
|
1959
|
+
request_url = "{host}{uri}".format(
|
|
1960
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1961
|
+
)
|
|
1962
|
+
method = transcoded_request["method"]
|
|
1963
|
+
try:
|
|
1964
|
+
request_payload = type(request).to_json(request)
|
|
1965
|
+
except:
|
|
1966
|
+
request_payload = None
|
|
1967
|
+
http_request = {
|
|
1968
|
+
"payload": request_payload,
|
|
1969
|
+
"requestMethod": method,
|
|
1970
|
+
"requestUrl": request_url,
|
|
1971
|
+
"headers": dict(metadata),
|
|
1972
|
+
}
|
|
1973
|
+
_LOGGER.debug(
|
|
1974
|
+
f"Sending request for google.spanner_v1.SpannerClient.ExecuteBatchDml",
|
|
1975
|
+
extra={
|
|
1976
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
1977
|
+
"rpcName": "ExecuteBatchDml",
|
|
1978
|
+
"httpRequest": http_request,
|
|
1979
|
+
"metadata": http_request["headers"],
|
|
1980
|
+
},
|
|
1981
|
+
)
|
|
1982
|
+
|
|
1983
|
+
# Send the request
|
|
1984
|
+
response = SpannerRestTransport._ExecuteBatchDml._get_response(
|
|
1985
|
+
self._host,
|
|
1986
|
+
metadata,
|
|
1987
|
+
query_params,
|
|
1988
|
+
self._session,
|
|
1989
|
+
timeout,
|
|
1990
|
+
transcoded_request,
|
|
1991
|
+
body,
|
|
1992
|
+
)
|
|
1993
|
+
|
|
1994
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1995
|
+
# subclass.
|
|
1996
|
+
if response.status_code >= 400:
|
|
1997
|
+
raise core_exceptions.from_http_response(response)
|
|
1998
|
+
|
|
1999
|
+
# Return the response
|
|
2000
|
+
resp = spanner.ExecuteBatchDmlResponse()
|
|
2001
|
+
pb_resp = spanner.ExecuteBatchDmlResponse.pb(resp)
|
|
2002
|
+
|
|
2003
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2004
|
+
|
|
2005
|
+
resp = self._interceptor.post_execute_batch_dml(resp)
|
|
2006
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2007
|
+
resp, _ = self._interceptor.post_execute_batch_dml_with_metadata(
|
|
2008
|
+
resp, response_metadata
|
|
2009
|
+
)
|
|
2010
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2011
|
+
logging.DEBUG
|
|
2012
|
+
): # pragma: NO COVER
|
|
2013
|
+
try:
|
|
2014
|
+
response_payload = spanner.ExecuteBatchDmlResponse.to_json(response)
|
|
2015
|
+
except:
|
|
2016
|
+
response_payload = None
|
|
2017
|
+
http_response = {
|
|
2018
|
+
"payload": response_payload,
|
|
2019
|
+
"headers": dict(response.headers),
|
|
2020
|
+
"status": response.status_code,
|
|
2021
|
+
}
|
|
2022
|
+
_LOGGER.debug(
|
|
2023
|
+
"Received response for google.spanner_v1.SpannerClient.execute_batch_dml",
|
|
2024
|
+
extra={
|
|
2025
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2026
|
+
"rpcName": "ExecuteBatchDml",
|
|
2027
|
+
"metadata": http_response["headers"],
|
|
2028
|
+
"httpResponse": http_response,
|
|
2029
|
+
},
|
|
2030
|
+
)
|
|
2031
|
+
return resp
|
|
2032
|
+
|
|
2033
|
+
class _ExecuteSql(_BaseSpannerRestTransport._BaseExecuteSql, SpannerRestStub):
|
|
2034
|
+
def __hash__(self):
|
|
2035
|
+
return hash("SpannerRestTransport.ExecuteSql")
|
|
2036
|
+
|
|
2037
|
+
@staticmethod
|
|
2038
|
+
def _get_response(
|
|
2039
|
+
host,
|
|
2040
|
+
metadata,
|
|
2041
|
+
query_params,
|
|
2042
|
+
session,
|
|
2043
|
+
timeout,
|
|
2044
|
+
transcoded_request,
|
|
2045
|
+
body=None,
|
|
2046
|
+
):
|
|
2047
|
+
uri = transcoded_request["uri"]
|
|
2048
|
+
method = transcoded_request["method"]
|
|
2049
|
+
headers = dict(metadata)
|
|
2050
|
+
headers["Content-Type"] = "application/json"
|
|
2051
|
+
response = getattr(session, method)(
|
|
2052
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2053
|
+
timeout=timeout,
|
|
2054
|
+
headers=headers,
|
|
2055
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2056
|
+
data=body,
|
|
2057
|
+
)
|
|
2058
|
+
return response
|
|
2059
|
+
|
|
2060
|
+
def __call__(
|
|
2061
|
+
self,
|
|
2062
|
+
request: spanner.ExecuteSqlRequest,
|
|
2063
|
+
*,
|
|
2064
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2065
|
+
timeout: Optional[float] = None,
|
|
2066
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2067
|
+
) -> result_set.ResultSet:
|
|
2068
|
+
r"""Call the execute sql method over HTTP.
|
|
2069
|
+
|
|
2070
|
+
Args:
|
|
2071
|
+
request (~.spanner.ExecuteSqlRequest):
|
|
2072
|
+
The request object. The request for
|
|
2073
|
+
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
|
|
2074
|
+
[ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
|
|
2075
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2076
|
+
should be retried.
|
|
2077
|
+
timeout (float): The timeout for this request.
|
|
2078
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2079
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2080
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2081
|
+
be of type `bytes`.
|
|
2082
|
+
|
|
2083
|
+
Returns:
|
|
2084
|
+
~.result_set.ResultSet:
|
|
2085
|
+
Results from [Read][google.spanner.v1.Spanner.Read] or
|
|
2086
|
+
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
|
|
2087
|
+
|
|
2088
|
+
"""
|
|
2089
|
+
|
|
2090
|
+
http_options = _BaseSpannerRestTransport._BaseExecuteSql._get_http_options()
|
|
2091
|
+
|
|
2092
|
+
request, metadata = self._interceptor.pre_execute_sql(request, metadata)
|
|
2093
|
+
transcoded_request = (
|
|
2094
|
+
_BaseSpannerRestTransport._BaseExecuteSql._get_transcoded_request(
|
|
2095
|
+
http_options, request
|
|
2096
|
+
)
|
|
2097
|
+
)
|
|
2098
|
+
|
|
2099
|
+
body = _BaseSpannerRestTransport._BaseExecuteSql._get_request_body_json(
|
|
2100
|
+
transcoded_request
|
|
2101
|
+
)
|
|
2102
|
+
|
|
2103
|
+
# Jsonify the query params
|
|
2104
|
+
query_params = (
|
|
2105
|
+
_BaseSpannerRestTransport._BaseExecuteSql._get_query_params_json(
|
|
2106
|
+
transcoded_request
|
|
2107
|
+
)
|
|
2108
|
+
)
|
|
2109
|
+
|
|
2110
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2111
|
+
logging.DEBUG
|
|
2112
|
+
): # pragma: NO COVER
|
|
2113
|
+
request_url = "{host}{uri}".format(
|
|
2114
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2115
|
+
)
|
|
2116
|
+
method = transcoded_request["method"]
|
|
2117
|
+
try:
|
|
2118
|
+
request_payload = type(request).to_json(request)
|
|
2119
|
+
except:
|
|
2120
|
+
request_payload = None
|
|
2121
|
+
http_request = {
|
|
2122
|
+
"payload": request_payload,
|
|
2123
|
+
"requestMethod": method,
|
|
2124
|
+
"requestUrl": request_url,
|
|
2125
|
+
"headers": dict(metadata),
|
|
2126
|
+
}
|
|
2127
|
+
_LOGGER.debug(
|
|
2128
|
+
f"Sending request for google.spanner_v1.SpannerClient.ExecuteSql",
|
|
2129
|
+
extra={
|
|
2130
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2131
|
+
"rpcName": "ExecuteSql",
|
|
2132
|
+
"httpRequest": http_request,
|
|
2133
|
+
"metadata": http_request["headers"],
|
|
2134
|
+
},
|
|
2135
|
+
)
|
|
2136
|
+
|
|
2137
|
+
# Send the request
|
|
2138
|
+
response = SpannerRestTransport._ExecuteSql._get_response(
|
|
2139
|
+
self._host,
|
|
2140
|
+
metadata,
|
|
2141
|
+
query_params,
|
|
2142
|
+
self._session,
|
|
2143
|
+
timeout,
|
|
2144
|
+
transcoded_request,
|
|
2145
|
+
body,
|
|
2146
|
+
)
|
|
2147
|
+
|
|
2148
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2149
|
+
# subclass.
|
|
2150
|
+
if response.status_code >= 400:
|
|
2151
|
+
raise core_exceptions.from_http_response(response)
|
|
2152
|
+
|
|
2153
|
+
# Return the response
|
|
2154
|
+
resp = result_set.ResultSet()
|
|
2155
|
+
pb_resp = result_set.ResultSet.pb(resp)
|
|
2156
|
+
|
|
2157
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2158
|
+
|
|
2159
|
+
resp = self._interceptor.post_execute_sql(resp)
|
|
2160
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2161
|
+
resp, _ = self._interceptor.post_execute_sql_with_metadata(
|
|
2162
|
+
resp, response_metadata
|
|
2163
|
+
)
|
|
2164
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2165
|
+
logging.DEBUG
|
|
2166
|
+
): # pragma: NO COVER
|
|
2167
|
+
try:
|
|
2168
|
+
response_payload = result_set.ResultSet.to_json(response)
|
|
2169
|
+
except:
|
|
2170
|
+
response_payload = None
|
|
2171
|
+
http_response = {
|
|
2172
|
+
"payload": response_payload,
|
|
2173
|
+
"headers": dict(response.headers),
|
|
2174
|
+
"status": response.status_code,
|
|
2175
|
+
}
|
|
2176
|
+
_LOGGER.debug(
|
|
2177
|
+
"Received response for google.spanner_v1.SpannerClient.execute_sql",
|
|
2178
|
+
extra={
|
|
2179
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2180
|
+
"rpcName": "ExecuteSql",
|
|
2181
|
+
"metadata": http_response["headers"],
|
|
2182
|
+
"httpResponse": http_response,
|
|
2183
|
+
},
|
|
2184
|
+
)
|
|
2185
|
+
return resp
|
|
2186
|
+
|
|
2187
|
+
class _ExecuteStreamingSql(
|
|
2188
|
+
_BaseSpannerRestTransport._BaseExecuteStreamingSql, SpannerRestStub
|
|
2189
|
+
):
|
|
2190
|
+
def __hash__(self):
|
|
2191
|
+
return hash("SpannerRestTransport.ExecuteStreamingSql")
|
|
2192
|
+
|
|
2193
|
+
@staticmethod
|
|
2194
|
+
def _get_response(
|
|
2195
|
+
host,
|
|
2196
|
+
metadata,
|
|
2197
|
+
query_params,
|
|
2198
|
+
session,
|
|
2199
|
+
timeout,
|
|
2200
|
+
transcoded_request,
|
|
2201
|
+
body=None,
|
|
2202
|
+
):
|
|
2203
|
+
uri = transcoded_request["uri"]
|
|
2204
|
+
method = transcoded_request["method"]
|
|
2205
|
+
headers = dict(metadata)
|
|
2206
|
+
headers["Content-Type"] = "application/json"
|
|
2207
|
+
response = getattr(session, method)(
|
|
2208
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2209
|
+
timeout=timeout,
|
|
2210
|
+
headers=headers,
|
|
2211
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2212
|
+
data=body,
|
|
2213
|
+
stream=True,
|
|
2214
|
+
)
|
|
2215
|
+
return response
|
|
2216
|
+
|
|
2217
|
+
def __call__(
|
|
2218
|
+
self,
|
|
2219
|
+
request: spanner.ExecuteSqlRequest,
|
|
2220
|
+
*,
|
|
2221
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2222
|
+
timeout: Optional[float] = None,
|
|
2223
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2224
|
+
) -> rest_streaming.ResponseIterator:
|
|
2225
|
+
r"""Call the execute streaming sql method over HTTP.
|
|
2226
|
+
|
|
2227
|
+
Args:
|
|
2228
|
+
request (~.spanner.ExecuteSqlRequest):
|
|
2229
|
+
The request object. The request for
|
|
2230
|
+
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
|
|
2231
|
+
[ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
|
|
2232
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2233
|
+
should be retried.
|
|
2234
|
+
timeout (float): The timeout for this request.
|
|
2235
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2236
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2237
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2238
|
+
be of type `bytes`.
|
|
2239
|
+
|
|
2240
|
+
Returns:
|
|
2241
|
+
~.result_set.PartialResultSet:
|
|
2242
|
+
Partial results from a streaming read
|
|
2243
|
+
or SQL query. Streaming reads and SQL
|
|
2244
|
+
queries better tolerate large result
|
|
2245
|
+
sets, large rows, and large values, but
|
|
2246
|
+
are a little trickier to consume.
|
|
2247
|
+
|
|
2248
|
+
"""
|
|
2249
|
+
|
|
2250
|
+
http_options = (
|
|
2251
|
+
_BaseSpannerRestTransport._BaseExecuteStreamingSql._get_http_options()
|
|
2252
|
+
)
|
|
2253
|
+
|
|
2254
|
+
request, metadata = self._interceptor.pre_execute_streaming_sql(
|
|
2255
|
+
request, metadata
|
|
2256
|
+
)
|
|
2257
|
+
transcoded_request = _BaseSpannerRestTransport._BaseExecuteStreamingSql._get_transcoded_request(
|
|
2258
|
+
http_options, request
|
|
2259
|
+
)
|
|
2260
|
+
|
|
2261
|
+
body = _BaseSpannerRestTransport._BaseExecuteStreamingSql._get_request_body_json(
|
|
2262
|
+
transcoded_request
|
|
2263
|
+
)
|
|
2264
|
+
|
|
2265
|
+
# Jsonify the query params
|
|
2266
|
+
query_params = _BaseSpannerRestTransport._BaseExecuteStreamingSql._get_query_params_json(
|
|
2267
|
+
transcoded_request
|
|
2268
|
+
)
|
|
2269
|
+
|
|
2270
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2271
|
+
logging.DEBUG
|
|
2272
|
+
): # pragma: NO COVER
|
|
2273
|
+
request_url = "{host}{uri}".format(
|
|
2274
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2275
|
+
)
|
|
2276
|
+
method = transcoded_request["method"]
|
|
2277
|
+
try:
|
|
2278
|
+
request_payload = type(request).to_json(request)
|
|
2279
|
+
except:
|
|
2280
|
+
request_payload = None
|
|
2281
|
+
http_request = {
|
|
2282
|
+
"payload": request_payload,
|
|
2283
|
+
"requestMethod": method,
|
|
2284
|
+
"requestUrl": request_url,
|
|
2285
|
+
"headers": dict(metadata),
|
|
2286
|
+
}
|
|
2287
|
+
_LOGGER.debug(
|
|
2288
|
+
f"Sending request for google.spanner_v1.SpannerClient.ExecuteStreamingSql",
|
|
2289
|
+
extra={
|
|
2290
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2291
|
+
"rpcName": "ExecuteStreamingSql",
|
|
2292
|
+
"httpRequest": http_request,
|
|
2293
|
+
"metadata": http_request["headers"],
|
|
2294
|
+
},
|
|
2295
|
+
)
|
|
2296
|
+
|
|
2297
|
+
# Send the request
|
|
2298
|
+
response = SpannerRestTransport._ExecuteStreamingSql._get_response(
|
|
2299
|
+
self._host,
|
|
2300
|
+
metadata,
|
|
2301
|
+
query_params,
|
|
2302
|
+
self._session,
|
|
2303
|
+
timeout,
|
|
2304
|
+
transcoded_request,
|
|
2305
|
+
body,
|
|
2306
|
+
)
|
|
2307
|
+
|
|
2308
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2309
|
+
# subclass.
|
|
2310
|
+
if response.status_code >= 400:
|
|
2311
|
+
raise core_exceptions.from_http_response(response)
|
|
2312
|
+
|
|
2313
|
+
# Return the response
|
|
2314
|
+
resp = rest_streaming.ResponseIterator(
|
|
2315
|
+
response, result_set.PartialResultSet
|
|
2316
|
+
)
|
|
2317
|
+
|
|
2318
|
+
resp = self._interceptor.post_execute_streaming_sql(resp)
|
|
2319
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2320
|
+
resp, _ = self._interceptor.post_execute_streaming_sql_with_metadata(
|
|
2321
|
+
resp, response_metadata
|
|
2322
|
+
)
|
|
2323
|
+
return resp
|
|
2324
|
+
|
|
2325
|
+
class _GetSession(_BaseSpannerRestTransport._BaseGetSession, SpannerRestStub):
|
|
2326
|
+
def __hash__(self):
|
|
2327
|
+
return hash("SpannerRestTransport.GetSession")
|
|
2328
|
+
|
|
2329
|
+
@staticmethod
|
|
2330
|
+
def _get_response(
|
|
2331
|
+
host,
|
|
2332
|
+
metadata,
|
|
2333
|
+
query_params,
|
|
2334
|
+
session,
|
|
2335
|
+
timeout,
|
|
2336
|
+
transcoded_request,
|
|
2337
|
+
body=None,
|
|
2338
|
+
):
|
|
2339
|
+
uri = transcoded_request["uri"]
|
|
2340
|
+
method = transcoded_request["method"]
|
|
2341
|
+
headers = dict(metadata)
|
|
2342
|
+
headers["Content-Type"] = "application/json"
|
|
2343
|
+
response = getattr(session, method)(
|
|
2344
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2345
|
+
timeout=timeout,
|
|
2346
|
+
headers=headers,
|
|
2347
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2348
|
+
)
|
|
2349
|
+
return response
|
|
2350
|
+
|
|
2351
|
+
def __call__(
|
|
2352
|
+
self,
|
|
2353
|
+
request: spanner.GetSessionRequest,
|
|
2354
|
+
*,
|
|
2355
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2356
|
+
timeout: Optional[float] = None,
|
|
2357
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2358
|
+
) -> spanner.Session:
|
|
2359
|
+
r"""Call the get session method over HTTP.
|
|
2360
|
+
|
|
2361
|
+
Args:
|
|
2362
|
+
request (~.spanner.GetSessionRequest):
|
|
2363
|
+
The request object. The request for
|
|
2364
|
+
[GetSession][google.spanner.v1.Spanner.GetSession].
|
|
2365
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2366
|
+
should be retried.
|
|
2367
|
+
timeout (float): The timeout for this request.
|
|
2368
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2369
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2370
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2371
|
+
be of type `bytes`.
|
|
2372
|
+
|
|
2373
|
+
Returns:
|
|
2374
|
+
~.spanner.Session:
|
|
2375
|
+
A session in the Cloud Spanner API.
|
|
2376
|
+
"""
|
|
2377
|
+
|
|
2378
|
+
http_options = _BaseSpannerRestTransport._BaseGetSession._get_http_options()
|
|
2379
|
+
|
|
2380
|
+
request, metadata = self._interceptor.pre_get_session(request, metadata)
|
|
2381
|
+
transcoded_request = (
|
|
2382
|
+
_BaseSpannerRestTransport._BaseGetSession._get_transcoded_request(
|
|
2383
|
+
http_options, request
|
|
2384
|
+
)
|
|
2385
|
+
)
|
|
2386
|
+
|
|
2387
|
+
# Jsonify the query params
|
|
2388
|
+
query_params = (
|
|
2389
|
+
_BaseSpannerRestTransport._BaseGetSession._get_query_params_json(
|
|
2390
|
+
transcoded_request
|
|
2391
|
+
)
|
|
2392
|
+
)
|
|
2393
|
+
|
|
2394
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2395
|
+
logging.DEBUG
|
|
2396
|
+
): # pragma: NO COVER
|
|
2397
|
+
request_url = "{host}{uri}".format(
|
|
2398
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2399
|
+
)
|
|
2400
|
+
method = transcoded_request["method"]
|
|
2401
|
+
try:
|
|
2402
|
+
request_payload = type(request).to_json(request)
|
|
2403
|
+
except:
|
|
2404
|
+
request_payload = None
|
|
2405
|
+
http_request = {
|
|
2406
|
+
"payload": request_payload,
|
|
2407
|
+
"requestMethod": method,
|
|
2408
|
+
"requestUrl": request_url,
|
|
2409
|
+
"headers": dict(metadata),
|
|
2410
|
+
}
|
|
2411
|
+
_LOGGER.debug(
|
|
2412
|
+
f"Sending request for google.spanner_v1.SpannerClient.GetSession",
|
|
2413
|
+
extra={
|
|
2414
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2415
|
+
"rpcName": "GetSession",
|
|
2416
|
+
"httpRequest": http_request,
|
|
2417
|
+
"metadata": http_request["headers"],
|
|
2418
|
+
},
|
|
2419
|
+
)
|
|
2420
|
+
|
|
2421
|
+
# Send the request
|
|
2422
|
+
response = SpannerRestTransport._GetSession._get_response(
|
|
2423
|
+
self._host,
|
|
2424
|
+
metadata,
|
|
2425
|
+
query_params,
|
|
2426
|
+
self._session,
|
|
2427
|
+
timeout,
|
|
2428
|
+
transcoded_request,
|
|
2429
|
+
)
|
|
2430
|
+
|
|
2431
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2432
|
+
# subclass.
|
|
2433
|
+
if response.status_code >= 400:
|
|
2434
|
+
raise core_exceptions.from_http_response(response)
|
|
2435
|
+
|
|
2436
|
+
# Return the response
|
|
2437
|
+
resp = spanner.Session()
|
|
2438
|
+
pb_resp = spanner.Session.pb(resp)
|
|
2439
|
+
|
|
2440
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2441
|
+
|
|
2442
|
+
resp = self._interceptor.post_get_session(resp)
|
|
2443
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2444
|
+
resp, _ = self._interceptor.post_get_session_with_metadata(
|
|
2445
|
+
resp, response_metadata
|
|
2446
|
+
)
|
|
2447
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2448
|
+
logging.DEBUG
|
|
2449
|
+
): # pragma: NO COVER
|
|
2450
|
+
try:
|
|
2451
|
+
response_payload = spanner.Session.to_json(response)
|
|
2452
|
+
except:
|
|
2453
|
+
response_payload = None
|
|
2454
|
+
http_response = {
|
|
2455
|
+
"payload": response_payload,
|
|
2456
|
+
"headers": dict(response.headers),
|
|
2457
|
+
"status": response.status_code,
|
|
2458
|
+
}
|
|
2459
|
+
_LOGGER.debug(
|
|
2460
|
+
"Received response for google.spanner_v1.SpannerClient.get_session",
|
|
2461
|
+
extra={
|
|
2462
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2463
|
+
"rpcName": "GetSession",
|
|
2464
|
+
"metadata": http_response["headers"],
|
|
2465
|
+
"httpResponse": http_response,
|
|
2466
|
+
},
|
|
2467
|
+
)
|
|
2468
|
+
return resp
|
|
2469
|
+
|
|
2470
|
+
class _ListSessions(_BaseSpannerRestTransport._BaseListSessions, SpannerRestStub):
|
|
2471
|
+
def __hash__(self):
|
|
2472
|
+
return hash("SpannerRestTransport.ListSessions")
|
|
2473
|
+
|
|
2474
|
+
@staticmethod
|
|
2475
|
+
def _get_response(
|
|
2476
|
+
host,
|
|
2477
|
+
metadata,
|
|
2478
|
+
query_params,
|
|
2479
|
+
session,
|
|
2480
|
+
timeout,
|
|
2481
|
+
transcoded_request,
|
|
2482
|
+
body=None,
|
|
2483
|
+
):
|
|
2484
|
+
uri = transcoded_request["uri"]
|
|
2485
|
+
method = transcoded_request["method"]
|
|
2486
|
+
headers = dict(metadata)
|
|
2487
|
+
headers["Content-Type"] = "application/json"
|
|
2488
|
+
response = getattr(session, method)(
|
|
2489
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2490
|
+
timeout=timeout,
|
|
2491
|
+
headers=headers,
|
|
2492
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2493
|
+
)
|
|
2494
|
+
return response
|
|
2495
|
+
|
|
2496
|
+
def __call__(
|
|
2497
|
+
self,
|
|
2498
|
+
request: spanner.ListSessionsRequest,
|
|
2499
|
+
*,
|
|
2500
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2501
|
+
timeout: Optional[float] = None,
|
|
2502
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2503
|
+
) -> spanner.ListSessionsResponse:
|
|
2504
|
+
r"""Call the list sessions method over HTTP.
|
|
2505
|
+
|
|
2506
|
+
Args:
|
|
2507
|
+
request (~.spanner.ListSessionsRequest):
|
|
2508
|
+
The request object. The request for
|
|
2509
|
+
[ListSessions][google.spanner.v1.Spanner.ListSessions].
|
|
2510
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2511
|
+
should be retried.
|
|
2512
|
+
timeout (float): The timeout for this request.
|
|
2513
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2514
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2515
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2516
|
+
be of type `bytes`.
|
|
2517
|
+
|
|
2518
|
+
Returns:
|
|
2519
|
+
~.spanner.ListSessionsResponse:
|
|
2520
|
+
The response for
|
|
2521
|
+
[ListSessions][google.spanner.v1.Spanner.ListSessions].
|
|
2522
|
+
|
|
2523
|
+
"""
|
|
2524
|
+
|
|
2525
|
+
http_options = (
|
|
2526
|
+
_BaseSpannerRestTransport._BaseListSessions._get_http_options()
|
|
2527
|
+
)
|
|
2528
|
+
|
|
2529
|
+
request, metadata = self._interceptor.pre_list_sessions(request, metadata)
|
|
2530
|
+
transcoded_request = (
|
|
2531
|
+
_BaseSpannerRestTransport._BaseListSessions._get_transcoded_request(
|
|
2532
|
+
http_options, request
|
|
2533
|
+
)
|
|
2534
|
+
)
|
|
2535
|
+
|
|
2536
|
+
# Jsonify the query params
|
|
2537
|
+
query_params = (
|
|
2538
|
+
_BaseSpannerRestTransport._BaseListSessions._get_query_params_json(
|
|
2539
|
+
transcoded_request
|
|
2540
|
+
)
|
|
2541
|
+
)
|
|
2542
|
+
|
|
2543
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2544
|
+
logging.DEBUG
|
|
2545
|
+
): # pragma: NO COVER
|
|
2546
|
+
request_url = "{host}{uri}".format(
|
|
2547
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2548
|
+
)
|
|
2549
|
+
method = transcoded_request["method"]
|
|
2550
|
+
try:
|
|
2551
|
+
request_payload = type(request).to_json(request)
|
|
2552
|
+
except:
|
|
2553
|
+
request_payload = None
|
|
2554
|
+
http_request = {
|
|
2555
|
+
"payload": request_payload,
|
|
2556
|
+
"requestMethod": method,
|
|
2557
|
+
"requestUrl": request_url,
|
|
2558
|
+
"headers": dict(metadata),
|
|
2559
|
+
}
|
|
2560
|
+
_LOGGER.debug(
|
|
2561
|
+
f"Sending request for google.spanner_v1.SpannerClient.ListSessions",
|
|
2562
|
+
extra={
|
|
2563
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2564
|
+
"rpcName": "ListSessions",
|
|
2565
|
+
"httpRequest": http_request,
|
|
2566
|
+
"metadata": http_request["headers"],
|
|
2567
|
+
},
|
|
2568
|
+
)
|
|
2569
|
+
|
|
2570
|
+
# Send the request
|
|
2571
|
+
response = SpannerRestTransport._ListSessions._get_response(
|
|
2572
|
+
self._host,
|
|
2573
|
+
metadata,
|
|
2574
|
+
query_params,
|
|
2575
|
+
self._session,
|
|
2576
|
+
timeout,
|
|
2577
|
+
transcoded_request,
|
|
2578
|
+
)
|
|
2579
|
+
|
|
2580
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2581
|
+
# subclass.
|
|
2582
|
+
if response.status_code >= 400:
|
|
2583
|
+
raise core_exceptions.from_http_response(response)
|
|
2584
|
+
|
|
2585
|
+
# Return the response
|
|
2586
|
+
resp = spanner.ListSessionsResponse()
|
|
2587
|
+
pb_resp = spanner.ListSessionsResponse.pb(resp)
|
|
2588
|
+
|
|
2589
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2590
|
+
|
|
2591
|
+
resp = self._interceptor.post_list_sessions(resp)
|
|
2592
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2593
|
+
resp, _ = self._interceptor.post_list_sessions_with_metadata(
|
|
2594
|
+
resp, response_metadata
|
|
2595
|
+
)
|
|
2596
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2597
|
+
logging.DEBUG
|
|
2598
|
+
): # pragma: NO COVER
|
|
2599
|
+
try:
|
|
2600
|
+
response_payload = spanner.ListSessionsResponse.to_json(response)
|
|
2601
|
+
except:
|
|
2602
|
+
response_payload = None
|
|
2603
|
+
http_response = {
|
|
2604
|
+
"payload": response_payload,
|
|
2605
|
+
"headers": dict(response.headers),
|
|
2606
|
+
"status": response.status_code,
|
|
2607
|
+
}
|
|
2608
|
+
_LOGGER.debug(
|
|
2609
|
+
"Received response for google.spanner_v1.SpannerClient.list_sessions",
|
|
2610
|
+
extra={
|
|
2611
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2612
|
+
"rpcName": "ListSessions",
|
|
2613
|
+
"metadata": http_response["headers"],
|
|
2614
|
+
"httpResponse": http_response,
|
|
2615
|
+
},
|
|
2616
|
+
)
|
|
2617
|
+
return resp
|
|
2618
|
+
|
|
2619
|
+
class _PartitionQuery(
|
|
2620
|
+
_BaseSpannerRestTransport._BasePartitionQuery, SpannerRestStub
|
|
2621
|
+
):
|
|
2622
|
+
def __hash__(self):
|
|
2623
|
+
return hash("SpannerRestTransport.PartitionQuery")
|
|
2624
|
+
|
|
2625
|
+
@staticmethod
|
|
2626
|
+
def _get_response(
|
|
2627
|
+
host,
|
|
2628
|
+
metadata,
|
|
2629
|
+
query_params,
|
|
2630
|
+
session,
|
|
2631
|
+
timeout,
|
|
2632
|
+
transcoded_request,
|
|
2633
|
+
body=None,
|
|
2634
|
+
):
|
|
2635
|
+
uri = transcoded_request["uri"]
|
|
2636
|
+
method = transcoded_request["method"]
|
|
2637
|
+
headers = dict(metadata)
|
|
2638
|
+
headers["Content-Type"] = "application/json"
|
|
2639
|
+
response = getattr(session, method)(
|
|
2640
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2641
|
+
timeout=timeout,
|
|
2642
|
+
headers=headers,
|
|
2643
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2644
|
+
data=body,
|
|
2645
|
+
)
|
|
2646
|
+
return response
|
|
2647
|
+
|
|
2648
|
+
def __call__(
|
|
2649
|
+
self,
|
|
2650
|
+
request: spanner.PartitionQueryRequest,
|
|
2651
|
+
*,
|
|
2652
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2653
|
+
timeout: Optional[float] = None,
|
|
2654
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2655
|
+
) -> spanner.PartitionResponse:
|
|
2656
|
+
r"""Call the partition query method over HTTP.
|
|
2657
|
+
|
|
2658
|
+
Args:
|
|
2659
|
+
request (~.spanner.PartitionQueryRequest):
|
|
2660
|
+
The request object. The request for
|
|
2661
|
+
[PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
|
|
2662
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2663
|
+
should be retried.
|
|
2664
|
+
timeout (float): The timeout for this request.
|
|
2665
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2666
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2667
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2668
|
+
be of type `bytes`.
|
|
2669
|
+
|
|
2670
|
+
Returns:
|
|
2671
|
+
~.spanner.PartitionResponse:
|
|
2672
|
+
The response for
|
|
2673
|
+
[PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
|
|
2674
|
+
or
|
|
2675
|
+
[PartitionRead][google.spanner.v1.Spanner.PartitionRead]
|
|
2676
|
+
|
|
2677
|
+
"""
|
|
2678
|
+
|
|
2679
|
+
http_options = (
|
|
2680
|
+
_BaseSpannerRestTransport._BasePartitionQuery._get_http_options()
|
|
2681
|
+
)
|
|
2682
|
+
|
|
2683
|
+
request, metadata = self._interceptor.pre_partition_query(request, metadata)
|
|
2684
|
+
transcoded_request = (
|
|
2685
|
+
_BaseSpannerRestTransport._BasePartitionQuery._get_transcoded_request(
|
|
2686
|
+
http_options, request
|
|
2687
|
+
)
|
|
2688
|
+
)
|
|
2689
|
+
|
|
2690
|
+
body = _BaseSpannerRestTransport._BasePartitionQuery._get_request_body_json(
|
|
2691
|
+
transcoded_request
|
|
2692
|
+
)
|
|
2693
|
+
|
|
2694
|
+
# Jsonify the query params
|
|
2695
|
+
query_params = (
|
|
2696
|
+
_BaseSpannerRestTransport._BasePartitionQuery._get_query_params_json(
|
|
2697
|
+
transcoded_request
|
|
2698
|
+
)
|
|
2699
|
+
)
|
|
2700
|
+
|
|
2701
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2702
|
+
logging.DEBUG
|
|
2703
|
+
): # pragma: NO COVER
|
|
2704
|
+
request_url = "{host}{uri}".format(
|
|
2705
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2706
|
+
)
|
|
2707
|
+
method = transcoded_request["method"]
|
|
2708
|
+
try:
|
|
2709
|
+
request_payload = type(request).to_json(request)
|
|
2710
|
+
except:
|
|
2711
|
+
request_payload = None
|
|
2712
|
+
http_request = {
|
|
2713
|
+
"payload": request_payload,
|
|
2714
|
+
"requestMethod": method,
|
|
2715
|
+
"requestUrl": request_url,
|
|
2716
|
+
"headers": dict(metadata),
|
|
2717
|
+
}
|
|
2718
|
+
_LOGGER.debug(
|
|
2719
|
+
f"Sending request for google.spanner_v1.SpannerClient.PartitionQuery",
|
|
2720
|
+
extra={
|
|
2721
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2722
|
+
"rpcName": "PartitionQuery",
|
|
2723
|
+
"httpRequest": http_request,
|
|
2724
|
+
"metadata": http_request["headers"],
|
|
2725
|
+
},
|
|
2726
|
+
)
|
|
2727
|
+
|
|
2728
|
+
# Send the request
|
|
2729
|
+
response = SpannerRestTransport._PartitionQuery._get_response(
|
|
2730
|
+
self._host,
|
|
2731
|
+
metadata,
|
|
2732
|
+
query_params,
|
|
2733
|
+
self._session,
|
|
2734
|
+
timeout,
|
|
2735
|
+
transcoded_request,
|
|
2736
|
+
body,
|
|
2737
|
+
)
|
|
2738
|
+
|
|
2739
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2740
|
+
# subclass.
|
|
2741
|
+
if response.status_code >= 400:
|
|
2742
|
+
raise core_exceptions.from_http_response(response)
|
|
2743
|
+
|
|
2744
|
+
# Return the response
|
|
2745
|
+
resp = spanner.PartitionResponse()
|
|
2746
|
+
pb_resp = spanner.PartitionResponse.pb(resp)
|
|
2747
|
+
|
|
2748
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2749
|
+
|
|
2750
|
+
resp = self._interceptor.post_partition_query(resp)
|
|
2751
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2752
|
+
resp, _ = self._interceptor.post_partition_query_with_metadata(
|
|
2753
|
+
resp, response_metadata
|
|
2754
|
+
)
|
|
2755
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2756
|
+
logging.DEBUG
|
|
2757
|
+
): # pragma: NO COVER
|
|
2758
|
+
try:
|
|
2759
|
+
response_payload = spanner.PartitionResponse.to_json(response)
|
|
2760
|
+
except:
|
|
2761
|
+
response_payload = None
|
|
2762
|
+
http_response = {
|
|
2763
|
+
"payload": response_payload,
|
|
2764
|
+
"headers": dict(response.headers),
|
|
2765
|
+
"status": response.status_code,
|
|
2766
|
+
}
|
|
2767
|
+
_LOGGER.debug(
|
|
2768
|
+
"Received response for google.spanner_v1.SpannerClient.partition_query",
|
|
2769
|
+
extra={
|
|
2770
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2771
|
+
"rpcName": "PartitionQuery",
|
|
2772
|
+
"metadata": http_response["headers"],
|
|
2773
|
+
"httpResponse": http_response,
|
|
2774
|
+
},
|
|
2775
|
+
)
|
|
2776
|
+
return resp
|
|
2777
|
+
|
|
2778
|
+
class _PartitionRead(_BaseSpannerRestTransport._BasePartitionRead, SpannerRestStub):
|
|
2779
|
+
def __hash__(self):
|
|
2780
|
+
return hash("SpannerRestTransport.PartitionRead")
|
|
2781
|
+
|
|
2782
|
+
@staticmethod
|
|
2783
|
+
def _get_response(
|
|
2784
|
+
host,
|
|
2785
|
+
metadata,
|
|
2786
|
+
query_params,
|
|
2787
|
+
session,
|
|
2788
|
+
timeout,
|
|
2789
|
+
transcoded_request,
|
|
2790
|
+
body=None,
|
|
2791
|
+
):
|
|
2792
|
+
uri = transcoded_request["uri"]
|
|
2793
|
+
method = transcoded_request["method"]
|
|
2794
|
+
headers = dict(metadata)
|
|
2795
|
+
headers["Content-Type"] = "application/json"
|
|
2796
|
+
response = getattr(session, method)(
|
|
2797
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2798
|
+
timeout=timeout,
|
|
2799
|
+
headers=headers,
|
|
2800
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2801
|
+
data=body,
|
|
2802
|
+
)
|
|
2803
|
+
return response
|
|
2804
|
+
|
|
2805
|
+
def __call__(
|
|
2806
|
+
self,
|
|
2807
|
+
request: spanner.PartitionReadRequest,
|
|
2808
|
+
*,
|
|
2809
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2810
|
+
timeout: Optional[float] = None,
|
|
2811
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2812
|
+
) -> spanner.PartitionResponse:
|
|
2813
|
+
r"""Call the partition read method over HTTP.
|
|
2814
|
+
|
|
2815
|
+
Args:
|
|
2816
|
+
request (~.spanner.PartitionReadRequest):
|
|
2817
|
+
The request object. The request for
|
|
2818
|
+
[PartitionRead][google.spanner.v1.Spanner.PartitionRead]
|
|
2819
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2820
|
+
should be retried.
|
|
2821
|
+
timeout (float): The timeout for this request.
|
|
2822
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2823
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2824
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2825
|
+
be of type `bytes`.
|
|
2826
|
+
|
|
2827
|
+
Returns:
|
|
2828
|
+
~.spanner.PartitionResponse:
|
|
2829
|
+
The response for
|
|
2830
|
+
[PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
|
|
2831
|
+
or
|
|
2832
|
+
[PartitionRead][google.spanner.v1.Spanner.PartitionRead]
|
|
2833
|
+
|
|
2834
|
+
"""
|
|
2835
|
+
|
|
2836
|
+
http_options = (
|
|
2837
|
+
_BaseSpannerRestTransport._BasePartitionRead._get_http_options()
|
|
2838
|
+
)
|
|
2839
|
+
|
|
2840
|
+
request, metadata = self._interceptor.pre_partition_read(request, metadata)
|
|
2841
|
+
transcoded_request = (
|
|
2842
|
+
_BaseSpannerRestTransport._BasePartitionRead._get_transcoded_request(
|
|
2843
|
+
http_options, request
|
|
2844
|
+
)
|
|
2845
|
+
)
|
|
2846
|
+
|
|
2847
|
+
body = _BaseSpannerRestTransport._BasePartitionRead._get_request_body_json(
|
|
2848
|
+
transcoded_request
|
|
2849
|
+
)
|
|
2850
|
+
|
|
2851
|
+
# Jsonify the query params
|
|
2852
|
+
query_params = (
|
|
2853
|
+
_BaseSpannerRestTransport._BasePartitionRead._get_query_params_json(
|
|
2854
|
+
transcoded_request
|
|
2855
|
+
)
|
|
2856
|
+
)
|
|
2857
|
+
|
|
2858
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2859
|
+
logging.DEBUG
|
|
2860
|
+
): # pragma: NO COVER
|
|
2861
|
+
request_url = "{host}{uri}".format(
|
|
2862
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
2863
|
+
)
|
|
2864
|
+
method = transcoded_request["method"]
|
|
2865
|
+
try:
|
|
2866
|
+
request_payload = type(request).to_json(request)
|
|
2867
|
+
except:
|
|
2868
|
+
request_payload = None
|
|
2869
|
+
http_request = {
|
|
2870
|
+
"payload": request_payload,
|
|
2871
|
+
"requestMethod": method,
|
|
2872
|
+
"requestUrl": request_url,
|
|
2873
|
+
"headers": dict(metadata),
|
|
2874
|
+
}
|
|
2875
|
+
_LOGGER.debug(
|
|
2876
|
+
f"Sending request for google.spanner_v1.SpannerClient.PartitionRead",
|
|
2877
|
+
extra={
|
|
2878
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2879
|
+
"rpcName": "PartitionRead",
|
|
2880
|
+
"httpRequest": http_request,
|
|
2881
|
+
"metadata": http_request["headers"],
|
|
2882
|
+
},
|
|
2883
|
+
)
|
|
2884
|
+
|
|
2885
|
+
# Send the request
|
|
2886
|
+
response = SpannerRestTransport._PartitionRead._get_response(
|
|
2887
|
+
self._host,
|
|
2888
|
+
metadata,
|
|
2889
|
+
query_params,
|
|
2890
|
+
self._session,
|
|
2891
|
+
timeout,
|
|
2892
|
+
transcoded_request,
|
|
2893
|
+
body,
|
|
2894
|
+
)
|
|
2895
|
+
|
|
2896
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
2897
|
+
# subclass.
|
|
2898
|
+
if response.status_code >= 400:
|
|
2899
|
+
raise core_exceptions.from_http_response(response)
|
|
2900
|
+
|
|
2901
|
+
# Return the response
|
|
2902
|
+
resp = spanner.PartitionResponse()
|
|
2903
|
+
pb_resp = spanner.PartitionResponse.pb(resp)
|
|
2904
|
+
|
|
2905
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
2906
|
+
|
|
2907
|
+
resp = self._interceptor.post_partition_read(resp)
|
|
2908
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
2909
|
+
resp, _ = self._interceptor.post_partition_read_with_metadata(
|
|
2910
|
+
resp, response_metadata
|
|
2911
|
+
)
|
|
2912
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
2913
|
+
logging.DEBUG
|
|
2914
|
+
): # pragma: NO COVER
|
|
2915
|
+
try:
|
|
2916
|
+
response_payload = spanner.PartitionResponse.to_json(response)
|
|
2917
|
+
except:
|
|
2918
|
+
response_payload = None
|
|
2919
|
+
http_response = {
|
|
2920
|
+
"payload": response_payload,
|
|
2921
|
+
"headers": dict(response.headers),
|
|
2922
|
+
"status": response.status_code,
|
|
2923
|
+
}
|
|
2924
|
+
_LOGGER.debug(
|
|
2925
|
+
"Received response for google.spanner_v1.SpannerClient.partition_read",
|
|
2926
|
+
extra={
|
|
2927
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
2928
|
+
"rpcName": "PartitionRead",
|
|
2929
|
+
"metadata": http_response["headers"],
|
|
2930
|
+
"httpResponse": http_response,
|
|
2931
|
+
},
|
|
2932
|
+
)
|
|
2933
|
+
return resp
|
|
2934
|
+
|
|
2935
|
+
class _Read(_BaseSpannerRestTransport._BaseRead, SpannerRestStub):
|
|
2936
|
+
def __hash__(self):
|
|
2937
|
+
return hash("SpannerRestTransport.Read")
|
|
2938
|
+
|
|
2939
|
+
@staticmethod
|
|
2940
|
+
def _get_response(
|
|
2941
|
+
host,
|
|
2942
|
+
metadata,
|
|
2943
|
+
query_params,
|
|
2944
|
+
session,
|
|
2945
|
+
timeout,
|
|
2946
|
+
transcoded_request,
|
|
2947
|
+
body=None,
|
|
2948
|
+
):
|
|
2949
|
+
uri = transcoded_request["uri"]
|
|
2950
|
+
method = transcoded_request["method"]
|
|
2951
|
+
headers = dict(metadata)
|
|
2952
|
+
headers["Content-Type"] = "application/json"
|
|
2953
|
+
response = getattr(session, method)(
|
|
2954
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
2955
|
+
timeout=timeout,
|
|
2956
|
+
headers=headers,
|
|
2957
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
2958
|
+
data=body,
|
|
2959
|
+
)
|
|
2960
|
+
return response
|
|
2961
|
+
|
|
2962
|
+
def __call__(
|
|
2963
|
+
self,
|
|
2964
|
+
request: spanner.ReadRequest,
|
|
2965
|
+
*,
|
|
2966
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2967
|
+
timeout: Optional[float] = None,
|
|
2968
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2969
|
+
) -> result_set.ResultSet:
|
|
2970
|
+
r"""Call the read method over HTTP.
|
|
2971
|
+
|
|
2972
|
+
Args:
|
|
2973
|
+
request (~.spanner.ReadRequest):
|
|
2974
|
+
The request object. The request for [Read][google.spanner.v1.Spanner.Read]
|
|
2975
|
+
and
|
|
2976
|
+
[StreamingRead][google.spanner.v1.Spanner.StreamingRead].
|
|
2977
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2978
|
+
should be retried.
|
|
2979
|
+
timeout (float): The timeout for this request.
|
|
2980
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2981
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2982
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2983
|
+
be of type `bytes`.
|
|
2984
|
+
|
|
2985
|
+
Returns:
|
|
2986
|
+
~.result_set.ResultSet:
|
|
2987
|
+
Results from [Read][google.spanner.v1.Spanner.Read] or
|
|
2988
|
+
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
|
|
2989
|
+
|
|
2990
|
+
"""
|
|
2991
|
+
|
|
2992
|
+
http_options = _BaseSpannerRestTransport._BaseRead._get_http_options()
|
|
2993
|
+
|
|
2994
|
+
request, metadata = self._interceptor.pre_read(request, metadata)
|
|
2995
|
+
transcoded_request = (
|
|
2996
|
+
_BaseSpannerRestTransport._BaseRead._get_transcoded_request(
|
|
2997
|
+
http_options, request
|
|
2998
|
+
)
|
|
2999
|
+
)
|
|
3000
|
+
|
|
3001
|
+
body = _BaseSpannerRestTransport._BaseRead._get_request_body_json(
|
|
3002
|
+
transcoded_request
|
|
3003
|
+
)
|
|
3004
|
+
|
|
3005
|
+
# Jsonify the query params
|
|
3006
|
+
query_params = _BaseSpannerRestTransport._BaseRead._get_query_params_json(
|
|
3007
|
+
transcoded_request
|
|
3008
|
+
)
|
|
3009
|
+
|
|
3010
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
3011
|
+
logging.DEBUG
|
|
3012
|
+
): # pragma: NO COVER
|
|
3013
|
+
request_url = "{host}{uri}".format(
|
|
3014
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
3015
|
+
)
|
|
3016
|
+
method = transcoded_request["method"]
|
|
3017
|
+
try:
|
|
3018
|
+
request_payload = type(request).to_json(request)
|
|
3019
|
+
except:
|
|
3020
|
+
request_payload = None
|
|
3021
|
+
http_request = {
|
|
3022
|
+
"payload": request_payload,
|
|
3023
|
+
"requestMethod": method,
|
|
3024
|
+
"requestUrl": request_url,
|
|
3025
|
+
"headers": dict(metadata),
|
|
3026
|
+
}
|
|
3027
|
+
_LOGGER.debug(
|
|
3028
|
+
f"Sending request for google.spanner_v1.SpannerClient.Read",
|
|
3029
|
+
extra={
|
|
3030
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
3031
|
+
"rpcName": "Read",
|
|
3032
|
+
"httpRequest": http_request,
|
|
3033
|
+
"metadata": http_request["headers"],
|
|
3034
|
+
},
|
|
3035
|
+
)
|
|
3036
|
+
|
|
3037
|
+
# Send the request
|
|
3038
|
+
response = SpannerRestTransport._Read._get_response(
|
|
3039
|
+
self._host,
|
|
3040
|
+
metadata,
|
|
3041
|
+
query_params,
|
|
3042
|
+
self._session,
|
|
3043
|
+
timeout,
|
|
3044
|
+
transcoded_request,
|
|
3045
|
+
body,
|
|
3046
|
+
)
|
|
3047
|
+
|
|
3048
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
3049
|
+
# subclass.
|
|
3050
|
+
if response.status_code >= 400:
|
|
3051
|
+
raise core_exceptions.from_http_response(response)
|
|
3052
|
+
|
|
3053
|
+
# Return the response
|
|
3054
|
+
resp = result_set.ResultSet()
|
|
3055
|
+
pb_resp = result_set.ResultSet.pb(resp)
|
|
3056
|
+
|
|
3057
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
3058
|
+
|
|
3059
|
+
resp = self._interceptor.post_read(resp)
|
|
3060
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
3061
|
+
resp, _ = self._interceptor.post_read_with_metadata(resp, response_metadata)
|
|
3062
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
3063
|
+
logging.DEBUG
|
|
3064
|
+
): # pragma: NO COVER
|
|
3065
|
+
try:
|
|
3066
|
+
response_payload = result_set.ResultSet.to_json(response)
|
|
3067
|
+
except:
|
|
3068
|
+
response_payload = None
|
|
3069
|
+
http_response = {
|
|
3070
|
+
"payload": response_payload,
|
|
3071
|
+
"headers": dict(response.headers),
|
|
3072
|
+
"status": response.status_code,
|
|
3073
|
+
}
|
|
3074
|
+
_LOGGER.debug(
|
|
3075
|
+
"Received response for google.spanner_v1.SpannerClient.read",
|
|
3076
|
+
extra={
|
|
3077
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
3078
|
+
"rpcName": "Read",
|
|
3079
|
+
"metadata": http_response["headers"],
|
|
3080
|
+
"httpResponse": http_response,
|
|
3081
|
+
},
|
|
3082
|
+
)
|
|
3083
|
+
return resp
|
|
3084
|
+
|
|
3085
|
+
class _Rollback(_BaseSpannerRestTransport._BaseRollback, SpannerRestStub):
|
|
3086
|
+
def __hash__(self):
|
|
3087
|
+
return hash("SpannerRestTransport.Rollback")
|
|
3088
|
+
|
|
3089
|
+
@staticmethod
|
|
3090
|
+
def _get_response(
|
|
3091
|
+
host,
|
|
3092
|
+
metadata,
|
|
3093
|
+
query_params,
|
|
3094
|
+
session,
|
|
3095
|
+
timeout,
|
|
3096
|
+
transcoded_request,
|
|
3097
|
+
body=None,
|
|
3098
|
+
):
|
|
3099
|
+
uri = transcoded_request["uri"]
|
|
3100
|
+
method = transcoded_request["method"]
|
|
3101
|
+
headers = dict(metadata)
|
|
3102
|
+
headers["Content-Type"] = "application/json"
|
|
3103
|
+
response = getattr(session, method)(
|
|
3104
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
3105
|
+
timeout=timeout,
|
|
3106
|
+
headers=headers,
|
|
3107
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
3108
|
+
data=body,
|
|
3109
|
+
)
|
|
3110
|
+
return response
|
|
3111
|
+
|
|
3112
|
+
def __call__(
|
|
3113
|
+
self,
|
|
3114
|
+
request: spanner.RollbackRequest,
|
|
3115
|
+
*,
|
|
3116
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3117
|
+
timeout: Optional[float] = None,
|
|
3118
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3119
|
+
):
|
|
3120
|
+
r"""Call the rollback method over HTTP.
|
|
3121
|
+
|
|
3122
|
+
Args:
|
|
3123
|
+
request (~.spanner.RollbackRequest):
|
|
3124
|
+
The request object. The request for
|
|
3125
|
+
[Rollback][google.spanner.v1.Spanner.Rollback].
|
|
3126
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
3127
|
+
should be retried.
|
|
3128
|
+
timeout (float): The timeout for this request.
|
|
3129
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3130
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3131
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3132
|
+
be of type `bytes`.
|
|
3133
|
+
"""
|
|
3134
|
+
|
|
3135
|
+
http_options = _BaseSpannerRestTransport._BaseRollback._get_http_options()
|
|
3136
|
+
|
|
3137
|
+
request, metadata = self._interceptor.pre_rollback(request, metadata)
|
|
3138
|
+
transcoded_request = (
|
|
3139
|
+
_BaseSpannerRestTransport._BaseRollback._get_transcoded_request(
|
|
3140
|
+
http_options, request
|
|
3141
|
+
)
|
|
3142
|
+
)
|
|
3143
|
+
|
|
3144
|
+
body = _BaseSpannerRestTransport._BaseRollback._get_request_body_json(
|
|
3145
|
+
transcoded_request
|
|
3146
|
+
)
|
|
3147
|
+
|
|
3148
|
+
# Jsonify the query params
|
|
3149
|
+
query_params = (
|
|
3150
|
+
_BaseSpannerRestTransport._BaseRollback._get_query_params_json(
|
|
3151
|
+
transcoded_request
|
|
3152
|
+
)
|
|
3153
|
+
)
|
|
3154
|
+
|
|
3155
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
3156
|
+
logging.DEBUG
|
|
3157
|
+
): # pragma: NO COVER
|
|
3158
|
+
request_url = "{host}{uri}".format(
|
|
3159
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
3160
|
+
)
|
|
3161
|
+
method = transcoded_request["method"]
|
|
3162
|
+
try:
|
|
3163
|
+
request_payload = json_format.MessageToJson(request)
|
|
3164
|
+
except:
|
|
3165
|
+
request_payload = None
|
|
3166
|
+
http_request = {
|
|
3167
|
+
"payload": request_payload,
|
|
3168
|
+
"requestMethod": method,
|
|
3169
|
+
"requestUrl": request_url,
|
|
3170
|
+
"headers": dict(metadata),
|
|
3171
|
+
}
|
|
3172
|
+
_LOGGER.debug(
|
|
3173
|
+
f"Sending request for google.spanner_v1.SpannerClient.Rollback",
|
|
3174
|
+
extra={
|
|
3175
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
3176
|
+
"rpcName": "Rollback",
|
|
3177
|
+
"httpRequest": http_request,
|
|
3178
|
+
"metadata": http_request["headers"],
|
|
3179
|
+
},
|
|
3180
|
+
)
|
|
3181
|
+
|
|
3182
|
+
# Send the request
|
|
3183
|
+
response = SpannerRestTransport._Rollback._get_response(
|
|
3184
|
+
self._host,
|
|
3185
|
+
metadata,
|
|
3186
|
+
query_params,
|
|
3187
|
+
self._session,
|
|
3188
|
+
timeout,
|
|
3189
|
+
transcoded_request,
|
|
3190
|
+
body,
|
|
3191
|
+
)
|
|
3192
|
+
|
|
3193
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
3194
|
+
# subclass.
|
|
3195
|
+
if response.status_code >= 400:
|
|
3196
|
+
raise core_exceptions.from_http_response(response)
|
|
3197
|
+
|
|
3198
|
+
class _StreamingRead(_BaseSpannerRestTransport._BaseStreamingRead, SpannerRestStub):
|
|
3199
|
+
def __hash__(self):
|
|
3200
|
+
return hash("SpannerRestTransport.StreamingRead")
|
|
3201
|
+
|
|
3202
|
+
@staticmethod
|
|
3203
|
+
def _get_response(
|
|
3204
|
+
host,
|
|
3205
|
+
metadata,
|
|
3206
|
+
query_params,
|
|
3207
|
+
session,
|
|
3208
|
+
timeout,
|
|
3209
|
+
transcoded_request,
|
|
3210
|
+
body=None,
|
|
3211
|
+
):
|
|
3212
|
+
uri = transcoded_request["uri"]
|
|
3213
|
+
method = transcoded_request["method"]
|
|
3214
|
+
headers = dict(metadata)
|
|
3215
|
+
headers["Content-Type"] = "application/json"
|
|
3216
|
+
response = getattr(session, method)(
|
|
3217
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
3218
|
+
timeout=timeout,
|
|
3219
|
+
headers=headers,
|
|
3220
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
3221
|
+
data=body,
|
|
3222
|
+
stream=True,
|
|
3223
|
+
)
|
|
3224
|
+
return response
|
|
3225
|
+
|
|
3226
|
+
def __call__(
|
|
3227
|
+
self,
|
|
3228
|
+
request: spanner.ReadRequest,
|
|
3229
|
+
*,
|
|
3230
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3231
|
+
timeout: Optional[float] = None,
|
|
3232
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3233
|
+
) -> rest_streaming.ResponseIterator:
|
|
3234
|
+
r"""Call the streaming read method over HTTP.
|
|
3235
|
+
|
|
3236
|
+
Args:
|
|
3237
|
+
request (~.spanner.ReadRequest):
|
|
3238
|
+
The request object. The request for [Read][google.spanner.v1.Spanner.Read]
|
|
3239
|
+
and
|
|
3240
|
+
[StreamingRead][google.spanner.v1.Spanner.StreamingRead].
|
|
3241
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
3242
|
+
should be retried.
|
|
3243
|
+
timeout (float): The timeout for this request.
|
|
3244
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3245
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3246
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3247
|
+
be of type `bytes`.
|
|
3248
|
+
|
|
3249
|
+
Returns:
|
|
3250
|
+
~.result_set.PartialResultSet:
|
|
3251
|
+
Partial results from a streaming read
|
|
3252
|
+
or SQL query. Streaming reads and SQL
|
|
3253
|
+
queries better tolerate large result
|
|
3254
|
+
sets, large rows, and large values, but
|
|
3255
|
+
are a little trickier to consume.
|
|
3256
|
+
|
|
3257
|
+
"""
|
|
3258
|
+
|
|
3259
|
+
http_options = (
|
|
3260
|
+
_BaseSpannerRestTransport._BaseStreamingRead._get_http_options()
|
|
3261
|
+
)
|
|
3262
|
+
|
|
3263
|
+
request, metadata = self._interceptor.pre_streaming_read(request, metadata)
|
|
3264
|
+
transcoded_request = (
|
|
3265
|
+
_BaseSpannerRestTransport._BaseStreamingRead._get_transcoded_request(
|
|
3266
|
+
http_options, request
|
|
3267
|
+
)
|
|
3268
|
+
)
|
|
3269
|
+
|
|
3270
|
+
body = _BaseSpannerRestTransport._BaseStreamingRead._get_request_body_json(
|
|
3271
|
+
transcoded_request
|
|
3272
|
+
)
|
|
3273
|
+
|
|
3274
|
+
# Jsonify the query params
|
|
3275
|
+
query_params = (
|
|
3276
|
+
_BaseSpannerRestTransport._BaseStreamingRead._get_query_params_json(
|
|
3277
|
+
transcoded_request
|
|
3278
|
+
)
|
|
3279
|
+
)
|
|
3280
|
+
|
|
3281
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
3282
|
+
logging.DEBUG
|
|
3283
|
+
): # pragma: NO COVER
|
|
3284
|
+
request_url = "{host}{uri}".format(
|
|
3285
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
3286
|
+
)
|
|
3287
|
+
method = transcoded_request["method"]
|
|
3288
|
+
try:
|
|
3289
|
+
request_payload = type(request).to_json(request)
|
|
3290
|
+
except:
|
|
3291
|
+
request_payload = None
|
|
3292
|
+
http_request = {
|
|
3293
|
+
"payload": request_payload,
|
|
3294
|
+
"requestMethod": method,
|
|
3295
|
+
"requestUrl": request_url,
|
|
3296
|
+
"headers": dict(metadata),
|
|
3297
|
+
}
|
|
3298
|
+
_LOGGER.debug(
|
|
3299
|
+
f"Sending request for google.spanner_v1.SpannerClient.StreamingRead",
|
|
3300
|
+
extra={
|
|
3301
|
+
"serviceName": "google.spanner.v1.Spanner",
|
|
3302
|
+
"rpcName": "StreamingRead",
|
|
3303
|
+
"httpRequest": http_request,
|
|
3304
|
+
"metadata": http_request["headers"],
|
|
3305
|
+
},
|
|
3306
|
+
)
|
|
3307
|
+
|
|
3308
|
+
# Send the request
|
|
3309
|
+
response = SpannerRestTransport._StreamingRead._get_response(
|
|
3310
|
+
self._host,
|
|
3311
|
+
metadata,
|
|
3312
|
+
query_params,
|
|
3313
|
+
self._session,
|
|
3314
|
+
timeout,
|
|
3315
|
+
transcoded_request,
|
|
3316
|
+
body,
|
|
3317
|
+
)
|
|
3318
|
+
|
|
3319
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
3320
|
+
# subclass.
|
|
3321
|
+
if response.status_code >= 400:
|
|
3322
|
+
raise core_exceptions.from_http_response(response)
|
|
3323
|
+
|
|
3324
|
+
# Return the response
|
|
3325
|
+
resp = rest_streaming.ResponseIterator(
|
|
3326
|
+
response, result_set.PartialResultSet
|
|
3327
|
+
)
|
|
3328
|
+
|
|
3329
|
+
resp = self._interceptor.post_streaming_read(resp)
|
|
3330
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
3331
|
+
resp, _ = self._interceptor.post_streaming_read_with_metadata(
|
|
3332
|
+
resp, response_metadata
|
|
3333
|
+
)
|
|
3334
|
+
return resp
|
|
3335
|
+
|
|
3336
|
+
@property
|
|
3337
|
+
def batch_create_sessions(
|
|
3338
|
+
self,
|
|
3339
|
+
) -> Callable[
|
|
3340
|
+
[spanner.BatchCreateSessionsRequest], spanner.BatchCreateSessionsResponse
|
|
3341
|
+
]:
|
|
3342
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3343
|
+
# In C++ this would require a dynamic_cast
|
|
3344
|
+
return self._BatchCreateSessions(self._session, self._host, self._interceptor) # type: ignore
|
|
3345
|
+
|
|
3346
|
+
@property
|
|
3347
|
+
def batch_write(
|
|
3348
|
+
self,
|
|
3349
|
+
) -> Callable[[spanner.BatchWriteRequest], spanner.BatchWriteResponse]:
|
|
3350
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3351
|
+
# In C++ this would require a dynamic_cast
|
|
3352
|
+
return self._BatchWrite(self._session, self._host, self._interceptor) # type: ignore
|
|
3353
|
+
|
|
3354
|
+
@property
|
|
3355
|
+
def begin_transaction(
|
|
3356
|
+
self,
|
|
3357
|
+
) -> Callable[[spanner.BeginTransactionRequest], transaction.Transaction]:
|
|
3358
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3359
|
+
# In C++ this would require a dynamic_cast
|
|
3360
|
+
return self._BeginTransaction(self._session, self._host, self._interceptor) # type: ignore
|
|
3361
|
+
|
|
3362
|
+
@property
|
|
3363
|
+
def commit(
|
|
3364
|
+
self,
|
|
3365
|
+
) -> Callable[[spanner.CommitRequest], commit_response.CommitResponse]:
|
|
3366
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3367
|
+
# In C++ this would require a dynamic_cast
|
|
3368
|
+
return self._Commit(self._session, self._host, self._interceptor) # type: ignore
|
|
3369
|
+
|
|
3370
|
+
@property
|
|
3371
|
+
def create_session(
|
|
3372
|
+
self,
|
|
3373
|
+
) -> Callable[[spanner.CreateSessionRequest], spanner.Session]:
|
|
3374
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3375
|
+
# In C++ this would require a dynamic_cast
|
|
3376
|
+
return self._CreateSession(self._session, self._host, self._interceptor) # type: ignore
|
|
3377
|
+
|
|
3378
|
+
@property
|
|
3379
|
+
def delete_session(
|
|
3380
|
+
self,
|
|
3381
|
+
) -> Callable[[spanner.DeleteSessionRequest], empty_pb2.Empty]:
|
|
3382
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3383
|
+
# In C++ this would require a dynamic_cast
|
|
3384
|
+
return self._DeleteSession(self._session, self._host, self._interceptor) # type: ignore
|
|
3385
|
+
|
|
3386
|
+
@property
|
|
3387
|
+
def execute_batch_dml(
|
|
3388
|
+
self,
|
|
3389
|
+
) -> Callable[[spanner.ExecuteBatchDmlRequest], spanner.ExecuteBatchDmlResponse]:
|
|
3390
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3391
|
+
# In C++ this would require a dynamic_cast
|
|
3392
|
+
return self._ExecuteBatchDml(self._session, self._host, self._interceptor) # type: ignore
|
|
3393
|
+
|
|
3394
|
+
@property
|
|
3395
|
+
def execute_sql(
|
|
3396
|
+
self,
|
|
3397
|
+
) -> Callable[[spanner.ExecuteSqlRequest], result_set.ResultSet]:
|
|
3398
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3399
|
+
# In C++ this would require a dynamic_cast
|
|
3400
|
+
return self._ExecuteSql(self._session, self._host, self._interceptor) # type: ignore
|
|
3401
|
+
|
|
3402
|
+
@property
|
|
3403
|
+
def execute_streaming_sql(
|
|
3404
|
+
self,
|
|
3405
|
+
) -> Callable[[spanner.ExecuteSqlRequest], result_set.PartialResultSet]:
|
|
3406
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3407
|
+
# In C++ this would require a dynamic_cast
|
|
3408
|
+
return self._ExecuteStreamingSql(self._session, self._host, self._interceptor) # type: ignore
|
|
3409
|
+
|
|
3410
|
+
@property
|
|
3411
|
+
def get_session(self) -> Callable[[spanner.GetSessionRequest], spanner.Session]:
|
|
3412
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3413
|
+
# In C++ this would require a dynamic_cast
|
|
3414
|
+
return self._GetSession(self._session, self._host, self._interceptor) # type: ignore
|
|
3415
|
+
|
|
3416
|
+
@property
|
|
3417
|
+
def list_sessions(
|
|
3418
|
+
self,
|
|
3419
|
+
) -> Callable[[spanner.ListSessionsRequest], spanner.ListSessionsResponse]:
|
|
3420
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3421
|
+
# In C++ this would require a dynamic_cast
|
|
3422
|
+
return self._ListSessions(self._session, self._host, self._interceptor) # type: ignore
|
|
3423
|
+
|
|
3424
|
+
@property
|
|
3425
|
+
def partition_query(
|
|
3426
|
+
self,
|
|
3427
|
+
) -> Callable[[spanner.PartitionQueryRequest], spanner.PartitionResponse]:
|
|
3428
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3429
|
+
# In C++ this would require a dynamic_cast
|
|
3430
|
+
return self._PartitionQuery(self._session, self._host, self._interceptor) # type: ignore
|
|
3431
|
+
|
|
3432
|
+
@property
|
|
3433
|
+
def partition_read(
|
|
3434
|
+
self,
|
|
3435
|
+
) -> Callable[[spanner.PartitionReadRequest], spanner.PartitionResponse]:
|
|
3436
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3437
|
+
# In C++ this would require a dynamic_cast
|
|
3438
|
+
return self._PartitionRead(self._session, self._host, self._interceptor) # type: ignore
|
|
3439
|
+
|
|
3440
|
+
@property
|
|
3441
|
+
def read(self) -> Callable[[spanner.ReadRequest], result_set.ResultSet]:
|
|
3442
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3443
|
+
# In C++ this would require a dynamic_cast
|
|
3444
|
+
return self._Read(self._session, self._host, self._interceptor) # type: ignore
|
|
3445
|
+
|
|
3446
|
+
@property
|
|
3447
|
+
def rollback(self) -> Callable[[spanner.RollbackRequest], empty_pb2.Empty]:
|
|
3448
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3449
|
+
# In C++ this would require a dynamic_cast
|
|
3450
|
+
return self._Rollback(self._session, self._host, self._interceptor) # type: ignore
|
|
3451
|
+
|
|
3452
|
+
@property
|
|
3453
|
+
def streaming_read(
|
|
3454
|
+
self,
|
|
3455
|
+
) -> Callable[[spanner.ReadRequest], result_set.PartialResultSet]:
|
|
3456
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
3457
|
+
# In C++ this would require a dynamic_cast
|
|
3458
|
+
return self._StreamingRead(self._session, self._host, self._interceptor) # type: ignore
|
|
3459
|
+
|
|
3460
|
+
@property
|
|
3461
|
+
def kind(self) -> str:
|
|
3462
|
+
return "rest"
|
|
3463
|
+
|
|
3464
|
+
def close(self):
|
|
3465
|
+
self._session.close()
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
__all__ = ("SpannerRestTransport",)
|