google-cloud-spanner 3.55.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. google/cloud/spanner.py +47 -0
  2. google/cloud/spanner_admin_database_v1/__init__.py +146 -0
  3. google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
  4. google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
  5. google/cloud/spanner_admin_database_v1/py.typed +2 -0
  6. google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
  7. google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
  8. google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
  9. google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
  10. google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
  11. google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
  12. google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
  13. google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
  14. google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
  15. google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
  16. google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
  17. google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
  18. google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
  19. google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
  20. google/cloud/spanner_admin_database_v1/types/common.py +180 -0
  21. google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
  22. google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
  23. google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
  24. google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
  25. google/cloud/spanner_admin_instance_v1/py.typed +2 -0
  26. google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
  27. google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
  28. google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
  29. google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
  30. google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
  31. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
  32. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
  33. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
  34. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
  35. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
  36. google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
  37. google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
  38. google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
  39. google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
  40. google/cloud/spanner_dbapi/__init__.py +93 -0
  41. google/cloud/spanner_dbapi/_helpers.py +113 -0
  42. google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
  43. google/cloud/spanner_dbapi/checksum.py +80 -0
  44. google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
  45. google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
  46. google/cloud/spanner_dbapi/connection.py +818 -0
  47. google/cloud/spanner_dbapi/cursor.py +609 -0
  48. google/cloud/spanner_dbapi/exceptions.py +172 -0
  49. google/cloud/spanner_dbapi/parse_utils.py +392 -0
  50. google/cloud/spanner_dbapi/parsed_statement.py +63 -0
  51. google/cloud/spanner_dbapi/parser.py +258 -0
  52. google/cloud/spanner_dbapi/partition_helper.py +41 -0
  53. google/cloud/spanner_dbapi/transaction_helper.py +294 -0
  54. google/cloud/spanner_dbapi/types.py +106 -0
  55. google/cloud/spanner_dbapi/utils.py +147 -0
  56. google/cloud/spanner_dbapi/version.py +20 -0
  57. google/cloud/spanner_v1/__init__.py +154 -0
  58. google/cloud/spanner_v1/_helpers.py +751 -0
  59. google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
  60. google/cloud/spanner_v1/backup.py +397 -0
  61. google/cloud/spanner_v1/batch.py +433 -0
  62. google/cloud/spanner_v1/client.py +538 -0
  63. google/cloud/spanner_v1/data_types.py +350 -0
  64. google/cloud/spanner_v1/database.py +1968 -0
  65. google/cloud/spanner_v1/database_sessions_manager.py +249 -0
  66. google/cloud/spanner_v1/gapic_metadata.json +268 -0
  67. google/cloud/spanner_v1/gapic_version.py +16 -0
  68. google/cloud/spanner_v1/instance.py +735 -0
  69. google/cloud/spanner_v1/keyset.py +193 -0
  70. google/cloud/spanner_v1/merged_result_set.py +146 -0
  71. google/cloud/spanner_v1/metrics/constants.py +71 -0
  72. google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
  73. google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
  74. google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
  75. google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
  76. google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
  77. google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
  78. google/cloud/spanner_v1/param_types.py +110 -0
  79. google/cloud/spanner_v1/pool.py +813 -0
  80. google/cloud/spanner_v1/py.typed +2 -0
  81. google/cloud/spanner_v1/request_id_header.py +64 -0
  82. google/cloud/spanner_v1/services/__init__.py +15 -0
  83. google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
  84. google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
  85. google/cloud/spanner_v1/services/spanner/client.py +2624 -0
  86. google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
  87. google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
  88. google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
  89. google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
  90. google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
  91. google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
  92. google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
  93. google/cloud/spanner_v1/session.py +631 -0
  94. google/cloud/spanner_v1/session_options.py +133 -0
  95. google/cloud/spanner_v1/snapshot.py +1057 -0
  96. google/cloud/spanner_v1/streamed.py +402 -0
  97. google/cloud/spanner_v1/table.py +181 -0
  98. google/cloud/spanner_v1/testing/__init__.py +0 -0
  99. google/cloud/spanner_v1/testing/database_test.py +121 -0
  100. google/cloud/spanner_v1/testing/interceptors.py +118 -0
  101. google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
  102. google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
  103. google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
  104. google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
  105. google/cloud/spanner_v1/transaction.py +747 -0
  106. google/cloud/spanner_v1/types/__init__.py +118 -0
  107. google/cloud/spanner_v1/types/commit_response.py +94 -0
  108. google/cloud/spanner_v1/types/keys.py +248 -0
  109. google/cloud/spanner_v1/types/mutation.py +201 -0
  110. google/cloud/spanner_v1/types/query_plan.py +220 -0
  111. google/cloud/spanner_v1/types/result_set.py +379 -0
  112. google/cloud/spanner_v1/types/spanner.py +1815 -0
  113. google/cloud/spanner_v1/types/transaction.py +818 -0
  114. google/cloud/spanner_v1/types/type.py +288 -0
  115. google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
  116. google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
  117. google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
  118. google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
  119. google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1303 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import json
17
+ import logging as std_logging
18
+ import pickle
19
+ import warnings
20
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
21
+
22
+ from google.api_core import grpc_helpers
23
+ from google.api_core import operations_v1
24
+ from google.api_core import gapic_v1
25
+ import google.auth # type: ignore
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.auth.transport.grpc import SslCredentials # type: ignore
28
+ from google.protobuf.json_format import MessageToJson
29
+ import google.protobuf.message
30
+
31
+ import grpc # type: ignore
32
+ import proto # type: ignore
33
+
34
+ from google.cloud.spanner_admin_database_v1.types import backup
35
+ from google.cloud.spanner_admin_database_v1.types import backup as gsad_backup
36
+ from google.cloud.spanner_admin_database_v1.types import backup_schedule
37
+ from google.cloud.spanner_admin_database_v1.types import (
38
+ backup_schedule as gsad_backup_schedule,
39
+ )
40
+ from google.cloud.spanner_admin_database_v1.types import spanner_database_admin
41
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
42
+ from google.iam.v1 import policy_pb2 # type: ignore
43
+ from google.longrunning import operations_pb2 # type: ignore
44
+ from google.protobuf import empty_pb2 # type: ignore
45
+ from .base import DatabaseAdminTransport, DEFAULT_CLIENT_INFO
46
+
47
+ try:
48
+ from google.api_core import client_logging # type: ignore
49
+
50
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
51
+ except ImportError: # pragma: NO COVER
52
+ CLIENT_LOGGING_SUPPORTED = False
53
+
54
+ _LOGGER = std_logging.getLogger(__name__)
55
+
56
+
57
+ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
58
+ def intercept_unary_unary(self, continuation, client_call_details, request):
59
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
60
+ std_logging.DEBUG
61
+ )
62
+ if logging_enabled: # pragma: NO COVER
63
+ request_metadata = client_call_details.metadata
64
+ if isinstance(request, proto.Message):
65
+ request_payload = type(request).to_json(request)
66
+ elif isinstance(request, google.protobuf.message.Message):
67
+ request_payload = MessageToJson(request)
68
+ else:
69
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
70
+
71
+ request_metadata = {
72
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
73
+ for key, value in request_metadata
74
+ }
75
+ grpc_request = {
76
+ "payload": request_payload,
77
+ "requestMethod": "grpc",
78
+ "metadata": dict(request_metadata),
79
+ }
80
+ _LOGGER.debug(
81
+ f"Sending request for {client_call_details.method}",
82
+ extra={
83
+ "serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
84
+ "rpcName": str(client_call_details.method),
85
+ "request": grpc_request,
86
+ "metadata": grpc_request["metadata"],
87
+ },
88
+ )
89
+ response = continuation(client_call_details, request)
90
+ if logging_enabled: # pragma: NO COVER
91
+ response_metadata = response.trailing_metadata()
92
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
93
+ metadata = (
94
+ dict([(k, str(v)) for k, v in response_metadata])
95
+ if response_metadata
96
+ else None
97
+ )
98
+ result = response.result()
99
+ if isinstance(result, proto.Message):
100
+ response_payload = type(result).to_json(result)
101
+ elif isinstance(result, google.protobuf.message.Message):
102
+ response_payload = MessageToJson(result)
103
+ else:
104
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
105
+ grpc_response = {
106
+ "payload": response_payload,
107
+ "metadata": metadata,
108
+ "status": "OK",
109
+ }
110
+ _LOGGER.debug(
111
+ f"Received response for {client_call_details.method}.",
112
+ extra={
113
+ "serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
114
+ "rpcName": client_call_details.method,
115
+ "response": grpc_response,
116
+ "metadata": grpc_response["metadata"],
117
+ },
118
+ )
119
+ return response
120
+
121
+
122
+ class DatabaseAdminGrpcTransport(DatabaseAdminTransport):
123
+ """gRPC backend transport for DatabaseAdmin.
124
+
125
+ Cloud Spanner Database Admin API
126
+
127
+ The Cloud Spanner Database Admin API can be used to:
128
+
129
+ - create, drop, and list databases
130
+ - update the schema of pre-existing databases
131
+ - create, delete, copy and list backups for a database
132
+ - restore a database from an existing backup
133
+
134
+ This class defines the same methods as the primary client, so the
135
+ primary client can load the underlying transport implementation
136
+ and call it.
137
+
138
+ It sends protocol buffers over the wire using gRPC (which is built on
139
+ top of HTTP/2); the ``grpcio`` package must be installed.
140
+ """
141
+
142
+ _stubs: Dict[str, Callable]
143
+
144
+ def __init__(
145
+ self,
146
+ *,
147
+ host: str = "spanner.googleapis.com",
148
+ credentials: Optional[ga_credentials.Credentials] = None,
149
+ credentials_file: Optional[str] = None,
150
+ scopes: Optional[Sequence[str]] = None,
151
+ channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
152
+ api_mtls_endpoint: Optional[str] = None,
153
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
154
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
155
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
156
+ quota_project_id: Optional[str] = None,
157
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
158
+ always_use_jwt_access: Optional[bool] = False,
159
+ api_audience: Optional[str] = None,
160
+ ) -> None:
161
+ """Instantiate the transport.
162
+
163
+ Args:
164
+ host (Optional[str]):
165
+ The hostname to connect to (default: 'spanner.googleapis.com').
166
+ credentials (Optional[google.auth.credentials.Credentials]): The
167
+ authorization credentials to attach to requests. These
168
+ credentials identify the application to the service; if none
169
+ are specified, the client will attempt to ascertain the
170
+ credentials from the environment.
171
+ This argument is ignored if a ``channel`` instance is provided.
172
+ credentials_file (Optional[str]): A file with credentials that can
173
+ be loaded with :func:`google.auth.load_credentials_from_file`.
174
+ This argument is ignored if a ``channel`` instance is provided.
175
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
176
+ ignored if a ``channel`` instance is provided.
177
+ channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
178
+ A ``Channel`` instance through which to make calls, or a Callable
179
+ that constructs and returns one. If set to None, ``self.create_channel``
180
+ is used to create the channel. If a Callable is given, it will be called
181
+ with the same arguments as used in ``self.create_channel``.
182
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
183
+ If provided, it overrides the ``host`` argument and tries to create
184
+ a mutual TLS channel with client SSL credentials from
185
+ ``client_cert_source`` or application default SSL credentials.
186
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
187
+ Deprecated. A callback to provide client SSL certificate bytes and
188
+ private key bytes, both in PEM format. It is ignored if
189
+ ``api_mtls_endpoint`` is None.
190
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
191
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
192
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
193
+ A callback to provide client certificate bytes and private key bytes,
194
+ both in PEM format. It is used to configure a mutual TLS channel. It is
195
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
196
+ quota_project_id (Optional[str]): An optional project to use for billing
197
+ and quota.
198
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
199
+ The client info used to send a user-agent string along with
200
+ API requests. If ``None``, then default info will be used.
201
+ Generally, you only need to set this if you're developing
202
+ your own client library.
203
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
204
+ be used for service account credentials.
205
+
206
+ Raises:
207
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
208
+ creation failed for any reason.
209
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
210
+ and ``credentials_file`` are passed.
211
+ """
212
+ self._grpc_channel = None
213
+ self._ssl_channel_credentials = ssl_channel_credentials
214
+ self._stubs: Dict[str, Callable] = {}
215
+ self._operations_client: Optional[operations_v1.OperationsClient] = None
216
+
217
+ if api_mtls_endpoint:
218
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
219
+ if client_cert_source:
220
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
221
+
222
+ if isinstance(channel, grpc.Channel):
223
+ # Ignore credentials if a channel was passed.
224
+ credentials = None
225
+ self._ignore_credentials = True
226
+ # If a channel was explicitly provided, set it.
227
+ self._grpc_channel = channel
228
+ self._ssl_channel_credentials = None
229
+
230
+ else:
231
+ if api_mtls_endpoint:
232
+ host = api_mtls_endpoint
233
+
234
+ # Create SSL credentials with client_cert_source or application
235
+ # default SSL credentials.
236
+ if client_cert_source:
237
+ cert, key = client_cert_source()
238
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
239
+ certificate_chain=cert, private_key=key
240
+ )
241
+ else:
242
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
243
+
244
+ else:
245
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
246
+ cert, key = client_cert_source_for_mtls()
247
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
248
+ certificate_chain=cert, private_key=key
249
+ )
250
+
251
+ # The base transport sets the host, credentials and scopes
252
+ super().__init__(
253
+ host=host,
254
+ credentials=credentials,
255
+ credentials_file=credentials_file,
256
+ scopes=scopes,
257
+ quota_project_id=quota_project_id,
258
+ client_info=client_info,
259
+ always_use_jwt_access=always_use_jwt_access,
260
+ api_audience=api_audience,
261
+ )
262
+
263
+ if not self._grpc_channel:
264
+ # initialize with the provided callable or the default channel
265
+ channel_init = channel or type(self).create_channel
266
+ self._grpc_channel = channel_init(
267
+ self._host,
268
+ # use the credentials which are saved
269
+ credentials=self._credentials,
270
+ # Set ``credentials_file`` to ``None`` here as
271
+ # the credentials that we saved earlier should be used.
272
+ credentials_file=None,
273
+ scopes=self._scopes,
274
+ ssl_credentials=self._ssl_channel_credentials,
275
+ quota_project_id=quota_project_id,
276
+ options=[
277
+ ("grpc.max_send_message_length", -1),
278
+ ("grpc.max_receive_message_length", -1),
279
+ ],
280
+ )
281
+
282
+ self._interceptor = _LoggingClientInterceptor()
283
+ self._logged_channel = grpc.intercept_channel(
284
+ self._grpc_channel, self._interceptor
285
+ )
286
+
287
+ # Wrap messages. This must be done after self._logged_channel exists
288
+ self._prep_wrapped_messages(client_info)
289
+
290
+ @classmethod
291
+ def create_channel(
292
+ cls,
293
+ host: str = "spanner.googleapis.com",
294
+ credentials: Optional[ga_credentials.Credentials] = None,
295
+ credentials_file: Optional[str] = None,
296
+ scopes: Optional[Sequence[str]] = None,
297
+ quota_project_id: Optional[str] = None,
298
+ **kwargs,
299
+ ) -> grpc.Channel:
300
+ """Create and return a gRPC channel object.
301
+ Args:
302
+ host (Optional[str]): The host for the channel to use.
303
+ credentials (Optional[~.Credentials]): The
304
+ authorization credentials to attach to requests. These
305
+ credentials identify this application to the service. If
306
+ none are specified, the client will attempt to ascertain
307
+ the credentials from the environment.
308
+ credentials_file (Optional[str]): A file with credentials that can
309
+ be loaded with :func:`google.auth.load_credentials_from_file`.
310
+ This argument is mutually exclusive with credentials.
311
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
312
+ service. These are only used when credentials are not specified and
313
+ are passed to :func:`google.auth.default`.
314
+ quota_project_id (Optional[str]): An optional project to use for billing
315
+ and quota.
316
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
317
+ channel creation.
318
+ Returns:
319
+ grpc.Channel: A gRPC channel object.
320
+
321
+ Raises:
322
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
323
+ and ``credentials_file`` are passed.
324
+ """
325
+
326
+ return grpc_helpers.create_channel(
327
+ host,
328
+ credentials=credentials,
329
+ credentials_file=credentials_file,
330
+ quota_project_id=quota_project_id,
331
+ default_scopes=cls.AUTH_SCOPES,
332
+ scopes=scopes,
333
+ default_host=cls.DEFAULT_HOST,
334
+ **kwargs,
335
+ )
336
+
337
+ @property
338
+ def grpc_channel(self) -> grpc.Channel:
339
+ """Return the channel designed to connect to this service."""
340
+ return self._grpc_channel
341
+
342
+ @property
343
+ def operations_client(self) -> operations_v1.OperationsClient:
344
+ """Create the client designed to process long-running operations.
345
+
346
+ This property caches on the instance; repeated calls return the same
347
+ client.
348
+ """
349
+ # Quick check: Only create a new client if we do not already have one.
350
+ if self._operations_client is None:
351
+ self._operations_client = operations_v1.OperationsClient(
352
+ self._logged_channel
353
+ )
354
+
355
+ # Return the client from cache.
356
+ return self._operations_client
357
+
358
+ @property
359
+ def list_databases(
360
+ self,
361
+ ) -> Callable[
362
+ [spanner_database_admin.ListDatabasesRequest],
363
+ spanner_database_admin.ListDatabasesResponse,
364
+ ]:
365
+ r"""Return a callable for the list databases method over gRPC.
366
+
367
+ Lists Cloud Spanner databases.
368
+
369
+ Returns:
370
+ Callable[[~.ListDatabasesRequest],
371
+ ~.ListDatabasesResponse]:
372
+ A function that, when called, will call the underlying RPC
373
+ on the server.
374
+ """
375
+ # Generate a "stub function" on-the-fly which will actually make
376
+ # the request.
377
+ # gRPC handles serialization and deserialization, so we just need
378
+ # to pass in the functions for each.
379
+ if "list_databases" not in self._stubs:
380
+ self._stubs["list_databases"] = self._logged_channel.unary_unary(
381
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases",
382
+ request_serializer=spanner_database_admin.ListDatabasesRequest.serialize,
383
+ response_deserializer=spanner_database_admin.ListDatabasesResponse.deserialize,
384
+ )
385
+ return self._stubs["list_databases"]
386
+
387
+ @property
388
+ def create_database(
389
+ self,
390
+ ) -> Callable[
391
+ [spanner_database_admin.CreateDatabaseRequest], operations_pb2.Operation
392
+ ]:
393
+ r"""Return a callable for the create database method over gRPC.
394
+
395
+ Creates a new Cloud Spanner database and starts to prepare it
396
+ for serving. The returned [long-running
397
+ operation][google.longrunning.Operation] will have a name of the
398
+ format ``<database_name>/operations/<operation_id>`` and can be
399
+ used to track preparation of the database. The
400
+ [metadata][google.longrunning.Operation.metadata] field type is
401
+ [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
402
+ The [response][google.longrunning.Operation.response] field type
403
+ is [Database][google.spanner.admin.database.v1.Database], if
404
+ successful.
405
+
406
+ Returns:
407
+ Callable[[~.CreateDatabaseRequest],
408
+ ~.Operation]:
409
+ A function that, when called, will call the underlying RPC
410
+ on the server.
411
+ """
412
+ # Generate a "stub function" on-the-fly which will actually make
413
+ # the request.
414
+ # gRPC handles serialization and deserialization, so we just need
415
+ # to pass in the functions for each.
416
+ if "create_database" not in self._stubs:
417
+ self._stubs["create_database"] = self._logged_channel.unary_unary(
418
+ "/google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase",
419
+ request_serializer=spanner_database_admin.CreateDatabaseRequest.serialize,
420
+ response_deserializer=operations_pb2.Operation.FromString,
421
+ )
422
+ return self._stubs["create_database"]
423
+
424
+ @property
425
+ def get_database(
426
+ self,
427
+ ) -> Callable[
428
+ [spanner_database_admin.GetDatabaseRequest], spanner_database_admin.Database
429
+ ]:
430
+ r"""Return a callable for the get database method over gRPC.
431
+
432
+ Gets the state of a Cloud Spanner database.
433
+
434
+ Returns:
435
+ Callable[[~.GetDatabaseRequest],
436
+ ~.Database]:
437
+ A function that, when called, will call the underlying RPC
438
+ on the server.
439
+ """
440
+ # Generate a "stub function" on-the-fly which will actually make
441
+ # the request.
442
+ # gRPC handles serialization and deserialization, so we just need
443
+ # to pass in the functions for each.
444
+ if "get_database" not in self._stubs:
445
+ self._stubs["get_database"] = self._logged_channel.unary_unary(
446
+ "/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase",
447
+ request_serializer=spanner_database_admin.GetDatabaseRequest.serialize,
448
+ response_deserializer=spanner_database_admin.Database.deserialize,
449
+ )
450
+ return self._stubs["get_database"]
451
+
452
+ @property
453
+ def update_database(
454
+ self,
455
+ ) -> Callable[
456
+ [spanner_database_admin.UpdateDatabaseRequest], operations_pb2.Operation
457
+ ]:
458
+ r"""Return a callable for the update database method over gRPC.
459
+
460
+ Updates a Cloud Spanner database. The returned [long-running
461
+ operation][google.longrunning.Operation] can be used to track
462
+ the progress of updating the database. If the named database
463
+ does not exist, returns ``NOT_FOUND``.
464
+
465
+ While the operation is pending:
466
+
467
+ - The database's
468
+ [reconciling][google.spanner.admin.database.v1.Database.reconciling]
469
+ field is set to true.
470
+ - Cancelling the operation is best-effort. If the cancellation
471
+ succeeds, the operation metadata's
472
+ [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time]
473
+ is set, the updates are reverted, and the operation
474
+ terminates with a ``CANCELLED`` status.
475
+ - New UpdateDatabase requests will return a
476
+ ``FAILED_PRECONDITION`` error until the pending operation is
477
+ done (returns successfully or with error).
478
+ - Reading the database via the API continues to give the
479
+ pre-request values.
480
+
481
+ Upon completion of the returned operation:
482
+
483
+ - The new values are in effect and readable via the API.
484
+ - The database's
485
+ [reconciling][google.spanner.admin.database.v1.Database.reconciling]
486
+ field becomes false.
487
+
488
+ The returned [long-running
489
+ operation][google.longrunning.Operation] will have a name of the
490
+ format
491
+ ``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``
492
+ and can be used to track the database modification. The
493
+ [metadata][google.longrunning.Operation.metadata] field type is
494
+ [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata].
495
+ The [response][google.longrunning.Operation.response] field type
496
+ is [Database][google.spanner.admin.database.v1.Database], if
497
+ successful.
498
+
499
+ Returns:
500
+ Callable[[~.UpdateDatabaseRequest],
501
+ ~.Operation]:
502
+ A function that, when called, will call the underlying RPC
503
+ on the server.
504
+ """
505
+ # Generate a "stub function" on-the-fly which will actually make
506
+ # the request.
507
+ # gRPC handles serialization and deserialization, so we just need
508
+ # to pass in the functions for each.
509
+ if "update_database" not in self._stubs:
510
+ self._stubs["update_database"] = self._logged_channel.unary_unary(
511
+ "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabase",
512
+ request_serializer=spanner_database_admin.UpdateDatabaseRequest.serialize,
513
+ response_deserializer=operations_pb2.Operation.FromString,
514
+ )
515
+ return self._stubs["update_database"]
516
+
517
+ @property
518
+ def update_database_ddl(
519
+ self,
520
+ ) -> Callable[
521
+ [spanner_database_admin.UpdateDatabaseDdlRequest], operations_pb2.Operation
522
+ ]:
523
+ r"""Return a callable for the update database ddl method over gRPC.
524
+
525
+ Updates the schema of a Cloud Spanner database by
526
+ creating/altering/dropping tables, columns, indexes, etc. The
527
+ returned [long-running operation][google.longrunning.Operation]
528
+ will have a name of the format
529
+ ``<database_name>/operations/<operation_id>`` and can be used to
530
+ track execution of the schema change(s). The
531
+ [metadata][google.longrunning.Operation.metadata] field type is
532
+ [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
533
+ The operation has no response.
534
+
535
+ Returns:
536
+ Callable[[~.UpdateDatabaseDdlRequest],
537
+ ~.Operation]:
538
+ A function that, when called, will call the underlying RPC
539
+ on the server.
540
+ """
541
+ # Generate a "stub function" on-the-fly which will actually make
542
+ # the request.
543
+ # gRPC handles serialization and deserialization, so we just need
544
+ # to pass in the functions for each.
545
+ if "update_database_ddl" not in self._stubs:
546
+ self._stubs["update_database_ddl"] = self._logged_channel.unary_unary(
547
+ "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl",
548
+ request_serializer=spanner_database_admin.UpdateDatabaseDdlRequest.serialize,
549
+ response_deserializer=operations_pb2.Operation.FromString,
550
+ )
551
+ return self._stubs["update_database_ddl"]
552
+
553
+ @property
554
+ def drop_database(
555
+ self,
556
+ ) -> Callable[[spanner_database_admin.DropDatabaseRequest], empty_pb2.Empty]:
557
+ r"""Return a callable for the drop database method over gRPC.
558
+
559
+ Drops (aka deletes) a Cloud Spanner database. Completed backups
560
+ for the database will be retained according to their
561
+ ``expire_time``. Note: Cloud Spanner might continue to accept
562
+ requests for a few seconds after the database has been deleted.
563
+
564
+ Returns:
565
+ Callable[[~.DropDatabaseRequest],
566
+ ~.Empty]:
567
+ A function that, when called, will call the underlying RPC
568
+ on the server.
569
+ """
570
+ # Generate a "stub function" on-the-fly which will actually make
571
+ # the request.
572
+ # gRPC handles serialization and deserialization, so we just need
573
+ # to pass in the functions for each.
574
+ if "drop_database" not in self._stubs:
575
+ self._stubs["drop_database"] = self._logged_channel.unary_unary(
576
+ "/google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase",
577
+ request_serializer=spanner_database_admin.DropDatabaseRequest.serialize,
578
+ response_deserializer=empty_pb2.Empty.FromString,
579
+ )
580
+ return self._stubs["drop_database"]
581
+
582
+ @property
583
+ def get_database_ddl(
584
+ self,
585
+ ) -> Callable[
586
+ [spanner_database_admin.GetDatabaseDdlRequest],
587
+ spanner_database_admin.GetDatabaseDdlResponse,
588
+ ]:
589
+ r"""Return a callable for the get database ddl method over gRPC.
590
+
591
+ Returns the schema of a Cloud Spanner database as a list of
592
+ formatted DDL statements. This method does not show pending
593
+ schema updates, those may be queried using the
594
+ [Operations][google.longrunning.Operations] API.
595
+
596
+ Returns:
597
+ Callable[[~.GetDatabaseDdlRequest],
598
+ ~.GetDatabaseDdlResponse]:
599
+ A function that, when called, will call the underlying RPC
600
+ on the server.
601
+ """
602
+ # Generate a "stub function" on-the-fly which will actually make
603
+ # the request.
604
+ # gRPC handles serialization and deserialization, so we just need
605
+ # to pass in the functions for each.
606
+ if "get_database_ddl" not in self._stubs:
607
+ self._stubs["get_database_ddl"] = self._logged_channel.unary_unary(
608
+ "/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl",
609
+ request_serializer=spanner_database_admin.GetDatabaseDdlRequest.serialize,
610
+ response_deserializer=spanner_database_admin.GetDatabaseDdlResponse.deserialize,
611
+ )
612
+ return self._stubs["get_database_ddl"]
613
+
614
+ @property
615
+ def set_iam_policy(
616
+ self,
617
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
618
+ r"""Return a callable for the set iam policy method over gRPC.
619
+
620
+ Sets the access control policy on a database or backup resource.
621
+ Replaces any existing policy.
622
+
623
+ Authorization requires ``spanner.databases.setIamPolicy``
624
+ permission on
625
+ [resource][google.iam.v1.SetIamPolicyRequest.resource]. For
626
+ backups, authorization requires ``spanner.backups.setIamPolicy``
627
+ permission on
628
+ [resource][google.iam.v1.SetIamPolicyRequest.resource].
629
+
630
+ Returns:
631
+ Callable[[~.SetIamPolicyRequest],
632
+ ~.Policy]:
633
+ A function that, when called, will call the underlying RPC
634
+ on the server.
635
+ """
636
+ # Generate a "stub function" on-the-fly which will actually make
637
+ # the request.
638
+ # gRPC handles serialization and deserialization, so we just need
639
+ # to pass in the functions for each.
640
+ if "set_iam_policy" not in self._stubs:
641
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
642
+ "/google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy",
643
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
644
+ response_deserializer=policy_pb2.Policy.FromString,
645
+ )
646
+ return self._stubs["set_iam_policy"]
647
+
648
+ @property
649
+ def get_iam_policy(
650
+ self,
651
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
652
+ r"""Return a callable for the get iam policy method over gRPC.
653
+
654
+ Gets the access control policy for a database or backup
655
+ resource. Returns an empty policy if a database or backup exists
656
+ but does not have a policy set.
657
+
658
+ Authorization requires ``spanner.databases.getIamPolicy``
659
+ permission on
660
+ [resource][google.iam.v1.GetIamPolicyRequest.resource]. For
661
+ backups, authorization requires ``spanner.backups.getIamPolicy``
662
+ permission on
663
+ [resource][google.iam.v1.GetIamPolicyRequest.resource].
664
+
665
+ Returns:
666
+ Callable[[~.GetIamPolicyRequest],
667
+ ~.Policy]:
668
+ A function that, when called, will call the underlying RPC
669
+ on the server.
670
+ """
671
+ # Generate a "stub function" on-the-fly which will actually make
672
+ # the request.
673
+ # gRPC handles serialization and deserialization, so we just need
674
+ # to pass in the functions for each.
675
+ if "get_iam_policy" not in self._stubs:
676
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
677
+ "/google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy",
678
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
679
+ response_deserializer=policy_pb2.Policy.FromString,
680
+ )
681
+ return self._stubs["get_iam_policy"]
682
+
683
+ @property
684
+ def test_iam_permissions(
685
+ self,
686
+ ) -> Callable[
687
+ [iam_policy_pb2.TestIamPermissionsRequest],
688
+ iam_policy_pb2.TestIamPermissionsResponse,
689
+ ]:
690
+ r"""Return a callable for the test iam permissions method over gRPC.
691
+
692
+ Returns permissions that the caller has on the specified
693
+ database or backup resource.
694
+
695
+ Attempting this RPC on a non-existent Cloud Spanner database
696
+ will result in a NOT_FOUND error if the user has
697
+ ``spanner.databases.list`` permission on the containing Cloud
698
+ Spanner instance. Otherwise returns an empty set of permissions.
699
+ Calling this method on a backup that does not exist will result
700
+ in a NOT_FOUND error if the user has ``spanner.backups.list``
701
+ permission on the containing instance.
702
+
703
+ Returns:
704
+ Callable[[~.TestIamPermissionsRequest],
705
+ ~.TestIamPermissionsResponse]:
706
+ A function that, when called, will call the underlying RPC
707
+ on the server.
708
+ """
709
+ # Generate a "stub function" on-the-fly which will actually make
710
+ # the request.
711
+ # gRPC handles serialization and deserialization, so we just need
712
+ # to pass in the functions for each.
713
+ if "test_iam_permissions" not in self._stubs:
714
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
715
+ "/google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions",
716
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
717
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
718
+ )
719
+ return self._stubs["test_iam_permissions"]
720
+
721
+ @property
722
+ def create_backup(
723
+ self,
724
+ ) -> Callable[[gsad_backup.CreateBackupRequest], operations_pb2.Operation]:
725
+ r"""Return a callable for the create backup method over gRPC.
726
+
727
+ Starts creating a new Cloud Spanner Backup. The returned backup
728
+ [long-running operation][google.longrunning.Operation] will have
729
+ a name of the format
730
+ ``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
731
+ and can be used to track creation of the backup. The
732
+ [metadata][google.longrunning.Operation.metadata] field type is
733
+ [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
734
+ The [response][google.longrunning.Operation.response] field type
735
+ is [Backup][google.spanner.admin.database.v1.Backup], if
736
+ successful. Cancelling the returned operation will stop the
737
+ creation and delete the backup. There can be only one pending
738
+ backup creation per database. Backup creation of different
739
+ databases can run concurrently.
740
+
741
+ Returns:
742
+ Callable[[~.CreateBackupRequest],
743
+ ~.Operation]:
744
+ A function that, when called, will call the underlying RPC
745
+ on the server.
746
+ """
747
+ # Generate a "stub function" on-the-fly which will actually make
748
+ # the request.
749
+ # gRPC handles serialization and deserialization, so we just need
750
+ # to pass in the functions for each.
751
+ if "create_backup" not in self._stubs:
752
+ self._stubs["create_backup"] = self._logged_channel.unary_unary(
753
+ "/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup",
754
+ request_serializer=gsad_backup.CreateBackupRequest.serialize,
755
+ response_deserializer=operations_pb2.Operation.FromString,
756
+ )
757
+ return self._stubs["create_backup"]
758
+
759
+ @property
760
+ def copy_backup(
761
+ self,
762
+ ) -> Callable[[backup.CopyBackupRequest], operations_pb2.Operation]:
763
+ r"""Return a callable for the copy backup method over gRPC.
764
+
765
+ Starts copying a Cloud Spanner Backup. The returned backup
766
+ [long-running operation][google.longrunning.Operation] will have
767
+ a name of the format
768
+ ``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
769
+ and can be used to track copying of the backup. The operation is
770
+ associated with the destination backup. The
771
+ [metadata][google.longrunning.Operation.metadata] field type is
772
+ [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
773
+ The [response][google.longrunning.Operation.response] field type
774
+ is [Backup][google.spanner.admin.database.v1.Backup], if
775
+ successful. Cancelling the returned operation will stop the
776
+ copying and delete the destination backup. Concurrent CopyBackup
777
+ requests can run on the same source backup.
778
+
779
+ Returns:
780
+ Callable[[~.CopyBackupRequest],
781
+ ~.Operation]:
782
+ A function that, when called, will call the underlying RPC
783
+ on the server.
784
+ """
785
+ # Generate a "stub function" on-the-fly which will actually make
786
+ # the request.
787
+ # gRPC handles serialization and deserialization, so we just need
788
+ # to pass in the functions for each.
789
+ if "copy_backup" not in self._stubs:
790
+ self._stubs["copy_backup"] = self._logged_channel.unary_unary(
791
+ "/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup",
792
+ request_serializer=backup.CopyBackupRequest.serialize,
793
+ response_deserializer=operations_pb2.Operation.FromString,
794
+ )
795
+ return self._stubs["copy_backup"]
796
+
797
+ @property
798
+ def get_backup(self) -> Callable[[backup.GetBackupRequest], backup.Backup]:
799
+ r"""Return a callable for the get backup method over gRPC.
800
+
801
+ Gets metadata on a pending or completed
802
+ [Backup][google.spanner.admin.database.v1.Backup].
803
+
804
+ Returns:
805
+ Callable[[~.GetBackupRequest],
806
+ ~.Backup]:
807
+ A function that, when called, will call the underlying RPC
808
+ on the server.
809
+ """
810
+ # Generate a "stub function" on-the-fly which will actually make
811
+ # the request.
812
+ # gRPC handles serialization and deserialization, so we just need
813
+ # to pass in the functions for each.
814
+ if "get_backup" not in self._stubs:
815
+ self._stubs["get_backup"] = self._logged_channel.unary_unary(
816
+ "/google.spanner.admin.database.v1.DatabaseAdmin/GetBackup",
817
+ request_serializer=backup.GetBackupRequest.serialize,
818
+ response_deserializer=backup.Backup.deserialize,
819
+ )
820
+ return self._stubs["get_backup"]
821
+
822
+ @property
823
+ def update_backup(
824
+ self,
825
+ ) -> Callable[[gsad_backup.UpdateBackupRequest], gsad_backup.Backup]:
826
+ r"""Return a callable for the update backup method over gRPC.
827
+
828
+ Updates a pending or completed
829
+ [Backup][google.spanner.admin.database.v1.Backup].
830
+
831
+ Returns:
832
+ Callable[[~.UpdateBackupRequest],
833
+ ~.Backup]:
834
+ A function that, when called, will call the underlying RPC
835
+ on the server.
836
+ """
837
+ # Generate a "stub function" on-the-fly which will actually make
838
+ # the request.
839
+ # gRPC handles serialization and deserialization, so we just need
840
+ # to pass in the functions for each.
841
+ if "update_backup" not in self._stubs:
842
+ self._stubs["update_backup"] = self._logged_channel.unary_unary(
843
+ "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup",
844
+ request_serializer=gsad_backup.UpdateBackupRequest.serialize,
845
+ response_deserializer=gsad_backup.Backup.deserialize,
846
+ )
847
+ return self._stubs["update_backup"]
848
+
849
+ @property
850
+ def delete_backup(self) -> Callable[[backup.DeleteBackupRequest], empty_pb2.Empty]:
851
+ r"""Return a callable for the delete backup method over gRPC.
852
+
853
+ Deletes a pending or completed
854
+ [Backup][google.spanner.admin.database.v1.Backup].
855
+
856
+ Returns:
857
+ Callable[[~.DeleteBackupRequest],
858
+ ~.Empty]:
859
+ A function that, when called, will call the underlying RPC
860
+ on the server.
861
+ """
862
+ # Generate a "stub function" on-the-fly which will actually make
863
+ # the request.
864
+ # gRPC handles serialization and deserialization, so we just need
865
+ # to pass in the functions for each.
866
+ if "delete_backup" not in self._stubs:
867
+ self._stubs["delete_backup"] = self._logged_channel.unary_unary(
868
+ "/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup",
869
+ request_serializer=backup.DeleteBackupRequest.serialize,
870
+ response_deserializer=empty_pb2.Empty.FromString,
871
+ )
872
+ return self._stubs["delete_backup"]
873
+
874
+ @property
875
+ def list_backups(
876
+ self,
877
+ ) -> Callable[[backup.ListBackupsRequest], backup.ListBackupsResponse]:
878
+ r"""Return a callable for the list backups method over gRPC.
879
+
880
+ Lists completed and pending backups. Backups returned are
881
+ ordered by ``create_time`` in descending order, starting from
882
+ the most recent ``create_time``.
883
+
884
+ Returns:
885
+ Callable[[~.ListBackupsRequest],
886
+ ~.ListBackupsResponse]:
887
+ A function that, when called, will call the underlying RPC
888
+ on the server.
889
+ """
890
+ # Generate a "stub function" on-the-fly which will actually make
891
+ # the request.
892
+ # gRPC handles serialization and deserialization, so we just need
893
+ # to pass in the functions for each.
894
+ if "list_backups" not in self._stubs:
895
+ self._stubs["list_backups"] = self._logged_channel.unary_unary(
896
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackups",
897
+ request_serializer=backup.ListBackupsRequest.serialize,
898
+ response_deserializer=backup.ListBackupsResponse.deserialize,
899
+ )
900
+ return self._stubs["list_backups"]
901
+
902
+ @property
903
+ def restore_database(
904
+ self,
905
+ ) -> Callable[
906
+ [spanner_database_admin.RestoreDatabaseRequest], operations_pb2.Operation
907
+ ]:
908
+ r"""Return a callable for the restore database method over gRPC.
909
+
910
+ Create a new database by restoring from a completed backup. The
911
+ new database must be in the same project and in an instance with
912
+ the same instance configuration as the instance containing the
913
+ backup. The returned database [long-running
914
+ operation][google.longrunning.Operation] has a name of the
915
+ format
916
+ ``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``,
917
+ and can be used to track the progress of the operation, and to
918
+ cancel it. The [metadata][google.longrunning.Operation.metadata]
919
+ field type is
920
+ [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
921
+ The [response][google.longrunning.Operation.response] type is
922
+ [Database][google.spanner.admin.database.v1.Database], if
923
+ successful. Cancelling the returned operation will stop the
924
+ restore and delete the database. There can be only one database
925
+ being restored into an instance at a time. Once the restore
926
+ operation completes, a new restore operation can be initiated,
927
+ without waiting for the optimize operation associated with the
928
+ first restore to complete.
929
+
930
+ Returns:
931
+ Callable[[~.RestoreDatabaseRequest],
932
+ ~.Operation]:
933
+ A function that, when called, will call the underlying RPC
934
+ on the server.
935
+ """
936
+ # Generate a "stub function" on-the-fly which will actually make
937
+ # the request.
938
+ # gRPC handles serialization and deserialization, so we just need
939
+ # to pass in the functions for each.
940
+ if "restore_database" not in self._stubs:
941
+ self._stubs["restore_database"] = self._logged_channel.unary_unary(
942
+ "/google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase",
943
+ request_serializer=spanner_database_admin.RestoreDatabaseRequest.serialize,
944
+ response_deserializer=operations_pb2.Operation.FromString,
945
+ )
946
+ return self._stubs["restore_database"]
947
+
948
+ @property
949
+ def list_database_operations(
950
+ self,
951
+ ) -> Callable[
952
+ [spanner_database_admin.ListDatabaseOperationsRequest],
953
+ spanner_database_admin.ListDatabaseOperationsResponse,
954
+ ]:
955
+ r"""Return a callable for the list database operations method over gRPC.
956
+
957
+ Lists database
958
+ [longrunning-operations][google.longrunning.Operation]. A
959
+ database operation has a name of the form
960
+ ``projects/<project>/instances/<instance>/databases/<database>/operations/<operation>``.
961
+ The long-running operation
962
+ [metadata][google.longrunning.Operation.metadata] field type
963
+ ``metadata.type_url`` describes the type of the metadata.
964
+ Operations returned include those that have
965
+ completed/failed/canceled within the last 7 days, and pending
966
+ operations.
967
+
968
+ Returns:
969
+ Callable[[~.ListDatabaseOperationsRequest],
970
+ ~.ListDatabaseOperationsResponse]:
971
+ A function that, when called, will call the underlying RPC
972
+ on the server.
973
+ """
974
+ # Generate a "stub function" on-the-fly which will actually make
975
+ # the request.
976
+ # gRPC handles serialization and deserialization, so we just need
977
+ # to pass in the functions for each.
978
+ if "list_database_operations" not in self._stubs:
979
+ self._stubs["list_database_operations"] = self._logged_channel.unary_unary(
980
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations",
981
+ request_serializer=spanner_database_admin.ListDatabaseOperationsRequest.serialize,
982
+ response_deserializer=spanner_database_admin.ListDatabaseOperationsResponse.deserialize,
983
+ )
984
+ return self._stubs["list_database_operations"]
985
+
986
+ @property
987
+ def list_backup_operations(
988
+ self,
989
+ ) -> Callable[
990
+ [backup.ListBackupOperationsRequest], backup.ListBackupOperationsResponse
991
+ ]:
992
+ r"""Return a callable for the list backup operations method over gRPC.
993
+
994
+ Lists the backup [long-running
995
+ operations][google.longrunning.Operation] in the given instance.
996
+ A backup operation has a name of the form
997
+ ``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>``.
998
+ The long-running operation
999
+ [metadata][google.longrunning.Operation.metadata] field type
1000
+ ``metadata.type_url`` describes the type of the metadata.
1001
+ Operations returned include those that have
1002
+ completed/failed/canceled within the last 7 days, and pending
1003
+ operations. Operations returned are ordered by
1004
+ ``operation.metadata.value.progress.start_time`` in descending
1005
+ order starting from the most recently started operation.
1006
+
1007
+ Returns:
1008
+ Callable[[~.ListBackupOperationsRequest],
1009
+ ~.ListBackupOperationsResponse]:
1010
+ A function that, when called, will call the underlying RPC
1011
+ on the server.
1012
+ """
1013
+ # Generate a "stub function" on-the-fly which will actually make
1014
+ # the request.
1015
+ # gRPC handles serialization and deserialization, so we just need
1016
+ # to pass in the functions for each.
1017
+ if "list_backup_operations" not in self._stubs:
1018
+ self._stubs["list_backup_operations"] = self._logged_channel.unary_unary(
1019
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations",
1020
+ request_serializer=backup.ListBackupOperationsRequest.serialize,
1021
+ response_deserializer=backup.ListBackupOperationsResponse.deserialize,
1022
+ )
1023
+ return self._stubs["list_backup_operations"]
1024
+
1025
+ @property
1026
+ def list_database_roles(
1027
+ self,
1028
+ ) -> Callable[
1029
+ [spanner_database_admin.ListDatabaseRolesRequest],
1030
+ spanner_database_admin.ListDatabaseRolesResponse,
1031
+ ]:
1032
+ r"""Return a callable for the list database roles method over gRPC.
1033
+
1034
+ Lists Cloud Spanner database roles.
1035
+
1036
+ Returns:
1037
+ Callable[[~.ListDatabaseRolesRequest],
1038
+ ~.ListDatabaseRolesResponse]:
1039
+ A function that, when called, will call the underlying RPC
1040
+ on the server.
1041
+ """
1042
+ # Generate a "stub function" on-the-fly which will actually make
1043
+ # the request.
1044
+ # gRPC handles serialization and deserialization, so we just need
1045
+ # to pass in the functions for each.
1046
+ if "list_database_roles" not in self._stubs:
1047
+ self._stubs["list_database_roles"] = self._logged_channel.unary_unary(
1048
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseRoles",
1049
+ request_serializer=spanner_database_admin.ListDatabaseRolesRequest.serialize,
1050
+ response_deserializer=spanner_database_admin.ListDatabaseRolesResponse.deserialize,
1051
+ )
1052
+ return self._stubs["list_database_roles"]
1053
+
1054
+ @property
1055
+ def add_split_points(
1056
+ self,
1057
+ ) -> Callable[
1058
+ [spanner_database_admin.AddSplitPointsRequest],
1059
+ spanner_database_admin.AddSplitPointsResponse,
1060
+ ]:
1061
+ r"""Return a callable for the add split points method over gRPC.
1062
+
1063
+ Adds split points to specified tables, indexes of a
1064
+ database.
1065
+
1066
+ Returns:
1067
+ Callable[[~.AddSplitPointsRequest],
1068
+ ~.AddSplitPointsResponse]:
1069
+ A function that, when called, will call the underlying RPC
1070
+ on the server.
1071
+ """
1072
+ # Generate a "stub function" on-the-fly which will actually make
1073
+ # the request.
1074
+ # gRPC handles serialization and deserialization, so we just need
1075
+ # to pass in the functions for each.
1076
+ if "add_split_points" not in self._stubs:
1077
+ self._stubs["add_split_points"] = self._logged_channel.unary_unary(
1078
+ "/google.spanner.admin.database.v1.DatabaseAdmin/AddSplitPoints",
1079
+ request_serializer=spanner_database_admin.AddSplitPointsRequest.serialize,
1080
+ response_deserializer=spanner_database_admin.AddSplitPointsResponse.deserialize,
1081
+ )
1082
+ return self._stubs["add_split_points"]
1083
+
1084
+ @property
1085
+ def create_backup_schedule(
1086
+ self,
1087
+ ) -> Callable[
1088
+ [gsad_backup_schedule.CreateBackupScheduleRequest],
1089
+ gsad_backup_schedule.BackupSchedule,
1090
+ ]:
1091
+ r"""Return a callable for the create backup schedule method over gRPC.
1092
+
1093
+ Creates a new backup schedule.
1094
+
1095
+ Returns:
1096
+ Callable[[~.CreateBackupScheduleRequest],
1097
+ ~.BackupSchedule]:
1098
+ A function that, when called, will call the underlying RPC
1099
+ on the server.
1100
+ """
1101
+ # Generate a "stub function" on-the-fly which will actually make
1102
+ # the request.
1103
+ # gRPC handles serialization and deserialization, so we just need
1104
+ # to pass in the functions for each.
1105
+ if "create_backup_schedule" not in self._stubs:
1106
+ self._stubs["create_backup_schedule"] = self._logged_channel.unary_unary(
1107
+ "/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule",
1108
+ request_serializer=gsad_backup_schedule.CreateBackupScheduleRequest.serialize,
1109
+ response_deserializer=gsad_backup_schedule.BackupSchedule.deserialize,
1110
+ )
1111
+ return self._stubs["create_backup_schedule"]
1112
+
1113
+ @property
1114
+ def get_backup_schedule(
1115
+ self,
1116
+ ) -> Callable[
1117
+ [backup_schedule.GetBackupScheduleRequest], backup_schedule.BackupSchedule
1118
+ ]:
1119
+ r"""Return a callable for the get backup schedule method over gRPC.
1120
+
1121
+ Gets backup schedule for the input schedule name.
1122
+
1123
+ Returns:
1124
+ Callable[[~.GetBackupScheduleRequest],
1125
+ ~.BackupSchedule]:
1126
+ A function that, when called, will call the underlying RPC
1127
+ on the server.
1128
+ """
1129
+ # Generate a "stub function" on-the-fly which will actually make
1130
+ # the request.
1131
+ # gRPC handles serialization and deserialization, so we just need
1132
+ # to pass in the functions for each.
1133
+ if "get_backup_schedule" not in self._stubs:
1134
+ self._stubs["get_backup_schedule"] = self._logged_channel.unary_unary(
1135
+ "/google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule",
1136
+ request_serializer=backup_schedule.GetBackupScheduleRequest.serialize,
1137
+ response_deserializer=backup_schedule.BackupSchedule.deserialize,
1138
+ )
1139
+ return self._stubs["get_backup_schedule"]
1140
+
1141
+ @property
1142
+ def update_backup_schedule(
1143
+ self,
1144
+ ) -> Callable[
1145
+ [gsad_backup_schedule.UpdateBackupScheduleRequest],
1146
+ gsad_backup_schedule.BackupSchedule,
1147
+ ]:
1148
+ r"""Return a callable for the update backup schedule method over gRPC.
1149
+
1150
+ Updates a backup schedule.
1151
+
1152
+ Returns:
1153
+ Callable[[~.UpdateBackupScheduleRequest],
1154
+ ~.BackupSchedule]:
1155
+ A function that, when called, will call the underlying RPC
1156
+ on the server.
1157
+ """
1158
+ # Generate a "stub function" on-the-fly which will actually make
1159
+ # the request.
1160
+ # gRPC handles serialization and deserialization, so we just need
1161
+ # to pass in the functions for each.
1162
+ if "update_backup_schedule" not in self._stubs:
1163
+ self._stubs["update_backup_schedule"] = self._logged_channel.unary_unary(
1164
+ "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule",
1165
+ request_serializer=gsad_backup_schedule.UpdateBackupScheduleRequest.serialize,
1166
+ response_deserializer=gsad_backup_schedule.BackupSchedule.deserialize,
1167
+ )
1168
+ return self._stubs["update_backup_schedule"]
1169
+
1170
+ @property
1171
+ def delete_backup_schedule(
1172
+ self,
1173
+ ) -> Callable[[backup_schedule.DeleteBackupScheduleRequest], empty_pb2.Empty]:
1174
+ r"""Return a callable for the delete backup schedule method over gRPC.
1175
+
1176
+ Deletes a backup schedule.
1177
+
1178
+ Returns:
1179
+ Callable[[~.DeleteBackupScheduleRequest],
1180
+ ~.Empty]:
1181
+ A function that, when called, will call the underlying RPC
1182
+ on the server.
1183
+ """
1184
+ # Generate a "stub function" on-the-fly which will actually make
1185
+ # the request.
1186
+ # gRPC handles serialization and deserialization, so we just need
1187
+ # to pass in the functions for each.
1188
+ if "delete_backup_schedule" not in self._stubs:
1189
+ self._stubs["delete_backup_schedule"] = self._logged_channel.unary_unary(
1190
+ "/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule",
1191
+ request_serializer=backup_schedule.DeleteBackupScheduleRequest.serialize,
1192
+ response_deserializer=empty_pb2.Empty.FromString,
1193
+ )
1194
+ return self._stubs["delete_backup_schedule"]
1195
+
1196
+ @property
1197
+ def list_backup_schedules(
1198
+ self,
1199
+ ) -> Callable[
1200
+ [backup_schedule.ListBackupSchedulesRequest],
1201
+ backup_schedule.ListBackupSchedulesResponse,
1202
+ ]:
1203
+ r"""Return a callable for the list backup schedules method over gRPC.
1204
+
1205
+ Lists all the backup schedules for the database.
1206
+
1207
+ Returns:
1208
+ Callable[[~.ListBackupSchedulesRequest],
1209
+ ~.ListBackupSchedulesResponse]:
1210
+ A function that, when called, will call the underlying RPC
1211
+ on the server.
1212
+ """
1213
+ # Generate a "stub function" on-the-fly which will actually make
1214
+ # the request.
1215
+ # gRPC handles serialization and deserialization, so we just need
1216
+ # to pass in the functions for each.
1217
+ if "list_backup_schedules" not in self._stubs:
1218
+ self._stubs["list_backup_schedules"] = self._logged_channel.unary_unary(
1219
+ "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules",
1220
+ request_serializer=backup_schedule.ListBackupSchedulesRequest.serialize,
1221
+ response_deserializer=backup_schedule.ListBackupSchedulesResponse.deserialize,
1222
+ )
1223
+ return self._stubs["list_backup_schedules"]
1224
+
1225
+ def close(self):
1226
+ self._logged_channel.close()
1227
+
1228
+ @property
1229
+ def delete_operation(
1230
+ self,
1231
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None]:
1232
+ r"""Return a callable for the delete_operation method over gRPC."""
1233
+ # Generate a "stub function" on-the-fly which will actually make
1234
+ # the request.
1235
+ # gRPC handles serialization and deserialization, so we just need
1236
+ # to pass in the functions for each.
1237
+ if "delete_operation" not in self._stubs:
1238
+ self._stubs["delete_operation"] = self._logged_channel.unary_unary(
1239
+ "/google.longrunning.Operations/DeleteOperation",
1240
+ request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString,
1241
+ response_deserializer=None,
1242
+ )
1243
+ return self._stubs["delete_operation"]
1244
+
1245
+ @property
1246
+ def cancel_operation(
1247
+ self,
1248
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
1249
+ r"""Return a callable for the cancel_operation method over gRPC."""
1250
+ # Generate a "stub function" on-the-fly which will actually make
1251
+ # the request.
1252
+ # gRPC handles serialization and deserialization, so we just need
1253
+ # to pass in the functions for each.
1254
+ if "cancel_operation" not in self._stubs:
1255
+ self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
1256
+ "/google.longrunning.Operations/CancelOperation",
1257
+ request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
1258
+ response_deserializer=None,
1259
+ )
1260
+ return self._stubs["cancel_operation"]
1261
+
1262
+ @property
1263
+ def get_operation(
1264
+ self,
1265
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
1266
+ r"""Return a callable for the get_operation method over gRPC."""
1267
+ # Generate a "stub function" on-the-fly which will actually make
1268
+ # the request.
1269
+ # gRPC handles serialization and deserialization, so we just need
1270
+ # to pass in the functions for each.
1271
+ if "get_operation" not in self._stubs:
1272
+ self._stubs["get_operation"] = self._logged_channel.unary_unary(
1273
+ "/google.longrunning.Operations/GetOperation",
1274
+ request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
1275
+ response_deserializer=operations_pb2.Operation.FromString,
1276
+ )
1277
+ return self._stubs["get_operation"]
1278
+
1279
+ @property
1280
+ def list_operations(
1281
+ self,
1282
+ ) -> Callable[
1283
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
1284
+ ]:
1285
+ r"""Return a callable for the list_operations method over gRPC."""
1286
+ # Generate a "stub function" on-the-fly which will actually make
1287
+ # the request.
1288
+ # gRPC handles serialization and deserialization, so we just need
1289
+ # to pass in the functions for each.
1290
+ if "list_operations" not in self._stubs:
1291
+ self._stubs["list_operations"] = self._logged_channel.unary_unary(
1292
+ "/google.longrunning.Operations/ListOperations",
1293
+ request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
1294
+ response_deserializer=operations_pb2.ListOperationsResponse.FromString,
1295
+ )
1296
+ return self._stubs["list_operations"]
1297
+
1298
+ @property
1299
+ def kind(self) -> str:
1300
+ return "grpc"
1301
+
1302
+
1303
+ __all__ = ("DatabaseAdminGrpcTransport",)