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,1347 @@
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_instance_v1.types import spanner_instance_admin
35
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
36
+ from google.iam.v1 import policy_pb2 # type: ignore
37
+ from google.longrunning import operations_pb2 # type: ignore
38
+ from google.protobuf import empty_pb2 # type: ignore
39
+ from .base import InstanceAdminTransport, DEFAULT_CLIENT_INFO
40
+
41
+ try:
42
+ from google.api_core import client_logging # type: ignore
43
+
44
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
45
+ except ImportError: # pragma: NO COVER
46
+ CLIENT_LOGGING_SUPPORTED = False
47
+
48
+ _LOGGER = std_logging.getLogger(__name__)
49
+
50
+
51
+ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
52
+ def intercept_unary_unary(self, continuation, client_call_details, request):
53
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
54
+ std_logging.DEBUG
55
+ )
56
+ if logging_enabled: # pragma: NO COVER
57
+ request_metadata = client_call_details.metadata
58
+ if isinstance(request, proto.Message):
59
+ request_payload = type(request).to_json(request)
60
+ elif isinstance(request, google.protobuf.message.Message):
61
+ request_payload = MessageToJson(request)
62
+ else:
63
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
64
+
65
+ request_metadata = {
66
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
67
+ for key, value in request_metadata
68
+ }
69
+ grpc_request = {
70
+ "payload": request_payload,
71
+ "requestMethod": "grpc",
72
+ "metadata": dict(request_metadata),
73
+ }
74
+ _LOGGER.debug(
75
+ f"Sending request for {client_call_details.method}",
76
+ extra={
77
+ "serviceName": "google.spanner.admin.instance.v1.InstanceAdmin",
78
+ "rpcName": str(client_call_details.method),
79
+ "request": grpc_request,
80
+ "metadata": grpc_request["metadata"],
81
+ },
82
+ )
83
+ response = continuation(client_call_details, request)
84
+ if logging_enabled: # pragma: NO COVER
85
+ response_metadata = response.trailing_metadata()
86
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
87
+ metadata = (
88
+ dict([(k, str(v)) for k, v in response_metadata])
89
+ if response_metadata
90
+ else None
91
+ )
92
+ result = response.result()
93
+ if isinstance(result, proto.Message):
94
+ response_payload = type(result).to_json(result)
95
+ elif isinstance(result, google.protobuf.message.Message):
96
+ response_payload = MessageToJson(result)
97
+ else:
98
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
99
+ grpc_response = {
100
+ "payload": response_payload,
101
+ "metadata": metadata,
102
+ "status": "OK",
103
+ }
104
+ _LOGGER.debug(
105
+ f"Received response for {client_call_details.method}.",
106
+ extra={
107
+ "serviceName": "google.spanner.admin.instance.v1.InstanceAdmin",
108
+ "rpcName": client_call_details.method,
109
+ "response": grpc_response,
110
+ "metadata": grpc_response["metadata"],
111
+ },
112
+ )
113
+ return response
114
+
115
+
116
+ class InstanceAdminGrpcTransport(InstanceAdminTransport):
117
+ """gRPC backend transport for InstanceAdmin.
118
+
119
+ Cloud Spanner Instance Admin API
120
+
121
+ The Cloud Spanner Instance Admin API can be used to create,
122
+ delete, modify and list instances. Instances are dedicated Cloud
123
+ Spanner serving and storage resources to be used by Cloud
124
+ Spanner databases.
125
+
126
+ Each instance has a "configuration", which dictates where the
127
+ serving resources for the Cloud Spanner instance are located
128
+ (e.g., US-central, Europe). Configurations are created by Google
129
+ based on resource availability.
130
+
131
+ Cloud Spanner billing is based on the instances that exist and
132
+ their sizes. After an instance exists, there are no additional
133
+ per-database or per-operation charges for use of the instance
134
+ (though there may be additional network bandwidth charges).
135
+ Instances offer isolation: problems with databases in one
136
+ instance will not affect other instances. However, within an
137
+ instance databases can affect each other. For example, if one
138
+ database in an instance receives a lot of requests and consumes
139
+ most of the instance resources, fewer resources are available
140
+ for other databases in that instance, and their performance may
141
+ suffer.
142
+
143
+ This class defines the same methods as the primary client, so the
144
+ primary client can load the underlying transport implementation
145
+ and call it.
146
+
147
+ It sends protocol buffers over the wire using gRPC (which is built on
148
+ top of HTTP/2); the ``grpcio`` package must be installed.
149
+ """
150
+
151
+ _stubs: Dict[str, Callable]
152
+
153
+ def __init__(
154
+ self,
155
+ *,
156
+ host: str = "spanner.googleapis.com",
157
+ credentials: Optional[ga_credentials.Credentials] = None,
158
+ credentials_file: Optional[str] = None,
159
+ scopes: Optional[Sequence[str]] = None,
160
+ channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
161
+ api_mtls_endpoint: Optional[str] = None,
162
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
163
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
164
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
165
+ quota_project_id: Optional[str] = None,
166
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
167
+ always_use_jwt_access: Optional[bool] = False,
168
+ api_audience: Optional[str] = None,
169
+ ) -> None:
170
+ """Instantiate the transport.
171
+
172
+ Args:
173
+ host (Optional[str]):
174
+ The hostname to connect to (default: 'spanner.googleapis.com').
175
+ credentials (Optional[google.auth.credentials.Credentials]): The
176
+ authorization credentials to attach to requests. These
177
+ credentials identify the application to the service; if none
178
+ are specified, the client will attempt to ascertain the
179
+ credentials from the environment.
180
+ This argument is ignored if a ``channel`` instance is provided.
181
+ credentials_file (Optional[str]): A file with credentials that can
182
+ be loaded with :func:`google.auth.load_credentials_from_file`.
183
+ This argument is ignored if a ``channel`` instance is provided.
184
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
185
+ ignored if a ``channel`` instance is provided.
186
+ channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
187
+ A ``Channel`` instance through which to make calls, or a Callable
188
+ that constructs and returns one. If set to None, ``self.create_channel``
189
+ is used to create the channel. If a Callable is given, it will be called
190
+ with the same arguments as used in ``self.create_channel``.
191
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
192
+ If provided, it overrides the ``host`` argument and tries to create
193
+ a mutual TLS channel with client SSL credentials from
194
+ ``client_cert_source`` or application default SSL credentials.
195
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
196
+ Deprecated. A callback to provide client SSL certificate bytes and
197
+ private key bytes, both in PEM format. It is ignored if
198
+ ``api_mtls_endpoint`` is None.
199
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
200
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
201
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
202
+ A callback to provide client certificate bytes and private key bytes,
203
+ both in PEM format. It is used to configure a mutual TLS channel. It is
204
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
205
+ quota_project_id (Optional[str]): An optional project to use for billing
206
+ and quota.
207
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
208
+ The client info used to send a user-agent string along with
209
+ API requests. If ``None``, then default info will be used.
210
+ Generally, you only need to set this if you're developing
211
+ your own client library.
212
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
213
+ be used for service account credentials.
214
+
215
+ Raises:
216
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
217
+ creation failed for any reason.
218
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
219
+ and ``credentials_file`` are passed.
220
+ """
221
+ self._grpc_channel = None
222
+ self._ssl_channel_credentials = ssl_channel_credentials
223
+ self._stubs: Dict[str, Callable] = {}
224
+ self._operations_client: Optional[operations_v1.OperationsClient] = None
225
+
226
+ if api_mtls_endpoint:
227
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
228
+ if client_cert_source:
229
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
230
+
231
+ if isinstance(channel, grpc.Channel):
232
+ # Ignore credentials if a channel was passed.
233
+ credentials = None
234
+ self._ignore_credentials = True
235
+ # If a channel was explicitly provided, set it.
236
+ self._grpc_channel = channel
237
+ self._ssl_channel_credentials = None
238
+
239
+ else:
240
+ if api_mtls_endpoint:
241
+ host = api_mtls_endpoint
242
+
243
+ # Create SSL credentials with client_cert_source or application
244
+ # default SSL credentials.
245
+ if client_cert_source:
246
+ cert, key = client_cert_source()
247
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
248
+ certificate_chain=cert, private_key=key
249
+ )
250
+ else:
251
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
252
+
253
+ else:
254
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
255
+ cert, key = client_cert_source_for_mtls()
256
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
257
+ certificate_chain=cert, private_key=key
258
+ )
259
+
260
+ # The base transport sets the host, credentials and scopes
261
+ super().__init__(
262
+ host=host,
263
+ credentials=credentials,
264
+ credentials_file=credentials_file,
265
+ scopes=scopes,
266
+ quota_project_id=quota_project_id,
267
+ client_info=client_info,
268
+ always_use_jwt_access=always_use_jwt_access,
269
+ api_audience=api_audience,
270
+ )
271
+
272
+ if not self._grpc_channel:
273
+ # initialize with the provided callable or the default channel
274
+ channel_init = channel or type(self).create_channel
275
+ self._grpc_channel = channel_init(
276
+ self._host,
277
+ # use the credentials which are saved
278
+ credentials=self._credentials,
279
+ # Set ``credentials_file`` to ``None`` here as
280
+ # the credentials that we saved earlier should be used.
281
+ credentials_file=None,
282
+ scopes=self._scopes,
283
+ ssl_credentials=self._ssl_channel_credentials,
284
+ quota_project_id=quota_project_id,
285
+ options=[
286
+ ("grpc.max_send_message_length", -1),
287
+ ("grpc.max_receive_message_length", -1),
288
+ ],
289
+ )
290
+
291
+ self._interceptor = _LoggingClientInterceptor()
292
+ self._logged_channel = grpc.intercept_channel(
293
+ self._grpc_channel, self._interceptor
294
+ )
295
+
296
+ # Wrap messages. This must be done after self._logged_channel exists
297
+ self._prep_wrapped_messages(client_info)
298
+
299
+ @classmethod
300
+ def create_channel(
301
+ cls,
302
+ host: str = "spanner.googleapis.com",
303
+ credentials: Optional[ga_credentials.Credentials] = None,
304
+ credentials_file: Optional[str] = None,
305
+ scopes: Optional[Sequence[str]] = None,
306
+ quota_project_id: Optional[str] = None,
307
+ **kwargs,
308
+ ) -> grpc.Channel:
309
+ """Create and return a gRPC channel object.
310
+ Args:
311
+ host (Optional[str]): The host for the channel to use.
312
+ credentials (Optional[~.Credentials]): The
313
+ authorization credentials to attach to requests. These
314
+ credentials identify this application to the service. If
315
+ none are specified, the client will attempt to ascertain
316
+ the credentials from the environment.
317
+ credentials_file (Optional[str]): A file with credentials that can
318
+ be loaded with :func:`google.auth.load_credentials_from_file`.
319
+ This argument is mutually exclusive with credentials.
320
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
321
+ service. These are only used when credentials are not specified and
322
+ are passed to :func:`google.auth.default`.
323
+ quota_project_id (Optional[str]): An optional project to use for billing
324
+ and quota.
325
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
326
+ channel creation.
327
+ Returns:
328
+ grpc.Channel: A gRPC channel object.
329
+
330
+ Raises:
331
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
332
+ and ``credentials_file`` are passed.
333
+ """
334
+
335
+ return grpc_helpers.create_channel(
336
+ host,
337
+ credentials=credentials,
338
+ credentials_file=credentials_file,
339
+ quota_project_id=quota_project_id,
340
+ default_scopes=cls.AUTH_SCOPES,
341
+ scopes=scopes,
342
+ default_host=cls.DEFAULT_HOST,
343
+ **kwargs,
344
+ )
345
+
346
+ @property
347
+ def grpc_channel(self) -> grpc.Channel:
348
+ """Return the channel designed to connect to this service."""
349
+ return self._grpc_channel
350
+
351
+ @property
352
+ def operations_client(self) -> operations_v1.OperationsClient:
353
+ """Create the client designed to process long-running operations.
354
+
355
+ This property caches on the instance; repeated calls return the same
356
+ client.
357
+ """
358
+ # Quick check: Only create a new client if we do not already have one.
359
+ if self._operations_client is None:
360
+ self._operations_client = operations_v1.OperationsClient(
361
+ self._logged_channel
362
+ )
363
+
364
+ # Return the client from cache.
365
+ return self._operations_client
366
+
367
+ @property
368
+ def list_instance_configs(
369
+ self,
370
+ ) -> Callable[
371
+ [spanner_instance_admin.ListInstanceConfigsRequest],
372
+ spanner_instance_admin.ListInstanceConfigsResponse,
373
+ ]:
374
+ r"""Return a callable for the list instance configs method over gRPC.
375
+
376
+ Lists the supported instance configurations for a
377
+ given project.
378
+ Returns both Google-managed configurations and
379
+ user-managed configurations.
380
+
381
+ Returns:
382
+ Callable[[~.ListInstanceConfigsRequest],
383
+ ~.ListInstanceConfigsResponse]:
384
+ A function that, when called, will call the underlying RPC
385
+ on the server.
386
+ """
387
+ # Generate a "stub function" on-the-fly which will actually make
388
+ # the request.
389
+ # gRPC handles serialization and deserialization, so we just need
390
+ # to pass in the functions for each.
391
+ if "list_instance_configs" not in self._stubs:
392
+ self._stubs["list_instance_configs"] = self._logged_channel.unary_unary(
393
+ "/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigs",
394
+ request_serializer=spanner_instance_admin.ListInstanceConfigsRequest.serialize,
395
+ response_deserializer=spanner_instance_admin.ListInstanceConfigsResponse.deserialize,
396
+ )
397
+ return self._stubs["list_instance_configs"]
398
+
399
+ @property
400
+ def get_instance_config(
401
+ self,
402
+ ) -> Callable[
403
+ [spanner_instance_admin.GetInstanceConfigRequest],
404
+ spanner_instance_admin.InstanceConfig,
405
+ ]:
406
+ r"""Return a callable for the get instance config method over gRPC.
407
+
408
+ Gets information about a particular instance
409
+ configuration.
410
+
411
+ Returns:
412
+ Callable[[~.GetInstanceConfigRequest],
413
+ ~.InstanceConfig]:
414
+ A function that, when called, will call the underlying RPC
415
+ on the server.
416
+ """
417
+ # Generate a "stub function" on-the-fly which will actually make
418
+ # the request.
419
+ # gRPC handles serialization and deserialization, so we just need
420
+ # to pass in the functions for each.
421
+ if "get_instance_config" not in self._stubs:
422
+ self._stubs["get_instance_config"] = self._logged_channel.unary_unary(
423
+ "/google.spanner.admin.instance.v1.InstanceAdmin/GetInstanceConfig",
424
+ request_serializer=spanner_instance_admin.GetInstanceConfigRequest.serialize,
425
+ response_deserializer=spanner_instance_admin.InstanceConfig.deserialize,
426
+ )
427
+ return self._stubs["get_instance_config"]
428
+
429
+ @property
430
+ def create_instance_config(
431
+ self,
432
+ ) -> Callable[
433
+ [spanner_instance_admin.CreateInstanceConfigRequest], operations_pb2.Operation
434
+ ]:
435
+ r"""Return a callable for the create instance config method over gRPC.
436
+
437
+ Creates an instance configuration and begins preparing it to be
438
+ used. The returned long-running operation can be used to track
439
+ the progress of preparing the new instance configuration. The
440
+ instance configuration name is assigned by the caller. If the
441
+ named instance configuration already exists,
442
+ ``CreateInstanceConfig`` returns ``ALREADY_EXISTS``.
443
+
444
+ Immediately after the request returns:
445
+
446
+ - The instance configuration is readable via the API, with all
447
+ requested attributes. The instance configuration's
448
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
449
+ field is set to true. Its state is ``CREATING``.
450
+
451
+ While the operation is pending:
452
+
453
+ - Cancelling the operation renders the instance configuration
454
+ immediately unreadable via the API.
455
+ - Except for deleting the creating resource, all other attempts
456
+ to modify the instance configuration are rejected.
457
+
458
+ Upon completion of the returned operation:
459
+
460
+ - Instances can be created using the instance configuration.
461
+ - The instance configuration's
462
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
463
+ field becomes false. Its state becomes ``READY``.
464
+
465
+ The returned long-running operation will have a name of the
466
+ format ``<instance_config_name>/operations/<operation_id>`` and
467
+ can be used to track creation of the instance configuration. The
468
+ metadata field type is
469
+ [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata].
470
+ The response field type is
471
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig],
472
+ if successful.
473
+
474
+ Authorization requires ``spanner.instanceConfigs.create``
475
+ permission on the resource
476
+ [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent].
477
+
478
+ Returns:
479
+ Callable[[~.CreateInstanceConfigRequest],
480
+ ~.Operation]:
481
+ A function that, when called, will call the underlying RPC
482
+ on the server.
483
+ """
484
+ # Generate a "stub function" on-the-fly which will actually make
485
+ # the request.
486
+ # gRPC handles serialization and deserialization, so we just need
487
+ # to pass in the functions for each.
488
+ if "create_instance_config" not in self._stubs:
489
+ self._stubs["create_instance_config"] = self._logged_channel.unary_unary(
490
+ "/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstanceConfig",
491
+ request_serializer=spanner_instance_admin.CreateInstanceConfigRequest.serialize,
492
+ response_deserializer=operations_pb2.Operation.FromString,
493
+ )
494
+ return self._stubs["create_instance_config"]
495
+
496
+ @property
497
+ def update_instance_config(
498
+ self,
499
+ ) -> Callable[
500
+ [spanner_instance_admin.UpdateInstanceConfigRequest], operations_pb2.Operation
501
+ ]:
502
+ r"""Return a callable for the update instance config method over gRPC.
503
+
504
+ Updates an instance configuration. The returned long-running
505
+ operation can be used to track the progress of updating the
506
+ instance. If the named instance configuration does not exist,
507
+ returns ``NOT_FOUND``.
508
+
509
+ Only user-managed configurations can be updated.
510
+
511
+ Immediately after the request returns:
512
+
513
+ - The instance configuration's
514
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
515
+ field is set to true.
516
+
517
+ While the operation is pending:
518
+
519
+ - Cancelling the operation sets its metadata's
520
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time].
521
+ The operation is guaranteed to succeed at undoing all
522
+ changes, after which point it terminates with a ``CANCELLED``
523
+ status.
524
+ - All other attempts to modify the instance configuration are
525
+ rejected.
526
+ - Reading the instance configuration via the API continues to
527
+ give the pre-request values.
528
+
529
+ Upon completion of the returned operation:
530
+
531
+ - Creating instances using the instance configuration uses the
532
+ new values.
533
+ - The new values of the instance configuration are readable via
534
+ the API.
535
+ - The instance configuration's
536
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
537
+ field becomes false.
538
+
539
+ The returned long-running operation will have a name of the
540
+ format ``<instance_config_name>/operations/<operation_id>`` and
541
+ can be used to track the instance configuration modification.
542
+ The metadata field type is
543
+ [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata].
544
+ The response field type is
545
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig],
546
+ if successful.
547
+
548
+ Authorization requires ``spanner.instanceConfigs.update``
549
+ permission on the resource
550
+ [name][google.spanner.admin.instance.v1.InstanceConfig.name].
551
+
552
+ Returns:
553
+ Callable[[~.UpdateInstanceConfigRequest],
554
+ ~.Operation]:
555
+ A function that, when called, will call the underlying RPC
556
+ on the server.
557
+ """
558
+ # Generate a "stub function" on-the-fly which will actually make
559
+ # the request.
560
+ # gRPC handles serialization and deserialization, so we just need
561
+ # to pass in the functions for each.
562
+ if "update_instance_config" not in self._stubs:
563
+ self._stubs["update_instance_config"] = self._logged_channel.unary_unary(
564
+ "/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstanceConfig",
565
+ request_serializer=spanner_instance_admin.UpdateInstanceConfigRequest.serialize,
566
+ response_deserializer=operations_pb2.Operation.FromString,
567
+ )
568
+ return self._stubs["update_instance_config"]
569
+
570
+ @property
571
+ def delete_instance_config(
572
+ self,
573
+ ) -> Callable[
574
+ [spanner_instance_admin.DeleteInstanceConfigRequest], empty_pb2.Empty
575
+ ]:
576
+ r"""Return a callable for the delete instance config method over gRPC.
577
+
578
+ Deletes the instance configuration. Deletion is only allowed
579
+ when no instances are using the configuration. If any instances
580
+ are using the configuration, returns ``FAILED_PRECONDITION``.
581
+
582
+ Only user-managed configurations can be deleted.
583
+
584
+ Authorization requires ``spanner.instanceConfigs.delete``
585
+ permission on the resource
586
+ [name][google.spanner.admin.instance.v1.InstanceConfig.name].
587
+
588
+ Returns:
589
+ Callable[[~.DeleteInstanceConfigRequest],
590
+ ~.Empty]:
591
+ A function that, when called, will call the underlying RPC
592
+ on the server.
593
+ """
594
+ # Generate a "stub function" on-the-fly which will actually make
595
+ # the request.
596
+ # gRPC handles serialization and deserialization, so we just need
597
+ # to pass in the functions for each.
598
+ if "delete_instance_config" not in self._stubs:
599
+ self._stubs["delete_instance_config"] = self._logged_channel.unary_unary(
600
+ "/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstanceConfig",
601
+ request_serializer=spanner_instance_admin.DeleteInstanceConfigRequest.serialize,
602
+ response_deserializer=empty_pb2.Empty.FromString,
603
+ )
604
+ return self._stubs["delete_instance_config"]
605
+
606
+ @property
607
+ def list_instance_config_operations(
608
+ self,
609
+ ) -> Callable[
610
+ [spanner_instance_admin.ListInstanceConfigOperationsRequest],
611
+ spanner_instance_admin.ListInstanceConfigOperationsResponse,
612
+ ]:
613
+ r"""Return a callable for the list instance config
614
+ operations method over gRPC.
615
+
616
+ Lists the user-managed instance configuration long-running
617
+ operations in the given project. An instance configuration
618
+ operation has a name of the form
619
+ ``projects/<project>/instanceConfigs/<instance_config>/operations/<operation>``.
620
+ The long-running operation metadata field type
621
+ ``metadata.type_url`` describes the type of the metadata.
622
+ Operations returned include those that have
623
+ completed/failed/canceled within the last 7 days, and pending
624
+ operations. Operations returned are ordered by
625
+ ``operation.metadata.value.start_time`` in descending order
626
+ starting from the most recently started operation.
627
+
628
+ Returns:
629
+ Callable[[~.ListInstanceConfigOperationsRequest],
630
+ ~.ListInstanceConfigOperationsResponse]:
631
+ A function that, when called, will call the underlying RPC
632
+ on the server.
633
+ """
634
+ # Generate a "stub function" on-the-fly which will actually make
635
+ # the request.
636
+ # gRPC handles serialization and deserialization, so we just need
637
+ # to pass in the functions for each.
638
+ if "list_instance_config_operations" not in self._stubs:
639
+ self._stubs[
640
+ "list_instance_config_operations"
641
+ ] = self._logged_channel.unary_unary(
642
+ "/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigOperations",
643
+ request_serializer=spanner_instance_admin.ListInstanceConfigOperationsRequest.serialize,
644
+ response_deserializer=spanner_instance_admin.ListInstanceConfigOperationsResponse.deserialize,
645
+ )
646
+ return self._stubs["list_instance_config_operations"]
647
+
648
+ @property
649
+ def list_instances(
650
+ self,
651
+ ) -> Callable[
652
+ [spanner_instance_admin.ListInstancesRequest],
653
+ spanner_instance_admin.ListInstancesResponse,
654
+ ]:
655
+ r"""Return a callable for the list instances method over gRPC.
656
+
657
+ Lists all instances in the given project.
658
+
659
+ Returns:
660
+ Callable[[~.ListInstancesRequest],
661
+ ~.ListInstancesResponse]:
662
+ A function that, when called, will call the underlying RPC
663
+ on the server.
664
+ """
665
+ # Generate a "stub function" on-the-fly which will actually make
666
+ # the request.
667
+ # gRPC handles serialization and deserialization, so we just need
668
+ # to pass in the functions for each.
669
+ if "list_instances" not in self._stubs:
670
+ self._stubs["list_instances"] = self._logged_channel.unary_unary(
671
+ "/google.spanner.admin.instance.v1.InstanceAdmin/ListInstances",
672
+ request_serializer=spanner_instance_admin.ListInstancesRequest.serialize,
673
+ response_deserializer=spanner_instance_admin.ListInstancesResponse.deserialize,
674
+ )
675
+ return self._stubs["list_instances"]
676
+
677
+ @property
678
+ def list_instance_partitions(
679
+ self,
680
+ ) -> Callable[
681
+ [spanner_instance_admin.ListInstancePartitionsRequest],
682
+ spanner_instance_admin.ListInstancePartitionsResponse,
683
+ ]:
684
+ r"""Return a callable for the list instance partitions method over gRPC.
685
+
686
+ Lists all instance partitions for the given instance.
687
+
688
+ Returns:
689
+ Callable[[~.ListInstancePartitionsRequest],
690
+ ~.ListInstancePartitionsResponse]:
691
+ A function that, when called, will call the underlying RPC
692
+ on the server.
693
+ """
694
+ # Generate a "stub function" on-the-fly which will actually make
695
+ # the request.
696
+ # gRPC handles serialization and deserialization, so we just need
697
+ # to pass in the functions for each.
698
+ if "list_instance_partitions" not in self._stubs:
699
+ self._stubs["list_instance_partitions"] = self._logged_channel.unary_unary(
700
+ "/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitions",
701
+ request_serializer=spanner_instance_admin.ListInstancePartitionsRequest.serialize,
702
+ response_deserializer=spanner_instance_admin.ListInstancePartitionsResponse.deserialize,
703
+ )
704
+ return self._stubs["list_instance_partitions"]
705
+
706
+ @property
707
+ def get_instance(
708
+ self,
709
+ ) -> Callable[
710
+ [spanner_instance_admin.GetInstanceRequest], spanner_instance_admin.Instance
711
+ ]:
712
+ r"""Return a callable for the get instance method over gRPC.
713
+
714
+ Gets information about a particular instance.
715
+
716
+ Returns:
717
+ Callable[[~.GetInstanceRequest],
718
+ ~.Instance]:
719
+ A function that, when called, will call the underlying RPC
720
+ on the server.
721
+ """
722
+ # Generate a "stub function" on-the-fly which will actually make
723
+ # the request.
724
+ # gRPC handles serialization and deserialization, so we just need
725
+ # to pass in the functions for each.
726
+ if "get_instance" not in self._stubs:
727
+ self._stubs["get_instance"] = self._logged_channel.unary_unary(
728
+ "/google.spanner.admin.instance.v1.InstanceAdmin/GetInstance",
729
+ request_serializer=spanner_instance_admin.GetInstanceRequest.serialize,
730
+ response_deserializer=spanner_instance_admin.Instance.deserialize,
731
+ )
732
+ return self._stubs["get_instance"]
733
+
734
+ @property
735
+ def create_instance(
736
+ self,
737
+ ) -> Callable[
738
+ [spanner_instance_admin.CreateInstanceRequest], operations_pb2.Operation
739
+ ]:
740
+ r"""Return a callable for the create instance method over gRPC.
741
+
742
+ Creates an instance and begins preparing it to begin serving.
743
+ The returned long-running operation can be used to track the
744
+ progress of preparing the new instance. The instance name is
745
+ assigned by the caller. If the named instance already exists,
746
+ ``CreateInstance`` returns ``ALREADY_EXISTS``.
747
+
748
+ Immediately upon completion of this request:
749
+
750
+ - The instance is readable via the API, with all requested
751
+ attributes but no allocated resources. Its state is
752
+ ``CREATING``.
753
+
754
+ Until completion of the returned operation:
755
+
756
+ - Cancelling the operation renders the instance immediately
757
+ unreadable via the API.
758
+ - The instance can be deleted.
759
+ - All other attempts to modify the instance are rejected.
760
+
761
+ Upon completion of the returned operation:
762
+
763
+ - Billing for all successfully-allocated resources begins (some
764
+ types may have lower than the requested levels).
765
+ - Databases can be created in the instance.
766
+ - The instance's allocated resource levels are readable via the
767
+ API.
768
+ - The instance's state becomes ``READY``.
769
+
770
+ The returned long-running operation will have a name of the
771
+ format ``<instance_name>/operations/<operation_id>`` and can be
772
+ used to track creation of the instance. The metadata field type
773
+ is
774
+ [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata].
775
+ The response field type is
776
+ [Instance][google.spanner.admin.instance.v1.Instance], if
777
+ successful.
778
+
779
+ Returns:
780
+ Callable[[~.CreateInstanceRequest],
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 "create_instance" not in self._stubs:
790
+ self._stubs["create_instance"] = self._logged_channel.unary_unary(
791
+ "/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance",
792
+ request_serializer=spanner_instance_admin.CreateInstanceRequest.serialize,
793
+ response_deserializer=operations_pb2.Operation.FromString,
794
+ )
795
+ return self._stubs["create_instance"]
796
+
797
+ @property
798
+ def update_instance(
799
+ self,
800
+ ) -> Callable[
801
+ [spanner_instance_admin.UpdateInstanceRequest], operations_pb2.Operation
802
+ ]:
803
+ r"""Return a callable for the update instance method over gRPC.
804
+
805
+ Updates an instance, and begins allocating or releasing
806
+ resources as requested. The returned long-running operation can
807
+ be used to track the progress of updating the instance. If the
808
+ named instance does not exist, returns ``NOT_FOUND``.
809
+
810
+ Immediately upon completion of this request:
811
+
812
+ - For resource types for which a decrease in the instance's
813
+ allocation has been requested, billing is based on the
814
+ newly-requested level.
815
+
816
+ Until completion of the returned operation:
817
+
818
+ - Cancelling the operation sets its metadata's
819
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time],
820
+ and begins restoring resources to their pre-request values.
821
+ The operation is guaranteed to succeed at undoing all
822
+ resource changes, after which point it terminates with a
823
+ ``CANCELLED`` status.
824
+ - All other attempts to modify the instance are rejected.
825
+ - Reading the instance via the API continues to give the
826
+ pre-request resource levels.
827
+
828
+ Upon completion of the returned operation:
829
+
830
+ - Billing begins for all successfully-allocated resources (some
831
+ types may have lower than the requested levels).
832
+ - All newly-reserved resources are available for serving the
833
+ instance's tables.
834
+ - The instance's new resource levels are readable via the API.
835
+
836
+ The returned long-running operation will have a name of the
837
+ format ``<instance_name>/operations/<operation_id>`` and can be
838
+ used to track the instance modification. The metadata field type
839
+ is
840
+ [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata].
841
+ The response field type is
842
+ [Instance][google.spanner.admin.instance.v1.Instance], if
843
+ successful.
844
+
845
+ Authorization requires ``spanner.instances.update`` permission
846
+ on the resource
847
+ [name][google.spanner.admin.instance.v1.Instance.name].
848
+
849
+ Returns:
850
+ Callable[[~.UpdateInstanceRequest],
851
+ ~.Operation]:
852
+ A function that, when called, will call the underlying RPC
853
+ on the server.
854
+ """
855
+ # Generate a "stub function" on-the-fly which will actually make
856
+ # the request.
857
+ # gRPC handles serialization and deserialization, so we just need
858
+ # to pass in the functions for each.
859
+ if "update_instance" not in self._stubs:
860
+ self._stubs["update_instance"] = self._logged_channel.unary_unary(
861
+ "/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance",
862
+ request_serializer=spanner_instance_admin.UpdateInstanceRequest.serialize,
863
+ response_deserializer=operations_pb2.Operation.FromString,
864
+ )
865
+ return self._stubs["update_instance"]
866
+
867
+ @property
868
+ def delete_instance(
869
+ self,
870
+ ) -> Callable[[spanner_instance_admin.DeleteInstanceRequest], empty_pb2.Empty]:
871
+ r"""Return a callable for the delete instance method over gRPC.
872
+
873
+ Deletes an instance.
874
+
875
+ Immediately upon completion of the request:
876
+
877
+ - Billing ceases for all of the instance's reserved resources.
878
+
879
+ Soon afterward:
880
+
881
+ - The instance and *all of its databases* immediately and
882
+ irrevocably disappear from the API. All data in the databases
883
+ is permanently deleted.
884
+
885
+ Returns:
886
+ Callable[[~.DeleteInstanceRequest],
887
+ ~.Empty]:
888
+ A function that, when called, will call the underlying RPC
889
+ on the server.
890
+ """
891
+ # Generate a "stub function" on-the-fly which will actually make
892
+ # the request.
893
+ # gRPC handles serialization and deserialization, so we just need
894
+ # to pass in the functions for each.
895
+ if "delete_instance" not in self._stubs:
896
+ self._stubs["delete_instance"] = self._logged_channel.unary_unary(
897
+ "/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstance",
898
+ request_serializer=spanner_instance_admin.DeleteInstanceRequest.serialize,
899
+ response_deserializer=empty_pb2.Empty.FromString,
900
+ )
901
+ return self._stubs["delete_instance"]
902
+
903
+ @property
904
+ def set_iam_policy(
905
+ self,
906
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
907
+ r"""Return a callable for the set iam policy method over gRPC.
908
+
909
+ Sets the access control policy on an instance resource. Replaces
910
+ any existing policy.
911
+
912
+ Authorization requires ``spanner.instances.setIamPolicy`` on
913
+ [resource][google.iam.v1.SetIamPolicyRequest.resource].
914
+
915
+ Returns:
916
+ Callable[[~.SetIamPolicyRequest],
917
+ ~.Policy]:
918
+ A function that, when called, will call the underlying RPC
919
+ on the server.
920
+ """
921
+ # Generate a "stub function" on-the-fly which will actually make
922
+ # the request.
923
+ # gRPC handles serialization and deserialization, so we just need
924
+ # to pass in the functions for each.
925
+ if "set_iam_policy" not in self._stubs:
926
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
927
+ "/google.spanner.admin.instance.v1.InstanceAdmin/SetIamPolicy",
928
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
929
+ response_deserializer=policy_pb2.Policy.FromString,
930
+ )
931
+ return self._stubs["set_iam_policy"]
932
+
933
+ @property
934
+ def get_iam_policy(
935
+ self,
936
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
937
+ r"""Return a callable for the get iam policy method over gRPC.
938
+
939
+ Gets the access control policy for an instance resource. Returns
940
+ an empty policy if an instance exists but does not have a policy
941
+ set.
942
+
943
+ Authorization requires ``spanner.instances.getIamPolicy`` on
944
+ [resource][google.iam.v1.GetIamPolicyRequest.resource].
945
+
946
+ Returns:
947
+ Callable[[~.GetIamPolicyRequest],
948
+ ~.Policy]:
949
+ A function that, when called, will call the underlying RPC
950
+ on the server.
951
+ """
952
+ # Generate a "stub function" on-the-fly which will actually make
953
+ # the request.
954
+ # gRPC handles serialization and deserialization, so we just need
955
+ # to pass in the functions for each.
956
+ if "get_iam_policy" not in self._stubs:
957
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
958
+ "/google.spanner.admin.instance.v1.InstanceAdmin/GetIamPolicy",
959
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
960
+ response_deserializer=policy_pb2.Policy.FromString,
961
+ )
962
+ return self._stubs["get_iam_policy"]
963
+
964
+ @property
965
+ def test_iam_permissions(
966
+ self,
967
+ ) -> Callable[
968
+ [iam_policy_pb2.TestIamPermissionsRequest],
969
+ iam_policy_pb2.TestIamPermissionsResponse,
970
+ ]:
971
+ r"""Return a callable for the test iam permissions method over gRPC.
972
+
973
+ Returns permissions that the caller has on the specified
974
+ instance resource.
975
+
976
+ Attempting this RPC on a non-existent Cloud Spanner instance
977
+ resource will result in a NOT_FOUND error if the user has
978
+ ``spanner.instances.list`` permission on the containing Google
979
+ Cloud Project. Otherwise returns an empty set of permissions.
980
+
981
+ Returns:
982
+ Callable[[~.TestIamPermissionsRequest],
983
+ ~.TestIamPermissionsResponse]:
984
+ A function that, when called, will call the underlying RPC
985
+ on the server.
986
+ """
987
+ # Generate a "stub function" on-the-fly which will actually make
988
+ # the request.
989
+ # gRPC handles serialization and deserialization, so we just need
990
+ # to pass in the functions for each.
991
+ if "test_iam_permissions" not in self._stubs:
992
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
993
+ "/google.spanner.admin.instance.v1.InstanceAdmin/TestIamPermissions",
994
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
995
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
996
+ )
997
+ return self._stubs["test_iam_permissions"]
998
+
999
+ @property
1000
+ def get_instance_partition(
1001
+ self,
1002
+ ) -> Callable[
1003
+ [spanner_instance_admin.GetInstancePartitionRequest],
1004
+ spanner_instance_admin.InstancePartition,
1005
+ ]:
1006
+ r"""Return a callable for the get instance partition method over gRPC.
1007
+
1008
+ Gets information about a particular instance
1009
+ partition.
1010
+
1011
+ Returns:
1012
+ Callable[[~.GetInstancePartitionRequest],
1013
+ ~.InstancePartition]:
1014
+ A function that, when called, will call the underlying RPC
1015
+ on the server.
1016
+ """
1017
+ # Generate a "stub function" on-the-fly which will actually make
1018
+ # the request.
1019
+ # gRPC handles serialization and deserialization, so we just need
1020
+ # to pass in the functions for each.
1021
+ if "get_instance_partition" not in self._stubs:
1022
+ self._stubs["get_instance_partition"] = self._logged_channel.unary_unary(
1023
+ "/google.spanner.admin.instance.v1.InstanceAdmin/GetInstancePartition",
1024
+ request_serializer=spanner_instance_admin.GetInstancePartitionRequest.serialize,
1025
+ response_deserializer=spanner_instance_admin.InstancePartition.deserialize,
1026
+ )
1027
+ return self._stubs["get_instance_partition"]
1028
+
1029
+ @property
1030
+ def create_instance_partition(
1031
+ self,
1032
+ ) -> Callable[
1033
+ [spanner_instance_admin.CreateInstancePartitionRequest],
1034
+ operations_pb2.Operation,
1035
+ ]:
1036
+ r"""Return a callable for the create instance partition method over gRPC.
1037
+
1038
+ Creates an instance partition and begins preparing it to be
1039
+ used. The returned long-running operation can be used to track
1040
+ the progress of preparing the new instance partition. The
1041
+ instance partition name is assigned by the caller. If the named
1042
+ instance partition already exists, ``CreateInstancePartition``
1043
+ returns ``ALREADY_EXISTS``.
1044
+
1045
+ Immediately upon completion of this request:
1046
+
1047
+ - The instance partition is readable via the API, with all
1048
+ requested attributes but no allocated resources. Its state is
1049
+ ``CREATING``.
1050
+
1051
+ Until completion of the returned operation:
1052
+
1053
+ - Cancelling the operation renders the instance partition
1054
+ immediately unreadable via the API.
1055
+ - The instance partition can be deleted.
1056
+ - All other attempts to modify the instance partition are
1057
+ rejected.
1058
+
1059
+ Upon completion of the returned operation:
1060
+
1061
+ - Billing for all successfully-allocated resources begins (some
1062
+ types may have lower than the requested levels).
1063
+ - Databases can start using this instance partition.
1064
+ - The instance partition's allocated resource levels are
1065
+ readable via the API.
1066
+ - The instance partition's state becomes ``READY``.
1067
+
1068
+ The returned long-running operation will have a name of the
1069
+ format ``<instance_partition_name>/operations/<operation_id>``
1070
+ and can be used to track creation of the instance partition. The
1071
+ metadata field type is
1072
+ [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata].
1073
+ The response field type is
1074
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition],
1075
+ if successful.
1076
+
1077
+ Returns:
1078
+ Callable[[~.CreateInstancePartitionRequest],
1079
+ ~.Operation]:
1080
+ A function that, when called, will call the underlying RPC
1081
+ on the server.
1082
+ """
1083
+ # Generate a "stub function" on-the-fly which will actually make
1084
+ # the request.
1085
+ # gRPC handles serialization and deserialization, so we just need
1086
+ # to pass in the functions for each.
1087
+ if "create_instance_partition" not in self._stubs:
1088
+ self._stubs["create_instance_partition"] = self._logged_channel.unary_unary(
1089
+ "/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstancePartition",
1090
+ request_serializer=spanner_instance_admin.CreateInstancePartitionRequest.serialize,
1091
+ response_deserializer=operations_pb2.Operation.FromString,
1092
+ )
1093
+ return self._stubs["create_instance_partition"]
1094
+
1095
+ @property
1096
+ def delete_instance_partition(
1097
+ self,
1098
+ ) -> Callable[
1099
+ [spanner_instance_admin.DeleteInstancePartitionRequest], empty_pb2.Empty
1100
+ ]:
1101
+ r"""Return a callable for the delete instance partition method over gRPC.
1102
+
1103
+ Deletes an existing instance partition. Requires that the
1104
+ instance partition is not used by any database or backup and is
1105
+ not the default instance partition of an instance.
1106
+
1107
+ Authorization requires ``spanner.instancePartitions.delete``
1108
+ permission on the resource
1109
+ [name][google.spanner.admin.instance.v1.InstancePartition.name].
1110
+
1111
+ Returns:
1112
+ Callable[[~.DeleteInstancePartitionRequest],
1113
+ ~.Empty]:
1114
+ A function that, when called, will call the underlying RPC
1115
+ on the server.
1116
+ """
1117
+ # Generate a "stub function" on-the-fly which will actually make
1118
+ # the request.
1119
+ # gRPC handles serialization and deserialization, so we just need
1120
+ # to pass in the functions for each.
1121
+ if "delete_instance_partition" not in self._stubs:
1122
+ self._stubs["delete_instance_partition"] = self._logged_channel.unary_unary(
1123
+ "/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstancePartition",
1124
+ request_serializer=spanner_instance_admin.DeleteInstancePartitionRequest.serialize,
1125
+ response_deserializer=empty_pb2.Empty.FromString,
1126
+ )
1127
+ return self._stubs["delete_instance_partition"]
1128
+
1129
+ @property
1130
+ def update_instance_partition(
1131
+ self,
1132
+ ) -> Callable[
1133
+ [spanner_instance_admin.UpdateInstancePartitionRequest],
1134
+ operations_pb2.Operation,
1135
+ ]:
1136
+ r"""Return a callable for the update instance partition method over gRPC.
1137
+
1138
+ Updates an instance partition, and begins allocating or
1139
+ releasing resources as requested. The returned long-running
1140
+ operation can be used to track the progress of updating the
1141
+ instance partition. If the named instance partition does not
1142
+ exist, returns ``NOT_FOUND``.
1143
+
1144
+ Immediately upon completion of this request:
1145
+
1146
+ - For resource types for which a decrease in the instance
1147
+ partition's allocation has been requested, billing is based
1148
+ on the newly-requested level.
1149
+
1150
+ Until completion of the returned operation:
1151
+
1152
+ - Cancelling the operation sets its metadata's
1153
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time],
1154
+ and begins restoring resources to their pre-request values.
1155
+ The operation is guaranteed to succeed at undoing all
1156
+ resource changes, after which point it terminates with a
1157
+ ``CANCELLED`` status.
1158
+ - All other attempts to modify the instance partition are
1159
+ rejected.
1160
+ - Reading the instance partition via the API continues to give
1161
+ the pre-request resource levels.
1162
+
1163
+ Upon completion of the returned operation:
1164
+
1165
+ - Billing begins for all successfully-allocated resources (some
1166
+ types may have lower than the requested levels).
1167
+ - All newly-reserved resources are available for serving the
1168
+ instance partition's tables.
1169
+ - The instance partition's new resource levels are readable via
1170
+ the API.
1171
+
1172
+ The returned long-running operation will have a name of the
1173
+ format ``<instance_partition_name>/operations/<operation_id>``
1174
+ and can be used to track the instance partition modification.
1175
+ The metadata field type is
1176
+ [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata].
1177
+ The response field type is
1178
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition],
1179
+ if successful.
1180
+
1181
+ Authorization requires ``spanner.instancePartitions.update``
1182
+ permission on the resource
1183
+ [name][google.spanner.admin.instance.v1.InstancePartition.name].
1184
+
1185
+ Returns:
1186
+ Callable[[~.UpdateInstancePartitionRequest],
1187
+ ~.Operation]:
1188
+ A function that, when called, will call the underlying RPC
1189
+ on the server.
1190
+ """
1191
+ # Generate a "stub function" on-the-fly which will actually make
1192
+ # the request.
1193
+ # gRPC handles serialization and deserialization, so we just need
1194
+ # to pass in the functions for each.
1195
+ if "update_instance_partition" not in self._stubs:
1196
+ self._stubs["update_instance_partition"] = self._logged_channel.unary_unary(
1197
+ "/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstancePartition",
1198
+ request_serializer=spanner_instance_admin.UpdateInstancePartitionRequest.serialize,
1199
+ response_deserializer=operations_pb2.Operation.FromString,
1200
+ )
1201
+ return self._stubs["update_instance_partition"]
1202
+
1203
+ @property
1204
+ def list_instance_partition_operations(
1205
+ self,
1206
+ ) -> Callable[
1207
+ [spanner_instance_admin.ListInstancePartitionOperationsRequest],
1208
+ spanner_instance_admin.ListInstancePartitionOperationsResponse,
1209
+ ]:
1210
+ r"""Return a callable for the list instance partition
1211
+ operations method over gRPC.
1212
+
1213
+ Lists instance partition long-running operations in the given
1214
+ instance. An instance partition operation has a name of the form
1215
+ ``projects/<project>/instances/<instance>/instancePartitions/<instance_partition>/operations/<operation>``.
1216
+ The long-running operation metadata field type
1217
+ ``metadata.type_url`` describes the type of the metadata.
1218
+ Operations returned include those that have
1219
+ completed/failed/canceled within the last 7 days, and pending
1220
+ operations. Operations returned are ordered by
1221
+ ``operation.metadata.value.start_time`` in descending order
1222
+ starting from the most recently started operation.
1223
+
1224
+ Authorization requires
1225
+ ``spanner.instancePartitionOperations.list`` permission on the
1226
+ resource
1227
+ [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent].
1228
+
1229
+ Returns:
1230
+ Callable[[~.ListInstancePartitionOperationsRequest],
1231
+ ~.ListInstancePartitionOperationsResponse]:
1232
+ A function that, when called, will call the underlying RPC
1233
+ on the server.
1234
+ """
1235
+ # Generate a "stub function" on-the-fly which will actually make
1236
+ # the request.
1237
+ # gRPC handles serialization and deserialization, so we just need
1238
+ # to pass in the functions for each.
1239
+ if "list_instance_partition_operations" not in self._stubs:
1240
+ self._stubs[
1241
+ "list_instance_partition_operations"
1242
+ ] = self._logged_channel.unary_unary(
1243
+ "/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitionOperations",
1244
+ request_serializer=spanner_instance_admin.ListInstancePartitionOperationsRequest.serialize,
1245
+ response_deserializer=spanner_instance_admin.ListInstancePartitionOperationsResponse.deserialize,
1246
+ )
1247
+ return self._stubs["list_instance_partition_operations"]
1248
+
1249
+ @property
1250
+ def move_instance(
1251
+ self,
1252
+ ) -> Callable[
1253
+ [spanner_instance_admin.MoveInstanceRequest], operations_pb2.Operation
1254
+ ]:
1255
+ r"""Return a callable for the move instance method over gRPC.
1256
+
1257
+ Moves an instance to the target instance configuration. You can
1258
+ use the returned long-running operation to track the progress of
1259
+ moving the instance.
1260
+
1261
+ ``MoveInstance`` returns ``FAILED_PRECONDITION`` if the instance
1262
+ meets any of the following criteria:
1263
+
1264
+ - Is undergoing a move to a different instance configuration
1265
+ - Has backups
1266
+ - Has an ongoing update
1267
+ - Contains any CMEK-enabled databases
1268
+ - Is a free trial instance
1269
+
1270
+ While the operation is pending:
1271
+
1272
+ - All other attempts to modify the instance, including changes
1273
+ to its compute capacity, are rejected.
1274
+
1275
+ - The following database and backup admin operations are
1276
+ rejected:
1277
+
1278
+ - ``DatabaseAdmin.CreateDatabase``
1279
+ - ``DatabaseAdmin.UpdateDatabaseDdl`` (disabled if
1280
+ default_leader is specified in the request.)
1281
+ - ``DatabaseAdmin.RestoreDatabase``
1282
+ - ``DatabaseAdmin.CreateBackup``
1283
+ - ``DatabaseAdmin.CopyBackup``
1284
+
1285
+ - Both the source and target instance configurations are
1286
+ subject to hourly compute and storage charges.
1287
+
1288
+ - The instance might experience higher read-write latencies and
1289
+ a higher transaction abort rate. However, moving an instance
1290
+ doesn't cause any downtime.
1291
+
1292
+ The returned long-running operation has a name of the format
1293
+ ``<instance_name>/operations/<operation_id>`` and can be used to
1294
+ track the move instance operation. The metadata field type is
1295
+ [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata].
1296
+ The response field type is
1297
+ [Instance][google.spanner.admin.instance.v1.Instance], if
1298
+ successful. Cancelling the operation sets its metadata's
1299
+ [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time].
1300
+ Cancellation is not immediate because it involves moving any
1301
+ data previously moved to the target instance configuration back
1302
+ to the original instance configuration. You can use this
1303
+ operation to track the progress of the cancellation. Upon
1304
+ successful completion of the cancellation, the operation
1305
+ terminates with ``CANCELLED`` status.
1306
+
1307
+ If not cancelled, upon completion of the returned operation:
1308
+
1309
+ - The instance successfully moves to the target instance
1310
+ configuration.
1311
+ - You are billed for compute and storage in target instance
1312
+ configuration.
1313
+
1314
+ Authorization requires the ``spanner.instances.update``
1315
+ permission on the resource
1316
+ [instance][google.spanner.admin.instance.v1.Instance].
1317
+
1318
+ For more details, see `Move an
1319
+ instance <https://cloud.google.com/spanner/docs/move-instance>`__.
1320
+
1321
+ Returns:
1322
+ Callable[[~.MoveInstanceRequest],
1323
+ ~.Operation]:
1324
+ A function that, when called, will call the underlying RPC
1325
+ on the server.
1326
+ """
1327
+ # Generate a "stub function" on-the-fly which will actually make
1328
+ # the request.
1329
+ # gRPC handles serialization and deserialization, so we just need
1330
+ # to pass in the functions for each.
1331
+ if "move_instance" not in self._stubs:
1332
+ self._stubs["move_instance"] = self._logged_channel.unary_unary(
1333
+ "/google.spanner.admin.instance.v1.InstanceAdmin/MoveInstance",
1334
+ request_serializer=spanner_instance_admin.MoveInstanceRequest.serialize,
1335
+ response_deserializer=operations_pb2.Operation.FromString,
1336
+ )
1337
+ return self._stubs["move_instance"]
1338
+
1339
+ def close(self):
1340
+ self._logged_channel.close()
1341
+
1342
+ @property
1343
+ def kind(self) -> str:
1344
+ return "grpc"
1345
+
1346
+
1347
+ __all__ = ("InstanceAdminGrpcTransport",)