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,3466 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging as std_logging
17
+ from collections import OrderedDict
18
+ import re
19
+ from typing import (
20
+ Dict,
21
+ Callable,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ from google.cloud.spanner_admin_instance_v1 import gapic_version as package_version
33
+
34
+ from google.api_core.client_options import ClientOptions
35
+ from google.api_core import exceptions as core_exceptions
36
+ from google.api_core import gapic_v1
37
+ from google.api_core import retry_async as retries
38
+ from google.auth import credentials as ga_credentials # type: ignore
39
+ from google.oauth2 import service_account # type: ignore
40
+ import google.protobuf
41
+
42
+
43
+ try:
44
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
45
+ except AttributeError: # pragma: NO COVER
46
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
47
+
48
+ from google.api_core import operation # type: ignore
49
+ from google.api_core import operation_async # type: ignore
50
+ from google.cloud.spanner_admin_instance_v1.services.instance_admin import pagers
51
+ from google.cloud.spanner_admin_instance_v1.types import spanner_instance_admin
52
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
53
+ from google.iam.v1 import policy_pb2 # type: ignore
54
+ from google.longrunning import operations_pb2 # type: ignore
55
+ from google.protobuf import field_mask_pb2 # type: ignore
56
+ from google.protobuf import timestamp_pb2 # type: ignore
57
+ from .transports.base import InstanceAdminTransport, DEFAULT_CLIENT_INFO
58
+ from .transports.grpc_asyncio import InstanceAdminGrpcAsyncIOTransport
59
+ from .client import InstanceAdminClient
60
+
61
+ try:
62
+ from google.api_core import client_logging # type: ignore
63
+
64
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
65
+ except ImportError: # pragma: NO COVER
66
+ CLIENT_LOGGING_SUPPORTED = False
67
+
68
+ _LOGGER = std_logging.getLogger(__name__)
69
+
70
+
71
+ class InstanceAdminAsyncClient:
72
+ """Cloud Spanner Instance Admin API
73
+
74
+ The Cloud Spanner Instance Admin API can be used to create,
75
+ delete, modify and list instances. Instances are dedicated Cloud
76
+ Spanner serving and storage resources to be used by Cloud
77
+ Spanner databases.
78
+
79
+ Each instance has a "configuration", which dictates where the
80
+ serving resources for the Cloud Spanner instance are located
81
+ (e.g., US-central, Europe). Configurations are created by Google
82
+ based on resource availability.
83
+
84
+ Cloud Spanner billing is based on the instances that exist and
85
+ their sizes. After an instance exists, there are no additional
86
+ per-database or per-operation charges for use of the instance
87
+ (though there may be additional network bandwidth charges).
88
+ Instances offer isolation: problems with databases in one
89
+ instance will not affect other instances. However, within an
90
+ instance databases can affect each other. For example, if one
91
+ database in an instance receives a lot of requests and consumes
92
+ most of the instance resources, fewer resources are available
93
+ for other databases in that instance, and their performance may
94
+ suffer.
95
+ """
96
+
97
+ _client: InstanceAdminClient
98
+
99
+ # Copy defaults from the synchronous client for use here.
100
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
101
+ DEFAULT_ENDPOINT = InstanceAdminClient.DEFAULT_ENDPOINT
102
+ DEFAULT_MTLS_ENDPOINT = InstanceAdminClient.DEFAULT_MTLS_ENDPOINT
103
+ _DEFAULT_ENDPOINT_TEMPLATE = InstanceAdminClient._DEFAULT_ENDPOINT_TEMPLATE
104
+ _DEFAULT_UNIVERSE = InstanceAdminClient._DEFAULT_UNIVERSE
105
+
106
+ instance_path = staticmethod(InstanceAdminClient.instance_path)
107
+ parse_instance_path = staticmethod(InstanceAdminClient.parse_instance_path)
108
+ instance_config_path = staticmethod(InstanceAdminClient.instance_config_path)
109
+ parse_instance_config_path = staticmethod(
110
+ InstanceAdminClient.parse_instance_config_path
111
+ )
112
+ instance_partition_path = staticmethod(InstanceAdminClient.instance_partition_path)
113
+ parse_instance_partition_path = staticmethod(
114
+ InstanceAdminClient.parse_instance_partition_path
115
+ )
116
+ common_billing_account_path = staticmethod(
117
+ InstanceAdminClient.common_billing_account_path
118
+ )
119
+ parse_common_billing_account_path = staticmethod(
120
+ InstanceAdminClient.parse_common_billing_account_path
121
+ )
122
+ common_folder_path = staticmethod(InstanceAdminClient.common_folder_path)
123
+ parse_common_folder_path = staticmethod(
124
+ InstanceAdminClient.parse_common_folder_path
125
+ )
126
+ common_organization_path = staticmethod(
127
+ InstanceAdminClient.common_organization_path
128
+ )
129
+ parse_common_organization_path = staticmethod(
130
+ InstanceAdminClient.parse_common_organization_path
131
+ )
132
+ common_project_path = staticmethod(InstanceAdminClient.common_project_path)
133
+ parse_common_project_path = staticmethod(
134
+ InstanceAdminClient.parse_common_project_path
135
+ )
136
+ common_location_path = staticmethod(InstanceAdminClient.common_location_path)
137
+ parse_common_location_path = staticmethod(
138
+ InstanceAdminClient.parse_common_location_path
139
+ )
140
+
141
+ @classmethod
142
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
143
+ """Creates an instance of this client using the provided credentials
144
+ info.
145
+
146
+ Args:
147
+ info (dict): The service account private key info.
148
+ args: Additional arguments to pass to the constructor.
149
+ kwargs: Additional arguments to pass to the constructor.
150
+
151
+ Returns:
152
+ InstanceAdminAsyncClient: The constructed client.
153
+ """
154
+ return InstanceAdminClient.from_service_account_info.__func__(InstanceAdminAsyncClient, info, *args, **kwargs) # type: ignore
155
+
156
+ @classmethod
157
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
158
+ """Creates an instance of this client using the provided credentials
159
+ file.
160
+
161
+ Args:
162
+ filename (str): The path to the service account private key json
163
+ file.
164
+ args: Additional arguments to pass to the constructor.
165
+ kwargs: Additional arguments to pass to the constructor.
166
+
167
+ Returns:
168
+ InstanceAdminAsyncClient: The constructed client.
169
+ """
170
+ return InstanceAdminClient.from_service_account_file.__func__(InstanceAdminAsyncClient, filename, *args, **kwargs) # type: ignore
171
+
172
+ from_service_account_json = from_service_account_file
173
+
174
+ @classmethod
175
+ def get_mtls_endpoint_and_cert_source(
176
+ cls, client_options: Optional[ClientOptions] = None
177
+ ):
178
+ """Return the API endpoint and client cert source for mutual TLS.
179
+
180
+ The client cert source is determined in the following order:
181
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
182
+ client cert source is None.
183
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
184
+ default client cert source exists, use the default one; otherwise the client cert
185
+ source is None.
186
+
187
+ The API endpoint is determined in the following order:
188
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
189
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
190
+ default mTLS endpoint; if the environment variable is "never", use the default API
191
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
192
+ use the default API endpoint.
193
+
194
+ More details can be found at https://google.aip.dev/auth/4114.
195
+
196
+ Args:
197
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
198
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
199
+ in this method.
200
+
201
+ Returns:
202
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
203
+ client cert source to use.
204
+
205
+ Raises:
206
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
207
+ """
208
+ return InstanceAdminClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
209
+
210
+ @property
211
+ def transport(self) -> InstanceAdminTransport:
212
+ """Returns the transport used by the client instance.
213
+
214
+ Returns:
215
+ InstanceAdminTransport: The transport used by the client instance.
216
+ """
217
+ return self._client.transport
218
+
219
+ @property
220
+ def api_endpoint(self):
221
+ """Return the API endpoint used by the client instance.
222
+
223
+ Returns:
224
+ str: The API endpoint used by the client instance.
225
+ """
226
+ return self._client._api_endpoint
227
+
228
+ @property
229
+ def universe_domain(self) -> str:
230
+ """Return the universe domain used by the client instance.
231
+
232
+ Returns:
233
+ str: The universe domain used
234
+ by the client instance.
235
+ """
236
+ return self._client._universe_domain
237
+
238
+ get_transport_class = InstanceAdminClient.get_transport_class
239
+
240
+ def __init__(
241
+ self,
242
+ *,
243
+ credentials: Optional[ga_credentials.Credentials] = None,
244
+ transport: Optional[
245
+ Union[str, InstanceAdminTransport, Callable[..., InstanceAdminTransport]]
246
+ ] = "grpc_asyncio",
247
+ client_options: Optional[ClientOptions] = None,
248
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
249
+ ) -> None:
250
+ """Instantiates the instance admin async client.
251
+
252
+ Args:
253
+ credentials (Optional[google.auth.credentials.Credentials]): The
254
+ authorization credentials to attach to requests. These
255
+ credentials identify the application to the service; if none
256
+ are specified, the client will attempt to ascertain the
257
+ credentials from the environment.
258
+ transport (Optional[Union[str,InstanceAdminTransport,Callable[..., InstanceAdminTransport]]]):
259
+ The transport to use, or a Callable that constructs and returns a new transport to use.
260
+ If a Callable is given, it will be called with the same set of initialization
261
+ arguments as used in the InstanceAdminTransport constructor.
262
+ If set to None, a transport is chosen automatically.
263
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
264
+ Custom options for the client.
265
+
266
+ 1. The ``api_endpoint`` property can be used to override the
267
+ default endpoint provided by the client when ``transport`` is
268
+ not explicitly provided. Only if this property is not set and
269
+ ``transport`` was not explicitly provided, the endpoint is
270
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
271
+ variable, which have one of the following values:
272
+ "always" (always use the default mTLS endpoint), "never" (always
273
+ use the default regular endpoint) and "auto" (auto-switch to the
274
+ default mTLS endpoint if client certificate is present; this is
275
+ the default value).
276
+
277
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
278
+ is "true", then the ``client_cert_source`` property can be used
279
+ to provide a client certificate for mTLS transport. If
280
+ not provided, the default SSL client certificate will be used if
281
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
282
+ set, no client certificate will be used.
283
+
284
+ 3. The ``universe_domain`` property can be used to override the
285
+ default "googleapis.com" universe. Note that ``api_endpoint``
286
+ property still takes precedence; and ``universe_domain`` is
287
+ currently not supported for mTLS.
288
+
289
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
290
+ The client info used to send a user-agent string along with
291
+ API requests. If ``None``, then default info will be used.
292
+ Generally, you only need to set this if you're developing
293
+ your own client library.
294
+
295
+ Raises:
296
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
297
+ creation failed for any reason.
298
+ """
299
+ self._client = InstanceAdminClient(
300
+ credentials=credentials,
301
+ transport=transport,
302
+ client_options=client_options,
303
+ client_info=client_info,
304
+ )
305
+
306
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
307
+ std_logging.DEBUG
308
+ ): # pragma: NO COVER
309
+ _LOGGER.debug(
310
+ "Created client `google.spanner.admin.instance_v1.InstanceAdminAsyncClient`.",
311
+ extra={
312
+ "serviceName": "google.spanner.admin.instance.v1.InstanceAdmin",
313
+ "universeDomain": getattr(
314
+ self._client._transport._credentials, "universe_domain", ""
315
+ ),
316
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
317
+ "credentialsInfo": getattr(
318
+ self.transport._credentials, "get_cred_info", lambda: None
319
+ )(),
320
+ }
321
+ if hasattr(self._client._transport, "_credentials")
322
+ else {
323
+ "serviceName": "google.spanner.admin.instance.v1.InstanceAdmin",
324
+ "credentialsType": None,
325
+ },
326
+ )
327
+
328
+ async def list_instance_configs(
329
+ self,
330
+ request: Optional[
331
+ Union[spanner_instance_admin.ListInstanceConfigsRequest, dict]
332
+ ] = None,
333
+ *,
334
+ parent: Optional[str] = None,
335
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
336
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
337
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
338
+ ) -> pagers.ListInstanceConfigsAsyncPager:
339
+ r"""Lists the supported instance configurations for a
340
+ given project.
341
+ Returns both Google-managed configurations and
342
+ user-managed configurations.
343
+
344
+ .. code-block:: python
345
+
346
+ # This snippet has been automatically generated and should be regarded as a
347
+ # code template only.
348
+ # It will require modifications to work:
349
+ # - It may require correct/in-range values for request initialization.
350
+ # - It may require specifying regional endpoints when creating the service
351
+ # client as shown in:
352
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
353
+ from google.cloud import spanner_admin_instance_v1
354
+
355
+ async def sample_list_instance_configs():
356
+ # Create a client
357
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
358
+
359
+ # Initialize request argument(s)
360
+ request = spanner_admin_instance_v1.ListInstanceConfigsRequest(
361
+ parent="parent_value",
362
+ )
363
+
364
+ # Make the request
365
+ page_result = client.list_instance_configs(request=request)
366
+
367
+ # Handle the response
368
+ async for response in page_result:
369
+ print(response)
370
+
371
+ Args:
372
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest, dict]]):
373
+ The request object. The request for
374
+ [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].
375
+ parent (:class:`str`):
376
+ Required. The name of the project for which a list of
377
+ supported instance configurations is requested. Values
378
+ are of the form ``projects/<project>``.
379
+
380
+ This corresponds to the ``parent`` field
381
+ on the ``request`` instance; if ``request`` is provided, this
382
+ should not be set.
383
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
384
+ should be retried.
385
+ timeout (float): The timeout for this request.
386
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
387
+ sent along with the request as metadata. Normally, each value must be of type `str`,
388
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
389
+ be of type `bytes`.
390
+
391
+ Returns:
392
+ google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstanceConfigsAsyncPager:
393
+ The response for
394
+ [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].
395
+
396
+ Iterating over this object will yield results and
397
+ resolve additional pages automatically.
398
+
399
+ """
400
+ # Create or coerce a protobuf request object.
401
+ # - Quick check: If we got a request object, we should *not* have
402
+ # gotten any keyword arguments that map to the request.
403
+ flattened_params = [parent]
404
+ has_flattened_params = (
405
+ len([param for param in flattened_params if param is not None]) > 0
406
+ )
407
+ if request is not None and has_flattened_params:
408
+ raise ValueError(
409
+ "If the `request` argument is set, then none of "
410
+ "the individual field arguments should be set."
411
+ )
412
+
413
+ # - Use the request object if provided (there's no risk of modifying the input as
414
+ # there are no flattened fields), or create one.
415
+ if not isinstance(request, spanner_instance_admin.ListInstanceConfigsRequest):
416
+ request = spanner_instance_admin.ListInstanceConfigsRequest(request)
417
+
418
+ # If we have keyword arguments corresponding to fields on the
419
+ # request, apply these.
420
+ if parent is not None:
421
+ request.parent = parent
422
+
423
+ # Wrap the RPC method; this adds retry and timeout information,
424
+ # and friendly error handling.
425
+ rpc = self._client._transport._wrapped_methods[
426
+ self._client._transport.list_instance_configs
427
+ ]
428
+
429
+ # Certain fields should be provided within the metadata header;
430
+ # add these here.
431
+ metadata = tuple(metadata) + (
432
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
433
+ )
434
+
435
+ # Validate the universe domain.
436
+ self._client._validate_universe_domain()
437
+
438
+ # Send the request.
439
+ response = await rpc(
440
+ request,
441
+ retry=retry,
442
+ timeout=timeout,
443
+ metadata=metadata,
444
+ )
445
+
446
+ # This method is paged; wrap the response in a pager, which provides
447
+ # an `__aiter__` convenience method.
448
+ response = pagers.ListInstanceConfigsAsyncPager(
449
+ method=rpc,
450
+ request=request,
451
+ response=response,
452
+ retry=retry,
453
+ timeout=timeout,
454
+ metadata=metadata,
455
+ )
456
+
457
+ # Done; return the response.
458
+ return response
459
+
460
+ async def get_instance_config(
461
+ self,
462
+ request: Optional[
463
+ Union[spanner_instance_admin.GetInstanceConfigRequest, dict]
464
+ ] = None,
465
+ *,
466
+ name: Optional[str] = None,
467
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
468
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
469
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
470
+ ) -> spanner_instance_admin.InstanceConfig:
471
+ r"""Gets information about a particular instance
472
+ configuration.
473
+
474
+ .. code-block:: python
475
+
476
+ # This snippet has been automatically generated and should be regarded as a
477
+ # code template only.
478
+ # It will require modifications to work:
479
+ # - It may require correct/in-range values for request initialization.
480
+ # - It may require specifying regional endpoints when creating the service
481
+ # client as shown in:
482
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
483
+ from google.cloud import spanner_admin_instance_v1
484
+
485
+ async def sample_get_instance_config():
486
+ # Create a client
487
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
488
+
489
+ # Initialize request argument(s)
490
+ request = spanner_admin_instance_v1.GetInstanceConfigRequest(
491
+ name="name_value",
492
+ )
493
+
494
+ # Make the request
495
+ response = await client.get_instance_config(request=request)
496
+
497
+ # Handle the response
498
+ print(response)
499
+
500
+ Args:
501
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest, dict]]):
502
+ The request object. The request for
503
+ [GetInstanceConfigRequest][google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig].
504
+ name (:class:`str`):
505
+ Required. The name of the requested instance
506
+ configuration. Values are of the form
507
+ ``projects/<project>/instanceConfigs/<config>``.
508
+
509
+ This corresponds to the ``name`` field
510
+ on the ``request`` instance; if ``request`` is provided, this
511
+ should not be set.
512
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
513
+ should be retried.
514
+ timeout (float): The timeout for this request.
515
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
516
+ sent along with the request as metadata. Normally, each value must be of type `str`,
517
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
518
+ be of type `bytes`.
519
+
520
+ Returns:
521
+ google.cloud.spanner_admin_instance_v1.types.InstanceConfig:
522
+ A possible configuration for a Cloud
523
+ Spanner instance. Configurations define
524
+ the geographic placement of nodes and
525
+ their replication.
526
+
527
+ """
528
+ # Create or coerce a protobuf request object.
529
+ # - Quick check: If we got a request object, we should *not* have
530
+ # gotten any keyword arguments that map to the request.
531
+ flattened_params = [name]
532
+ has_flattened_params = (
533
+ len([param for param in flattened_params if param is not None]) > 0
534
+ )
535
+ if request is not None and has_flattened_params:
536
+ raise ValueError(
537
+ "If the `request` argument is set, then none of "
538
+ "the individual field arguments should be set."
539
+ )
540
+
541
+ # - Use the request object if provided (there's no risk of modifying the input as
542
+ # there are no flattened fields), or create one.
543
+ if not isinstance(request, spanner_instance_admin.GetInstanceConfigRequest):
544
+ request = spanner_instance_admin.GetInstanceConfigRequest(request)
545
+
546
+ # If we have keyword arguments corresponding to fields on the
547
+ # request, apply these.
548
+ if name is not None:
549
+ request.name = name
550
+
551
+ # Wrap the RPC method; this adds retry and timeout information,
552
+ # and friendly error handling.
553
+ rpc = self._client._transport._wrapped_methods[
554
+ self._client._transport.get_instance_config
555
+ ]
556
+
557
+ # Certain fields should be provided within the metadata header;
558
+ # add these here.
559
+ metadata = tuple(metadata) + (
560
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
561
+ )
562
+
563
+ # Validate the universe domain.
564
+ self._client._validate_universe_domain()
565
+
566
+ # Send the request.
567
+ response = await rpc(
568
+ request,
569
+ retry=retry,
570
+ timeout=timeout,
571
+ metadata=metadata,
572
+ )
573
+
574
+ # Done; return the response.
575
+ return response
576
+
577
+ async def create_instance_config(
578
+ self,
579
+ request: Optional[
580
+ Union[spanner_instance_admin.CreateInstanceConfigRequest, dict]
581
+ ] = None,
582
+ *,
583
+ parent: Optional[str] = None,
584
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
585
+ instance_config_id: Optional[str] = None,
586
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
587
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
588
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
589
+ ) -> operation_async.AsyncOperation:
590
+ r"""Creates an instance configuration and begins preparing it to be
591
+ used. The returned long-running operation can be used to track
592
+ the progress of preparing the new instance configuration. The
593
+ instance configuration name is assigned by the caller. If the
594
+ named instance configuration already exists,
595
+ ``CreateInstanceConfig`` returns ``ALREADY_EXISTS``.
596
+
597
+ Immediately after the request returns:
598
+
599
+ - The instance configuration is readable via the API, with all
600
+ requested attributes. The instance configuration's
601
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
602
+ field is set to true. Its state is ``CREATING``.
603
+
604
+ While the operation is pending:
605
+
606
+ - Cancelling the operation renders the instance configuration
607
+ immediately unreadable via the API.
608
+ - Except for deleting the creating resource, all other attempts
609
+ to modify the instance configuration are rejected.
610
+
611
+ Upon completion of the returned operation:
612
+
613
+ - Instances can be created using the instance configuration.
614
+ - The instance configuration's
615
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
616
+ field becomes false. Its state becomes ``READY``.
617
+
618
+ The returned long-running operation will have a name of the
619
+ format ``<instance_config_name>/operations/<operation_id>`` and
620
+ can be used to track creation of the instance configuration. The
621
+ metadata field type is
622
+ [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata].
623
+ The response field type is
624
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig],
625
+ if successful.
626
+
627
+ Authorization requires ``spanner.instanceConfigs.create``
628
+ permission on the resource
629
+ [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent].
630
+
631
+ .. code-block:: python
632
+
633
+ # This snippet has been automatically generated and should be regarded as a
634
+ # code template only.
635
+ # It will require modifications to work:
636
+ # - It may require correct/in-range values for request initialization.
637
+ # - It may require specifying regional endpoints when creating the service
638
+ # client as shown in:
639
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
640
+ from google.cloud import spanner_admin_instance_v1
641
+
642
+ async def sample_create_instance_config():
643
+ # Create a client
644
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
645
+
646
+ # Initialize request argument(s)
647
+ request = spanner_admin_instance_v1.CreateInstanceConfigRequest(
648
+ parent="parent_value",
649
+ instance_config_id="instance_config_id_value",
650
+ )
651
+
652
+ # Make the request
653
+ operation = client.create_instance_config(request=request)
654
+
655
+ print("Waiting for operation to complete...")
656
+
657
+ response = (await operation).result()
658
+
659
+ # Handle the response
660
+ print(response)
661
+
662
+ Args:
663
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceConfigRequest, dict]]):
664
+ The request object. The request for
665
+ [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig].
666
+ parent (:class:`str`):
667
+ Required. The name of the project in which to create the
668
+ instance configuration. Values are of the form
669
+ ``projects/<project>``.
670
+
671
+ This corresponds to the ``parent`` field
672
+ on the ``request`` instance; if ``request`` is provided, this
673
+ should not be set.
674
+ instance_config (:class:`google.cloud.spanner_admin_instance_v1.types.InstanceConfig`):
675
+ Required. The ``InstanceConfig`` proto of the
676
+ configuration to create. ``instance_config.name`` must
677
+ be ``<parent>/instanceConfigs/<instance_config_id>``.
678
+ ``instance_config.base_config`` must be a Google-managed
679
+ configuration name, e.g. /instanceConfigs/us-east1,
680
+ /instanceConfigs/nam3.
681
+
682
+ This corresponds to the ``instance_config`` field
683
+ on the ``request`` instance; if ``request`` is provided, this
684
+ should not be set.
685
+ instance_config_id (:class:`str`):
686
+ Required. The ID of the instance configuration to
687
+ create. Valid identifiers are of the form
688
+ ``custom-[-a-z0-9]*[a-z0-9]`` and must be between 2 and
689
+ 64 characters in length. The ``custom-`` prefix is
690
+ required to avoid name conflicts with Google-managed
691
+ configurations.
692
+
693
+ This corresponds to the ``instance_config_id`` field
694
+ on the ``request`` instance; if ``request`` is provided, this
695
+ should not be set.
696
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
697
+ should be retried.
698
+ timeout (float): The timeout for this request.
699
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
700
+ sent along with the request as metadata. Normally, each value must be of type `str`,
701
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
702
+ be of type `bytes`.
703
+
704
+ Returns:
705
+ google.api_core.operation_async.AsyncOperation:
706
+ An object representing a long-running operation.
707
+
708
+ The result type for the operation will be :class:`google.cloud.spanner_admin_instance_v1.types.InstanceConfig` A possible configuration for a Cloud Spanner instance. Configurations
709
+ define the geographic placement of nodes and their
710
+ replication.
711
+
712
+ """
713
+ # Create or coerce a protobuf request object.
714
+ # - Quick check: If we got a request object, we should *not* have
715
+ # gotten any keyword arguments that map to the request.
716
+ flattened_params = [parent, instance_config, instance_config_id]
717
+ has_flattened_params = (
718
+ len([param for param in flattened_params if param is not None]) > 0
719
+ )
720
+ if request is not None and has_flattened_params:
721
+ raise ValueError(
722
+ "If the `request` argument is set, then none of "
723
+ "the individual field arguments should be set."
724
+ )
725
+
726
+ # - Use the request object if provided (there's no risk of modifying the input as
727
+ # there are no flattened fields), or create one.
728
+ if not isinstance(request, spanner_instance_admin.CreateInstanceConfigRequest):
729
+ request = spanner_instance_admin.CreateInstanceConfigRequest(request)
730
+
731
+ # If we have keyword arguments corresponding to fields on the
732
+ # request, apply these.
733
+ if parent is not None:
734
+ request.parent = parent
735
+ if instance_config is not None:
736
+ request.instance_config = instance_config
737
+ if instance_config_id is not None:
738
+ request.instance_config_id = instance_config_id
739
+
740
+ # Wrap the RPC method; this adds retry and timeout information,
741
+ # and friendly error handling.
742
+ rpc = self._client._transport._wrapped_methods[
743
+ self._client._transport.create_instance_config
744
+ ]
745
+
746
+ # Certain fields should be provided within the metadata header;
747
+ # add these here.
748
+ metadata = tuple(metadata) + (
749
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
750
+ )
751
+
752
+ # Validate the universe domain.
753
+ self._client._validate_universe_domain()
754
+
755
+ # Send the request.
756
+ response = await rpc(
757
+ request,
758
+ retry=retry,
759
+ timeout=timeout,
760
+ metadata=metadata,
761
+ )
762
+
763
+ # Wrap the response in an operation future.
764
+ response = operation_async.from_gapic(
765
+ response,
766
+ self._client._transport.operations_client,
767
+ spanner_instance_admin.InstanceConfig,
768
+ metadata_type=spanner_instance_admin.CreateInstanceConfigMetadata,
769
+ )
770
+
771
+ # Done; return the response.
772
+ return response
773
+
774
+ async def update_instance_config(
775
+ self,
776
+ request: Optional[
777
+ Union[spanner_instance_admin.UpdateInstanceConfigRequest, dict]
778
+ ] = None,
779
+ *,
780
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
781
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
782
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
783
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
784
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
785
+ ) -> operation_async.AsyncOperation:
786
+ r"""Updates an instance configuration. The returned long-running
787
+ operation can be used to track the progress of updating the
788
+ instance. If the named instance configuration does not exist,
789
+ returns ``NOT_FOUND``.
790
+
791
+ Only user-managed configurations can be updated.
792
+
793
+ Immediately after the request returns:
794
+
795
+ - The instance configuration's
796
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
797
+ field is set to true.
798
+
799
+ While the operation is pending:
800
+
801
+ - Cancelling the operation sets its metadata's
802
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time].
803
+ The operation is guaranteed to succeed at undoing all
804
+ changes, after which point it terminates with a ``CANCELLED``
805
+ status.
806
+ - All other attempts to modify the instance configuration are
807
+ rejected.
808
+ - Reading the instance configuration via the API continues to
809
+ give the pre-request values.
810
+
811
+ Upon completion of the returned operation:
812
+
813
+ - Creating instances using the instance configuration uses the
814
+ new values.
815
+ - The new values of the instance configuration are readable via
816
+ the API.
817
+ - The instance configuration's
818
+ [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
819
+ field becomes false.
820
+
821
+ The returned long-running operation will have a name of the
822
+ format ``<instance_config_name>/operations/<operation_id>`` and
823
+ can be used to track the instance configuration modification.
824
+ The metadata field type is
825
+ [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata].
826
+ The response field type is
827
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig],
828
+ if successful.
829
+
830
+ Authorization requires ``spanner.instanceConfigs.update``
831
+ permission on the resource
832
+ [name][google.spanner.admin.instance.v1.InstanceConfig.name].
833
+
834
+ .. code-block:: python
835
+
836
+ # This snippet has been automatically generated and should be regarded as a
837
+ # code template only.
838
+ # It will require modifications to work:
839
+ # - It may require correct/in-range values for request initialization.
840
+ # - It may require specifying regional endpoints when creating the service
841
+ # client as shown in:
842
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
843
+ from google.cloud import spanner_admin_instance_v1
844
+
845
+ async def sample_update_instance_config():
846
+ # Create a client
847
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
848
+
849
+ # Initialize request argument(s)
850
+ request = spanner_admin_instance_v1.UpdateInstanceConfigRequest(
851
+ )
852
+
853
+ # Make the request
854
+ operation = client.update_instance_config(request=request)
855
+
856
+ print("Waiting for operation to complete...")
857
+
858
+ response = (await operation).result()
859
+
860
+ # Handle the response
861
+ print(response)
862
+
863
+ Args:
864
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceConfigRequest, dict]]):
865
+ The request object. The request for
866
+ [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig].
867
+ instance_config (:class:`google.cloud.spanner_admin_instance_v1.types.InstanceConfig`):
868
+ Required. The user instance configuration to update,
869
+ which must always include the instance configuration
870
+ name. Otherwise, only fields mentioned in
871
+ [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask]
872
+ need be included. To prevent conflicts of concurrent
873
+ updates,
874
+ [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
875
+ can be used.
876
+
877
+ This corresponds to the ``instance_config`` field
878
+ on the ``request`` instance; if ``request`` is provided, this
879
+ should not be set.
880
+ update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
881
+ Required. A mask specifying which fields in
882
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig]
883
+ should be updated. The field mask must always be
884
+ specified; this prevents any future fields in
885
+ [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig]
886
+ from being erased accidentally by clients that do not
887
+ know about them. Only display_name and labels can be
888
+ updated.
889
+
890
+ This corresponds to the ``update_mask`` field
891
+ on the ``request`` instance; if ``request`` is provided, this
892
+ should not be set.
893
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
894
+ should be retried.
895
+ timeout (float): The timeout for this request.
896
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
897
+ sent along with the request as metadata. Normally, each value must be of type `str`,
898
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
899
+ be of type `bytes`.
900
+
901
+ Returns:
902
+ google.api_core.operation_async.AsyncOperation:
903
+ An object representing a long-running operation.
904
+
905
+ The result type for the operation will be :class:`google.cloud.spanner_admin_instance_v1.types.InstanceConfig` A possible configuration for a Cloud Spanner instance. Configurations
906
+ define the geographic placement of nodes and their
907
+ replication.
908
+
909
+ """
910
+ # Create or coerce a protobuf request object.
911
+ # - Quick check: If we got a request object, we should *not* have
912
+ # gotten any keyword arguments that map to the request.
913
+ flattened_params = [instance_config, update_mask]
914
+ has_flattened_params = (
915
+ len([param for param in flattened_params if param is not None]) > 0
916
+ )
917
+ if request is not None and has_flattened_params:
918
+ raise ValueError(
919
+ "If the `request` argument is set, then none of "
920
+ "the individual field arguments should be set."
921
+ )
922
+
923
+ # - Use the request object if provided (there's no risk of modifying the input as
924
+ # there are no flattened fields), or create one.
925
+ if not isinstance(request, spanner_instance_admin.UpdateInstanceConfigRequest):
926
+ request = spanner_instance_admin.UpdateInstanceConfigRequest(request)
927
+
928
+ # If we have keyword arguments corresponding to fields on the
929
+ # request, apply these.
930
+ if instance_config is not None:
931
+ request.instance_config = instance_config
932
+ if update_mask is not None:
933
+ request.update_mask = update_mask
934
+
935
+ # Wrap the RPC method; this adds retry and timeout information,
936
+ # and friendly error handling.
937
+ rpc = self._client._transport._wrapped_methods[
938
+ self._client._transport.update_instance_config
939
+ ]
940
+
941
+ # Certain fields should be provided within the metadata header;
942
+ # add these here.
943
+ metadata = tuple(metadata) + (
944
+ gapic_v1.routing_header.to_grpc_metadata(
945
+ (("instance_config.name", request.instance_config.name),)
946
+ ),
947
+ )
948
+
949
+ # Validate the universe domain.
950
+ self._client._validate_universe_domain()
951
+
952
+ # Send the request.
953
+ response = await rpc(
954
+ request,
955
+ retry=retry,
956
+ timeout=timeout,
957
+ metadata=metadata,
958
+ )
959
+
960
+ # Wrap the response in an operation future.
961
+ response = operation_async.from_gapic(
962
+ response,
963
+ self._client._transport.operations_client,
964
+ spanner_instance_admin.InstanceConfig,
965
+ metadata_type=spanner_instance_admin.UpdateInstanceConfigMetadata,
966
+ )
967
+
968
+ # Done; return the response.
969
+ return response
970
+
971
+ async def delete_instance_config(
972
+ self,
973
+ request: Optional[
974
+ Union[spanner_instance_admin.DeleteInstanceConfigRequest, dict]
975
+ ] = None,
976
+ *,
977
+ name: Optional[str] = None,
978
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
979
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
980
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
981
+ ) -> None:
982
+ r"""Deletes the instance configuration. Deletion is only allowed
983
+ when no instances are using the configuration. If any instances
984
+ are using the configuration, returns ``FAILED_PRECONDITION``.
985
+
986
+ Only user-managed configurations can be deleted.
987
+
988
+ Authorization requires ``spanner.instanceConfigs.delete``
989
+ permission on the resource
990
+ [name][google.spanner.admin.instance.v1.InstanceConfig.name].
991
+
992
+ .. code-block:: python
993
+
994
+ # This snippet has been automatically generated and should be regarded as a
995
+ # code template only.
996
+ # It will require modifications to work:
997
+ # - It may require correct/in-range values for request initialization.
998
+ # - It may require specifying regional endpoints when creating the service
999
+ # client as shown in:
1000
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1001
+ from google.cloud import spanner_admin_instance_v1
1002
+
1003
+ async def sample_delete_instance_config():
1004
+ # Create a client
1005
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1006
+
1007
+ # Initialize request argument(s)
1008
+ request = spanner_admin_instance_v1.DeleteInstanceConfigRequest(
1009
+ name="name_value",
1010
+ )
1011
+
1012
+ # Make the request
1013
+ await client.delete_instance_config(request=request)
1014
+
1015
+ Args:
1016
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceConfigRequest, dict]]):
1017
+ The request object. The request for
1018
+ [DeleteInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfig].
1019
+ name (:class:`str`):
1020
+ Required. The name of the instance configuration to be
1021
+ deleted. Values are of the form
1022
+ ``projects/<project>/instanceConfigs/<instance_config>``
1023
+
1024
+ This corresponds to the ``name`` field
1025
+ on the ``request`` instance; if ``request`` is provided, this
1026
+ should not be set.
1027
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1028
+ should be retried.
1029
+ timeout (float): The timeout for this request.
1030
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1031
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1032
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1033
+ be of type `bytes`.
1034
+ """
1035
+ # Create or coerce a protobuf request object.
1036
+ # - Quick check: If we got a request object, we should *not* have
1037
+ # gotten any keyword arguments that map to the request.
1038
+ flattened_params = [name]
1039
+ has_flattened_params = (
1040
+ len([param for param in flattened_params if param is not None]) > 0
1041
+ )
1042
+ if request is not None and has_flattened_params:
1043
+ raise ValueError(
1044
+ "If the `request` argument is set, then none of "
1045
+ "the individual field arguments should be set."
1046
+ )
1047
+
1048
+ # - Use the request object if provided (there's no risk of modifying the input as
1049
+ # there are no flattened fields), or create one.
1050
+ if not isinstance(request, spanner_instance_admin.DeleteInstanceConfigRequest):
1051
+ request = spanner_instance_admin.DeleteInstanceConfigRequest(request)
1052
+
1053
+ # If we have keyword arguments corresponding to fields on the
1054
+ # request, apply these.
1055
+ if name is not None:
1056
+ request.name = name
1057
+
1058
+ # Wrap the RPC method; this adds retry and timeout information,
1059
+ # and friendly error handling.
1060
+ rpc = self._client._transport._wrapped_methods[
1061
+ self._client._transport.delete_instance_config
1062
+ ]
1063
+
1064
+ # Certain fields should be provided within the metadata header;
1065
+ # add these here.
1066
+ metadata = tuple(metadata) + (
1067
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1068
+ )
1069
+
1070
+ # Validate the universe domain.
1071
+ self._client._validate_universe_domain()
1072
+
1073
+ # Send the request.
1074
+ await rpc(
1075
+ request,
1076
+ retry=retry,
1077
+ timeout=timeout,
1078
+ metadata=metadata,
1079
+ )
1080
+
1081
+ async def list_instance_config_operations(
1082
+ self,
1083
+ request: Optional[
1084
+ Union[spanner_instance_admin.ListInstanceConfigOperationsRequest, dict]
1085
+ ] = None,
1086
+ *,
1087
+ parent: Optional[str] = None,
1088
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1089
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1090
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1091
+ ) -> pagers.ListInstanceConfigOperationsAsyncPager:
1092
+ r"""Lists the user-managed instance configuration long-running
1093
+ operations in the given project. An instance configuration
1094
+ operation has a name of the form
1095
+ ``projects/<project>/instanceConfigs/<instance_config>/operations/<operation>``.
1096
+ The long-running operation metadata field type
1097
+ ``metadata.type_url`` describes the type of the metadata.
1098
+ Operations returned include those that have
1099
+ completed/failed/canceled within the last 7 days, and pending
1100
+ operations. Operations returned are ordered by
1101
+ ``operation.metadata.value.start_time`` in descending order
1102
+ starting from the most recently started operation.
1103
+
1104
+ .. code-block:: python
1105
+
1106
+ # This snippet has been automatically generated and should be regarded as a
1107
+ # code template only.
1108
+ # It will require modifications to work:
1109
+ # - It may require correct/in-range values for request initialization.
1110
+ # - It may require specifying regional endpoints when creating the service
1111
+ # client as shown in:
1112
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1113
+ from google.cloud import spanner_admin_instance_v1
1114
+
1115
+ async def sample_list_instance_config_operations():
1116
+ # Create a client
1117
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1118
+
1119
+ # Initialize request argument(s)
1120
+ request = spanner_admin_instance_v1.ListInstanceConfigOperationsRequest(
1121
+ parent="parent_value",
1122
+ )
1123
+
1124
+ # Make the request
1125
+ page_result = client.list_instance_config_operations(request=request)
1126
+
1127
+ # Handle the response
1128
+ async for response in page_result:
1129
+ print(response)
1130
+
1131
+ Args:
1132
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigOperationsRequest, dict]]):
1133
+ The request object. The request for
1134
+ [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].
1135
+ parent (:class:`str`):
1136
+ Required. The project of the instance configuration
1137
+ operations. Values are of the form
1138
+ ``projects/<project>``.
1139
+
1140
+ This corresponds to the ``parent`` field
1141
+ on the ``request`` instance; if ``request`` is provided, this
1142
+ should not be set.
1143
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1144
+ should be retried.
1145
+ timeout (float): The timeout for this request.
1146
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1147
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1148
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1149
+ be of type `bytes`.
1150
+
1151
+ Returns:
1152
+ google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstanceConfigOperationsAsyncPager:
1153
+ The response for
1154
+ [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].
1155
+
1156
+ Iterating over this object will yield results and
1157
+ resolve additional pages automatically.
1158
+
1159
+ """
1160
+ # Create or coerce a protobuf request object.
1161
+ # - Quick check: If we got a request object, we should *not* have
1162
+ # gotten any keyword arguments that map to the request.
1163
+ flattened_params = [parent]
1164
+ has_flattened_params = (
1165
+ len([param for param in flattened_params if param is not None]) > 0
1166
+ )
1167
+ if request is not None and has_flattened_params:
1168
+ raise ValueError(
1169
+ "If the `request` argument is set, then none of "
1170
+ "the individual field arguments should be set."
1171
+ )
1172
+
1173
+ # - Use the request object if provided (there's no risk of modifying the input as
1174
+ # there are no flattened fields), or create one.
1175
+ if not isinstance(
1176
+ request, spanner_instance_admin.ListInstanceConfigOperationsRequest
1177
+ ):
1178
+ request = spanner_instance_admin.ListInstanceConfigOperationsRequest(
1179
+ request
1180
+ )
1181
+
1182
+ # If we have keyword arguments corresponding to fields on the
1183
+ # request, apply these.
1184
+ if parent is not None:
1185
+ request.parent = parent
1186
+
1187
+ # Wrap the RPC method; this adds retry and timeout information,
1188
+ # and friendly error handling.
1189
+ rpc = self._client._transport._wrapped_methods[
1190
+ self._client._transport.list_instance_config_operations
1191
+ ]
1192
+
1193
+ # Certain fields should be provided within the metadata header;
1194
+ # add these here.
1195
+ metadata = tuple(metadata) + (
1196
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1197
+ )
1198
+
1199
+ # Validate the universe domain.
1200
+ self._client._validate_universe_domain()
1201
+
1202
+ # Send the request.
1203
+ response = await rpc(
1204
+ request,
1205
+ retry=retry,
1206
+ timeout=timeout,
1207
+ metadata=metadata,
1208
+ )
1209
+
1210
+ # This method is paged; wrap the response in a pager, which provides
1211
+ # an `__aiter__` convenience method.
1212
+ response = pagers.ListInstanceConfigOperationsAsyncPager(
1213
+ method=rpc,
1214
+ request=request,
1215
+ response=response,
1216
+ retry=retry,
1217
+ timeout=timeout,
1218
+ metadata=metadata,
1219
+ )
1220
+
1221
+ # Done; return the response.
1222
+ return response
1223
+
1224
+ async def list_instances(
1225
+ self,
1226
+ request: Optional[
1227
+ Union[spanner_instance_admin.ListInstancesRequest, dict]
1228
+ ] = None,
1229
+ *,
1230
+ parent: Optional[str] = None,
1231
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1232
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1233
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1234
+ ) -> pagers.ListInstancesAsyncPager:
1235
+ r"""Lists all instances in the given project.
1236
+
1237
+ .. code-block:: python
1238
+
1239
+ # This snippet has been automatically generated and should be regarded as a
1240
+ # code template only.
1241
+ # It will require modifications to work:
1242
+ # - It may require correct/in-range values for request initialization.
1243
+ # - It may require specifying regional endpoints when creating the service
1244
+ # client as shown in:
1245
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1246
+ from google.cloud import spanner_admin_instance_v1
1247
+
1248
+ async def sample_list_instances():
1249
+ # Create a client
1250
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1251
+
1252
+ # Initialize request argument(s)
1253
+ request = spanner_admin_instance_v1.ListInstancesRequest(
1254
+ parent="parent_value",
1255
+ )
1256
+
1257
+ # Make the request
1258
+ page_result = client.list_instances(request=request)
1259
+
1260
+ # Handle the response
1261
+ async for response in page_result:
1262
+ print(response)
1263
+
1264
+ Args:
1265
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest, dict]]):
1266
+ The request object. The request for
1267
+ [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].
1268
+ parent (:class:`str`):
1269
+ Required. The name of the project for which a list of
1270
+ instances is requested. Values are of the form
1271
+ ``projects/<project>``.
1272
+
1273
+ This corresponds to the ``parent`` field
1274
+ on the ``request`` instance; if ``request`` is provided, this
1275
+ should not be set.
1276
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1277
+ should be retried.
1278
+ timeout (float): The timeout for this request.
1279
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1280
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1281
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1282
+ be of type `bytes`.
1283
+
1284
+ Returns:
1285
+ google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstancesAsyncPager:
1286
+ The response for
1287
+ [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].
1288
+
1289
+ Iterating over this object will yield results and
1290
+ resolve additional pages automatically.
1291
+
1292
+ """
1293
+ # Create or coerce a protobuf request object.
1294
+ # - Quick check: If we got a request object, we should *not* have
1295
+ # gotten any keyword arguments that map to the request.
1296
+ flattened_params = [parent]
1297
+ has_flattened_params = (
1298
+ len([param for param in flattened_params if param is not None]) > 0
1299
+ )
1300
+ if request is not None and has_flattened_params:
1301
+ raise ValueError(
1302
+ "If the `request` argument is set, then none of "
1303
+ "the individual field arguments should be set."
1304
+ )
1305
+
1306
+ # - Use the request object if provided (there's no risk of modifying the input as
1307
+ # there are no flattened fields), or create one.
1308
+ if not isinstance(request, spanner_instance_admin.ListInstancesRequest):
1309
+ request = spanner_instance_admin.ListInstancesRequest(request)
1310
+
1311
+ # If we have keyword arguments corresponding to fields on the
1312
+ # request, apply these.
1313
+ if parent is not None:
1314
+ request.parent = parent
1315
+
1316
+ # Wrap the RPC method; this adds retry and timeout information,
1317
+ # and friendly error handling.
1318
+ rpc = self._client._transport._wrapped_methods[
1319
+ self._client._transport.list_instances
1320
+ ]
1321
+
1322
+ # Certain fields should be provided within the metadata header;
1323
+ # add these here.
1324
+ metadata = tuple(metadata) + (
1325
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1326
+ )
1327
+
1328
+ # Validate the universe domain.
1329
+ self._client._validate_universe_domain()
1330
+
1331
+ # Send the request.
1332
+ response = await rpc(
1333
+ request,
1334
+ retry=retry,
1335
+ timeout=timeout,
1336
+ metadata=metadata,
1337
+ )
1338
+
1339
+ # This method is paged; wrap the response in a pager, which provides
1340
+ # an `__aiter__` convenience method.
1341
+ response = pagers.ListInstancesAsyncPager(
1342
+ method=rpc,
1343
+ request=request,
1344
+ response=response,
1345
+ retry=retry,
1346
+ timeout=timeout,
1347
+ metadata=metadata,
1348
+ )
1349
+
1350
+ # Done; return the response.
1351
+ return response
1352
+
1353
+ async def list_instance_partitions(
1354
+ self,
1355
+ request: Optional[
1356
+ Union[spanner_instance_admin.ListInstancePartitionsRequest, dict]
1357
+ ] = None,
1358
+ *,
1359
+ parent: Optional[str] = None,
1360
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1361
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1362
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1363
+ ) -> pagers.ListInstancePartitionsAsyncPager:
1364
+ r"""Lists all instance partitions for the given instance.
1365
+
1366
+ .. code-block:: python
1367
+
1368
+ # This snippet has been automatically generated and should be regarded as a
1369
+ # code template only.
1370
+ # It will require modifications to work:
1371
+ # - It may require correct/in-range values for request initialization.
1372
+ # - It may require specifying regional endpoints when creating the service
1373
+ # client as shown in:
1374
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1375
+ from google.cloud import spanner_admin_instance_v1
1376
+
1377
+ async def sample_list_instance_partitions():
1378
+ # Create a client
1379
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1380
+
1381
+ # Initialize request argument(s)
1382
+ request = spanner_admin_instance_v1.ListInstancePartitionsRequest(
1383
+ parent="parent_value",
1384
+ )
1385
+
1386
+ # Make the request
1387
+ page_result = client.list_instance_partitions(request=request)
1388
+
1389
+ # Handle the response
1390
+ async for response in page_result:
1391
+ print(response)
1392
+
1393
+ Args:
1394
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstancePartitionsRequest, dict]]):
1395
+ The request object. The request for
1396
+ [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions].
1397
+ parent (:class:`str`):
1398
+ Required. The instance whose instance partitions should
1399
+ be listed. Values are of the form
1400
+ ``projects/<project>/instances/<instance>``. Use
1401
+ ``{instance} = '-'`` to list instance partitions for all
1402
+ Instances in a project, e.g.,
1403
+ ``projects/myproject/instances/-``.
1404
+
1405
+ This corresponds to the ``parent`` field
1406
+ on the ``request`` instance; if ``request`` is provided, this
1407
+ should not be set.
1408
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1409
+ should be retried.
1410
+ timeout (float): The timeout for this request.
1411
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1412
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1413
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1414
+ be of type `bytes`.
1415
+
1416
+ Returns:
1417
+ google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstancePartitionsAsyncPager:
1418
+ The response for
1419
+ [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions].
1420
+
1421
+ Iterating over this object will yield results and
1422
+ resolve additional pages automatically.
1423
+
1424
+ """
1425
+ # Create or coerce a protobuf request object.
1426
+ # - Quick check: If we got a request object, we should *not* have
1427
+ # gotten any keyword arguments that map to the request.
1428
+ flattened_params = [parent]
1429
+ has_flattened_params = (
1430
+ len([param for param in flattened_params if param is not None]) > 0
1431
+ )
1432
+ if request is not None and has_flattened_params:
1433
+ raise ValueError(
1434
+ "If the `request` argument is set, then none of "
1435
+ "the individual field arguments should be set."
1436
+ )
1437
+
1438
+ # - Use the request object if provided (there's no risk of modifying the input as
1439
+ # there are no flattened fields), or create one.
1440
+ if not isinstance(
1441
+ request, spanner_instance_admin.ListInstancePartitionsRequest
1442
+ ):
1443
+ request = spanner_instance_admin.ListInstancePartitionsRequest(request)
1444
+
1445
+ # If we have keyword arguments corresponding to fields on the
1446
+ # request, apply these.
1447
+ if parent is not None:
1448
+ request.parent = parent
1449
+
1450
+ # Wrap the RPC method; this adds retry and timeout information,
1451
+ # and friendly error handling.
1452
+ rpc = self._client._transport._wrapped_methods[
1453
+ self._client._transport.list_instance_partitions
1454
+ ]
1455
+
1456
+ # Certain fields should be provided within the metadata header;
1457
+ # add these here.
1458
+ metadata = tuple(metadata) + (
1459
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1460
+ )
1461
+
1462
+ # Validate the universe domain.
1463
+ self._client._validate_universe_domain()
1464
+
1465
+ # Send the request.
1466
+ response = await rpc(
1467
+ request,
1468
+ retry=retry,
1469
+ timeout=timeout,
1470
+ metadata=metadata,
1471
+ )
1472
+
1473
+ # This method is paged; wrap the response in a pager, which provides
1474
+ # an `__aiter__` convenience method.
1475
+ response = pagers.ListInstancePartitionsAsyncPager(
1476
+ method=rpc,
1477
+ request=request,
1478
+ response=response,
1479
+ retry=retry,
1480
+ timeout=timeout,
1481
+ metadata=metadata,
1482
+ )
1483
+
1484
+ # Done; return the response.
1485
+ return response
1486
+
1487
+ async def get_instance(
1488
+ self,
1489
+ request: Optional[
1490
+ Union[spanner_instance_admin.GetInstanceRequest, dict]
1491
+ ] = None,
1492
+ *,
1493
+ name: Optional[str] = None,
1494
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1495
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1496
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1497
+ ) -> spanner_instance_admin.Instance:
1498
+ r"""Gets information about a particular instance.
1499
+
1500
+ .. code-block:: python
1501
+
1502
+ # This snippet has been automatically generated and should be regarded as a
1503
+ # code template only.
1504
+ # It will require modifications to work:
1505
+ # - It may require correct/in-range values for request initialization.
1506
+ # - It may require specifying regional endpoints when creating the service
1507
+ # client as shown in:
1508
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1509
+ from google.cloud import spanner_admin_instance_v1
1510
+
1511
+ async def sample_get_instance():
1512
+ # Create a client
1513
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1514
+
1515
+ # Initialize request argument(s)
1516
+ request = spanner_admin_instance_v1.GetInstanceRequest(
1517
+ name="name_value",
1518
+ )
1519
+
1520
+ # Make the request
1521
+ response = await client.get_instance(request=request)
1522
+
1523
+ # Handle the response
1524
+ print(response)
1525
+
1526
+ Args:
1527
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest, dict]]):
1528
+ The request object. The request for
1529
+ [GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance].
1530
+ name (:class:`str`):
1531
+ Required. The name of the requested instance. Values are
1532
+ of the form ``projects/<project>/instances/<instance>``.
1533
+
1534
+ This corresponds to the ``name`` field
1535
+ on the ``request`` instance; if ``request`` is provided, this
1536
+ should not be set.
1537
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1538
+ should be retried.
1539
+ timeout (float): The timeout for this request.
1540
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1541
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1542
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1543
+ be of type `bytes`.
1544
+
1545
+ Returns:
1546
+ google.cloud.spanner_admin_instance_v1.types.Instance:
1547
+ An isolated set of Cloud Spanner
1548
+ resources on which databases can be
1549
+ hosted.
1550
+
1551
+ """
1552
+ # Create or coerce a protobuf request object.
1553
+ # - Quick check: If we got a request object, we should *not* have
1554
+ # gotten any keyword arguments that map to the request.
1555
+ flattened_params = [name]
1556
+ has_flattened_params = (
1557
+ len([param for param in flattened_params if param is not None]) > 0
1558
+ )
1559
+ if request is not None and has_flattened_params:
1560
+ raise ValueError(
1561
+ "If the `request` argument is set, then none of "
1562
+ "the individual field arguments should be set."
1563
+ )
1564
+
1565
+ # - Use the request object if provided (there's no risk of modifying the input as
1566
+ # there are no flattened fields), or create one.
1567
+ if not isinstance(request, spanner_instance_admin.GetInstanceRequest):
1568
+ request = spanner_instance_admin.GetInstanceRequest(request)
1569
+
1570
+ # If we have keyword arguments corresponding to fields on the
1571
+ # request, apply these.
1572
+ if name is not None:
1573
+ request.name = name
1574
+
1575
+ # Wrap the RPC method; this adds retry and timeout information,
1576
+ # and friendly error handling.
1577
+ rpc = self._client._transport._wrapped_methods[
1578
+ self._client._transport.get_instance
1579
+ ]
1580
+
1581
+ # Certain fields should be provided within the metadata header;
1582
+ # add these here.
1583
+ metadata = tuple(metadata) + (
1584
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1585
+ )
1586
+
1587
+ # Validate the universe domain.
1588
+ self._client._validate_universe_domain()
1589
+
1590
+ # Send the request.
1591
+ response = await rpc(
1592
+ request,
1593
+ retry=retry,
1594
+ timeout=timeout,
1595
+ metadata=metadata,
1596
+ )
1597
+
1598
+ # Done; return the response.
1599
+ return response
1600
+
1601
+ async def create_instance(
1602
+ self,
1603
+ request: Optional[
1604
+ Union[spanner_instance_admin.CreateInstanceRequest, dict]
1605
+ ] = None,
1606
+ *,
1607
+ parent: Optional[str] = None,
1608
+ instance_id: Optional[str] = None,
1609
+ instance: Optional[spanner_instance_admin.Instance] = None,
1610
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1611
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1612
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1613
+ ) -> operation_async.AsyncOperation:
1614
+ r"""Creates an instance and begins preparing it to begin serving.
1615
+ The returned long-running operation can be used to track the
1616
+ progress of preparing the new instance. The instance name is
1617
+ assigned by the caller. If the named instance already exists,
1618
+ ``CreateInstance`` returns ``ALREADY_EXISTS``.
1619
+
1620
+ Immediately upon completion of this request:
1621
+
1622
+ - The instance is readable via the API, with all requested
1623
+ attributes but no allocated resources. Its state is
1624
+ ``CREATING``.
1625
+
1626
+ Until completion of the returned operation:
1627
+
1628
+ - Cancelling the operation renders the instance immediately
1629
+ unreadable via the API.
1630
+ - The instance can be deleted.
1631
+ - All other attempts to modify the instance are rejected.
1632
+
1633
+ Upon completion of the returned operation:
1634
+
1635
+ - Billing for all successfully-allocated resources begins (some
1636
+ types may have lower than the requested levels).
1637
+ - Databases can be created in the instance.
1638
+ - The instance's allocated resource levels are readable via the
1639
+ API.
1640
+ - The instance's state becomes ``READY``.
1641
+
1642
+ The returned long-running operation will have a name of the
1643
+ format ``<instance_name>/operations/<operation_id>`` and can be
1644
+ used to track creation of the instance. The metadata field type
1645
+ is
1646
+ [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata].
1647
+ The response field type is
1648
+ [Instance][google.spanner.admin.instance.v1.Instance], if
1649
+ successful.
1650
+
1651
+ .. code-block:: python
1652
+
1653
+ # This snippet has been automatically generated and should be regarded as a
1654
+ # code template only.
1655
+ # It will require modifications to work:
1656
+ # - It may require correct/in-range values for request initialization.
1657
+ # - It may require specifying regional endpoints when creating the service
1658
+ # client as shown in:
1659
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1660
+ from google.cloud import spanner_admin_instance_v1
1661
+
1662
+ async def sample_create_instance():
1663
+ # Create a client
1664
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1665
+
1666
+ # Initialize request argument(s)
1667
+ instance = spanner_admin_instance_v1.Instance()
1668
+ instance.name = "name_value"
1669
+ instance.config = "config_value"
1670
+ instance.display_name = "display_name_value"
1671
+
1672
+ request = spanner_admin_instance_v1.CreateInstanceRequest(
1673
+ parent="parent_value",
1674
+ instance_id="instance_id_value",
1675
+ instance=instance,
1676
+ )
1677
+
1678
+ # Make the request
1679
+ operation = client.create_instance(request=request)
1680
+
1681
+ print("Waiting for operation to complete...")
1682
+
1683
+ response = (await operation).result()
1684
+
1685
+ # Handle the response
1686
+ print(response)
1687
+
1688
+ Args:
1689
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest, dict]]):
1690
+ The request object. The request for
1691
+ [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance].
1692
+ parent (:class:`str`):
1693
+ Required. The name of the project in which to create the
1694
+ instance. Values are of the form ``projects/<project>``.
1695
+
1696
+ This corresponds to the ``parent`` field
1697
+ on the ``request`` instance; if ``request`` is provided, this
1698
+ should not be set.
1699
+ instance_id (:class:`str`):
1700
+ Required. The ID of the instance to create. Valid
1701
+ identifiers are of the form ``[a-z][-a-z0-9]*[a-z0-9]``
1702
+ and must be between 2 and 64 characters in length.
1703
+
1704
+ This corresponds to the ``instance_id`` field
1705
+ on the ``request`` instance; if ``request`` is provided, this
1706
+ should not be set.
1707
+ instance (:class:`google.cloud.spanner_admin_instance_v1.types.Instance`):
1708
+ Required. The instance to create. The name may be
1709
+ omitted, but if specified must be
1710
+ ``<parent>/instances/<instance_id>``.
1711
+
1712
+ This corresponds to the ``instance`` field
1713
+ on the ``request`` instance; if ``request`` is provided, this
1714
+ should not be set.
1715
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1716
+ should be retried.
1717
+ timeout (float): The timeout for this request.
1718
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1719
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1720
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1721
+ be of type `bytes`.
1722
+
1723
+ Returns:
1724
+ google.api_core.operation_async.AsyncOperation:
1725
+ An object representing a long-running operation.
1726
+
1727
+ The result type for the operation will be
1728
+ :class:`google.cloud.spanner_admin_instance_v1.types.Instance`
1729
+ An isolated set of Cloud Spanner resources on which
1730
+ databases can be hosted.
1731
+
1732
+ """
1733
+ # Create or coerce a protobuf request object.
1734
+ # - Quick check: If we got a request object, we should *not* have
1735
+ # gotten any keyword arguments that map to the request.
1736
+ flattened_params = [parent, instance_id, instance]
1737
+ has_flattened_params = (
1738
+ len([param for param in flattened_params if param is not None]) > 0
1739
+ )
1740
+ if request is not None and has_flattened_params:
1741
+ raise ValueError(
1742
+ "If the `request` argument is set, then none of "
1743
+ "the individual field arguments should be set."
1744
+ )
1745
+
1746
+ # - Use the request object if provided (there's no risk of modifying the input as
1747
+ # there are no flattened fields), or create one.
1748
+ if not isinstance(request, spanner_instance_admin.CreateInstanceRequest):
1749
+ request = spanner_instance_admin.CreateInstanceRequest(request)
1750
+
1751
+ # If we have keyword arguments corresponding to fields on the
1752
+ # request, apply these.
1753
+ if parent is not None:
1754
+ request.parent = parent
1755
+ if instance_id is not None:
1756
+ request.instance_id = instance_id
1757
+ if instance is not None:
1758
+ request.instance = instance
1759
+
1760
+ # Wrap the RPC method; this adds retry and timeout information,
1761
+ # and friendly error handling.
1762
+ rpc = self._client._transport._wrapped_methods[
1763
+ self._client._transport.create_instance
1764
+ ]
1765
+
1766
+ # Certain fields should be provided within the metadata header;
1767
+ # add these here.
1768
+ metadata = tuple(metadata) + (
1769
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1770
+ )
1771
+
1772
+ # Validate the universe domain.
1773
+ self._client._validate_universe_domain()
1774
+
1775
+ # Send the request.
1776
+ response = await rpc(
1777
+ request,
1778
+ retry=retry,
1779
+ timeout=timeout,
1780
+ metadata=metadata,
1781
+ )
1782
+
1783
+ # Wrap the response in an operation future.
1784
+ response = operation_async.from_gapic(
1785
+ response,
1786
+ self._client._transport.operations_client,
1787
+ spanner_instance_admin.Instance,
1788
+ metadata_type=spanner_instance_admin.CreateInstanceMetadata,
1789
+ )
1790
+
1791
+ # Done; return the response.
1792
+ return response
1793
+
1794
+ async def update_instance(
1795
+ self,
1796
+ request: Optional[
1797
+ Union[spanner_instance_admin.UpdateInstanceRequest, dict]
1798
+ ] = None,
1799
+ *,
1800
+ instance: Optional[spanner_instance_admin.Instance] = None,
1801
+ field_mask: Optional[field_mask_pb2.FieldMask] = None,
1802
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1803
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1804
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1805
+ ) -> operation_async.AsyncOperation:
1806
+ r"""Updates an instance, and begins allocating or releasing
1807
+ resources as requested. The returned long-running operation can
1808
+ be used to track the progress of updating the instance. If the
1809
+ named instance does not exist, returns ``NOT_FOUND``.
1810
+
1811
+ Immediately upon completion of this request:
1812
+
1813
+ - For resource types for which a decrease in the instance's
1814
+ allocation has been requested, billing is based on the
1815
+ newly-requested level.
1816
+
1817
+ Until completion of the returned operation:
1818
+
1819
+ - Cancelling the operation sets its metadata's
1820
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time],
1821
+ and begins restoring resources to their pre-request values.
1822
+ The operation is guaranteed to succeed at undoing all
1823
+ resource changes, after which point it terminates with a
1824
+ ``CANCELLED`` status.
1825
+ - All other attempts to modify the instance are rejected.
1826
+ - Reading the instance via the API continues to give the
1827
+ pre-request resource levels.
1828
+
1829
+ Upon completion of the returned operation:
1830
+
1831
+ - Billing begins for all successfully-allocated resources (some
1832
+ types may have lower than the requested levels).
1833
+ - All newly-reserved resources are available for serving the
1834
+ instance's tables.
1835
+ - The instance's new resource levels are readable via the API.
1836
+
1837
+ The returned long-running operation will have a name of the
1838
+ format ``<instance_name>/operations/<operation_id>`` and can be
1839
+ used to track the instance modification. The metadata field type
1840
+ is
1841
+ [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata].
1842
+ The response field type is
1843
+ [Instance][google.spanner.admin.instance.v1.Instance], if
1844
+ successful.
1845
+
1846
+ Authorization requires ``spanner.instances.update`` permission
1847
+ on the resource
1848
+ [name][google.spanner.admin.instance.v1.Instance.name].
1849
+
1850
+ .. code-block:: python
1851
+
1852
+ # This snippet has been automatically generated and should be regarded as a
1853
+ # code template only.
1854
+ # It will require modifications to work:
1855
+ # - It may require correct/in-range values for request initialization.
1856
+ # - It may require specifying regional endpoints when creating the service
1857
+ # client as shown in:
1858
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1859
+ from google.cloud import spanner_admin_instance_v1
1860
+
1861
+ async def sample_update_instance():
1862
+ # Create a client
1863
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
1864
+
1865
+ # Initialize request argument(s)
1866
+ instance = spanner_admin_instance_v1.Instance()
1867
+ instance.name = "name_value"
1868
+ instance.config = "config_value"
1869
+ instance.display_name = "display_name_value"
1870
+
1871
+ request = spanner_admin_instance_v1.UpdateInstanceRequest(
1872
+ instance=instance,
1873
+ )
1874
+
1875
+ # Make the request
1876
+ operation = client.update_instance(request=request)
1877
+
1878
+ print("Waiting for operation to complete...")
1879
+
1880
+ response = (await operation).result()
1881
+
1882
+ # Handle the response
1883
+ print(response)
1884
+
1885
+ Args:
1886
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest, dict]]):
1887
+ The request object. The request for
1888
+ [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance].
1889
+ instance (:class:`google.cloud.spanner_admin_instance_v1.types.Instance`):
1890
+ Required. The instance to update, which must always
1891
+ include the instance name. Otherwise, only fields
1892
+ mentioned in
1893
+ [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask]
1894
+ need be included.
1895
+
1896
+ This corresponds to the ``instance`` field
1897
+ on the ``request`` instance; if ``request`` is provided, this
1898
+ should not be set.
1899
+ field_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
1900
+ Required. A mask specifying which fields in
1901
+ [Instance][google.spanner.admin.instance.v1.Instance]
1902
+ should be updated. The field mask must always be
1903
+ specified; this prevents any future fields in
1904
+ [Instance][google.spanner.admin.instance.v1.Instance]
1905
+ from being erased accidentally by clients that do not
1906
+ know about them.
1907
+
1908
+ This corresponds to the ``field_mask`` field
1909
+ on the ``request`` instance; if ``request`` is provided, this
1910
+ should not be set.
1911
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1912
+ should be retried.
1913
+ timeout (float): The timeout for this request.
1914
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1915
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1916
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1917
+ be of type `bytes`.
1918
+
1919
+ Returns:
1920
+ google.api_core.operation_async.AsyncOperation:
1921
+ An object representing a long-running operation.
1922
+
1923
+ The result type for the operation will be
1924
+ :class:`google.cloud.spanner_admin_instance_v1.types.Instance`
1925
+ An isolated set of Cloud Spanner resources on which
1926
+ databases can be hosted.
1927
+
1928
+ """
1929
+ # Create or coerce a protobuf request object.
1930
+ # - Quick check: If we got a request object, we should *not* have
1931
+ # gotten any keyword arguments that map to the request.
1932
+ flattened_params = [instance, field_mask]
1933
+ has_flattened_params = (
1934
+ len([param for param in flattened_params if param is not None]) > 0
1935
+ )
1936
+ if request is not None and has_flattened_params:
1937
+ raise ValueError(
1938
+ "If the `request` argument is set, then none of "
1939
+ "the individual field arguments should be set."
1940
+ )
1941
+
1942
+ # - Use the request object if provided (there's no risk of modifying the input as
1943
+ # there are no flattened fields), or create one.
1944
+ if not isinstance(request, spanner_instance_admin.UpdateInstanceRequest):
1945
+ request = spanner_instance_admin.UpdateInstanceRequest(request)
1946
+
1947
+ # If we have keyword arguments corresponding to fields on the
1948
+ # request, apply these.
1949
+ if instance is not None:
1950
+ request.instance = instance
1951
+ if field_mask is not None:
1952
+ request.field_mask = field_mask
1953
+
1954
+ # Wrap the RPC method; this adds retry and timeout information,
1955
+ # and friendly error handling.
1956
+ rpc = self._client._transport._wrapped_methods[
1957
+ self._client._transport.update_instance
1958
+ ]
1959
+
1960
+ # Certain fields should be provided within the metadata header;
1961
+ # add these here.
1962
+ metadata = tuple(metadata) + (
1963
+ gapic_v1.routing_header.to_grpc_metadata(
1964
+ (("instance.name", request.instance.name),)
1965
+ ),
1966
+ )
1967
+
1968
+ # Validate the universe domain.
1969
+ self._client._validate_universe_domain()
1970
+
1971
+ # Send the request.
1972
+ response = await rpc(
1973
+ request,
1974
+ retry=retry,
1975
+ timeout=timeout,
1976
+ metadata=metadata,
1977
+ )
1978
+
1979
+ # Wrap the response in an operation future.
1980
+ response = operation_async.from_gapic(
1981
+ response,
1982
+ self._client._transport.operations_client,
1983
+ spanner_instance_admin.Instance,
1984
+ metadata_type=spanner_instance_admin.UpdateInstanceMetadata,
1985
+ )
1986
+
1987
+ # Done; return the response.
1988
+ return response
1989
+
1990
+ async def delete_instance(
1991
+ self,
1992
+ request: Optional[
1993
+ Union[spanner_instance_admin.DeleteInstanceRequest, dict]
1994
+ ] = None,
1995
+ *,
1996
+ name: Optional[str] = None,
1997
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1998
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1999
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2000
+ ) -> None:
2001
+ r"""Deletes an instance.
2002
+
2003
+ Immediately upon completion of the request:
2004
+
2005
+ - Billing ceases for all of the instance's reserved resources.
2006
+
2007
+ Soon afterward:
2008
+
2009
+ - The instance and *all of its databases* immediately and
2010
+ irrevocably disappear from the API. All data in the databases
2011
+ is permanently deleted.
2012
+
2013
+ .. code-block:: python
2014
+
2015
+ # This snippet has been automatically generated and should be regarded as a
2016
+ # code template only.
2017
+ # It will require modifications to work:
2018
+ # - It may require correct/in-range values for request initialization.
2019
+ # - It may require specifying regional endpoints when creating the service
2020
+ # client as shown in:
2021
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2022
+ from google.cloud import spanner_admin_instance_v1
2023
+
2024
+ async def sample_delete_instance():
2025
+ # Create a client
2026
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2027
+
2028
+ # Initialize request argument(s)
2029
+ request = spanner_admin_instance_v1.DeleteInstanceRequest(
2030
+ name="name_value",
2031
+ )
2032
+
2033
+ # Make the request
2034
+ await client.delete_instance(request=request)
2035
+
2036
+ Args:
2037
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest, dict]]):
2038
+ The request object. The request for
2039
+ [DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance].
2040
+ name (:class:`str`):
2041
+ Required. The name of the instance to be deleted. Values
2042
+ are of the form
2043
+ ``projects/<project>/instances/<instance>``
2044
+
2045
+ This corresponds to the ``name`` field
2046
+ on the ``request`` instance; if ``request`` is provided, this
2047
+ should not be set.
2048
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2049
+ should be retried.
2050
+ timeout (float): The timeout for this request.
2051
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2052
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2053
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2054
+ be of type `bytes`.
2055
+ """
2056
+ # Create or coerce a protobuf request object.
2057
+ # - Quick check: If we got a request object, we should *not* have
2058
+ # gotten any keyword arguments that map to the request.
2059
+ flattened_params = [name]
2060
+ has_flattened_params = (
2061
+ len([param for param in flattened_params if param is not None]) > 0
2062
+ )
2063
+ if request is not None and has_flattened_params:
2064
+ raise ValueError(
2065
+ "If the `request` argument is set, then none of "
2066
+ "the individual field arguments should be set."
2067
+ )
2068
+
2069
+ # - Use the request object if provided (there's no risk of modifying the input as
2070
+ # there are no flattened fields), or create one.
2071
+ if not isinstance(request, spanner_instance_admin.DeleteInstanceRequest):
2072
+ request = spanner_instance_admin.DeleteInstanceRequest(request)
2073
+
2074
+ # If we have keyword arguments corresponding to fields on the
2075
+ # request, apply these.
2076
+ if name is not None:
2077
+ request.name = name
2078
+
2079
+ # Wrap the RPC method; this adds retry and timeout information,
2080
+ # and friendly error handling.
2081
+ rpc = self._client._transport._wrapped_methods[
2082
+ self._client._transport.delete_instance
2083
+ ]
2084
+
2085
+ # Certain fields should be provided within the metadata header;
2086
+ # add these here.
2087
+ metadata = tuple(metadata) + (
2088
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2089
+ )
2090
+
2091
+ # Validate the universe domain.
2092
+ self._client._validate_universe_domain()
2093
+
2094
+ # Send the request.
2095
+ await rpc(
2096
+ request,
2097
+ retry=retry,
2098
+ timeout=timeout,
2099
+ metadata=metadata,
2100
+ )
2101
+
2102
+ async def set_iam_policy(
2103
+ self,
2104
+ request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
2105
+ *,
2106
+ resource: Optional[str] = None,
2107
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2108
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2109
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2110
+ ) -> policy_pb2.Policy:
2111
+ r"""Sets the access control policy on an instance resource. Replaces
2112
+ any existing policy.
2113
+
2114
+ Authorization requires ``spanner.instances.setIamPolicy`` on
2115
+ [resource][google.iam.v1.SetIamPolicyRequest.resource].
2116
+
2117
+ .. code-block:: python
2118
+
2119
+ # This snippet has been automatically generated and should be regarded as a
2120
+ # code template only.
2121
+ # It will require modifications to work:
2122
+ # - It may require correct/in-range values for request initialization.
2123
+ # - It may require specifying regional endpoints when creating the service
2124
+ # client as shown in:
2125
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2126
+ from google.cloud import spanner_admin_instance_v1
2127
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
2128
+
2129
+ async def sample_set_iam_policy():
2130
+ # Create a client
2131
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2132
+
2133
+ # Initialize request argument(s)
2134
+ request = iam_policy_pb2.SetIamPolicyRequest(
2135
+ resource="resource_value",
2136
+ )
2137
+
2138
+ # Make the request
2139
+ response = await client.set_iam_policy(request=request)
2140
+
2141
+ # Handle the response
2142
+ print(response)
2143
+
2144
+ Args:
2145
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]):
2146
+ The request object. Request message for ``SetIamPolicy`` method.
2147
+ resource (:class:`str`):
2148
+ REQUIRED: The resource for which the
2149
+ policy is being specified. See the
2150
+ operation documentation for the
2151
+ appropriate value for this field.
2152
+
2153
+ This corresponds to the ``resource`` field
2154
+ on the ``request`` instance; if ``request`` is provided, this
2155
+ should not be set.
2156
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2157
+ should be retried.
2158
+ timeout (float): The timeout for this request.
2159
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2160
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2161
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2162
+ be of type `bytes`.
2163
+
2164
+ Returns:
2165
+ google.iam.v1.policy_pb2.Policy:
2166
+ An Identity and Access Management (IAM) policy, which specifies access
2167
+ controls for Google Cloud resources.
2168
+
2169
+ A Policy is a collection of bindings. A binding binds
2170
+ one or more members, or principals, to a single role.
2171
+ Principals can be user accounts, service accounts,
2172
+ Google groups, and domains (such as G Suite). A role
2173
+ is a named list of permissions; each role can be an
2174
+ IAM predefined role or a user-created custom role.
2175
+
2176
+ For some types of Google Cloud resources, a binding
2177
+ can also specify a condition, which is a logical
2178
+ expression that allows access to a resource only if
2179
+ the expression evaluates to true. A condition can add
2180
+ constraints based on attributes of the request, the
2181
+ resource, or both. To learn which resources support
2182
+ conditions in their IAM policies, see the [IAM
2183
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
2184
+
2185
+ **JSON example:**
2186
+
2187
+ :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \`
2188
+
2189
+ **YAML example:**
2190
+
2191
+ :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \`
2192
+
2193
+ For a description of IAM and its features, see the
2194
+ [IAM
2195
+ documentation](\ https://cloud.google.com/iam/docs/).
2196
+
2197
+ """
2198
+ # Create or coerce a protobuf request object.
2199
+ # - Quick check: If we got a request object, we should *not* have
2200
+ # gotten any keyword arguments that map to the request.
2201
+ flattened_params = [resource]
2202
+ has_flattened_params = (
2203
+ len([param for param in flattened_params if param is not None]) > 0
2204
+ )
2205
+ if request is not None and has_flattened_params:
2206
+ raise ValueError(
2207
+ "If the `request` argument is set, then none of "
2208
+ "the individual field arguments should be set."
2209
+ )
2210
+
2211
+ # - The request isn't a proto-plus wrapped type,
2212
+ # so it must be constructed via keyword expansion.
2213
+ if isinstance(request, dict):
2214
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
2215
+ elif not request:
2216
+ request = iam_policy_pb2.SetIamPolicyRequest(resource=resource)
2217
+
2218
+ # Wrap the RPC method; this adds retry and timeout information,
2219
+ # and friendly error handling.
2220
+ rpc = self._client._transport._wrapped_methods[
2221
+ self._client._transport.set_iam_policy
2222
+ ]
2223
+
2224
+ # Certain fields should be provided within the metadata header;
2225
+ # add these here.
2226
+ metadata = tuple(metadata) + (
2227
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
2228
+ )
2229
+
2230
+ # Validate the universe domain.
2231
+ self._client._validate_universe_domain()
2232
+
2233
+ # Send the request.
2234
+ response = await rpc(
2235
+ request,
2236
+ retry=retry,
2237
+ timeout=timeout,
2238
+ metadata=metadata,
2239
+ )
2240
+
2241
+ # Done; return the response.
2242
+ return response
2243
+
2244
+ async def get_iam_policy(
2245
+ self,
2246
+ request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
2247
+ *,
2248
+ resource: Optional[str] = None,
2249
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2250
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2251
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2252
+ ) -> policy_pb2.Policy:
2253
+ r"""Gets the access control policy for an instance resource. Returns
2254
+ an empty policy if an instance exists but does not have a policy
2255
+ set.
2256
+
2257
+ Authorization requires ``spanner.instances.getIamPolicy`` on
2258
+ [resource][google.iam.v1.GetIamPolicyRequest.resource].
2259
+
2260
+ .. code-block:: python
2261
+
2262
+ # This snippet has been automatically generated and should be regarded as a
2263
+ # code template only.
2264
+ # It will require modifications to work:
2265
+ # - It may require correct/in-range values for request initialization.
2266
+ # - It may require specifying regional endpoints when creating the service
2267
+ # client as shown in:
2268
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2269
+ from google.cloud import spanner_admin_instance_v1
2270
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
2271
+
2272
+ async def sample_get_iam_policy():
2273
+ # Create a client
2274
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2275
+
2276
+ # Initialize request argument(s)
2277
+ request = iam_policy_pb2.GetIamPolicyRequest(
2278
+ resource="resource_value",
2279
+ )
2280
+
2281
+ # Make the request
2282
+ response = await client.get_iam_policy(request=request)
2283
+
2284
+ # Handle the response
2285
+ print(response)
2286
+
2287
+ Args:
2288
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]):
2289
+ The request object. Request message for ``GetIamPolicy`` method.
2290
+ resource (:class:`str`):
2291
+ REQUIRED: The resource for which the
2292
+ policy is being requested. See the
2293
+ operation documentation for the
2294
+ appropriate value for this field.
2295
+
2296
+ This corresponds to the ``resource`` field
2297
+ on the ``request`` instance; if ``request`` is provided, this
2298
+ should not be set.
2299
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2300
+ should be retried.
2301
+ timeout (float): The timeout for this request.
2302
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2303
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2304
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2305
+ be of type `bytes`.
2306
+
2307
+ Returns:
2308
+ google.iam.v1.policy_pb2.Policy:
2309
+ An Identity and Access Management (IAM) policy, which specifies access
2310
+ controls for Google Cloud resources.
2311
+
2312
+ A Policy is a collection of bindings. A binding binds
2313
+ one or more members, or principals, to a single role.
2314
+ Principals can be user accounts, service accounts,
2315
+ Google groups, and domains (such as G Suite). A role
2316
+ is a named list of permissions; each role can be an
2317
+ IAM predefined role or a user-created custom role.
2318
+
2319
+ For some types of Google Cloud resources, a binding
2320
+ can also specify a condition, which is a logical
2321
+ expression that allows access to a resource only if
2322
+ the expression evaluates to true. A condition can add
2323
+ constraints based on attributes of the request, the
2324
+ resource, or both. To learn which resources support
2325
+ conditions in their IAM policies, see the [IAM
2326
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
2327
+
2328
+ **JSON example:**
2329
+
2330
+ :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \`
2331
+
2332
+ **YAML example:**
2333
+
2334
+ :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \`
2335
+
2336
+ For a description of IAM and its features, see the
2337
+ [IAM
2338
+ documentation](\ https://cloud.google.com/iam/docs/).
2339
+
2340
+ """
2341
+ # Create or coerce a protobuf request object.
2342
+ # - Quick check: If we got a request object, we should *not* have
2343
+ # gotten any keyword arguments that map to the request.
2344
+ flattened_params = [resource]
2345
+ has_flattened_params = (
2346
+ len([param for param in flattened_params if param is not None]) > 0
2347
+ )
2348
+ if request is not None and has_flattened_params:
2349
+ raise ValueError(
2350
+ "If the `request` argument is set, then none of "
2351
+ "the individual field arguments should be set."
2352
+ )
2353
+
2354
+ # - The request isn't a proto-plus wrapped type,
2355
+ # so it must be constructed via keyword expansion.
2356
+ if isinstance(request, dict):
2357
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
2358
+ elif not request:
2359
+ request = iam_policy_pb2.GetIamPolicyRequest(resource=resource)
2360
+
2361
+ # Wrap the RPC method; this adds retry and timeout information,
2362
+ # and friendly error handling.
2363
+ rpc = self._client._transport._wrapped_methods[
2364
+ self._client._transport.get_iam_policy
2365
+ ]
2366
+
2367
+ # Certain fields should be provided within the metadata header;
2368
+ # add these here.
2369
+ metadata = tuple(metadata) + (
2370
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
2371
+ )
2372
+
2373
+ # Validate the universe domain.
2374
+ self._client._validate_universe_domain()
2375
+
2376
+ # Send the request.
2377
+ response = await rpc(
2378
+ request,
2379
+ retry=retry,
2380
+ timeout=timeout,
2381
+ metadata=metadata,
2382
+ )
2383
+
2384
+ # Done; return the response.
2385
+ return response
2386
+
2387
+ async def test_iam_permissions(
2388
+ self,
2389
+ request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
2390
+ *,
2391
+ resource: Optional[str] = None,
2392
+ permissions: Optional[MutableSequence[str]] = None,
2393
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2394
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2395
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2396
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
2397
+ r"""Returns permissions that the caller has on the specified
2398
+ instance resource.
2399
+
2400
+ Attempting this RPC on a non-existent Cloud Spanner instance
2401
+ resource will result in a NOT_FOUND error if the user has
2402
+ ``spanner.instances.list`` permission on the containing Google
2403
+ Cloud Project. Otherwise returns an empty set of permissions.
2404
+
2405
+ .. code-block:: python
2406
+
2407
+ # This snippet has been automatically generated and should be regarded as a
2408
+ # code template only.
2409
+ # It will require modifications to work:
2410
+ # - It may require correct/in-range values for request initialization.
2411
+ # - It may require specifying regional endpoints when creating the service
2412
+ # client as shown in:
2413
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2414
+ from google.cloud import spanner_admin_instance_v1
2415
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
2416
+
2417
+ async def sample_test_iam_permissions():
2418
+ # Create a client
2419
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2420
+
2421
+ # Initialize request argument(s)
2422
+ request = iam_policy_pb2.TestIamPermissionsRequest(
2423
+ resource="resource_value",
2424
+ permissions=['permissions_value1', 'permissions_value2'],
2425
+ )
2426
+
2427
+ # Make the request
2428
+ response = await client.test_iam_permissions(request=request)
2429
+
2430
+ # Handle the response
2431
+ print(response)
2432
+
2433
+ Args:
2434
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]):
2435
+ The request object. Request message for ``TestIamPermissions`` method.
2436
+ resource (:class:`str`):
2437
+ REQUIRED: The resource for which the
2438
+ policy detail is being requested. See
2439
+ the operation documentation for the
2440
+ appropriate value for this field.
2441
+
2442
+ This corresponds to the ``resource`` field
2443
+ on the ``request`` instance; if ``request`` is provided, this
2444
+ should not be set.
2445
+ permissions (:class:`MutableSequence[str]`):
2446
+ The set of permissions to check for the ``resource``.
2447
+ Permissions with wildcards (such as '*' or 'storage.*')
2448
+ are not allowed. For more information see `IAM
2449
+ Overview <https://cloud.google.com/iam/docs/overview#permissions>`__.
2450
+
2451
+ This corresponds to the ``permissions`` field
2452
+ on the ``request`` instance; if ``request`` is provided, this
2453
+ should not be set.
2454
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2455
+ should be retried.
2456
+ timeout (float): The timeout for this request.
2457
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2458
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2459
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2460
+ be of type `bytes`.
2461
+
2462
+ Returns:
2463
+ google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse:
2464
+ Response message for TestIamPermissions method.
2465
+ """
2466
+ # Create or coerce a protobuf request object.
2467
+ # - Quick check: If we got a request object, we should *not* have
2468
+ # gotten any keyword arguments that map to the request.
2469
+ flattened_params = [resource, permissions]
2470
+ has_flattened_params = (
2471
+ len([param for param in flattened_params if param is not None]) > 0
2472
+ )
2473
+ if request is not None and has_flattened_params:
2474
+ raise ValueError(
2475
+ "If the `request` argument is set, then none of "
2476
+ "the individual field arguments should be set."
2477
+ )
2478
+
2479
+ # - The request isn't a proto-plus wrapped type,
2480
+ # so it must be constructed via keyword expansion.
2481
+ if isinstance(request, dict):
2482
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
2483
+ elif not request:
2484
+ request = iam_policy_pb2.TestIamPermissionsRequest(
2485
+ resource=resource, permissions=permissions
2486
+ )
2487
+
2488
+ # Wrap the RPC method; this adds retry and timeout information,
2489
+ # and friendly error handling.
2490
+ rpc = self._client._transport._wrapped_methods[
2491
+ self._client._transport.test_iam_permissions
2492
+ ]
2493
+
2494
+ # Certain fields should be provided within the metadata header;
2495
+ # add these here.
2496
+ metadata = tuple(metadata) + (
2497
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
2498
+ )
2499
+
2500
+ # Validate the universe domain.
2501
+ self._client._validate_universe_domain()
2502
+
2503
+ # Send the request.
2504
+ response = await rpc(
2505
+ request,
2506
+ retry=retry,
2507
+ timeout=timeout,
2508
+ metadata=metadata,
2509
+ )
2510
+
2511
+ # Done; return the response.
2512
+ return response
2513
+
2514
+ async def get_instance_partition(
2515
+ self,
2516
+ request: Optional[
2517
+ Union[spanner_instance_admin.GetInstancePartitionRequest, dict]
2518
+ ] = None,
2519
+ *,
2520
+ name: Optional[str] = None,
2521
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2522
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2523
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2524
+ ) -> spanner_instance_admin.InstancePartition:
2525
+ r"""Gets information about a particular instance
2526
+ partition.
2527
+
2528
+ .. code-block:: python
2529
+
2530
+ # This snippet has been automatically generated and should be regarded as a
2531
+ # code template only.
2532
+ # It will require modifications to work:
2533
+ # - It may require correct/in-range values for request initialization.
2534
+ # - It may require specifying regional endpoints when creating the service
2535
+ # client as shown in:
2536
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2537
+ from google.cloud import spanner_admin_instance_v1
2538
+
2539
+ async def sample_get_instance_partition():
2540
+ # Create a client
2541
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2542
+
2543
+ # Initialize request argument(s)
2544
+ request = spanner_admin_instance_v1.GetInstancePartitionRequest(
2545
+ name="name_value",
2546
+ )
2547
+
2548
+ # Make the request
2549
+ response = await client.get_instance_partition(request=request)
2550
+
2551
+ # Handle the response
2552
+ print(response)
2553
+
2554
+ Args:
2555
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.GetInstancePartitionRequest, dict]]):
2556
+ The request object. The request for
2557
+ [GetInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.GetInstancePartition].
2558
+ name (:class:`str`):
2559
+ Required. The name of the requested instance partition.
2560
+ Values are of the form
2561
+ ``projects/{project}/instances/{instance}/instancePartitions/{instance_partition}``.
2562
+
2563
+ This corresponds to the ``name`` field
2564
+ on the ``request`` instance; if ``request`` is provided, this
2565
+ should not be set.
2566
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2567
+ should be retried.
2568
+ timeout (float): The timeout for this request.
2569
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2570
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2571
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2572
+ be of type `bytes`.
2573
+
2574
+ Returns:
2575
+ google.cloud.spanner_admin_instance_v1.types.InstancePartition:
2576
+ An isolated set of Cloud Spanner
2577
+ resources that databases can define
2578
+ placements on.
2579
+
2580
+ """
2581
+ # Create or coerce a protobuf request object.
2582
+ # - Quick check: If we got a request object, we should *not* have
2583
+ # gotten any keyword arguments that map to the request.
2584
+ flattened_params = [name]
2585
+ has_flattened_params = (
2586
+ len([param for param in flattened_params if param is not None]) > 0
2587
+ )
2588
+ if request is not None and has_flattened_params:
2589
+ raise ValueError(
2590
+ "If the `request` argument is set, then none of "
2591
+ "the individual field arguments should be set."
2592
+ )
2593
+
2594
+ # - Use the request object if provided (there's no risk of modifying the input as
2595
+ # there are no flattened fields), or create one.
2596
+ if not isinstance(request, spanner_instance_admin.GetInstancePartitionRequest):
2597
+ request = spanner_instance_admin.GetInstancePartitionRequest(request)
2598
+
2599
+ # If we have keyword arguments corresponding to fields on the
2600
+ # request, apply these.
2601
+ if name is not None:
2602
+ request.name = name
2603
+
2604
+ # Wrap the RPC method; this adds retry and timeout information,
2605
+ # and friendly error handling.
2606
+ rpc = self._client._transport._wrapped_methods[
2607
+ self._client._transport.get_instance_partition
2608
+ ]
2609
+
2610
+ # Certain fields should be provided within the metadata header;
2611
+ # add these here.
2612
+ metadata = tuple(metadata) + (
2613
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2614
+ )
2615
+
2616
+ # Validate the universe domain.
2617
+ self._client._validate_universe_domain()
2618
+
2619
+ # Send the request.
2620
+ response = await rpc(
2621
+ request,
2622
+ retry=retry,
2623
+ timeout=timeout,
2624
+ metadata=metadata,
2625
+ )
2626
+
2627
+ # Done; return the response.
2628
+ return response
2629
+
2630
+ async def create_instance_partition(
2631
+ self,
2632
+ request: Optional[
2633
+ Union[spanner_instance_admin.CreateInstancePartitionRequest, dict]
2634
+ ] = None,
2635
+ *,
2636
+ parent: Optional[str] = None,
2637
+ instance_partition: Optional[spanner_instance_admin.InstancePartition] = None,
2638
+ instance_partition_id: Optional[str] = None,
2639
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2640
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2641
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2642
+ ) -> operation_async.AsyncOperation:
2643
+ r"""Creates an instance partition and begins preparing it to be
2644
+ used. The returned long-running operation can be used to track
2645
+ the progress of preparing the new instance partition. The
2646
+ instance partition name is assigned by the caller. If the named
2647
+ instance partition already exists, ``CreateInstancePartition``
2648
+ returns ``ALREADY_EXISTS``.
2649
+
2650
+ Immediately upon completion of this request:
2651
+
2652
+ - The instance partition is readable via the API, with all
2653
+ requested attributes but no allocated resources. Its state is
2654
+ ``CREATING``.
2655
+
2656
+ Until completion of the returned operation:
2657
+
2658
+ - Cancelling the operation renders the instance partition
2659
+ immediately unreadable via the API.
2660
+ - The instance partition can be deleted.
2661
+ - All other attempts to modify the instance partition are
2662
+ rejected.
2663
+
2664
+ Upon completion of the returned operation:
2665
+
2666
+ - Billing for all successfully-allocated resources begins (some
2667
+ types may have lower than the requested levels).
2668
+ - Databases can start using this instance partition.
2669
+ - The instance partition's allocated resource levels are
2670
+ readable via the API.
2671
+ - The instance partition's state becomes ``READY``.
2672
+
2673
+ The returned long-running operation will have a name of the
2674
+ format ``<instance_partition_name>/operations/<operation_id>``
2675
+ and can be used to track creation of the instance partition. The
2676
+ metadata field type is
2677
+ [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata].
2678
+ The response field type is
2679
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition],
2680
+ if successful.
2681
+
2682
+ .. code-block:: python
2683
+
2684
+ # This snippet has been automatically generated and should be regarded as a
2685
+ # code template only.
2686
+ # It will require modifications to work:
2687
+ # - It may require correct/in-range values for request initialization.
2688
+ # - It may require specifying regional endpoints when creating the service
2689
+ # client as shown in:
2690
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2691
+ from google.cloud import spanner_admin_instance_v1
2692
+
2693
+ async def sample_create_instance_partition():
2694
+ # Create a client
2695
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2696
+
2697
+ # Initialize request argument(s)
2698
+ instance_partition = spanner_admin_instance_v1.InstancePartition()
2699
+ instance_partition.node_count = 1070
2700
+ instance_partition.name = "name_value"
2701
+ instance_partition.config = "config_value"
2702
+ instance_partition.display_name = "display_name_value"
2703
+
2704
+ request = spanner_admin_instance_v1.CreateInstancePartitionRequest(
2705
+ parent="parent_value",
2706
+ instance_partition_id="instance_partition_id_value",
2707
+ instance_partition=instance_partition,
2708
+ )
2709
+
2710
+ # Make the request
2711
+ operation = client.create_instance_partition(request=request)
2712
+
2713
+ print("Waiting for operation to complete...")
2714
+
2715
+ response = (await operation).result()
2716
+
2717
+ # Handle the response
2718
+ print(response)
2719
+
2720
+ Args:
2721
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.CreateInstancePartitionRequest, dict]]):
2722
+ The request object. The request for
2723
+ [CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition].
2724
+ parent (:class:`str`):
2725
+ Required. The name of the instance in which to create
2726
+ the instance partition. Values are of the form
2727
+ ``projects/<project>/instances/<instance>``.
2728
+
2729
+ This corresponds to the ``parent`` field
2730
+ on the ``request`` instance; if ``request`` is provided, this
2731
+ should not be set.
2732
+ instance_partition (:class:`google.cloud.spanner_admin_instance_v1.types.InstancePartition`):
2733
+ Required. The instance partition to create. The
2734
+ instance_partition.name may be omitted, but if specified
2735
+ must be
2736
+ ``<parent>/instancePartitions/<instance_partition_id>``.
2737
+
2738
+ This corresponds to the ``instance_partition`` field
2739
+ on the ``request`` instance; if ``request`` is provided, this
2740
+ should not be set.
2741
+ instance_partition_id (:class:`str`):
2742
+ Required. The ID of the instance partition to create.
2743
+ Valid identifiers are of the form
2744
+ ``[a-z][-a-z0-9]*[a-z0-9]`` and must be between 2 and 64
2745
+ characters in length.
2746
+
2747
+ This corresponds to the ``instance_partition_id`` field
2748
+ on the ``request`` instance; if ``request`` is provided, this
2749
+ should not be set.
2750
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2751
+ should be retried.
2752
+ timeout (float): The timeout for this request.
2753
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2754
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2755
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2756
+ be of type `bytes`.
2757
+
2758
+ Returns:
2759
+ google.api_core.operation_async.AsyncOperation:
2760
+ An object representing a long-running operation.
2761
+
2762
+ The result type for the operation will be :class:`google.cloud.spanner_admin_instance_v1.types.InstancePartition` An isolated set of Cloud Spanner resources that databases can define
2763
+ placements on.
2764
+
2765
+ """
2766
+ # Create or coerce a protobuf request object.
2767
+ # - Quick check: If we got a request object, we should *not* have
2768
+ # gotten any keyword arguments that map to the request.
2769
+ flattened_params = [parent, instance_partition, instance_partition_id]
2770
+ has_flattened_params = (
2771
+ len([param for param in flattened_params if param is not None]) > 0
2772
+ )
2773
+ if request is not None and has_flattened_params:
2774
+ raise ValueError(
2775
+ "If the `request` argument is set, then none of "
2776
+ "the individual field arguments should be set."
2777
+ )
2778
+
2779
+ # - Use the request object if provided (there's no risk of modifying the input as
2780
+ # there are no flattened fields), or create one.
2781
+ if not isinstance(
2782
+ request, spanner_instance_admin.CreateInstancePartitionRequest
2783
+ ):
2784
+ request = spanner_instance_admin.CreateInstancePartitionRequest(request)
2785
+
2786
+ # If we have keyword arguments corresponding to fields on the
2787
+ # request, apply these.
2788
+ if parent is not None:
2789
+ request.parent = parent
2790
+ if instance_partition is not None:
2791
+ request.instance_partition = instance_partition
2792
+ if instance_partition_id is not None:
2793
+ request.instance_partition_id = instance_partition_id
2794
+
2795
+ # Wrap the RPC method; this adds retry and timeout information,
2796
+ # and friendly error handling.
2797
+ rpc = self._client._transport._wrapped_methods[
2798
+ self._client._transport.create_instance_partition
2799
+ ]
2800
+
2801
+ # Certain fields should be provided within the metadata header;
2802
+ # add these here.
2803
+ metadata = tuple(metadata) + (
2804
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2805
+ )
2806
+
2807
+ # Validate the universe domain.
2808
+ self._client._validate_universe_domain()
2809
+
2810
+ # Send the request.
2811
+ response = await rpc(
2812
+ request,
2813
+ retry=retry,
2814
+ timeout=timeout,
2815
+ metadata=metadata,
2816
+ )
2817
+
2818
+ # Wrap the response in an operation future.
2819
+ response = operation_async.from_gapic(
2820
+ response,
2821
+ self._client._transport.operations_client,
2822
+ spanner_instance_admin.InstancePartition,
2823
+ metadata_type=spanner_instance_admin.CreateInstancePartitionMetadata,
2824
+ )
2825
+
2826
+ # Done; return the response.
2827
+ return response
2828
+
2829
+ async def delete_instance_partition(
2830
+ self,
2831
+ request: Optional[
2832
+ Union[spanner_instance_admin.DeleteInstancePartitionRequest, dict]
2833
+ ] = None,
2834
+ *,
2835
+ name: Optional[str] = None,
2836
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2837
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2838
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2839
+ ) -> None:
2840
+ r"""Deletes an existing instance partition. Requires that the
2841
+ instance partition is not used by any database or backup and is
2842
+ not the default instance partition of an instance.
2843
+
2844
+ Authorization requires ``spanner.instancePartitions.delete``
2845
+ permission on the resource
2846
+ [name][google.spanner.admin.instance.v1.InstancePartition.name].
2847
+
2848
+ .. code-block:: python
2849
+
2850
+ # This snippet has been automatically generated and should be regarded as a
2851
+ # code template only.
2852
+ # It will require modifications to work:
2853
+ # - It may require correct/in-range values for request initialization.
2854
+ # - It may require specifying regional endpoints when creating the service
2855
+ # client as shown in:
2856
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2857
+ from google.cloud import spanner_admin_instance_v1
2858
+
2859
+ async def sample_delete_instance_partition():
2860
+ # Create a client
2861
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
2862
+
2863
+ # Initialize request argument(s)
2864
+ request = spanner_admin_instance_v1.DeleteInstancePartitionRequest(
2865
+ name="name_value",
2866
+ )
2867
+
2868
+ # Make the request
2869
+ await client.delete_instance_partition(request=request)
2870
+
2871
+ Args:
2872
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstancePartitionRequest, dict]]):
2873
+ The request object. The request for
2874
+ [DeleteInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstancePartition].
2875
+ name (:class:`str`):
2876
+ Required. The name of the instance partition to be
2877
+ deleted. Values are of the form
2878
+ ``projects/{project}/instances/{instance}/instancePartitions/{instance_partition}``
2879
+
2880
+ This corresponds to the ``name`` field
2881
+ on the ``request`` instance; if ``request`` is provided, this
2882
+ should not be set.
2883
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
2884
+ should be retried.
2885
+ timeout (float): The timeout for this request.
2886
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2887
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2888
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2889
+ be of type `bytes`.
2890
+ """
2891
+ # Create or coerce a protobuf request object.
2892
+ # - Quick check: If we got a request object, we should *not* have
2893
+ # gotten any keyword arguments that map to the request.
2894
+ flattened_params = [name]
2895
+ has_flattened_params = (
2896
+ len([param for param in flattened_params if param is not None]) > 0
2897
+ )
2898
+ if request is not None and has_flattened_params:
2899
+ raise ValueError(
2900
+ "If the `request` argument is set, then none of "
2901
+ "the individual field arguments should be set."
2902
+ )
2903
+
2904
+ # - Use the request object if provided (there's no risk of modifying the input as
2905
+ # there are no flattened fields), or create one.
2906
+ if not isinstance(
2907
+ request, spanner_instance_admin.DeleteInstancePartitionRequest
2908
+ ):
2909
+ request = spanner_instance_admin.DeleteInstancePartitionRequest(request)
2910
+
2911
+ # If we have keyword arguments corresponding to fields on the
2912
+ # request, apply these.
2913
+ if name is not None:
2914
+ request.name = name
2915
+
2916
+ # Wrap the RPC method; this adds retry and timeout information,
2917
+ # and friendly error handling.
2918
+ rpc = self._client._transport._wrapped_methods[
2919
+ self._client._transport.delete_instance_partition
2920
+ ]
2921
+
2922
+ # Certain fields should be provided within the metadata header;
2923
+ # add these here.
2924
+ metadata = tuple(metadata) + (
2925
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2926
+ )
2927
+
2928
+ # Validate the universe domain.
2929
+ self._client._validate_universe_domain()
2930
+
2931
+ # Send the request.
2932
+ await rpc(
2933
+ request,
2934
+ retry=retry,
2935
+ timeout=timeout,
2936
+ metadata=metadata,
2937
+ )
2938
+
2939
+ async def update_instance_partition(
2940
+ self,
2941
+ request: Optional[
2942
+ Union[spanner_instance_admin.UpdateInstancePartitionRequest, dict]
2943
+ ] = None,
2944
+ *,
2945
+ instance_partition: Optional[spanner_instance_admin.InstancePartition] = None,
2946
+ field_mask: Optional[field_mask_pb2.FieldMask] = None,
2947
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2948
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2949
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2950
+ ) -> operation_async.AsyncOperation:
2951
+ r"""Updates an instance partition, and begins allocating or
2952
+ releasing resources as requested. The returned long-running
2953
+ operation can be used to track the progress of updating the
2954
+ instance partition. If the named instance partition does not
2955
+ exist, returns ``NOT_FOUND``.
2956
+
2957
+ Immediately upon completion of this request:
2958
+
2959
+ - For resource types for which a decrease in the instance
2960
+ partition's allocation has been requested, billing is based
2961
+ on the newly-requested level.
2962
+
2963
+ Until completion of the returned operation:
2964
+
2965
+ - Cancelling the operation sets its metadata's
2966
+ [cancel_time][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time],
2967
+ and begins restoring resources to their pre-request values.
2968
+ The operation is guaranteed to succeed at undoing all
2969
+ resource changes, after which point it terminates with a
2970
+ ``CANCELLED`` status.
2971
+ - All other attempts to modify the instance partition are
2972
+ rejected.
2973
+ - Reading the instance partition via the API continues to give
2974
+ the pre-request resource levels.
2975
+
2976
+ Upon completion of the returned operation:
2977
+
2978
+ - Billing begins for all successfully-allocated resources (some
2979
+ types may have lower than the requested levels).
2980
+ - All newly-reserved resources are available for serving the
2981
+ instance partition's tables.
2982
+ - The instance partition's new resource levels are readable via
2983
+ the API.
2984
+
2985
+ The returned long-running operation will have a name of the
2986
+ format ``<instance_partition_name>/operations/<operation_id>``
2987
+ and can be used to track the instance partition modification.
2988
+ The metadata field type is
2989
+ [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata].
2990
+ The response field type is
2991
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition],
2992
+ if successful.
2993
+
2994
+ Authorization requires ``spanner.instancePartitions.update``
2995
+ permission on the resource
2996
+ [name][google.spanner.admin.instance.v1.InstancePartition.name].
2997
+
2998
+ .. code-block:: python
2999
+
3000
+ # This snippet has been automatically generated and should be regarded as a
3001
+ # code template only.
3002
+ # It will require modifications to work:
3003
+ # - It may require correct/in-range values for request initialization.
3004
+ # - It may require specifying regional endpoints when creating the service
3005
+ # client as shown in:
3006
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3007
+ from google.cloud import spanner_admin_instance_v1
3008
+
3009
+ async def sample_update_instance_partition():
3010
+ # Create a client
3011
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
3012
+
3013
+ # Initialize request argument(s)
3014
+ instance_partition = spanner_admin_instance_v1.InstancePartition()
3015
+ instance_partition.node_count = 1070
3016
+ instance_partition.name = "name_value"
3017
+ instance_partition.config = "config_value"
3018
+ instance_partition.display_name = "display_name_value"
3019
+
3020
+ request = spanner_admin_instance_v1.UpdateInstancePartitionRequest(
3021
+ instance_partition=instance_partition,
3022
+ )
3023
+
3024
+ # Make the request
3025
+ operation = client.update_instance_partition(request=request)
3026
+
3027
+ print("Waiting for operation to complete...")
3028
+
3029
+ response = (await operation).result()
3030
+
3031
+ # Handle the response
3032
+ print(response)
3033
+
3034
+ Args:
3035
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstancePartitionRequest, dict]]):
3036
+ The request object. The request for
3037
+ [UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition].
3038
+ instance_partition (:class:`google.cloud.spanner_admin_instance_v1.types.InstancePartition`):
3039
+ Required. The instance partition to update, which must
3040
+ always include the instance partition name. Otherwise,
3041
+ only fields mentioned in
3042
+ [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask]
3043
+ need be included.
3044
+
3045
+ This corresponds to the ``instance_partition`` field
3046
+ on the ``request`` instance; if ``request`` is provided, this
3047
+ should not be set.
3048
+ field_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
3049
+ Required. A mask specifying which fields in
3050
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition]
3051
+ should be updated. The field mask must always be
3052
+ specified; this prevents any future fields in
3053
+ [InstancePartition][google.spanner.admin.instance.v1.InstancePartition]
3054
+ from being erased accidentally by clients that do not
3055
+ know about them.
3056
+
3057
+ This corresponds to the ``field_mask`` field
3058
+ on the ``request`` instance; if ``request`` is provided, this
3059
+ should not be set.
3060
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
3061
+ should be retried.
3062
+ timeout (float): The timeout for this request.
3063
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3064
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3065
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3066
+ be of type `bytes`.
3067
+
3068
+ Returns:
3069
+ google.api_core.operation_async.AsyncOperation:
3070
+ An object representing a long-running operation.
3071
+
3072
+ The result type for the operation will be :class:`google.cloud.spanner_admin_instance_v1.types.InstancePartition` An isolated set of Cloud Spanner resources that databases can define
3073
+ placements on.
3074
+
3075
+ """
3076
+ # Create or coerce a protobuf request object.
3077
+ # - Quick check: If we got a request object, we should *not* have
3078
+ # gotten any keyword arguments that map to the request.
3079
+ flattened_params = [instance_partition, field_mask]
3080
+ has_flattened_params = (
3081
+ len([param for param in flattened_params if param is not None]) > 0
3082
+ )
3083
+ if request is not None and has_flattened_params:
3084
+ raise ValueError(
3085
+ "If the `request` argument is set, then none of "
3086
+ "the individual field arguments should be set."
3087
+ )
3088
+
3089
+ # - Use the request object if provided (there's no risk of modifying the input as
3090
+ # there are no flattened fields), or create one.
3091
+ if not isinstance(
3092
+ request, spanner_instance_admin.UpdateInstancePartitionRequest
3093
+ ):
3094
+ request = spanner_instance_admin.UpdateInstancePartitionRequest(request)
3095
+
3096
+ # If we have keyword arguments corresponding to fields on the
3097
+ # request, apply these.
3098
+ if instance_partition is not None:
3099
+ request.instance_partition = instance_partition
3100
+ if field_mask is not None:
3101
+ request.field_mask = field_mask
3102
+
3103
+ # Wrap the RPC method; this adds retry and timeout information,
3104
+ # and friendly error handling.
3105
+ rpc = self._client._transport._wrapped_methods[
3106
+ self._client._transport.update_instance_partition
3107
+ ]
3108
+
3109
+ # Certain fields should be provided within the metadata header;
3110
+ # add these here.
3111
+ metadata = tuple(metadata) + (
3112
+ gapic_v1.routing_header.to_grpc_metadata(
3113
+ (("instance_partition.name", request.instance_partition.name),)
3114
+ ),
3115
+ )
3116
+
3117
+ # Validate the universe domain.
3118
+ self._client._validate_universe_domain()
3119
+
3120
+ # Send the request.
3121
+ response = await rpc(
3122
+ request,
3123
+ retry=retry,
3124
+ timeout=timeout,
3125
+ metadata=metadata,
3126
+ )
3127
+
3128
+ # Wrap the response in an operation future.
3129
+ response = operation_async.from_gapic(
3130
+ response,
3131
+ self._client._transport.operations_client,
3132
+ spanner_instance_admin.InstancePartition,
3133
+ metadata_type=spanner_instance_admin.UpdateInstancePartitionMetadata,
3134
+ )
3135
+
3136
+ # Done; return the response.
3137
+ return response
3138
+
3139
+ async def list_instance_partition_operations(
3140
+ self,
3141
+ request: Optional[
3142
+ Union[spanner_instance_admin.ListInstancePartitionOperationsRequest, dict]
3143
+ ] = None,
3144
+ *,
3145
+ parent: Optional[str] = None,
3146
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3147
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3148
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3149
+ ) -> pagers.ListInstancePartitionOperationsAsyncPager:
3150
+ r"""Lists instance partition long-running operations in the given
3151
+ instance. An instance partition operation has a name of the form
3152
+ ``projects/<project>/instances/<instance>/instancePartitions/<instance_partition>/operations/<operation>``.
3153
+ The long-running operation metadata field type
3154
+ ``metadata.type_url`` describes the type of the metadata.
3155
+ Operations returned include those that have
3156
+ completed/failed/canceled within the last 7 days, and pending
3157
+ operations. Operations returned are ordered by
3158
+ ``operation.metadata.value.start_time`` in descending order
3159
+ starting from the most recently started operation.
3160
+
3161
+ Authorization requires
3162
+ ``spanner.instancePartitionOperations.list`` permission on the
3163
+ resource
3164
+ [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent].
3165
+
3166
+ .. code-block:: python
3167
+
3168
+ # This snippet has been automatically generated and should be regarded as a
3169
+ # code template only.
3170
+ # It will require modifications to work:
3171
+ # - It may require correct/in-range values for request initialization.
3172
+ # - It may require specifying regional endpoints when creating the service
3173
+ # client as shown in:
3174
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3175
+ from google.cloud import spanner_admin_instance_v1
3176
+
3177
+ async def sample_list_instance_partition_operations():
3178
+ # Create a client
3179
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
3180
+
3181
+ # Initialize request argument(s)
3182
+ request = spanner_admin_instance_v1.ListInstancePartitionOperationsRequest(
3183
+ parent="parent_value",
3184
+ )
3185
+
3186
+ # Make the request
3187
+ page_result = client.list_instance_partition_operations(request=request)
3188
+
3189
+ # Handle the response
3190
+ async for response in page_result:
3191
+ print(response)
3192
+
3193
+ Args:
3194
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstancePartitionOperationsRequest, dict]]):
3195
+ The request object. The request for
3196
+ [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations].
3197
+ parent (:class:`str`):
3198
+ Required. The parent instance of the instance partition
3199
+ operations. Values are of the form
3200
+ ``projects/<project>/instances/<instance>``.
3201
+
3202
+ This corresponds to the ``parent`` field
3203
+ on the ``request`` instance; if ``request`` is provided, this
3204
+ should not be set.
3205
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
3206
+ should be retried.
3207
+ timeout (float): The timeout for this request.
3208
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3209
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3210
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3211
+ be of type `bytes`.
3212
+
3213
+ Returns:
3214
+ google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstancePartitionOperationsAsyncPager:
3215
+ The response for
3216
+ [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations].
3217
+
3218
+ Iterating over this object will yield results and
3219
+ resolve additional pages automatically.
3220
+
3221
+ """
3222
+ # Create or coerce a protobuf request object.
3223
+ # - Quick check: If we got a request object, we should *not* have
3224
+ # gotten any keyword arguments that map to the request.
3225
+ flattened_params = [parent]
3226
+ has_flattened_params = (
3227
+ len([param for param in flattened_params if param is not None]) > 0
3228
+ )
3229
+ if request is not None and has_flattened_params:
3230
+ raise ValueError(
3231
+ "If the `request` argument is set, then none of "
3232
+ "the individual field arguments should be set."
3233
+ )
3234
+
3235
+ # - Use the request object if provided (there's no risk of modifying the input as
3236
+ # there are no flattened fields), or create one.
3237
+ if not isinstance(
3238
+ request, spanner_instance_admin.ListInstancePartitionOperationsRequest
3239
+ ):
3240
+ request = spanner_instance_admin.ListInstancePartitionOperationsRequest(
3241
+ request
3242
+ )
3243
+
3244
+ # If we have keyword arguments corresponding to fields on the
3245
+ # request, apply these.
3246
+ if parent is not None:
3247
+ request.parent = parent
3248
+
3249
+ # Wrap the RPC method; this adds retry and timeout information,
3250
+ # and friendly error handling.
3251
+ rpc = self._client._transport._wrapped_methods[
3252
+ self._client._transport.list_instance_partition_operations
3253
+ ]
3254
+
3255
+ # Certain fields should be provided within the metadata header;
3256
+ # add these here.
3257
+ metadata = tuple(metadata) + (
3258
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3259
+ )
3260
+
3261
+ # Validate the universe domain.
3262
+ self._client._validate_universe_domain()
3263
+
3264
+ # Send the request.
3265
+ response = await rpc(
3266
+ request,
3267
+ retry=retry,
3268
+ timeout=timeout,
3269
+ metadata=metadata,
3270
+ )
3271
+
3272
+ # This method is paged; wrap the response in a pager, which provides
3273
+ # an `__aiter__` convenience method.
3274
+ response = pagers.ListInstancePartitionOperationsAsyncPager(
3275
+ method=rpc,
3276
+ request=request,
3277
+ response=response,
3278
+ retry=retry,
3279
+ timeout=timeout,
3280
+ metadata=metadata,
3281
+ )
3282
+
3283
+ # Done; return the response.
3284
+ return response
3285
+
3286
+ async def move_instance(
3287
+ self,
3288
+ request: Optional[
3289
+ Union[spanner_instance_admin.MoveInstanceRequest, dict]
3290
+ ] = None,
3291
+ *,
3292
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3293
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3294
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3295
+ ) -> operation_async.AsyncOperation:
3296
+ r"""Moves an instance to the target instance configuration. You can
3297
+ use the returned long-running operation to track the progress of
3298
+ moving the instance.
3299
+
3300
+ ``MoveInstance`` returns ``FAILED_PRECONDITION`` if the instance
3301
+ meets any of the following criteria:
3302
+
3303
+ - Is undergoing a move to a different instance configuration
3304
+ - Has backups
3305
+ - Has an ongoing update
3306
+ - Contains any CMEK-enabled databases
3307
+ - Is a free trial instance
3308
+
3309
+ While the operation is pending:
3310
+
3311
+ - All other attempts to modify the instance, including changes
3312
+ to its compute capacity, are rejected.
3313
+
3314
+ - The following database and backup admin operations are
3315
+ rejected:
3316
+
3317
+ - ``DatabaseAdmin.CreateDatabase``
3318
+ - ``DatabaseAdmin.UpdateDatabaseDdl`` (disabled if
3319
+ default_leader is specified in the request.)
3320
+ - ``DatabaseAdmin.RestoreDatabase``
3321
+ - ``DatabaseAdmin.CreateBackup``
3322
+ - ``DatabaseAdmin.CopyBackup``
3323
+
3324
+ - Both the source and target instance configurations are
3325
+ subject to hourly compute and storage charges.
3326
+
3327
+ - The instance might experience higher read-write latencies and
3328
+ a higher transaction abort rate. However, moving an instance
3329
+ doesn't cause any downtime.
3330
+
3331
+ The returned long-running operation has a name of the format
3332
+ ``<instance_name>/operations/<operation_id>`` and can be used to
3333
+ track the move instance operation. The metadata field type is
3334
+ [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata].
3335
+ The response field type is
3336
+ [Instance][google.spanner.admin.instance.v1.Instance], if
3337
+ successful. Cancelling the operation sets its metadata's
3338
+ [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time].
3339
+ Cancellation is not immediate because it involves moving any
3340
+ data previously moved to the target instance configuration back
3341
+ to the original instance configuration. You can use this
3342
+ operation to track the progress of the cancellation. Upon
3343
+ successful completion of the cancellation, the operation
3344
+ terminates with ``CANCELLED`` status.
3345
+
3346
+ If not cancelled, upon completion of the returned operation:
3347
+
3348
+ - The instance successfully moves to the target instance
3349
+ configuration.
3350
+ - You are billed for compute and storage in target instance
3351
+ configuration.
3352
+
3353
+ Authorization requires the ``spanner.instances.update``
3354
+ permission on the resource
3355
+ [instance][google.spanner.admin.instance.v1.Instance].
3356
+
3357
+ For more details, see `Move an
3358
+ instance <https://cloud.google.com/spanner/docs/move-instance>`__.
3359
+
3360
+ .. code-block:: python
3361
+
3362
+ # This snippet has been automatically generated and should be regarded as a
3363
+ # code template only.
3364
+ # It will require modifications to work:
3365
+ # - It may require correct/in-range values for request initialization.
3366
+ # - It may require specifying regional endpoints when creating the service
3367
+ # client as shown in:
3368
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3369
+ from google.cloud import spanner_admin_instance_v1
3370
+
3371
+ async def sample_move_instance():
3372
+ # Create a client
3373
+ client = spanner_admin_instance_v1.InstanceAdminAsyncClient()
3374
+
3375
+ # Initialize request argument(s)
3376
+ request = spanner_admin_instance_v1.MoveInstanceRequest(
3377
+ name="name_value",
3378
+ target_config="target_config_value",
3379
+ )
3380
+
3381
+ # Make the request
3382
+ operation = client.move_instance(request=request)
3383
+
3384
+ print("Waiting for operation to complete...")
3385
+
3386
+ response = (await operation).result()
3387
+
3388
+ # Handle the response
3389
+ print(response)
3390
+
3391
+ Args:
3392
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.MoveInstanceRequest, dict]]):
3393
+ The request object. The request for
3394
+ [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance].
3395
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
3396
+ should be retried.
3397
+ timeout (float): The timeout for this request.
3398
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3399
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3400
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3401
+ be of type `bytes`.
3402
+
3403
+ Returns:
3404
+ google.api_core.operation_async.AsyncOperation:
3405
+ An object representing a long-running operation.
3406
+
3407
+ The result type for the operation will be :class:`google.cloud.spanner_admin_instance_v1.types.MoveInstanceResponse` The response for
3408
+ [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance].
3409
+
3410
+ """
3411
+ # Create or coerce a protobuf request object.
3412
+ # - Use the request object if provided (there's no risk of modifying the input as
3413
+ # there are no flattened fields), or create one.
3414
+ if not isinstance(request, spanner_instance_admin.MoveInstanceRequest):
3415
+ request = spanner_instance_admin.MoveInstanceRequest(request)
3416
+
3417
+ # Wrap the RPC method; this adds retry and timeout information,
3418
+ # and friendly error handling.
3419
+ rpc = self._client._transport._wrapped_methods[
3420
+ self._client._transport.move_instance
3421
+ ]
3422
+
3423
+ # Certain fields should be provided within the metadata header;
3424
+ # add these here.
3425
+ metadata = tuple(metadata) + (
3426
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3427
+ )
3428
+
3429
+ # Validate the universe domain.
3430
+ self._client._validate_universe_domain()
3431
+
3432
+ # Send the request.
3433
+ response = await rpc(
3434
+ request,
3435
+ retry=retry,
3436
+ timeout=timeout,
3437
+ metadata=metadata,
3438
+ )
3439
+
3440
+ # Wrap the response in an operation future.
3441
+ response = operation_async.from_gapic(
3442
+ response,
3443
+ self._client._transport.operations_client,
3444
+ spanner_instance_admin.MoveInstanceResponse,
3445
+ metadata_type=spanner_instance_admin.MoveInstanceMetadata,
3446
+ )
3447
+
3448
+ # Done; return the response.
3449
+ return response
3450
+
3451
+ async def __aenter__(self) -> "InstanceAdminAsyncClient":
3452
+ return self
3453
+
3454
+ async def __aexit__(self, exc_type, exc, tb):
3455
+ await self.transport.close()
3456
+
3457
+
3458
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
3459
+ gapic_version=package_version.__version__
3460
+ )
3461
+
3462
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
3463
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
3464
+
3465
+
3466
+ __all__ = ("InstanceAdminAsyncClient",)