google-cloud-spanner 3.55.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/spanner.py +47 -0
- google/cloud/spanner_admin_database_v1/__init__.py +146 -0
- google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
- google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_database_v1/py.typed +2 -0
- google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
- google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
- google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
- google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
- google/cloud/spanner_admin_database_v1/types/common.py +180 -0
- google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
- google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
- google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
- google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_instance_v1/py.typed +2 -0
- google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
- google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
- google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
- google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
- google/cloud/spanner_dbapi/__init__.py +93 -0
- google/cloud/spanner_dbapi/_helpers.py +113 -0
- google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
- google/cloud/spanner_dbapi/checksum.py +80 -0
- google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
- google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
- google/cloud/spanner_dbapi/connection.py +818 -0
- google/cloud/spanner_dbapi/cursor.py +609 -0
- google/cloud/spanner_dbapi/exceptions.py +172 -0
- google/cloud/spanner_dbapi/parse_utils.py +392 -0
- google/cloud/spanner_dbapi/parsed_statement.py +63 -0
- google/cloud/spanner_dbapi/parser.py +258 -0
- google/cloud/spanner_dbapi/partition_helper.py +41 -0
- google/cloud/spanner_dbapi/transaction_helper.py +294 -0
- google/cloud/spanner_dbapi/types.py +106 -0
- google/cloud/spanner_dbapi/utils.py +147 -0
- google/cloud/spanner_dbapi/version.py +20 -0
- google/cloud/spanner_v1/__init__.py +154 -0
- google/cloud/spanner_v1/_helpers.py +751 -0
- google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
- google/cloud/spanner_v1/backup.py +397 -0
- google/cloud/spanner_v1/batch.py +433 -0
- google/cloud/spanner_v1/client.py +538 -0
- google/cloud/spanner_v1/data_types.py +350 -0
- google/cloud/spanner_v1/database.py +1968 -0
- google/cloud/spanner_v1/database_sessions_manager.py +249 -0
- google/cloud/spanner_v1/gapic_metadata.json +268 -0
- google/cloud/spanner_v1/gapic_version.py +16 -0
- google/cloud/spanner_v1/instance.py +735 -0
- google/cloud/spanner_v1/keyset.py +193 -0
- google/cloud/spanner_v1/merged_result_set.py +146 -0
- google/cloud/spanner_v1/metrics/constants.py +71 -0
- google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
- google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
- google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
- google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
- google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
- google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
- google/cloud/spanner_v1/param_types.py +110 -0
- google/cloud/spanner_v1/pool.py +813 -0
- google/cloud/spanner_v1/py.typed +2 -0
- google/cloud/spanner_v1/request_id_header.py +64 -0
- google/cloud/spanner_v1/services/__init__.py +15 -0
- google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
- google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
- google/cloud/spanner_v1/services/spanner/client.py +2624 -0
- google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
- google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
- google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
- google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
- google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
- google/cloud/spanner_v1/session.py +631 -0
- google/cloud/spanner_v1/session_options.py +133 -0
- google/cloud/spanner_v1/snapshot.py +1057 -0
- google/cloud/spanner_v1/streamed.py +402 -0
- google/cloud/spanner_v1/table.py +181 -0
- google/cloud/spanner_v1/testing/__init__.py +0 -0
- google/cloud/spanner_v1/testing/database_test.py +121 -0
- google/cloud/spanner_v1/testing/interceptors.py +118 -0
- google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
- google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
- google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
- google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
- google/cloud/spanner_v1/transaction.py +747 -0
- google/cloud/spanner_v1/types/__init__.py +118 -0
- google/cloud/spanner_v1/types/commit_response.py +94 -0
- google/cloud/spanner_v1/types/keys.py +248 -0
- google/cloud/spanner_v1/types/mutation.py +201 -0
- google/cloud/spanner_v1/types/query_plan.py +220 -0
- google/cloud/spanner_v1/types/result_set.py +379 -0
- google/cloud/spanner_v1/types/spanner.py +1815 -0
- google/cloud/spanner_v1/types/transaction.py +818 -0
- google/cloud/spanner_v1/types/type.py +288 -0
- google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
- google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
- google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
- google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
- google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,4097 @@
|
|
|
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_database_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_database_v1.services.database_admin import pagers
|
|
51
|
+
from google.cloud.spanner_admin_database_v1.types import backup
|
|
52
|
+
from google.cloud.spanner_admin_database_v1.types import backup as gsad_backup
|
|
53
|
+
from google.cloud.spanner_admin_database_v1.types import backup_schedule
|
|
54
|
+
from google.cloud.spanner_admin_database_v1.types import (
|
|
55
|
+
backup_schedule as gsad_backup_schedule,
|
|
56
|
+
)
|
|
57
|
+
from google.cloud.spanner_admin_database_v1.types import common
|
|
58
|
+
from google.cloud.spanner_admin_database_v1.types import spanner_database_admin
|
|
59
|
+
from google.iam.v1 import iam_policy_pb2 # type: ignore
|
|
60
|
+
from google.iam.v1 import policy_pb2 # type: ignore
|
|
61
|
+
from google.longrunning import operations_pb2 # type: ignore
|
|
62
|
+
from google.longrunning import operations_pb2 # type: ignore
|
|
63
|
+
from google.protobuf import duration_pb2 # type: ignore
|
|
64
|
+
from google.protobuf import empty_pb2 # type: ignore
|
|
65
|
+
from google.protobuf import field_mask_pb2 # type: ignore
|
|
66
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
67
|
+
from .transports.base import DatabaseAdminTransport, DEFAULT_CLIENT_INFO
|
|
68
|
+
from .transports.grpc_asyncio import DatabaseAdminGrpcAsyncIOTransport
|
|
69
|
+
from .client import DatabaseAdminClient
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
from google.api_core import client_logging # type: ignore
|
|
73
|
+
|
|
74
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
75
|
+
except ImportError: # pragma: NO COVER
|
|
76
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
77
|
+
|
|
78
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class DatabaseAdminAsyncClient:
|
|
82
|
+
"""Cloud Spanner Database Admin API
|
|
83
|
+
|
|
84
|
+
The Cloud Spanner Database Admin API can be used to:
|
|
85
|
+
|
|
86
|
+
- create, drop, and list databases
|
|
87
|
+
- update the schema of pre-existing databases
|
|
88
|
+
- create, delete, copy and list backups for a database
|
|
89
|
+
- restore a database from an existing backup
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
_client: DatabaseAdminClient
|
|
93
|
+
|
|
94
|
+
# Copy defaults from the synchronous client for use here.
|
|
95
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
96
|
+
DEFAULT_ENDPOINT = DatabaseAdminClient.DEFAULT_ENDPOINT
|
|
97
|
+
DEFAULT_MTLS_ENDPOINT = DatabaseAdminClient.DEFAULT_MTLS_ENDPOINT
|
|
98
|
+
_DEFAULT_ENDPOINT_TEMPLATE = DatabaseAdminClient._DEFAULT_ENDPOINT_TEMPLATE
|
|
99
|
+
_DEFAULT_UNIVERSE = DatabaseAdminClient._DEFAULT_UNIVERSE
|
|
100
|
+
|
|
101
|
+
backup_path = staticmethod(DatabaseAdminClient.backup_path)
|
|
102
|
+
parse_backup_path = staticmethod(DatabaseAdminClient.parse_backup_path)
|
|
103
|
+
backup_schedule_path = staticmethod(DatabaseAdminClient.backup_schedule_path)
|
|
104
|
+
parse_backup_schedule_path = staticmethod(
|
|
105
|
+
DatabaseAdminClient.parse_backup_schedule_path
|
|
106
|
+
)
|
|
107
|
+
crypto_key_path = staticmethod(DatabaseAdminClient.crypto_key_path)
|
|
108
|
+
parse_crypto_key_path = staticmethod(DatabaseAdminClient.parse_crypto_key_path)
|
|
109
|
+
crypto_key_version_path = staticmethod(DatabaseAdminClient.crypto_key_version_path)
|
|
110
|
+
parse_crypto_key_version_path = staticmethod(
|
|
111
|
+
DatabaseAdminClient.parse_crypto_key_version_path
|
|
112
|
+
)
|
|
113
|
+
database_path = staticmethod(DatabaseAdminClient.database_path)
|
|
114
|
+
parse_database_path = staticmethod(DatabaseAdminClient.parse_database_path)
|
|
115
|
+
database_role_path = staticmethod(DatabaseAdminClient.database_role_path)
|
|
116
|
+
parse_database_role_path = staticmethod(
|
|
117
|
+
DatabaseAdminClient.parse_database_role_path
|
|
118
|
+
)
|
|
119
|
+
instance_path = staticmethod(DatabaseAdminClient.instance_path)
|
|
120
|
+
parse_instance_path = staticmethod(DatabaseAdminClient.parse_instance_path)
|
|
121
|
+
instance_partition_path = staticmethod(DatabaseAdminClient.instance_partition_path)
|
|
122
|
+
parse_instance_partition_path = staticmethod(
|
|
123
|
+
DatabaseAdminClient.parse_instance_partition_path
|
|
124
|
+
)
|
|
125
|
+
common_billing_account_path = staticmethod(
|
|
126
|
+
DatabaseAdminClient.common_billing_account_path
|
|
127
|
+
)
|
|
128
|
+
parse_common_billing_account_path = staticmethod(
|
|
129
|
+
DatabaseAdminClient.parse_common_billing_account_path
|
|
130
|
+
)
|
|
131
|
+
common_folder_path = staticmethod(DatabaseAdminClient.common_folder_path)
|
|
132
|
+
parse_common_folder_path = staticmethod(
|
|
133
|
+
DatabaseAdminClient.parse_common_folder_path
|
|
134
|
+
)
|
|
135
|
+
common_organization_path = staticmethod(
|
|
136
|
+
DatabaseAdminClient.common_organization_path
|
|
137
|
+
)
|
|
138
|
+
parse_common_organization_path = staticmethod(
|
|
139
|
+
DatabaseAdminClient.parse_common_organization_path
|
|
140
|
+
)
|
|
141
|
+
common_project_path = staticmethod(DatabaseAdminClient.common_project_path)
|
|
142
|
+
parse_common_project_path = staticmethod(
|
|
143
|
+
DatabaseAdminClient.parse_common_project_path
|
|
144
|
+
)
|
|
145
|
+
common_location_path = staticmethod(DatabaseAdminClient.common_location_path)
|
|
146
|
+
parse_common_location_path = staticmethod(
|
|
147
|
+
DatabaseAdminClient.parse_common_location_path
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
@classmethod
|
|
151
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
152
|
+
"""Creates an instance of this client using the provided credentials
|
|
153
|
+
info.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
info (dict): The service account private key info.
|
|
157
|
+
args: Additional arguments to pass to the constructor.
|
|
158
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
DatabaseAdminAsyncClient: The constructed client.
|
|
162
|
+
"""
|
|
163
|
+
return DatabaseAdminClient.from_service_account_info.__func__(DatabaseAdminAsyncClient, info, *args, **kwargs) # type: ignore
|
|
164
|
+
|
|
165
|
+
@classmethod
|
|
166
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
167
|
+
"""Creates an instance of this client using the provided credentials
|
|
168
|
+
file.
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
filename (str): The path to the service account private key json
|
|
172
|
+
file.
|
|
173
|
+
args: Additional arguments to pass to the constructor.
|
|
174
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
DatabaseAdminAsyncClient: The constructed client.
|
|
178
|
+
"""
|
|
179
|
+
return DatabaseAdminClient.from_service_account_file.__func__(DatabaseAdminAsyncClient, filename, *args, **kwargs) # type: ignore
|
|
180
|
+
|
|
181
|
+
from_service_account_json = from_service_account_file
|
|
182
|
+
|
|
183
|
+
@classmethod
|
|
184
|
+
def get_mtls_endpoint_and_cert_source(
|
|
185
|
+
cls, client_options: Optional[ClientOptions] = None
|
|
186
|
+
):
|
|
187
|
+
"""Return the API endpoint and client cert source for mutual TLS.
|
|
188
|
+
|
|
189
|
+
The client cert source is determined in the following order:
|
|
190
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
191
|
+
client cert source is None.
|
|
192
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
193
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
194
|
+
source is None.
|
|
195
|
+
|
|
196
|
+
The API endpoint is determined in the following order:
|
|
197
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
198
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
199
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
200
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
201
|
+
use the default API endpoint.
|
|
202
|
+
|
|
203
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
207
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
208
|
+
in this method.
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
212
|
+
client cert source to use.
|
|
213
|
+
|
|
214
|
+
Raises:
|
|
215
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
216
|
+
"""
|
|
217
|
+
return DatabaseAdminClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
|
218
|
+
|
|
219
|
+
@property
|
|
220
|
+
def transport(self) -> DatabaseAdminTransport:
|
|
221
|
+
"""Returns the transport used by the client instance.
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
DatabaseAdminTransport: The transport used by the client instance.
|
|
225
|
+
"""
|
|
226
|
+
return self._client.transport
|
|
227
|
+
|
|
228
|
+
@property
|
|
229
|
+
def api_endpoint(self):
|
|
230
|
+
"""Return the API endpoint used by the client instance.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
str: The API endpoint used by the client instance.
|
|
234
|
+
"""
|
|
235
|
+
return self._client._api_endpoint
|
|
236
|
+
|
|
237
|
+
@property
|
|
238
|
+
def universe_domain(self) -> str:
|
|
239
|
+
"""Return the universe domain used by the client instance.
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
str: The universe domain used
|
|
243
|
+
by the client instance.
|
|
244
|
+
"""
|
|
245
|
+
return self._client._universe_domain
|
|
246
|
+
|
|
247
|
+
get_transport_class = DatabaseAdminClient.get_transport_class
|
|
248
|
+
|
|
249
|
+
def __init__(
|
|
250
|
+
self,
|
|
251
|
+
*,
|
|
252
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
253
|
+
transport: Optional[
|
|
254
|
+
Union[str, DatabaseAdminTransport, Callable[..., DatabaseAdminTransport]]
|
|
255
|
+
] = "grpc_asyncio",
|
|
256
|
+
client_options: Optional[ClientOptions] = None,
|
|
257
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
258
|
+
) -> None:
|
|
259
|
+
"""Instantiates the database admin async client.
|
|
260
|
+
|
|
261
|
+
Args:
|
|
262
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
263
|
+
authorization credentials to attach to requests. These
|
|
264
|
+
credentials identify the application to the service; if none
|
|
265
|
+
are specified, the client will attempt to ascertain the
|
|
266
|
+
credentials from the environment.
|
|
267
|
+
transport (Optional[Union[str,DatabaseAdminTransport,Callable[..., DatabaseAdminTransport]]]):
|
|
268
|
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
|
269
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
270
|
+
arguments as used in the DatabaseAdminTransport constructor.
|
|
271
|
+
If set to None, a transport is chosen automatically.
|
|
272
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
273
|
+
Custom options for the client.
|
|
274
|
+
|
|
275
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
276
|
+
default endpoint provided by the client when ``transport`` is
|
|
277
|
+
not explicitly provided. Only if this property is not set and
|
|
278
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
279
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
280
|
+
variable, which have one of the following values:
|
|
281
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
282
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
283
|
+
default mTLS endpoint if client certificate is present; this is
|
|
284
|
+
the default value).
|
|
285
|
+
|
|
286
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
287
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
288
|
+
to provide a client certificate for mTLS transport. If
|
|
289
|
+
not provided, the default SSL client certificate will be used if
|
|
290
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
291
|
+
set, no client certificate will be used.
|
|
292
|
+
|
|
293
|
+
3. The ``universe_domain`` property can be used to override the
|
|
294
|
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
|
295
|
+
property still takes precedence; and ``universe_domain`` is
|
|
296
|
+
currently not supported for mTLS.
|
|
297
|
+
|
|
298
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
299
|
+
The client info used to send a user-agent string along with
|
|
300
|
+
API requests. If ``None``, then default info will be used.
|
|
301
|
+
Generally, you only need to set this if you're developing
|
|
302
|
+
your own client library.
|
|
303
|
+
|
|
304
|
+
Raises:
|
|
305
|
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
|
306
|
+
creation failed for any reason.
|
|
307
|
+
"""
|
|
308
|
+
self._client = DatabaseAdminClient(
|
|
309
|
+
credentials=credentials,
|
|
310
|
+
transport=transport,
|
|
311
|
+
client_options=client_options,
|
|
312
|
+
client_info=client_info,
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
316
|
+
std_logging.DEBUG
|
|
317
|
+
): # pragma: NO COVER
|
|
318
|
+
_LOGGER.debug(
|
|
319
|
+
"Created client `google.spanner.admin.database_v1.DatabaseAdminAsyncClient`.",
|
|
320
|
+
extra={
|
|
321
|
+
"serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
|
|
322
|
+
"universeDomain": getattr(
|
|
323
|
+
self._client._transport._credentials, "universe_domain", ""
|
|
324
|
+
),
|
|
325
|
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
|
326
|
+
"credentialsInfo": getattr(
|
|
327
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
328
|
+
)(),
|
|
329
|
+
}
|
|
330
|
+
if hasattr(self._client._transport, "_credentials")
|
|
331
|
+
else {
|
|
332
|
+
"serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
|
|
333
|
+
"credentialsType": None,
|
|
334
|
+
},
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
async def list_databases(
|
|
338
|
+
self,
|
|
339
|
+
request: Optional[
|
|
340
|
+
Union[spanner_database_admin.ListDatabasesRequest, dict]
|
|
341
|
+
] = None,
|
|
342
|
+
*,
|
|
343
|
+
parent: Optional[str] = None,
|
|
344
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
345
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
346
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
347
|
+
) -> pagers.ListDatabasesAsyncPager:
|
|
348
|
+
r"""Lists Cloud Spanner databases.
|
|
349
|
+
|
|
350
|
+
.. code-block:: python
|
|
351
|
+
|
|
352
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
353
|
+
# code template only.
|
|
354
|
+
# It will require modifications to work:
|
|
355
|
+
# - It may require correct/in-range values for request initialization.
|
|
356
|
+
# - It may require specifying regional endpoints when creating the service
|
|
357
|
+
# client as shown in:
|
|
358
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
359
|
+
from google.cloud import spanner_admin_database_v1
|
|
360
|
+
|
|
361
|
+
async def sample_list_databases():
|
|
362
|
+
# Create a client
|
|
363
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
364
|
+
|
|
365
|
+
# Initialize request argument(s)
|
|
366
|
+
request = spanner_admin_database_v1.ListDatabasesRequest(
|
|
367
|
+
parent="parent_value",
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
# Make the request
|
|
371
|
+
page_result = client.list_databases(request=request)
|
|
372
|
+
|
|
373
|
+
# Handle the response
|
|
374
|
+
async for response in page_result:
|
|
375
|
+
print(response)
|
|
376
|
+
|
|
377
|
+
Args:
|
|
378
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest, dict]]):
|
|
379
|
+
The request object. The request for
|
|
380
|
+
[ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
|
|
381
|
+
parent (:class:`str`):
|
|
382
|
+
Required. The instance whose databases should be listed.
|
|
383
|
+
Values are of the form
|
|
384
|
+
``projects/<project>/instances/<instance>``.
|
|
385
|
+
|
|
386
|
+
This corresponds to the ``parent`` field
|
|
387
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
388
|
+
should not be set.
|
|
389
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
390
|
+
should be retried.
|
|
391
|
+
timeout (float): The timeout for this request.
|
|
392
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
393
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
394
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
395
|
+
be of type `bytes`.
|
|
396
|
+
|
|
397
|
+
Returns:
|
|
398
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabasesAsyncPager:
|
|
399
|
+
The response for
|
|
400
|
+
[ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
|
|
401
|
+
|
|
402
|
+
Iterating over this object will yield results and
|
|
403
|
+
resolve additional pages automatically.
|
|
404
|
+
|
|
405
|
+
"""
|
|
406
|
+
# Create or coerce a protobuf request object.
|
|
407
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
408
|
+
# gotten any keyword arguments that map to the request.
|
|
409
|
+
flattened_params = [parent]
|
|
410
|
+
has_flattened_params = (
|
|
411
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
412
|
+
)
|
|
413
|
+
if request is not None and has_flattened_params:
|
|
414
|
+
raise ValueError(
|
|
415
|
+
"If the `request` argument is set, then none of "
|
|
416
|
+
"the individual field arguments should be set."
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
420
|
+
# there are no flattened fields), or create one.
|
|
421
|
+
if not isinstance(request, spanner_database_admin.ListDatabasesRequest):
|
|
422
|
+
request = spanner_database_admin.ListDatabasesRequest(request)
|
|
423
|
+
|
|
424
|
+
# If we have keyword arguments corresponding to fields on the
|
|
425
|
+
# request, apply these.
|
|
426
|
+
if parent is not None:
|
|
427
|
+
request.parent = parent
|
|
428
|
+
|
|
429
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
430
|
+
# and friendly error handling.
|
|
431
|
+
rpc = self._client._transport._wrapped_methods[
|
|
432
|
+
self._client._transport.list_databases
|
|
433
|
+
]
|
|
434
|
+
|
|
435
|
+
# Certain fields should be provided within the metadata header;
|
|
436
|
+
# add these here.
|
|
437
|
+
metadata = tuple(metadata) + (
|
|
438
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
# Validate the universe domain.
|
|
442
|
+
self._client._validate_universe_domain()
|
|
443
|
+
|
|
444
|
+
# Send the request.
|
|
445
|
+
response = await rpc(
|
|
446
|
+
request,
|
|
447
|
+
retry=retry,
|
|
448
|
+
timeout=timeout,
|
|
449
|
+
metadata=metadata,
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
453
|
+
# an `__aiter__` convenience method.
|
|
454
|
+
response = pagers.ListDatabasesAsyncPager(
|
|
455
|
+
method=rpc,
|
|
456
|
+
request=request,
|
|
457
|
+
response=response,
|
|
458
|
+
retry=retry,
|
|
459
|
+
timeout=timeout,
|
|
460
|
+
metadata=metadata,
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
# Done; return the response.
|
|
464
|
+
return response
|
|
465
|
+
|
|
466
|
+
async def create_database(
|
|
467
|
+
self,
|
|
468
|
+
request: Optional[
|
|
469
|
+
Union[spanner_database_admin.CreateDatabaseRequest, dict]
|
|
470
|
+
] = None,
|
|
471
|
+
*,
|
|
472
|
+
parent: Optional[str] = None,
|
|
473
|
+
create_statement: Optional[str] = None,
|
|
474
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
475
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
476
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
477
|
+
) -> operation_async.AsyncOperation:
|
|
478
|
+
r"""Creates a new Cloud Spanner database and starts to prepare it
|
|
479
|
+
for serving. The returned [long-running
|
|
480
|
+
operation][google.longrunning.Operation] will have a name of the
|
|
481
|
+
format ``<database_name>/operations/<operation_id>`` and can be
|
|
482
|
+
used to track preparation of the database. The
|
|
483
|
+
[metadata][google.longrunning.Operation.metadata] field type is
|
|
484
|
+
[CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
|
|
485
|
+
The [response][google.longrunning.Operation.response] field type
|
|
486
|
+
is [Database][google.spanner.admin.database.v1.Database], if
|
|
487
|
+
successful.
|
|
488
|
+
|
|
489
|
+
.. code-block:: python
|
|
490
|
+
|
|
491
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
492
|
+
# code template only.
|
|
493
|
+
# It will require modifications to work:
|
|
494
|
+
# - It may require correct/in-range values for request initialization.
|
|
495
|
+
# - It may require specifying regional endpoints when creating the service
|
|
496
|
+
# client as shown in:
|
|
497
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
498
|
+
from google.cloud import spanner_admin_database_v1
|
|
499
|
+
|
|
500
|
+
async def sample_create_database():
|
|
501
|
+
# Create a client
|
|
502
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
503
|
+
|
|
504
|
+
# Initialize request argument(s)
|
|
505
|
+
request = spanner_admin_database_v1.CreateDatabaseRequest(
|
|
506
|
+
parent="parent_value",
|
|
507
|
+
create_statement="create_statement_value",
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
# Make the request
|
|
511
|
+
operation = client.create_database(request=request)
|
|
512
|
+
|
|
513
|
+
print("Waiting for operation to complete...")
|
|
514
|
+
|
|
515
|
+
response = (await operation).result()
|
|
516
|
+
|
|
517
|
+
# Handle the response
|
|
518
|
+
print(response)
|
|
519
|
+
|
|
520
|
+
Args:
|
|
521
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest, dict]]):
|
|
522
|
+
The request object. The request for
|
|
523
|
+
[CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
|
|
524
|
+
parent (:class:`str`):
|
|
525
|
+
Required. The name of the instance that will serve the
|
|
526
|
+
new database. Values are of the form
|
|
527
|
+
``projects/<project>/instances/<instance>``.
|
|
528
|
+
|
|
529
|
+
This corresponds to the ``parent`` field
|
|
530
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
531
|
+
should not be set.
|
|
532
|
+
create_statement (:class:`str`):
|
|
533
|
+
Required. A ``CREATE DATABASE`` statement, which
|
|
534
|
+
specifies the ID of the new database. The database ID
|
|
535
|
+
must conform to the regular expression
|
|
536
|
+
``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30
|
|
537
|
+
characters in length. If the database ID is a reserved
|
|
538
|
+
word or if it contains a hyphen, the database ID must be
|
|
539
|
+
enclosed in backticks (:literal:`\``).
|
|
540
|
+
|
|
541
|
+
This corresponds to the ``create_statement`` field
|
|
542
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
543
|
+
should not be set.
|
|
544
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
545
|
+
should be retried.
|
|
546
|
+
timeout (float): The timeout for this request.
|
|
547
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
548
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
549
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
550
|
+
be of type `bytes`.
|
|
551
|
+
|
|
552
|
+
Returns:
|
|
553
|
+
google.api_core.operation_async.AsyncOperation:
|
|
554
|
+
An object representing a long-running operation.
|
|
555
|
+
|
|
556
|
+
The result type for the operation will be
|
|
557
|
+
:class:`google.cloud.spanner_admin_database_v1.types.Database`
|
|
558
|
+
A Cloud Spanner database.
|
|
559
|
+
|
|
560
|
+
"""
|
|
561
|
+
# Create or coerce a protobuf request object.
|
|
562
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
563
|
+
# gotten any keyword arguments that map to the request.
|
|
564
|
+
flattened_params = [parent, create_statement]
|
|
565
|
+
has_flattened_params = (
|
|
566
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
567
|
+
)
|
|
568
|
+
if request is not None and has_flattened_params:
|
|
569
|
+
raise ValueError(
|
|
570
|
+
"If the `request` argument is set, then none of "
|
|
571
|
+
"the individual field arguments should be set."
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
575
|
+
# there are no flattened fields), or create one.
|
|
576
|
+
if not isinstance(request, spanner_database_admin.CreateDatabaseRequest):
|
|
577
|
+
request = spanner_database_admin.CreateDatabaseRequest(request)
|
|
578
|
+
|
|
579
|
+
# If we have keyword arguments corresponding to fields on the
|
|
580
|
+
# request, apply these.
|
|
581
|
+
if parent is not None:
|
|
582
|
+
request.parent = parent
|
|
583
|
+
if create_statement is not None:
|
|
584
|
+
request.create_statement = create_statement
|
|
585
|
+
|
|
586
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
587
|
+
# and friendly error handling.
|
|
588
|
+
rpc = self._client._transport._wrapped_methods[
|
|
589
|
+
self._client._transport.create_database
|
|
590
|
+
]
|
|
591
|
+
|
|
592
|
+
# Certain fields should be provided within the metadata header;
|
|
593
|
+
# add these here.
|
|
594
|
+
metadata = tuple(metadata) + (
|
|
595
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
# Validate the universe domain.
|
|
599
|
+
self._client._validate_universe_domain()
|
|
600
|
+
|
|
601
|
+
# Send the request.
|
|
602
|
+
response = await rpc(
|
|
603
|
+
request,
|
|
604
|
+
retry=retry,
|
|
605
|
+
timeout=timeout,
|
|
606
|
+
metadata=metadata,
|
|
607
|
+
)
|
|
608
|
+
|
|
609
|
+
# Wrap the response in an operation future.
|
|
610
|
+
response = operation_async.from_gapic(
|
|
611
|
+
response,
|
|
612
|
+
self._client._transport.operations_client,
|
|
613
|
+
spanner_database_admin.Database,
|
|
614
|
+
metadata_type=spanner_database_admin.CreateDatabaseMetadata,
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
# Done; return the response.
|
|
618
|
+
return response
|
|
619
|
+
|
|
620
|
+
async def get_database(
|
|
621
|
+
self,
|
|
622
|
+
request: Optional[
|
|
623
|
+
Union[spanner_database_admin.GetDatabaseRequest, dict]
|
|
624
|
+
] = None,
|
|
625
|
+
*,
|
|
626
|
+
name: Optional[str] = None,
|
|
627
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
628
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
629
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
630
|
+
) -> spanner_database_admin.Database:
|
|
631
|
+
r"""Gets the state of a Cloud Spanner database.
|
|
632
|
+
|
|
633
|
+
.. code-block:: python
|
|
634
|
+
|
|
635
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
636
|
+
# code template only.
|
|
637
|
+
# It will require modifications to work:
|
|
638
|
+
# - It may require correct/in-range values for request initialization.
|
|
639
|
+
# - It may require specifying regional endpoints when creating the service
|
|
640
|
+
# client as shown in:
|
|
641
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
642
|
+
from google.cloud import spanner_admin_database_v1
|
|
643
|
+
|
|
644
|
+
async def sample_get_database():
|
|
645
|
+
# Create a client
|
|
646
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
647
|
+
|
|
648
|
+
# Initialize request argument(s)
|
|
649
|
+
request = spanner_admin_database_v1.GetDatabaseRequest(
|
|
650
|
+
name="name_value",
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
# Make the request
|
|
654
|
+
response = await client.get_database(request=request)
|
|
655
|
+
|
|
656
|
+
# Handle the response
|
|
657
|
+
print(response)
|
|
658
|
+
|
|
659
|
+
Args:
|
|
660
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest, dict]]):
|
|
661
|
+
The request object. The request for
|
|
662
|
+
[GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
|
|
663
|
+
name (:class:`str`):
|
|
664
|
+
Required. The name of the requested database. Values are
|
|
665
|
+
of the form
|
|
666
|
+
``projects/<project>/instances/<instance>/databases/<database>``.
|
|
667
|
+
|
|
668
|
+
This corresponds to the ``name`` field
|
|
669
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
670
|
+
should not be set.
|
|
671
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
672
|
+
should be retried.
|
|
673
|
+
timeout (float): The timeout for this request.
|
|
674
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
675
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
676
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
677
|
+
be of type `bytes`.
|
|
678
|
+
|
|
679
|
+
Returns:
|
|
680
|
+
google.cloud.spanner_admin_database_v1.types.Database:
|
|
681
|
+
A Cloud Spanner database.
|
|
682
|
+
"""
|
|
683
|
+
# Create or coerce a protobuf request object.
|
|
684
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
685
|
+
# gotten any keyword arguments that map to the request.
|
|
686
|
+
flattened_params = [name]
|
|
687
|
+
has_flattened_params = (
|
|
688
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
689
|
+
)
|
|
690
|
+
if request is not None and has_flattened_params:
|
|
691
|
+
raise ValueError(
|
|
692
|
+
"If the `request` argument is set, then none of "
|
|
693
|
+
"the individual field arguments should be set."
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
697
|
+
# there are no flattened fields), or create one.
|
|
698
|
+
if not isinstance(request, spanner_database_admin.GetDatabaseRequest):
|
|
699
|
+
request = spanner_database_admin.GetDatabaseRequest(request)
|
|
700
|
+
|
|
701
|
+
# If we have keyword arguments corresponding to fields on the
|
|
702
|
+
# request, apply these.
|
|
703
|
+
if name is not None:
|
|
704
|
+
request.name = name
|
|
705
|
+
|
|
706
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
707
|
+
# and friendly error handling.
|
|
708
|
+
rpc = self._client._transport._wrapped_methods[
|
|
709
|
+
self._client._transport.get_database
|
|
710
|
+
]
|
|
711
|
+
|
|
712
|
+
# Certain fields should be provided within the metadata header;
|
|
713
|
+
# add these here.
|
|
714
|
+
metadata = tuple(metadata) + (
|
|
715
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
# Validate the universe domain.
|
|
719
|
+
self._client._validate_universe_domain()
|
|
720
|
+
|
|
721
|
+
# Send the request.
|
|
722
|
+
response = await rpc(
|
|
723
|
+
request,
|
|
724
|
+
retry=retry,
|
|
725
|
+
timeout=timeout,
|
|
726
|
+
metadata=metadata,
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
# Done; return the response.
|
|
730
|
+
return response
|
|
731
|
+
|
|
732
|
+
async def update_database(
|
|
733
|
+
self,
|
|
734
|
+
request: Optional[
|
|
735
|
+
Union[spanner_database_admin.UpdateDatabaseRequest, dict]
|
|
736
|
+
] = None,
|
|
737
|
+
*,
|
|
738
|
+
database: Optional[spanner_database_admin.Database] = None,
|
|
739
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
740
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
741
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
742
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
743
|
+
) -> operation_async.AsyncOperation:
|
|
744
|
+
r"""Updates a Cloud Spanner database. The returned [long-running
|
|
745
|
+
operation][google.longrunning.Operation] can be used to track
|
|
746
|
+
the progress of updating the database. If the named database
|
|
747
|
+
does not exist, returns ``NOT_FOUND``.
|
|
748
|
+
|
|
749
|
+
While the operation is pending:
|
|
750
|
+
|
|
751
|
+
- The database's
|
|
752
|
+
[reconciling][google.spanner.admin.database.v1.Database.reconciling]
|
|
753
|
+
field is set to true.
|
|
754
|
+
- Cancelling the operation is best-effort. If the cancellation
|
|
755
|
+
succeeds, the operation metadata's
|
|
756
|
+
[cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time]
|
|
757
|
+
is set, the updates are reverted, and the operation
|
|
758
|
+
terminates with a ``CANCELLED`` status.
|
|
759
|
+
- New UpdateDatabase requests will return a
|
|
760
|
+
``FAILED_PRECONDITION`` error until the pending operation is
|
|
761
|
+
done (returns successfully or with error).
|
|
762
|
+
- Reading the database via the API continues to give the
|
|
763
|
+
pre-request values.
|
|
764
|
+
|
|
765
|
+
Upon completion of the returned operation:
|
|
766
|
+
|
|
767
|
+
- The new values are in effect and readable via the API.
|
|
768
|
+
- The database's
|
|
769
|
+
[reconciling][google.spanner.admin.database.v1.Database.reconciling]
|
|
770
|
+
field becomes false.
|
|
771
|
+
|
|
772
|
+
The returned [long-running
|
|
773
|
+
operation][google.longrunning.Operation] will have a name of the
|
|
774
|
+
format
|
|
775
|
+
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``
|
|
776
|
+
and can be used to track the database modification. The
|
|
777
|
+
[metadata][google.longrunning.Operation.metadata] field type is
|
|
778
|
+
[UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata].
|
|
779
|
+
The [response][google.longrunning.Operation.response] field type
|
|
780
|
+
is [Database][google.spanner.admin.database.v1.Database], if
|
|
781
|
+
successful.
|
|
782
|
+
|
|
783
|
+
.. code-block:: python
|
|
784
|
+
|
|
785
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
786
|
+
# code template only.
|
|
787
|
+
# It will require modifications to work:
|
|
788
|
+
# - It may require correct/in-range values for request initialization.
|
|
789
|
+
# - It may require specifying regional endpoints when creating the service
|
|
790
|
+
# client as shown in:
|
|
791
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
792
|
+
from google.cloud import spanner_admin_database_v1
|
|
793
|
+
|
|
794
|
+
async def sample_update_database():
|
|
795
|
+
# Create a client
|
|
796
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
797
|
+
|
|
798
|
+
# Initialize request argument(s)
|
|
799
|
+
database = spanner_admin_database_v1.Database()
|
|
800
|
+
database.name = "name_value"
|
|
801
|
+
|
|
802
|
+
request = spanner_admin_database_v1.UpdateDatabaseRequest(
|
|
803
|
+
database=database,
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
# Make the request
|
|
807
|
+
operation = client.update_database(request=request)
|
|
808
|
+
|
|
809
|
+
print("Waiting for operation to complete...")
|
|
810
|
+
|
|
811
|
+
response = (await operation).result()
|
|
812
|
+
|
|
813
|
+
# Handle the response
|
|
814
|
+
print(response)
|
|
815
|
+
|
|
816
|
+
Args:
|
|
817
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseRequest, dict]]):
|
|
818
|
+
The request object. The request for
|
|
819
|
+
[UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
|
|
820
|
+
database (:class:`google.cloud.spanner_admin_database_v1.types.Database`):
|
|
821
|
+
Required. The database to update. The ``name`` field of
|
|
822
|
+
the database is of the form
|
|
823
|
+
``projects/<project>/instances/<instance>/databases/<database>``.
|
|
824
|
+
|
|
825
|
+
This corresponds to the ``database`` field
|
|
826
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
827
|
+
should not be set.
|
|
828
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
829
|
+
Required. The list of fields to update. Currently, only
|
|
830
|
+
``enable_drop_protection`` field can be updated.
|
|
831
|
+
|
|
832
|
+
This corresponds to the ``update_mask`` field
|
|
833
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
834
|
+
should not be set.
|
|
835
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
836
|
+
should be retried.
|
|
837
|
+
timeout (float): The timeout for this request.
|
|
838
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
839
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
840
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
841
|
+
be of type `bytes`.
|
|
842
|
+
|
|
843
|
+
Returns:
|
|
844
|
+
google.api_core.operation_async.AsyncOperation:
|
|
845
|
+
An object representing a long-running operation.
|
|
846
|
+
|
|
847
|
+
The result type for the operation will be
|
|
848
|
+
:class:`google.cloud.spanner_admin_database_v1.types.Database`
|
|
849
|
+
A Cloud Spanner database.
|
|
850
|
+
|
|
851
|
+
"""
|
|
852
|
+
# Create or coerce a protobuf request object.
|
|
853
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
854
|
+
# gotten any keyword arguments that map to the request.
|
|
855
|
+
flattened_params = [database, update_mask]
|
|
856
|
+
has_flattened_params = (
|
|
857
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
858
|
+
)
|
|
859
|
+
if request is not None and has_flattened_params:
|
|
860
|
+
raise ValueError(
|
|
861
|
+
"If the `request` argument is set, then none of "
|
|
862
|
+
"the individual field arguments should be set."
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
866
|
+
# there are no flattened fields), or create one.
|
|
867
|
+
if not isinstance(request, spanner_database_admin.UpdateDatabaseRequest):
|
|
868
|
+
request = spanner_database_admin.UpdateDatabaseRequest(request)
|
|
869
|
+
|
|
870
|
+
# If we have keyword arguments corresponding to fields on the
|
|
871
|
+
# request, apply these.
|
|
872
|
+
if database is not None:
|
|
873
|
+
request.database = database
|
|
874
|
+
if update_mask is not None:
|
|
875
|
+
request.update_mask = update_mask
|
|
876
|
+
|
|
877
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
878
|
+
# and friendly error handling.
|
|
879
|
+
rpc = self._client._transport._wrapped_methods[
|
|
880
|
+
self._client._transport.update_database
|
|
881
|
+
]
|
|
882
|
+
|
|
883
|
+
# Certain fields should be provided within the metadata header;
|
|
884
|
+
# add these here.
|
|
885
|
+
metadata = tuple(metadata) + (
|
|
886
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
887
|
+
(("database.name", request.database.name),)
|
|
888
|
+
),
|
|
889
|
+
)
|
|
890
|
+
|
|
891
|
+
# Validate the universe domain.
|
|
892
|
+
self._client._validate_universe_domain()
|
|
893
|
+
|
|
894
|
+
# Send the request.
|
|
895
|
+
response = await rpc(
|
|
896
|
+
request,
|
|
897
|
+
retry=retry,
|
|
898
|
+
timeout=timeout,
|
|
899
|
+
metadata=metadata,
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
# Wrap the response in an operation future.
|
|
903
|
+
response = operation_async.from_gapic(
|
|
904
|
+
response,
|
|
905
|
+
self._client._transport.operations_client,
|
|
906
|
+
spanner_database_admin.Database,
|
|
907
|
+
metadata_type=spanner_database_admin.UpdateDatabaseMetadata,
|
|
908
|
+
)
|
|
909
|
+
|
|
910
|
+
# Done; return the response.
|
|
911
|
+
return response
|
|
912
|
+
|
|
913
|
+
async def update_database_ddl(
|
|
914
|
+
self,
|
|
915
|
+
request: Optional[
|
|
916
|
+
Union[spanner_database_admin.UpdateDatabaseDdlRequest, dict]
|
|
917
|
+
] = None,
|
|
918
|
+
*,
|
|
919
|
+
database: Optional[str] = None,
|
|
920
|
+
statements: Optional[MutableSequence[str]] = None,
|
|
921
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
922
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
923
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
924
|
+
) -> operation_async.AsyncOperation:
|
|
925
|
+
r"""Updates the schema of a Cloud Spanner database by
|
|
926
|
+
creating/altering/dropping tables, columns, indexes, etc. The
|
|
927
|
+
returned [long-running operation][google.longrunning.Operation]
|
|
928
|
+
will have a name of the format
|
|
929
|
+
``<database_name>/operations/<operation_id>`` and can be used to
|
|
930
|
+
track execution of the schema change(s). The
|
|
931
|
+
[metadata][google.longrunning.Operation.metadata] field type is
|
|
932
|
+
[UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
|
|
933
|
+
The operation has no response.
|
|
934
|
+
|
|
935
|
+
.. code-block:: python
|
|
936
|
+
|
|
937
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
938
|
+
# code template only.
|
|
939
|
+
# It will require modifications to work:
|
|
940
|
+
# - It may require correct/in-range values for request initialization.
|
|
941
|
+
# - It may require specifying regional endpoints when creating the service
|
|
942
|
+
# client as shown in:
|
|
943
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
944
|
+
from google.cloud import spanner_admin_database_v1
|
|
945
|
+
|
|
946
|
+
async def sample_update_database_ddl():
|
|
947
|
+
# Create a client
|
|
948
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
949
|
+
|
|
950
|
+
# Initialize request argument(s)
|
|
951
|
+
request = spanner_admin_database_v1.UpdateDatabaseDdlRequest(
|
|
952
|
+
database="database_value",
|
|
953
|
+
statements=['statements_value1', 'statements_value2'],
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
# Make the request
|
|
957
|
+
operation = client.update_database_ddl(request=request)
|
|
958
|
+
|
|
959
|
+
print("Waiting for operation to complete...")
|
|
960
|
+
|
|
961
|
+
response = (await operation).result()
|
|
962
|
+
|
|
963
|
+
# Handle the response
|
|
964
|
+
print(response)
|
|
965
|
+
|
|
966
|
+
Args:
|
|
967
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest, dict]]):
|
|
968
|
+
The request object. Enqueues the given DDL statements to be applied, in
|
|
969
|
+
order but not necessarily all at once, to the database
|
|
970
|
+
schema at some point (or points) in the future. The
|
|
971
|
+
server checks that the statements are executable
|
|
972
|
+
(syntactically valid, name tables that exist, etc.)
|
|
973
|
+
before enqueueing them, but they may still fail upon
|
|
974
|
+
later execution (e.g., if a statement from another batch
|
|
975
|
+
of statements is applied first and it conflicts in some
|
|
976
|
+
way, or if there is some data-related problem like a
|
|
977
|
+
``NULL`` value in a column to which ``NOT NULL`` would
|
|
978
|
+
be added). If a statement fails, all subsequent
|
|
979
|
+
statements in the batch are automatically cancelled.
|
|
980
|
+
|
|
981
|
+
Each batch of statements is assigned a name which can be
|
|
982
|
+
used with the
|
|
983
|
+
[Operations][google.longrunning.Operations] API to
|
|
984
|
+
monitor progress. See the
|
|
985
|
+
[operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id]
|
|
986
|
+
field for more details.
|
|
987
|
+
database (:class:`str`):
|
|
988
|
+
Required. The database to update.
|
|
989
|
+
This corresponds to the ``database`` field
|
|
990
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
991
|
+
should not be set.
|
|
992
|
+
statements (:class:`MutableSequence[str]`):
|
|
993
|
+
Required. DDL statements to be
|
|
994
|
+
applied to the database.
|
|
995
|
+
|
|
996
|
+
This corresponds to the ``statements`` field
|
|
997
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
998
|
+
should not be set.
|
|
999
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1000
|
+
should be retried.
|
|
1001
|
+
timeout (float): The timeout for this request.
|
|
1002
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1003
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1004
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1005
|
+
be of type `bytes`.
|
|
1006
|
+
|
|
1007
|
+
Returns:
|
|
1008
|
+
google.api_core.operation_async.AsyncOperation:
|
|
1009
|
+
An object representing a long-running operation.
|
|
1010
|
+
|
|
1011
|
+
The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
|
|
1012
|
+
empty messages in your APIs. A typical example is to
|
|
1013
|
+
use it as the request or the response type of an API
|
|
1014
|
+
method. For instance:
|
|
1015
|
+
|
|
1016
|
+
service Foo {
|
|
1017
|
+
rpc Bar(google.protobuf.Empty) returns
|
|
1018
|
+
(google.protobuf.Empty);
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
"""
|
|
1023
|
+
# Create or coerce a protobuf request object.
|
|
1024
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1025
|
+
# gotten any keyword arguments that map to the request.
|
|
1026
|
+
flattened_params = [database, statements]
|
|
1027
|
+
has_flattened_params = (
|
|
1028
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1029
|
+
)
|
|
1030
|
+
if request is not None and has_flattened_params:
|
|
1031
|
+
raise ValueError(
|
|
1032
|
+
"If the `request` argument is set, then none of "
|
|
1033
|
+
"the individual field arguments should be set."
|
|
1034
|
+
)
|
|
1035
|
+
|
|
1036
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1037
|
+
# there are no flattened fields), or create one.
|
|
1038
|
+
if not isinstance(request, spanner_database_admin.UpdateDatabaseDdlRequest):
|
|
1039
|
+
request = spanner_database_admin.UpdateDatabaseDdlRequest(request)
|
|
1040
|
+
|
|
1041
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1042
|
+
# request, apply these.
|
|
1043
|
+
if database is not None:
|
|
1044
|
+
request.database = database
|
|
1045
|
+
if statements:
|
|
1046
|
+
request.statements.extend(statements)
|
|
1047
|
+
|
|
1048
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1049
|
+
# and friendly error handling.
|
|
1050
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1051
|
+
self._client._transport.update_database_ddl
|
|
1052
|
+
]
|
|
1053
|
+
|
|
1054
|
+
# Certain fields should be provided within the metadata header;
|
|
1055
|
+
# add these here.
|
|
1056
|
+
metadata = tuple(metadata) + (
|
|
1057
|
+
gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
|
|
1058
|
+
)
|
|
1059
|
+
|
|
1060
|
+
# Validate the universe domain.
|
|
1061
|
+
self._client._validate_universe_domain()
|
|
1062
|
+
|
|
1063
|
+
# Send the request.
|
|
1064
|
+
response = await rpc(
|
|
1065
|
+
request,
|
|
1066
|
+
retry=retry,
|
|
1067
|
+
timeout=timeout,
|
|
1068
|
+
metadata=metadata,
|
|
1069
|
+
)
|
|
1070
|
+
|
|
1071
|
+
# Wrap the response in an operation future.
|
|
1072
|
+
response = operation_async.from_gapic(
|
|
1073
|
+
response,
|
|
1074
|
+
self._client._transport.operations_client,
|
|
1075
|
+
empty_pb2.Empty,
|
|
1076
|
+
metadata_type=spanner_database_admin.UpdateDatabaseDdlMetadata,
|
|
1077
|
+
)
|
|
1078
|
+
|
|
1079
|
+
# Done; return the response.
|
|
1080
|
+
return response
|
|
1081
|
+
|
|
1082
|
+
async def drop_database(
|
|
1083
|
+
self,
|
|
1084
|
+
request: Optional[
|
|
1085
|
+
Union[spanner_database_admin.DropDatabaseRequest, dict]
|
|
1086
|
+
] = None,
|
|
1087
|
+
*,
|
|
1088
|
+
database: Optional[str] = None,
|
|
1089
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1090
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1091
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1092
|
+
) -> None:
|
|
1093
|
+
r"""Drops (aka deletes) a Cloud Spanner database. Completed backups
|
|
1094
|
+
for the database will be retained according to their
|
|
1095
|
+
``expire_time``. Note: Cloud Spanner might continue to accept
|
|
1096
|
+
requests for a few seconds after the database has been deleted.
|
|
1097
|
+
|
|
1098
|
+
.. code-block:: python
|
|
1099
|
+
|
|
1100
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1101
|
+
# code template only.
|
|
1102
|
+
# It will require modifications to work:
|
|
1103
|
+
# - It may require correct/in-range values for request initialization.
|
|
1104
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1105
|
+
# client as shown in:
|
|
1106
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1107
|
+
from google.cloud import spanner_admin_database_v1
|
|
1108
|
+
|
|
1109
|
+
async def sample_drop_database():
|
|
1110
|
+
# Create a client
|
|
1111
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1112
|
+
|
|
1113
|
+
# Initialize request argument(s)
|
|
1114
|
+
request = spanner_admin_database_v1.DropDatabaseRequest(
|
|
1115
|
+
database="database_value",
|
|
1116
|
+
)
|
|
1117
|
+
|
|
1118
|
+
# Make the request
|
|
1119
|
+
await client.drop_database(request=request)
|
|
1120
|
+
|
|
1121
|
+
Args:
|
|
1122
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest, dict]]):
|
|
1123
|
+
The request object. The request for
|
|
1124
|
+
[DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
|
|
1125
|
+
database (:class:`str`):
|
|
1126
|
+
Required. The database to be dropped.
|
|
1127
|
+
This corresponds to the ``database`` field
|
|
1128
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1129
|
+
should not be set.
|
|
1130
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1131
|
+
should be retried.
|
|
1132
|
+
timeout (float): The timeout for this request.
|
|
1133
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1134
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1135
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1136
|
+
be of type `bytes`.
|
|
1137
|
+
"""
|
|
1138
|
+
# Create or coerce a protobuf request object.
|
|
1139
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1140
|
+
# gotten any keyword arguments that map to the request.
|
|
1141
|
+
flattened_params = [database]
|
|
1142
|
+
has_flattened_params = (
|
|
1143
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1144
|
+
)
|
|
1145
|
+
if request is not None and has_flattened_params:
|
|
1146
|
+
raise ValueError(
|
|
1147
|
+
"If the `request` argument is set, then none of "
|
|
1148
|
+
"the individual field arguments should be set."
|
|
1149
|
+
)
|
|
1150
|
+
|
|
1151
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1152
|
+
# there are no flattened fields), or create one.
|
|
1153
|
+
if not isinstance(request, spanner_database_admin.DropDatabaseRequest):
|
|
1154
|
+
request = spanner_database_admin.DropDatabaseRequest(request)
|
|
1155
|
+
|
|
1156
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1157
|
+
# request, apply these.
|
|
1158
|
+
if database is not None:
|
|
1159
|
+
request.database = database
|
|
1160
|
+
|
|
1161
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1162
|
+
# and friendly error handling.
|
|
1163
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1164
|
+
self._client._transport.drop_database
|
|
1165
|
+
]
|
|
1166
|
+
|
|
1167
|
+
# Certain fields should be provided within the metadata header;
|
|
1168
|
+
# add these here.
|
|
1169
|
+
metadata = tuple(metadata) + (
|
|
1170
|
+
gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
|
|
1171
|
+
)
|
|
1172
|
+
|
|
1173
|
+
# Validate the universe domain.
|
|
1174
|
+
self._client._validate_universe_domain()
|
|
1175
|
+
|
|
1176
|
+
# Send the request.
|
|
1177
|
+
await rpc(
|
|
1178
|
+
request,
|
|
1179
|
+
retry=retry,
|
|
1180
|
+
timeout=timeout,
|
|
1181
|
+
metadata=metadata,
|
|
1182
|
+
)
|
|
1183
|
+
|
|
1184
|
+
async def get_database_ddl(
|
|
1185
|
+
self,
|
|
1186
|
+
request: Optional[
|
|
1187
|
+
Union[spanner_database_admin.GetDatabaseDdlRequest, dict]
|
|
1188
|
+
] = None,
|
|
1189
|
+
*,
|
|
1190
|
+
database: Optional[str] = None,
|
|
1191
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1192
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1193
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1194
|
+
) -> spanner_database_admin.GetDatabaseDdlResponse:
|
|
1195
|
+
r"""Returns the schema of a Cloud Spanner database as a list of
|
|
1196
|
+
formatted DDL statements. This method does not show pending
|
|
1197
|
+
schema updates, those may be queried using the
|
|
1198
|
+
[Operations][google.longrunning.Operations] API.
|
|
1199
|
+
|
|
1200
|
+
.. code-block:: python
|
|
1201
|
+
|
|
1202
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1203
|
+
# code template only.
|
|
1204
|
+
# It will require modifications to work:
|
|
1205
|
+
# - It may require correct/in-range values for request initialization.
|
|
1206
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1207
|
+
# client as shown in:
|
|
1208
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1209
|
+
from google.cloud import spanner_admin_database_v1
|
|
1210
|
+
|
|
1211
|
+
async def sample_get_database_ddl():
|
|
1212
|
+
# Create a client
|
|
1213
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1214
|
+
|
|
1215
|
+
# Initialize request argument(s)
|
|
1216
|
+
request = spanner_admin_database_v1.GetDatabaseDdlRequest(
|
|
1217
|
+
database="database_value",
|
|
1218
|
+
)
|
|
1219
|
+
|
|
1220
|
+
# Make the request
|
|
1221
|
+
response = await client.get_database_ddl(request=request)
|
|
1222
|
+
|
|
1223
|
+
# Handle the response
|
|
1224
|
+
print(response)
|
|
1225
|
+
|
|
1226
|
+
Args:
|
|
1227
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest, dict]]):
|
|
1228
|
+
The request object. The request for
|
|
1229
|
+
[GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
|
|
1230
|
+
database (:class:`str`):
|
|
1231
|
+
Required. The database whose schema we wish to get.
|
|
1232
|
+
Values are of the form
|
|
1233
|
+
``projects/<project>/instances/<instance>/databases/<database>``
|
|
1234
|
+
|
|
1235
|
+
This corresponds to the ``database`` field
|
|
1236
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1237
|
+
should not be set.
|
|
1238
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1239
|
+
should be retried.
|
|
1240
|
+
timeout (float): The timeout for this request.
|
|
1241
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1242
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1243
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1244
|
+
be of type `bytes`.
|
|
1245
|
+
|
|
1246
|
+
Returns:
|
|
1247
|
+
google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlResponse:
|
|
1248
|
+
The response for
|
|
1249
|
+
[GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
|
|
1250
|
+
|
|
1251
|
+
"""
|
|
1252
|
+
# Create or coerce a protobuf request object.
|
|
1253
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1254
|
+
# gotten any keyword arguments that map to the request.
|
|
1255
|
+
flattened_params = [database]
|
|
1256
|
+
has_flattened_params = (
|
|
1257
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1258
|
+
)
|
|
1259
|
+
if request is not None and has_flattened_params:
|
|
1260
|
+
raise ValueError(
|
|
1261
|
+
"If the `request` argument is set, then none of "
|
|
1262
|
+
"the individual field arguments should be set."
|
|
1263
|
+
)
|
|
1264
|
+
|
|
1265
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1266
|
+
# there are no flattened fields), or create one.
|
|
1267
|
+
if not isinstance(request, spanner_database_admin.GetDatabaseDdlRequest):
|
|
1268
|
+
request = spanner_database_admin.GetDatabaseDdlRequest(request)
|
|
1269
|
+
|
|
1270
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1271
|
+
# request, apply these.
|
|
1272
|
+
if database is not None:
|
|
1273
|
+
request.database = database
|
|
1274
|
+
|
|
1275
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1276
|
+
# and friendly error handling.
|
|
1277
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1278
|
+
self._client._transport.get_database_ddl
|
|
1279
|
+
]
|
|
1280
|
+
|
|
1281
|
+
# Certain fields should be provided within the metadata header;
|
|
1282
|
+
# add these here.
|
|
1283
|
+
metadata = tuple(metadata) + (
|
|
1284
|
+
gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
|
|
1285
|
+
)
|
|
1286
|
+
|
|
1287
|
+
# Validate the universe domain.
|
|
1288
|
+
self._client._validate_universe_domain()
|
|
1289
|
+
|
|
1290
|
+
# Send the request.
|
|
1291
|
+
response = await rpc(
|
|
1292
|
+
request,
|
|
1293
|
+
retry=retry,
|
|
1294
|
+
timeout=timeout,
|
|
1295
|
+
metadata=metadata,
|
|
1296
|
+
)
|
|
1297
|
+
|
|
1298
|
+
# Done; return the response.
|
|
1299
|
+
return response
|
|
1300
|
+
|
|
1301
|
+
async def set_iam_policy(
|
|
1302
|
+
self,
|
|
1303
|
+
request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
|
|
1304
|
+
*,
|
|
1305
|
+
resource: Optional[str] = None,
|
|
1306
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1307
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1308
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1309
|
+
) -> policy_pb2.Policy:
|
|
1310
|
+
r"""Sets the access control policy on a database or backup resource.
|
|
1311
|
+
Replaces any existing policy.
|
|
1312
|
+
|
|
1313
|
+
Authorization requires ``spanner.databases.setIamPolicy``
|
|
1314
|
+
permission on
|
|
1315
|
+
[resource][google.iam.v1.SetIamPolicyRequest.resource]. For
|
|
1316
|
+
backups, authorization requires ``spanner.backups.setIamPolicy``
|
|
1317
|
+
permission on
|
|
1318
|
+
[resource][google.iam.v1.SetIamPolicyRequest.resource].
|
|
1319
|
+
|
|
1320
|
+
.. code-block:: python
|
|
1321
|
+
|
|
1322
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1323
|
+
# code template only.
|
|
1324
|
+
# It will require modifications to work:
|
|
1325
|
+
# - It may require correct/in-range values for request initialization.
|
|
1326
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1327
|
+
# client as shown in:
|
|
1328
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1329
|
+
from google.cloud import spanner_admin_database_v1
|
|
1330
|
+
from google.iam.v1 import iam_policy_pb2 # type: ignore
|
|
1331
|
+
|
|
1332
|
+
async def sample_set_iam_policy():
|
|
1333
|
+
# Create a client
|
|
1334
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1335
|
+
|
|
1336
|
+
# Initialize request argument(s)
|
|
1337
|
+
request = iam_policy_pb2.SetIamPolicyRequest(
|
|
1338
|
+
resource="resource_value",
|
|
1339
|
+
)
|
|
1340
|
+
|
|
1341
|
+
# Make the request
|
|
1342
|
+
response = await client.set_iam_policy(request=request)
|
|
1343
|
+
|
|
1344
|
+
# Handle the response
|
|
1345
|
+
print(response)
|
|
1346
|
+
|
|
1347
|
+
Args:
|
|
1348
|
+
request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]):
|
|
1349
|
+
The request object. Request message for ``SetIamPolicy`` method.
|
|
1350
|
+
resource (:class:`str`):
|
|
1351
|
+
REQUIRED: The resource for which the
|
|
1352
|
+
policy is being specified. See the
|
|
1353
|
+
operation documentation for the
|
|
1354
|
+
appropriate value for this field.
|
|
1355
|
+
|
|
1356
|
+
This corresponds to the ``resource`` field
|
|
1357
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1358
|
+
should not be set.
|
|
1359
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1360
|
+
should be retried.
|
|
1361
|
+
timeout (float): The timeout for this request.
|
|
1362
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1363
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1364
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1365
|
+
be of type `bytes`.
|
|
1366
|
+
|
|
1367
|
+
Returns:
|
|
1368
|
+
google.iam.v1.policy_pb2.Policy:
|
|
1369
|
+
An Identity and Access Management (IAM) policy, which specifies access
|
|
1370
|
+
controls for Google Cloud resources.
|
|
1371
|
+
|
|
1372
|
+
A Policy is a collection of bindings. A binding binds
|
|
1373
|
+
one or more members, or principals, to a single role.
|
|
1374
|
+
Principals can be user accounts, service accounts,
|
|
1375
|
+
Google groups, and domains (such as G Suite). A role
|
|
1376
|
+
is a named list of permissions; each role can be an
|
|
1377
|
+
IAM predefined role or a user-created custom role.
|
|
1378
|
+
|
|
1379
|
+
For some types of Google Cloud resources, a binding
|
|
1380
|
+
can also specify a condition, which is a logical
|
|
1381
|
+
expression that allows access to a resource only if
|
|
1382
|
+
the expression evaluates to true. A condition can add
|
|
1383
|
+
constraints based on attributes of the request, the
|
|
1384
|
+
resource, or both. To learn which resources support
|
|
1385
|
+
conditions in their IAM policies, see the [IAM
|
|
1386
|
+
documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
|
|
1387
|
+
|
|
1388
|
+
**JSON example:**
|
|
1389
|
+
|
|
1390
|
+
: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 }`\ \`
|
|
1391
|
+
|
|
1392
|
+
**YAML example:**
|
|
1393
|
+
|
|
1394
|
+
: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`\ \`
|
|
1395
|
+
|
|
1396
|
+
For a description of IAM and its features, see the
|
|
1397
|
+
[IAM
|
|
1398
|
+
documentation](\ https://cloud.google.com/iam/docs/).
|
|
1399
|
+
|
|
1400
|
+
"""
|
|
1401
|
+
# Create or coerce a protobuf request object.
|
|
1402
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1403
|
+
# gotten any keyword arguments that map to the request.
|
|
1404
|
+
flattened_params = [resource]
|
|
1405
|
+
has_flattened_params = (
|
|
1406
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1407
|
+
)
|
|
1408
|
+
if request is not None and has_flattened_params:
|
|
1409
|
+
raise ValueError(
|
|
1410
|
+
"If the `request` argument is set, then none of "
|
|
1411
|
+
"the individual field arguments should be set."
|
|
1412
|
+
)
|
|
1413
|
+
|
|
1414
|
+
# - The request isn't a proto-plus wrapped type,
|
|
1415
|
+
# so it must be constructed via keyword expansion.
|
|
1416
|
+
if isinstance(request, dict):
|
|
1417
|
+
request = iam_policy_pb2.SetIamPolicyRequest(**request)
|
|
1418
|
+
elif not request:
|
|
1419
|
+
request = iam_policy_pb2.SetIamPolicyRequest(resource=resource)
|
|
1420
|
+
|
|
1421
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1422
|
+
# and friendly error handling.
|
|
1423
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1424
|
+
self._client._transport.set_iam_policy
|
|
1425
|
+
]
|
|
1426
|
+
|
|
1427
|
+
# Certain fields should be provided within the metadata header;
|
|
1428
|
+
# add these here.
|
|
1429
|
+
metadata = tuple(metadata) + (
|
|
1430
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
1431
|
+
)
|
|
1432
|
+
|
|
1433
|
+
# Validate the universe domain.
|
|
1434
|
+
self._client._validate_universe_domain()
|
|
1435
|
+
|
|
1436
|
+
# Send the request.
|
|
1437
|
+
response = await rpc(
|
|
1438
|
+
request,
|
|
1439
|
+
retry=retry,
|
|
1440
|
+
timeout=timeout,
|
|
1441
|
+
metadata=metadata,
|
|
1442
|
+
)
|
|
1443
|
+
|
|
1444
|
+
# Done; return the response.
|
|
1445
|
+
return response
|
|
1446
|
+
|
|
1447
|
+
async def get_iam_policy(
|
|
1448
|
+
self,
|
|
1449
|
+
request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
|
|
1450
|
+
*,
|
|
1451
|
+
resource: Optional[str] = None,
|
|
1452
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1453
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1454
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1455
|
+
) -> policy_pb2.Policy:
|
|
1456
|
+
r"""Gets the access control policy for a database or backup
|
|
1457
|
+
resource. Returns an empty policy if a database or backup exists
|
|
1458
|
+
but does not have a policy set.
|
|
1459
|
+
|
|
1460
|
+
Authorization requires ``spanner.databases.getIamPolicy``
|
|
1461
|
+
permission on
|
|
1462
|
+
[resource][google.iam.v1.GetIamPolicyRequest.resource]. For
|
|
1463
|
+
backups, authorization requires ``spanner.backups.getIamPolicy``
|
|
1464
|
+
permission on
|
|
1465
|
+
[resource][google.iam.v1.GetIamPolicyRequest.resource].
|
|
1466
|
+
|
|
1467
|
+
.. code-block:: python
|
|
1468
|
+
|
|
1469
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1470
|
+
# code template only.
|
|
1471
|
+
# It will require modifications to work:
|
|
1472
|
+
# - It may require correct/in-range values for request initialization.
|
|
1473
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1474
|
+
# client as shown in:
|
|
1475
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1476
|
+
from google.cloud import spanner_admin_database_v1
|
|
1477
|
+
from google.iam.v1 import iam_policy_pb2 # type: ignore
|
|
1478
|
+
|
|
1479
|
+
async def sample_get_iam_policy():
|
|
1480
|
+
# Create a client
|
|
1481
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1482
|
+
|
|
1483
|
+
# Initialize request argument(s)
|
|
1484
|
+
request = iam_policy_pb2.GetIamPolicyRequest(
|
|
1485
|
+
resource="resource_value",
|
|
1486
|
+
)
|
|
1487
|
+
|
|
1488
|
+
# Make the request
|
|
1489
|
+
response = await client.get_iam_policy(request=request)
|
|
1490
|
+
|
|
1491
|
+
# Handle the response
|
|
1492
|
+
print(response)
|
|
1493
|
+
|
|
1494
|
+
Args:
|
|
1495
|
+
request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]):
|
|
1496
|
+
The request object. Request message for ``GetIamPolicy`` method.
|
|
1497
|
+
resource (:class:`str`):
|
|
1498
|
+
REQUIRED: The resource for which the
|
|
1499
|
+
policy is being requested. See the
|
|
1500
|
+
operation documentation for the
|
|
1501
|
+
appropriate value for this field.
|
|
1502
|
+
|
|
1503
|
+
This corresponds to the ``resource`` field
|
|
1504
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1505
|
+
should not be set.
|
|
1506
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1507
|
+
should be retried.
|
|
1508
|
+
timeout (float): The timeout for this request.
|
|
1509
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1510
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1511
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1512
|
+
be of type `bytes`.
|
|
1513
|
+
|
|
1514
|
+
Returns:
|
|
1515
|
+
google.iam.v1.policy_pb2.Policy:
|
|
1516
|
+
An Identity and Access Management (IAM) policy, which specifies access
|
|
1517
|
+
controls for Google Cloud resources.
|
|
1518
|
+
|
|
1519
|
+
A Policy is a collection of bindings. A binding binds
|
|
1520
|
+
one or more members, or principals, to a single role.
|
|
1521
|
+
Principals can be user accounts, service accounts,
|
|
1522
|
+
Google groups, and domains (such as G Suite). A role
|
|
1523
|
+
is a named list of permissions; each role can be an
|
|
1524
|
+
IAM predefined role or a user-created custom role.
|
|
1525
|
+
|
|
1526
|
+
For some types of Google Cloud resources, a binding
|
|
1527
|
+
can also specify a condition, which is a logical
|
|
1528
|
+
expression that allows access to a resource only if
|
|
1529
|
+
the expression evaluates to true. A condition can add
|
|
1530
|
+
constraints based on attributes of the request, the
|
|
1531
|
+
resource, or both. To learn which resources support
|
|
1532
|
+
conditions in their IAM policies, see the [IAM
|
|
1533
|
+
documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
|
|
1534
|
+
|
|
1535
|
+
**JSON example:**
|
|
1536
|
+
|
|
1537
|
+
: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 }`\ \`
|
|
1538
|
+
|
|
1539
|
+
**YAML example:**
|
|
1540
|
+
|
|
1541
|
+
: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`\ \`
|
|
1542
|
+
|
|
1543
|
+
For a description of IAM and its features, see the
|
|
1544
|
+
[IAM
|
|
1545
|
+
documentation](\ https://cloud.google.com/iam/docs/).
|
|
1546
|
+
|
|
1547
|
+
"""
|
|
1548
|
+
# Create or coerce a protobuf request object.
|
|
1549
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1550
|
+
# gotten any keyword arguments that map to the request.
|
|
1551
|
+
flattened_params = [resource]
|
|
1552
|
+
has_flattened_params = (
|
|
1553
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1554
|
+
)
|
|
1555
|
+
if request is not None and has_flattened_params:
|
|
1556
|
+
raise ValueError(
|
|
1557
|
+
"If the `request` argument is set, then none of "
|
|
1558
|
+
"the individual field arguments should be set."
|
|
1559
|
+
)
|
|
1560
|
+
|
|
1561
|
+
# - The request isn't a proto-plus wrapped type,
|
|
1562
|
+
# so it must be constructed via keyword expansion.
|
|
1563
|
+
if isinstance(request, dict):
|
|
1564
|
+
request = iam_policy_pb2.GetIamPolicyRequest(**request)
|
|
1565
|
+
elif not request:
|
|
1566
|
+
request = iam_policy_pb2.GetIamPolicyRequest(resource=resource)
|
|
1567
|
+
|
|
1568
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1569
|
+
# and friendly error handling.
|
|
1570
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1571
|
+
self._client._transport.get_iam_policy
|
|
1572
|
+
]
|
|
1573
|
+
|
|
1574
|
+
# Certain fields should be provided within the metadata header;
|
|
1575
|
+
# add these here.
|
|
1576
|
+
metadata = tuple(metadata) + (
|
|
1577
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
1578
|
+
)
|
|
1579
|
+
|
|
1580
|
+
# Validate the universe domain.
|
|
1581
|
+
self._client._validate_universe_domain()
|
|
1582
|
+
|
|
1583
|
+
# Send the request.
|
|
1584
|
+
response = await rpc(
|
|
1585
|
+
request,
|
|
1586
|
+
retry=retry,
|
|
1587
|
+
timeout=timeout,
|
|
1588
|
+
metadata=metadata,
|
|
1589
|
+
)
|
|
1590
|
+
|
|
1591
|
+
# Done; return the response.
|
|
1592
|
+
return response
|
|
1593
|
+
|
|
1594
|
+
async def test_iam_permissions(
|
|
1595
|
+
self,
|
|
1596
|
+
request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
|
|
1597
|
+
*,
|
|
1598
|
+
resource: Optional[str] = None,
|
|
1599
|
+
permissions: Optional[MutableSequence[str]] = None,
|
|
1600
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1601
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1602
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1603
|
+
) -> iam_policy_pb2.TestIamPermissionsResponse:
|
|
1604
|
+
r"""Returns permissions that the caller has on the specified
|
|
1605
|
+
database or backup resource.
|
|
1606
|
+
|
|
1607
|
+
Attempting this RPC on a non-existent Cloud Spanner database
|
|
1608
|
+
will result in a NOT_FOUND error if the user has
|
|
1609
|
+
``spanner.databases.list`` permission on the containing Cloud
|
|
1610
|
+
Spanner instance. Otherwise returns an empty set of permissions.
|
|
1611
|
+
Calling this method on a backup that does not exist will result
|
|
1612
|
+
in a NOT_FOUND error if the user has ``spanner.backups.list``
|
|
1613
|
+
permission on the containing instance.
|
|
1614
|
+
|
|
1615
|
+
.. code-block:: python
|
|
1616
|
+
|
|
1617
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1618
|
+
# code template only.
|
|
1619
|
+
# It will require modifications to work:
|
|
1620
|
+
# - It may require correct/in-range values for request initialization.
|
|
1621
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1622
|
+
# client as shown in:
|
|
1623
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1624
|
+
from google.cloud import spanner_admin_database_v1
|
|
1625
|
+
from google.iam.v1 import iam_policy_pb2 # type: ignore
|
|
1626
|
+
|
|
1627
|
+
async def sample_test_iam_permissions():
|
|
1628
|
+
# Create a client
|
|
1629
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1630
|
+
|
|
1631
|
+
# Initialize request argument(s)
|
|
1632
|
+
request = iam_policy_pb2.TestIamPermissionsRequest(
|
|
1633
|
+
resource="resource_value",
|
|
1634
|
+
permissions=['permissions_value1', 'permissions_value2'],
|
|
1635
|
+
)
|
|
1636
|
+
|
|
1637
|
+
# Make the request
|
|
1638
|
+
response = await client.test_iam_permissions(request=request)
|
|
1639
|
+
|
|
1640
|
+
# Handle the response
|
|
1641
|
+
print(response)
|
|
1642
|
+
|
|
1643
|
+
Args:
|
|
1644
|
+
request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]):
|
|
1645
|
+
The request object. Request message for ``TestIamPermissions`` method.
|
|
1646
|
+
resource (:class:`str`):
|
|
1647
|
+
REQUIRED: The resource for which the
|
|
1648
|
+
policy detail is being requested. See
|
|
1649
|
+
the operation documentation for the
|
|
1650
|
+
appropriate value for this field.
|
|
1651
|
+
|
|
1652
|
+
This corresponds to the ``resource`` field
|
|
1653
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1654
|
+
should not be set.
|
|
1655
|
+
permissions (:class:`MutableSequence[str]`):
|
|
1656
|
+
The set of permissions to check for the ``resource``.
|
|
1657
|
+
Permissions with wildcards (such as '*' or 'storage.*')
|
|
1658
|
+
are not allowed. For more information see `IAM
|
|
1659
|
+
Overview <https://cloud.google.com/iam/docs/overview#permissions>`__.
|
|
1660
|
+
|
|
1661
|
+
This corresponds to the ``permissions`` field
|
|
1662
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1663
|
+
should not be set.
|
|
1664
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1665
|
+
should be retried.
|
|
1666
|
+
timeout (float): The timeout for this request.
|
|
1667
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1668
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1669
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1670
|
+
be of type `bytes`.
|
|
1671
|
+
|
|
1672
|
+
Returns:
|
|
1673
|
+
google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse:
|
|
1674
|
+
Response message for TestIamPermissions method.
|
|
1675
|
+
"""
|
|
1676
|
+
# Create or coerce a protobuf request object.
|
|
1677
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1678
|
+
# gotten any keyword arguments that map to the request.
|
|
1679
|
+
flattened_params = [resource, permissions]
|
|
1680
|
+
has_flattened_params = (
|
|
1681
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1682
|
+
)
|
|
1683
|
+
if request is not None and has_flattened_params:
|
|
1684
|
+
raise ValueError(
|
|
1685
|
+
"If the `request` argument is set, then none of "
|
|
1686
|
+
"the individual field arguments should be set."
|
|
1687
|
+
)
|
|
1688
|
+
|
|
1689
|
+
# - The request isn't a proto-plus wrapped type,
|
|
1690
|
+
# so it must be constructed via keyword expansion.
|
|
1691
|
+
if isinstance(request, dict):
|
|
1692
|
+
request = iam_policy_pb2.TestIamPermissionsRequest(**request)
|
|
1693
|
+
elif not request:
|
|
1694
|
+
request = iam_policy_pb2.TestIamPermissionsRequest(
|
|
1695
|
+
resource=resource, permissions=permissions
|
|
1696
|
+
)
|
|
1697
|
+
|
|
1698
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1699
|
+
# and friendly error handling.
|
|
1700
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1701
|
+
self._client._transport.test_iam_permissions
|
|
1702
|
+
]
|
|
1703
|
+
|
|
1704
|
+
# Certain fields should be provided within the metadata header;
|
|
1705
|
+
# add these here.
|
|
1706
|
+
metadata = tuple(metadata) + (
|
|
1707
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
1708
|
+
)
|
|
1709
|
+
|
|
1710
|
+
# Validate the universe domain.
|
|
1711
|
+
self._client._validate_universe_domain()
|
|
1712
|
+
|
|
1713
|
+
# Send the request.
|
|
1714
|
+
response = await rpc(
|
|
1715
|
+
request,
|
|
1716
|
+
retry=retry,
|
|
1717
|
+
timeout=timeout,
|
|
1718
|
+
metadata=metadata,
|
|
1719
|
+
)
|
|
1720
|
+
|
|
1721
|
+
# Done; return the response.
|
|
1722
|
+
return response
|
|
1723
|
+
|
|
1724
|
+
async def create_backup(
|
|
1725
|
+
self,
|
|
1726
|
+
request: Optional[Union[gsad_backup.CreateBackupRequest, dict]] = None,
|
|
1727
|
+
*,
|
|
1728
|
+
parent: Optional[str] = None,
|
|
1729
|
+
backup: Optional[gsad_backup.Backup] = None,
|
|
1730
|
+
backup_id: Optional[str] = None,
|
|
1731
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1732
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1733
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1734
|
+
) -> operation_async.AsyncOperation:
|
|
1735
|
+
r"""Starts creating a new Cloud Spanner Backup. The returned backup
|
|
1736
|
+
[long-running operation][google.longrunning.Operation] will have
|
|
1737
|
+
a name of the format
|
|
1738
|
+
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
|
|
1739
|
+
and can be used to track creation of the backup. The
|
|
1740
|
+
[metadata][google.longrunning.Operation.metadata] field type is
|
|
1741
|
+
[CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
|
|
1742
|
+
The [response][google.longrunning.Operation.response] field type
|
|
1743
|
+
is [Backup][google.spanner.admin.database.v1.Backup], if
|
|
1744
|
+
successful. Cancelling the returned operation will stop the
|
|
1745
|
+
creation and delete the backup. There can be only one pending
|
|
1746
|
+
backup creation per database. Backup creation of different
|
|
1747
|
+
databases can run concurrently.
|
|
1748
|
+
|
|
1749
|
+
.. code-block:: python
|
|
1750
|
+
|
|
1751
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1752
|
+
# code template only.
|
|
1753
|
+
# It will require modifications to work:
|
|
1754
|
+
# - It may require correct/in-range values for request initialization.
|
|
1755
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1756
|
+
# client as shown in:
|
|
1757
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1758
|
+
from google.cloud import spanner_admin_database_v1
|
|
1759
|
+
|
|
1760
|
+
async def sample_create_backup():
|
|
1761
|
+
# Create a client
|
|
1762
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1763
|
+
|
|
1764
|
+
# Initialize request argument(s)
|
|
1765
|
+
request = spanner_admin_database_v1.CreateBackupRequest(
|
|
1766
|
+
parent="parent_value",
|
|
1767
|
+
backup_id="backup_id_value",
|
|
1768
|
+
)
|
|
1769
|
+
|
|
1770
|
+
# Make the request
|
|
1771
|
+
operation = client.create_backup(request=request)
|
|
1772
|
+
|
|
1773
|
+
print("Waiting for operation to complete...")
|
|
1774
|
+
|
|
1775
|
+
response = (await operation).result()
|
|
1776
|
+
|
|
1777
|
+
# Handle the response
|
|
1778
|
+
print(response)
|
|
1779
|
+
|
|
1780
|
+
Args:
|
|
1781
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CreateBackupRequest, dict]]):
|
|
1782
|
+
The request object. The request for
|
|
1783
|
+
[CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
|
|
1784
|
+
parent (:class:`str`):
|
|
1785
|
+
Required. The name of the instance in which the backup
|
|
1786
|
+
will be created. This must be the same instance that
|
|
1787
|
+
contains the database the backup will be created from.
|
|
1788
|
+
The backup will be stored in the location(s) specified
|
|
1789
|
+
in the instance configuration of this instance. Values
|
|
1790
|
+
are of the form
|
|
1791
|
+
``projects/<project>/instances/<instance>``.
|
|
1792
|
+
|
|
1793
|
+
This corresponds to the ``parent`` field
|
|
1794
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1795
|
+
should not be set.
|
|
1796
|
+
backup (:class:`google.cloud.spanner_admin_database_v1.types.Backup`):
|
|
1797
|
+
Required. The backup to create.
|
|
1798
|
+
This corresponds to the ``backup`` field
|
|
1799
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1800
|
+
should not be set.
|
|
1801
|
+
backup_id (:class:`str`):
|
|
1802
|
+
Required. The id of the backup to be created. The
|
|
1803
|
+
``backup_id`` appended to ``parent`` forms the full
|
|
1804
|
+
backup name of the form
|
|
1805
|
+
``projects/<project>/instances/<instance>/backups/<backup_id>``.
|
|
1806
|
+
|
|
1807
|
+
This corresponds to the ``backup_id`` field
|
|
1808
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1809
|
+
should not be set.
|
|
1810
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1811
|
+
should be retried.
|
|
1812
|
+
timeout (float): The timeout for this request.
|
|
1813
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1814
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1815
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1816
|
+
be of type `bytes`.
|
|
1817
|
+
|
|
1818
|
+
Returns:
|
|
1819
|
+
google.api_core.operation_async.AsyncOperation:
|
|
1820
|
+
An object representing a long-running operation.
|
|
1821
|
+
|
|
1822
|
+
The result type for the operation will be
|
|
1823
|
+
:class:`google.cloud.spanner_admin_database_v1.types.Backup`
|
|
1824
|
+
A backup of a Cloud Spanner database.
|
|
1825
|
+
|
|
1826
|
+
"""
|
|
1827
|
+
# Create or coerce a protobuf request object.
|
|
1828
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1829
|
+
# gotten any keyword arguments that map to the request.
|
|
1830
|
+
flattened_params = [parent, backup, backup_id]
|
|
1831
|
+
has_flattened_params = (
|
|
1832
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1833
|
+
)
|
|
1834
|
+
if request is not None and has_flattened_params:
|
|
1835
|
+
raise ValueError(
|
|
1836
|
+
"If the `request` argument is set, then none of "
|
|
1837
|
+
"the individual field arguments should be set."
|
|
1838
|
+
)
|
|
1839
|
+
|
|
1840
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1841
|
+
# there are no flattened fields), or create one.
|
|
1842
|
+
if not isinstance(request, gsad_backup.CreateBackupRequest):
|
|
1843
|
+
request = gsad_backup.CreateBackupRequest(request)
|
|
1844
|
+
|
|
1845
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1846
|
+
# request, apply these.
|
|
1847
|
+
if parent is not None:
|
|
1848
|
+
request.parent = parent
|
|
1849
|
+
if backup is not None:
|
|
1850
|
+
request.backup = backup
|
|
1851
|
+
if backup_id is not None:
|
|
1852
|
+
request.backup_id = backup_id
|
|
1853
|
+
|
|
1854
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1855
|
+
# and friendly error handling.
|
|
1856
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1857
|
+
self._client._transport.create_backup
|
|
1858
|
+
]
|
|
1859
|
+
|
|
1860
|
+
# Certain fields should be provided within the metadata header;
|
|
1861
|
+
# add these here.
|
|
1862
|
+
metadata = tuple(metadata) + (
|
|
1863
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1864
|
+
)
|
|
1865
|
+
|
|
1866
|
+
# Validate the universe domain.
|
|
1867
|
+
self._client._validate_universe_domain()
|
|
1868
|
+
|
|
1869
|
+
# Send the request.
|
|
1870
|
+
response = await rpc(
|
|
1871
|
+
request,
|
|
1872
|
+
retry=retry,
|
|
1873
|
+
timeout=timeout,
|
|
1874
|
+
metadata=metadata,
|
|
1875
|
+
)
|
|
1876
|
+
|
|
1877
|
+
# Wrap the response in an operation future.
|
|
1878
|
+
response = operation_async.from_gapic(
|
|
1879
|
+
response,
|
|
1880
|
+
self._client._transport.operations_client,
|
|
1881
|
+
gsad_backup.Backup,
|
|
1882
|
+
metadata_type=gsad_backup.CreateBackupMetadata,
|
|
1883
|
+
)
|
|
1884
|
+
|
|
1885
|
+
# Done; return the response.
|
|
1886
|
+
return response
|
|
1887
|
+
|
|
1888
|
+
async def copy_backup(
|
|
1889
|
+
self,
|
|
1890
|
+
request: Optional[Union[backup.CopyBackupRequest, dict]] = None,
|
|
1891
|
+
*,
|
|
1892
|
+
parent: Optional[str] = None,
|
|
1893
|
+
backup_id: Optional[str] = None,
|
|
1894
|
+
source_backup: Optional[str] = None,
|
|
1895
|
+
expire_time: Optional[timestamp_pb2.Timestamp] = None,
|
|
1896
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1897
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1898
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1899
|
+
) -> operation_async.AsyncOperation:
|
|
1900
|
+
r"""Starts copying a Cloud Spanner Backup. The returned backup
|
|
1901
|
+
[long-running operation][google.longrunning.Operation] will have
|
|
1902
|
+
a name of the format
|
|
1903
|
+
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
|
|
1904
|
+
and can be used to track copying of the backup. The operation is
|
|
1905
|
+
associated with the destination backup. The
|
|
1906
|
+
[metadata][google.longrunning.Operation.metadata] field type is
|
|
1907
|
+
[CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
|
|
1908
|
+
The [response][google.longrunning.Operation.response] field type
|
|
1909
|
+
is [Backup][google.spanner.admin.database.v1.Backup], if
|
|
1910
|
+
successful. Cancelling the returned operation will stop the
|
|
1911
|
+
copying and delete the destination backup. Concurrent CopyBackup
|
|
1912
|
+
requests can run on the same source backup.
|
|
1913
|
+
|
|
1914
|
+
.. code-block:: python
|
|
1915
|
+
|
|
1916
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1917
|
+
# code template only.
|
|
1918
|
+
# It will require modifications to work:
|
|
1919
|
+
# - It may require correct/in-range values for request initialization.
|
|
1920
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1921
|
+
# client as shown in:
|
|
1922
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1923
|
+
from google.cloud import spanner_admin_database_v1
|
|
1924
|
+
|
|
1925
|
+
async def sample_copy_backup():
|
|
1926
|
+
# Create a client
|
|
1927
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
1928
|
+
|
|
1929
|
+
# Initialize request argument(s)
|
|
1930
|
+
request = spanner_admin_database_v1.CopyBackupRequest(
|
|
1931
|
+
parent="parent_value",
|
|
1932
|
+
backup_id="backup_id_value",
|
|
1933
|
+
source_backup="source_backup_value",
|
|
1934
|
+
)
|
|
1935
|
+
|
|
1936
|
+
# Make the request
|
|
1937
|
+
operation = client.copy_backup(request=request)
|
|
1938
|
+
|
|
1939
|
+
print("Waiting for operation to complete...")
|
|
1940
|
+
|
|
1941
|
+
response = (await operation).result()
|
|
1942
|
+
|
|
1943
|
+
# Handle the response
|
|
1944
|
+
print(response)
|
|
1945
|
+
|
|
1946
|
+
Args:
|
|
1947
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CopyBackupRequest, dict]]):
|
|
1948
|
+
The request object. The request for
|
|
1949
|
+
[CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
|
|
1950
|
+
parent (:class:`str`):
|
|
1951
|
+
Required. The name of the destination instance that will
|
|
1952
|
+
contain the backup copy. Values are of the form:
|
|
1953
|
+
``projects/<project>/instances/<instance>``.
|
|
1954
|
+
|
|
1955
|
+
This corresponds to the ``parent`` field
|
|
1956
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1957
|
+
should not be set.
|
|
1958
|
+
backup_id (:class:`str`):
|
|
1959
|
+
Required. The id of the backup copy. The ``backup_id``
|
|
1960
|
+
appended to ``parent`` forms the full backup_uri of the
|
|
1961
|
+
form
|
|
1962
|
+
``projects/<project>/instances/<instance>/backups/<backup>``.
|
|
1963
|
+
|
|
1964
|
+
This corresponds to the ``backup_id`` field
|
|
1965
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1966
|
+
should not be set.
|
|
1967
|
+
source_backup (:class:`str`):
|
|
1968
|
+
Required. The source backup to be copied. The source
|
|
1969
|
+
backup needs to be in READY state for it to be copied.
|
|
1970
|
+
Once CopyBackup is in progress, the source backup cannot
|
|
1971
|
+
be deleted or cleaned up on expiration until CopyBackup
|
|
1972
|
+
is finished. Values are of the form:
|
|
1973
|
+
``projects/<project>/instances/<instance>/backups/<backup>``.
|
|
1974
|
+
|
|
1975
|
+
This corresponds to the ``source_backup`` field
|
|
1976
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1977
|
+
should not be set.
|
|
1978
|
+
expire_time (:class:`google.protobuf.timestamp_pb2.Timestamp`):
|
|
1979
|
+
Required. The expiration time of the backup in
|
|
1980
|
+
microsecond granularity. The expiration time must be at
|
|
1981
|
+
least 6 hours and at most 366 days from the
|
|
1982
|
+
``create_time`` of the source backup. Once the
|
|
1983
|
+
``expire_time`` has passed, the backup is eligible to be
|
|
1984
|
+
automatically deleted by Cloud Spanner to free the
|
|
1985
|
+
resources used by the backup.
|
|
1986
|
+
|
|
1987
|
+
This corresponds to the ``expire_time`` field
|
|
1988
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1989
|
+
should not be set.
|
|
1990
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1991
|
+
should be retried.
|
|
1992
|
+
timeout (float): The timeout for this request.
|
|
1993
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1994
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1995
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1996
|
+
be of type `bytes`.
|
|
1997
|
+
|
|
1998
|
+
Returns:
|
|
1999
|
+
google.api_core.operation_async.AsyncOperation:
|
|
2000
|
+
An object representing a long-running operation.
|
|
2001
|
+
|
|
2002
|
+
The result type for the operation will be
|
|
2003
|
+
:class:`google.cloud.spanner_admin_database_v1.types.Backup`
|
|
2004
|
+
A backup of a Cloud Spanner database.
|
|
2005
|
+
|
|
2006
|
+
"""
|
|
2007
|
+
# Create or coerce a protobuf request object.
|
|
2008
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2009
|
+
# gotten any keyword arguments that map to the request.
|
|
2010
|
+
flattened_params = [parent, backup_id, source_backup, expire_time]
|
|
2011
|
+
has_flattened_params = (
|
|
2012
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2013
|
+
)
|
|
2014
|
+
if request is not None and has_flattened_params:
|
|
2015
|
+
raise ValueError(
|
|
2016
|
+
"If the `request` argument is set, then none of "
|
|
2017
|
+
"the individual field arguments should be set."
|
|
2018
|
+
)
|
|
2019
|
+
|
|
2020
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2021
|
+
# there are no flattened fields), or create one.
|
|
2022
|
+
if not isinstance(request, backup.CopyBackupRequest):
|
|
2023
|
+
request = backup.CopyBackupRequest(request)
|
|
2024
|
+
|
|
2025
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2026
|
+
# request, apply these.
|
|
2027
|
+
if parent is not None:
|
|
2028
|
+
request.parent = parent
|
|
2029
|
+
if backup_id is not None:
|
|
2030
|
+
request.backup_id = backup_id
|
|
2031
|
+
if source_backup is not None:
|
|
2032
|
+
request.source_backup = source_backup
|
|
2033
|
+
if expire_time is not None:
|
|
2034
|
+
request.expire_time = expire_time
|
|
2035
|
+
|
|
2036
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2037
|
+
# and friendly error handling.
|
|
2038
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2039
|
+
self._client._transport.copy_backup
|
|
2040
|
+
]
|
|
2041
|
+
|
|
2042
|
+
# Certain fields should be provided within the metadata header;
|
|
2043
|
+
# add these here.
|
|
2044
|
+
metadata = tuple(metadata) + (
|
|
2045
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2046
|
+
)
|
|
2047
|
+
|
|
2048
|
+
# Validate the universe domain.
|
|
2049
|
+
self._client._validate_universe_domain()
|
|
2050
|
+
|
|
2051
|
+
# Send the request.
|
|
2052
|
+
response = await rpc(
|
|
2053
|
+
request,
|
|
2054
|
+
retry=retry,
|
|
2055
|
+
timeout=timeout,
|
|
2056
|
+
metadata=metadata,
|
|
2057
|
+
)
|
|
2058
|
+
|
|
2059
|
+
# Wrap the response in an operation future.
|
|
2060
|
+
response = operation_async.from_gapic(
|
|
2061
|
+
response,
|
|
2062
|
+
self._client._transport.operations_client,
|
|
2063
|
+
backup.Backup,
|
|
2064
|
+
metadata_type=backup.CopyBackupMetadata,
|
|
2065
|
+
)
|
|
2066
|
+
|
|
2067
|
+
# Done; return the response.
|
|
2068
|
+
return response
|
|
2069
|
+
|
|
2070
|
+
async def get_backup(
|
|
2071
|
+
self,
|
|
2072
|
+
request: Optional[Union[backup.GetBackupRequest, dict]] = None,
|
|
2073
|
+
*,
|
|
2074
|
+
name: Optional[str] = None,
|
|
2075
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2076
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2077
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2078
|
+
) -> backup.Backup:
|
|
2079
|
+
r"""Gets metadata on a pending or completed
|
|
2080
|
+
[Backup][google.spanner.admin.database.v1.Backup].
|
|
2081
|
+
|
|
2082
|
+
.. code-block:: python
|
|
2083
|
+
|
|
2084
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2085
|
+
# code template only.
|
|
2086
|
+
# It will require modifications to work:
|
|
2087
|
+
# - It may require correct/in-range values for request initialization.
|
|
2088
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2089
|
+
# client as shown in:
|
|
2090
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2091
|
+
from google.cloud import spanner_admin_database_v1
|
|
2092
|
+
|
|
2093
|
+
async def sample_get_backup():
|
|
2094
|
+
# Create a client
|
|
2095
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2096
|
+
|
|
2097
|
+
# Initialize request argument(s)
|
|
2098
|
+
request = spanner_admin_database_v1.GetBackupRequest(
|
|
2099
|
+
name="name_value",
|
|
2100
|
+
)
|
|
2101
|
+
|
|
2102
|
+
# Make the request
|
|
2103
|
+
response = await client.get_backup(request=request)
|
|
2104
|
+
|
|
2105
|
+
# Handle the response
|
|
2106
|
+
print(response)
|
|
2107
|
+
|
|
2108
|
+
Args:
|
|
2109
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetBackupRequest, dict]]):
|
|
2110
|
+
The request object. The request for
|
|
2111
|
+
[GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
|
|
2112
|
+
name (:class:`str`):
|
|
2113
|
+
Required. Name of the backup. Values are of the form
|
|
2114
|
+
``projects/<project>/instances/<instance>/backups/<backup>``.
|
|
2115
|
+
|
|
2116
|
+
This corresponds to the ``name`` field
|
|
2117
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2118
|
+
should not be set.
|
|
2119
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2120
|
+
should be retried.
|
|
2121
|
+
timeout (float): The timeout for this request.
|
|
2122
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2123
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2124
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2125
|
+
be of type `bytes`.
|
|
2126
|
+
|
|
2127
|
+
Returns:
|
|
2128
|
+
google.cloud.spanner_admin_database_v1.types.Backup:
|
|
2129
|
+
A backup of a Cloud Spanner database.
|
|
2130
|
+
"""
|
|
2131
|
+
# Create or coerce a protobuf request object.
|
|
2132
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2133
|
+
# gotten any keyword arguments that map to the request.
|
|
2134
|
+
flattened_params = [name]
|
|
2135
|
+
has_flattened_params = (
|
|
2136
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2137
|
+
)
|
|
2138
|
+
if request is not None and has_flattened_params:
|
|
2139
|
+
raise ValueError(
|
|
2140
|
+
"If the `request` argument is set, then none of "
|
|
2141
|
+
"the individual field arguments should be set."
|
|
2142
|
+
)
|
|
2143
|
+
|
|
2144
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2145
|
+
# there are no flattened fields), or create one.
|
|
2146
|
+
if not isinstance(request, backup.GetBackupRequest):
|
|
2147
|
+
request = backup.GetBackupRequest(request)
|
|
2148
|
+
|
|
2149
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2150
|
+
# request, apply these.
|
|
2151
|
+
if name is not None:
|
|
2152
|
+
request.name = name
|
|
2153
|
+
|
|
2154
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2155
|
+
# and friendly error handling.
|
|
2156
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2157
|
+
self._client._transport.get_backup
|
|
2158
|
+
]
|
|
2159
|
+
|
|
2160
|
+
# Certain fields should be provided within the metadata header;
|
|
2161
|
+
# add these here.
|
|
2162
|
+
metadata = tuple(metadata) + (
|
|
2163
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2164
|
+
)
|
|
2165
|
+
|
|
2166
|
+
# Validate the universe domain.
|
|
2167
|
+
self._client._validate_universe_domain()
|
|
2168
|
+
|
|
2169
|
+
# Send the request.
|
|
2170
|
+
response = await rpc(
|
|
2171
|
+
request,
|
|
2172
|
+
retry=retry,
|
|
2173
|
+
timeout=timeout,
|
|
2174
|
+
metadata=metadata,
|
|
2175
|
+
)
|
|
2176
|
+
|
|
2177
|
+
# Done; return the response.
|
|
2178
|
+
return response
|
|
2179
|
+
|
|
2180
|
+
async def update_backup(
|
|
2181
|
+
self,
|
|
2182
|
+
request: Optional[Union[gsad_backup.UpdateBackupRequest, dict]] = None,
|
|
2183
|
+
*,
|
|
2184
|
+
backup: Optional[gsad_backup.Backup] = None,
|
|
2185
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
2186
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2187
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2188
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2189
|
+
) -> gsad_backup.Backup:
|
|
2190
|
+
r"""Updates a pending or completed
|
|
2191
|
+
[Backup][google.spanner.admin.database.v1.Backup].
|
|
2192
|
+
|
|
2193
|
+
.. code-block:: python
|
|
2194
|
+
|
|
2195
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2196
|
+
# code template only.
|
|
2197
|
+
# It will require modifications to work:
|
|
2198
|
+
# - It may require correct/in-range values for request initialization.
|
|
2199
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2200
|
+
# client as shown in:
|
|
2201
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2202
|
+
from google.cloud import spanner_admin_database_v1
|
|
2203
|
+
|
|
2204
|
+
async def sample_update_backup():
|
|
2205
|
+
# Create a client
|
|
2206
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2207
|
+
|
|
2208
|
+
# Initialize request argument(s)
|
|
2209
|
+
request = spanner_admin_database_v1.UpdateBackupRequest(
|
|
2210
|
+
)
|
|
2211
|
+
|
|
2212
|
+
# Make the request
|
|
2213
|
+
response = await client.update_backup(request=request)
|
|
2214
|
+
|
|
2215
|
+
# Handle the response
|
|
2216
|
+
print(response)
|
|
2217
|
+
|
|
2218
|
+
Args:
|
|
2219
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest, dict]]):
|
|
2220
|
+
The request object. The request for
|
|
2221
|
+
[UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
|
|
2222
|
+
backup (:class:`google.cloud.spanner_admin_database_v1.types.Backup`):
|
|
2223
|
+
Required. The backup to update. ``backup.name``, and the
|
|
2224
|
+
fields to be updated as specified by ``update_mask`` are
|
|
2225
|
+
required. Other fields are ignored. Update is only
|
|
2226
|
+
supported for the following fields:
|
|
2227
|
+
|
|
2228
|
+
- ``backup.expire_time``.
|
|
2229
|
+
|
|
2230
|
+
This corresponds to the ``backup`` field
|
|
2231
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2232
|
+
should not be set.
|
|
2233
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
2234
|
+
Required. A mask specifying which fields (e.g.
|
|
2235
|
+
``expire_time``) in the Backup resource should be
|
|
2236
|
+
updated. This mask is relative to the Backup resource,
|
|
2237
|
+
not to the request message. The field mask must always
|
|
2238
|
+
be specified; this prevents any future fields from being
|
|
2239
|
+
erased accidentally by clients that do not know about
|
|
2240
|
+
them.
|
|
2241
|
+
|
|
2242
|
+
This corresponds to the ``update_mask`` field
|
|
2243
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2244
|
+
should not be set.
|
|
2245
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2246
|
+
should be retried.
|
|
2247
|
+
timeout (float): The timeout for this request.
|
|
2248
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2249
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2250
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2251
|
+
be of type `bytes`.
|
|
2252
|
+
|
|
2253
|
+
Returns:
|
|
2254
|
+
google.cloud.spanner_admin_database_v1.types.Backup:
|
|
2255
|
+
A backup of a Cloud Spanner database.
|
|
2256
|
+
"""
|
|
2257
|
+
# Create or coerce a protobuf request object.
|
|
2258
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2259
|
+
# gotten any keyword arguments that map to the request.
|
|
2260
|
+
flattened_params = [backup, update_mask]
|
|
2261
|
+
has_flattened_params = (
|
|
2262
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2263
|
+
)
|
|
2264
|
+
if request is not None and has_flattened_params:
|
|
2265
|
+
raise ValueError(
|
|
2266
|
+
"If the `request` argument is set, then none of "
|
|
2267
|
+
"the individual field arguments should be set."
|
|
2268
|
+
)
|
|
2269
|
+
|
|
2270
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2271
|
+
# there are no flattened fields), or create one.
|
|
2272
|
+
if not isinstance(request, gsad_backup.UpdateBackupRequest):
|
|
2273
|
+
request = gsad_backup.UpdateBackupRequest(request)
|
|
2274
|
+
|
|
2275
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2276
|
+
# request, apply these.
|
|
2277
|
+
if backup is not None:
|
|
2278
|
+
request.backup = backup
|
|
2279
|
+
if update_mask is not None:
|
|
2280
|
+
request.update_mask = update_mask
|
|
2281
|
+
|
|
2282
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2283
|
+
# and friendly error handling.
|
|
2284
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2285
|
+
self._client._transport.update_backup
|
|
2286
|
+
]
|
|
2287
|
+
|
|
2288
|
+
# Certain fields should be provided within the metadata header;
|
|
2289
|
+
# add these here.
|
|
2290
|
+
metadata = tuple(metadata) + (
|
|
2291
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
2292
|
+
(("backup.name", request.backup.name),)
|
|
2293
|
+
),
|
|
2294
|
+
)
|
|
2295
|
+
|
|
2296
|
+
# Validate the universe domain.
|
|
2297
|
+
self._client._validate_universe_domain()
|
|
2298
|
+
|
|
2299
|
+
# Send the request.
|
|
2300
|
+
response = await rpc(
|
|
2301
|
+
request,
|
|
2302
|
+
retry=retry,
|
|
2303
|
+
timeout=timeout,
|
|
2304
|
+
metadata=metadata,
|
|
2305
|
+
)
|
|
2306
|
+
|
|
2307
|
+
# Done; return the response.
|
|
2308
|
+
return response
|
|
2309
|
+
|
|
2310
|
+
async def delete_backup(
|
|
2311
|
+
self,
|
|
2312
|
+
request: Optional[Union[backup.DeleteBackupRequest, dict]] = None,
|
|
2313
|
+
*,
|
|
2314
|
+
name: Optional[str] = None,
|
|
2315
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2316
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2317
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2318
|
+
) -> None:
|
|
2319
|
+
r"""Deletes a pending or completed
|
|
2320
|
+
[Backup][google.spanner.admin.database.v1.Backup].
|
|
2321
|
+
|
|
2322
|
+
.. code-block:: python
|
|
2323
|
+
|
|
2324
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2325
|
+
# code template only.
|
|
2326
|
+
# It will require modifications to work:
|
|
2327
|
+
# - It may require correct/in-range values for request initialization.
|
|
2328
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2329
|
+
# client as shown in:
|
|
2330
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2331
|
+
from google.cloud import spanner_admin_database_v1
|
|
2332
|
+
|
|
2333
|
+
async def sample_delete_backup():
|
|
2334
|
+
# Create a client
|
|
2335
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2336
|
+
|
|
2337
|
+
# Initialize request argument(s)
|
|
2338
|
+
request = spanner_admin_database_v1.DeleteBackupRequest(
|
|
2339
|
+
name="name_value",
|
|
2340
|
+
)
|
|
2341
|
+
|
|
2342
|
+
# Make the request
|
|
2343
|
+
await client.delete_backup(request=request)
|
|
2344
|
+
|
|
2345
|
+
Args:
|
|
2346
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupRequest, dict]]):
|
|
2347
|
+
The request object. The request for
|
|
2348
|
+
[DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
|
|
2349
|
+
name (:class:`str`):
|
|
2350
|
+
Required. Name of the backup to delete. Values are of
|
|
2351
|
+
the form
|
|
2352
|
+
``projects/<project>/instances/<instance>/backups/<backup>``.
|
|
2353
|
+
|
|
2354
|
+
This corresponds to the ``name`` field
|
|
2355
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2356
|
+
should not be set.
|
|
2357
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2358
|
+
should be retried.
|
|
2359
|
+
timeout (float): The timeout for this request.
|
|
2360
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2361
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2362
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2363
|
+
be of type `bytes`.
|
|
2364
|
+
"""
|
|
2365
|
+
# Create or coerce a protobuf request object.
|
|
2366
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2367
|
+
# gotten any keyword arguments that map to the request.
|
|
2368
|
+
flattened_params = [name]
|
|
2369
|
+
has_flattened_params = (
|
|
2370
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2371
|
+
)
|
|
2372
|
+
if request is not None and has_flattened_params:
|
|
2373
|
+
raise ValueError(
|
|
2374
|
+
"If the `request` argument is set, then none of "
|
|
2375
|
+
"the individual field arguments should be set."
|
|
2376
|
+
)
|
|
2377
|
+
|
|
2378
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2379
|
+
# there are no flattened fields), or create one.
|
|
2380
|
+
if not isinstance(request, backup.DeleteBackupRequest):
|
|
2381
|
+
request = backup.DeleteBackupRequest(request)
|
|
2382
|
+
|
|
2383
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2384
|
+
# request, apply these.
|
|
2385
|
+
if name is not None:
|
|
2386
|
+
request.name = name
|
|
2387
|
+
|
|
2388
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2389
|
+
# and friendly error handling.
|
|
2390
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2391
|
+
self._client._transport.delete_backup
|
|
2392
|
+
]
|
|
2393
|
+
|
|
2394
|
+
# Certain fields should be provided within the metadata header;
|
|
2395
|
+
# add these here.
|
|
2396
|
+
metadata = tuple(metadata) + (
|
|
2397
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2398
|
+
)
|
|
2399
|
+
|
|
2400
|
+
# Validate the universe domain.
|
|
2401
|
+
self._client._validate_universe_domain()
|
|
2402
|
+
|
|
2403
|
+
# Send the request.
|
|
2404
|
+
await rpc(
|
|
2405
|
+
request,
|
|
2406
|
+
retry=retry,
|
|
2407
|
+
timeout=timeout,
|
|
2408
|
+
metadata=metadata,
|
|
2409
|
+
)
|
|
2410
|
+
|
|
2411
|
+
async def list_backups(
|
|
2412
|
+
self,
|
|
2413
|
+
request: Optional[Union[backup.ListBackupsRequest, dict]] = None,
|
|
2414
|
+
*,
|
|
2415
|
+
parent: Optional[str] = None,
|
|
2416
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2417
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2418
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2419
|
+
) -> pagers.ListBackupsAsyncPager:
|
|
2420
|
+
r"""Lists completed and pending backups. Backups returned are
|
|
2421
|
+
ordered by ``create_time`` in descending order, starting from
|
|
2422
|
+
the most recent ``create_time``.
|
|
2423
|
+
|
|
2424
|
+
.. code-block:: python
|
|
2425
|
+
|
|
2426
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2427
|
+
# code template only.
|
|
2428
|
+
# It will require modifications to work:
|
|
2429
|
+
# - It may require correct/in-range values for request initialization.
|
|
2430
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2431
|
+
# client as shown in:
|
|
2432
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2433
|
+
from google.cloud import spanner_admin_database_v1
|
|
2434
|
+
|
|
2435
|
+
async def sample_list_backups():
|
|
2436
|
+
# Create a client
|
|
2437
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2438
|
+
|
|
2439
|
+
# Initialize request argument(s)
|
|
2440
|
+
request = spanner_admin_database_v1.ListBackupsRequest(
|
|
2441
|
+
parent="parent_value",
|
|
2442
|
+
)
|
|
2443
|
+
|
|
2444
|
+
# Make the request
|
|
2445
|
+
page_result = client.list_backups(request=request)
|
|
2446
|
+
|
|
2447
|
+
# Handle the response
|
|
2448
|
+
async for response in page_result:
|
|
2449
|
+
print(response)
|
|
2450
|
+
|
|
2451
|
+
Args:
|
|
2452
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListBackupsRequest, dict]]):
|
|
2453
|
+
The request object. The request for
|
|
2454
|
+
[ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
|
|
2455
|
+
parent (:class:`str`):
|
|
2456
|
+
Required. The instance to list backups from. Values are
|
|
2457
|
+
of the form ``projects/<project>/instances/<instance>``.
|
|
2458
|
+
|
|
2459
|
+
This corresponds to the ``parent`` field
|
|
2460
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2461
|
+
should not be set.
|
|
2462
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2463
|
+
should be retried.
|
|
2464
|
+
timeout (float): The timeout for this request.
|
|
2465
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2466
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2467
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2468
|
+
be of type `bytes`.
|
|
2469
|
+
|
|
2470
|
+
Returns:
|
|
2471
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupsAsyncPager:
|
|
2472
|
+
The response for
|
|
2473
|
+
[ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
|
|
2474
|
+
|
|
2475
|
+
Iterating over this object will yield results and
|
|
2476
|
+
resolve additional pages automatically.
|
|
2477
|
+
|
|
2478
|
+
"""
|
|
2479
|
+
# Create or coerce a protobuf request object.
|
|
2480
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2481
|
+
# gotten any keyword arguments that map to the request.
|
|
2482
|
+
flattened_params = [parent]
|
|
2483
|
+
has_flattened_params = (
|
|
2484
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2485
|
+
)
|
|
2486
|
+
if request is not None and has_flattened_params:
|
|
2487
|
+
raise ValueError(
|
|
2488
|
+
"If the `request` argument is set, then none of "
|
|
2489
|
+
"the individual field arguments should be set."
|
|
2490
|
+
)
|
|
2491
|
+
|
|
2492
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2493
|
+
# there are no flattened fields), or create one.
|
|
2494
|
+
if not isinstance(request, backup.ListBackupsRequest):
|
|
2495
|
+
request = backup.ListBackupsRequest(request)
|
|
2496
|
+
|
|
2497
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2498
|
+
# request, apply these.
|
|
2499
|
+
if parent is not None:
|
|
2500
|
+
request.parent = parent
|
|
2501
|
+
|
|
2502
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2503
|
+
# and friendly error handling.
|
|
2504
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2505
|
+
self._client._transport.list_backups
|
|
2506
|
+
]
|
|
2507
|
+
|
|
2508
|
+
# Certain fields should be provided within the metadata header;
|
|
2509
|
+
# add these here.
|
|
2510
|
+
metadata = tuple(metadata) + (
|
|
2511
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2512
|
+
)
|
|
2513
|
+
|
|
2514
|
+
# Validate the universe domain.
|
|
2515
|
+
self._client._validate_universe_domain()
|
|
2516
|
+
|
|
2517
|
+
# Send the request.
|
|
2518
|
+
response = await rpc(
|
|
2519
|
+
request,
|
|
2520
|
+
retry=retry,
|
|
2521
|
+
timeout=timeout,
|
|
2522
|
+
metadata=metadata,
|
|
2523
|
+
)
|
|
2524
|
+
|
|
2525
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
2526
|
+
# an `__aiter__` convenience method.
|
|
2527
|
+
response = pagers.ListBackupsAsyncPager(
|
|
2528
|
+
method=rpc,
|
|
2529
|
+
request=request,
|
|
2530
|
+
response=response,
|
|
2531
|
+
retry=retry,
|
|
2532
|
+
timeout=timeout,
|
|
2533
|
+
metadata=metadata,
|
|
2534
|
+
)
|
|
2535
|
+
|
|
2536
|
+
# Done; return the response.
|
|
2537
|
+
return response
|
|
2538
|
+
|
|
2539
|
+
async def restore_database(
|
|
2540
|
+
self,
|
|
2541
|
+
request: Optional[
|
|
2542
|
+
Union[spanner_database_admin.RestoreDatabaseRequest, dict]
|
|
2543
|
+
] = None,
|
|
2544
|
+
*,
|
|
2545
|
+
parent: Optional[str] = None,
|
|
2546
|
+
database_id: Optional[str] = None,
|
|
2547
|
+
backup: Optional[str] = None,
|
|
2548
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2549
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2550
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2551
|
+
) -> operation_async.AsyncOperation:
|
|
2552
|
+
r"""Create a new database by restoring from a completed backup. The
|
|
2553
|
+
new database must be in the same project and in an instance with
|
|
2554
|
+
the same instance configuration as the instance containing the
|
|
2555
|
+
backup. The returned database [long-running
|
|
2556
|
+
operation][google.longrunning.Operation] has a name of the
|
|
2557
|
+
format
|
|
2558
|
+
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``,
|
|
2559
|
+
and can be used to track the progress of the operation, and to
|
|
2560
|
+
cancel it. The [metadata][google.longrunning.Operation.metadata]
|
|
2561
|
+
field type is
|
|
2562
|
+
[RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
|
|
2563
|
+
The [response][google.longrunning.Operation.response] type is
|
|
2564
|
+
[Database][google.spanner.admin.database.v1.Database], if
|
|
2565
|
+
successful. Cancelling the returned operation will stop the
|
|
2566
|
+
restore and delete the database. There can be only one database
|
|
2567
|
+
being restored into an instance at a time. Once the restore
|
|
2568
|
+
operation completes, a new restore operation can be initiated,
|
|
2569
|
+
without waiting for the optimize operation associated with the
|
|
2570
|
+
first restore to complete.
|
|
2571
|
+
|
|
2572
|
+
.. code-block:: python
|
|
2573
|
+
|
|
2574
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2575
|
+
# code template only.
|
|
2576
|
+
# It will require modifications to work:
|
|
2577
|
+
# - It may require correct/in-range values for request initialization.
|
|
2578
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2579
|
+
# client as shown in:
|
|
2580
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2581
|
+
from google.cloud import spanner_admin_database_v1
|
|
2582
|
+
|
|
2583
|
+
async def sample_restore_database():
|
|
2584
|
+
# Create a client
|
|
2585
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2586
|
+
|
|
2587
|
+
# Initialize request argument(s)
|
|
2588
|
+
request = spanner_admin_database_v1.RestoreDatabaseRequest(
|
|
2589
|
+
backup="backup_value",
|
|
2590
|
+
parent="parent_value",
|
|
2591
|
+
database_id="database_id_value",
|
|
2592
|
+
)
|
|
2593
|
+
|
|
2594
|
+
# Make the request
|
|
2595
|
+
operation = client.restore_database(request=request)
|
|
2596
|
+
|
|
2597
|
+
print("Waiting for operation to complete...")
|
|
2598
|
+
|
|
2599
|
+
response = (await operation).result()
|
|
2600
|
+
|
|
2601
|
+
# Handle the response
|
|
2602
|
+
print(response)
|
|
2603
|
+
|
|
2604
|
+
Args:
|
|
2605
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest, dict]]):
|
|
2606
|
+
The request object. The request for
|
|
2607
|
+
[RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
|
|
2608
|
+
parent (:class:`str`):
|
|
2609
|
+
Required. The name of the instance in which to create
|
|
2610
|
+
the restored database. This instance must be in the same
|
|
2611
|
+
project and have the same instance configuration as the
|
|
2612
|
+
instance containing the source backup. Values are of the
|
|
2613
|
+
form ``projects/<project>/instances/<instance>``.
|
|
2614
|
+
|
|
2615
|
+
This corresponds to the ``parent`` field
|
|
2616
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2617
|
+
should not be set.
|
|
2618
|
+
database_id (:class:`str`):
|
|
2619
|
+
Required. The id of the database to create and restore
|
|
2620
|
+
to. This database must not already exist. The
|
|
2621
|
+
``database_id`` appended to ``parent`` forms the full
|
|
2622
|
+
database name of the form
|
|
2623
|
+
``projects/<project>/instances/<instance>/databases/<database_id>``.
|
|
2624
|
+
|
|
2625
|
+
This corresponds to the ``database_id`` field
|
|
2626
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2627
|
+
should not be set.
|
|
2628
|
+
backup (:class:`str`):
|
|
2629
|
+
Name of the backup from which to restore. Values are of
|
|
2630
|
+
the form
|
|
2631
|
+
``projects/<project>/instances/<instance>/backups/<backup>``.
|
|
2632
|
+
|
|
2633
|
+
This corresponds to the ``backup`` field
|
|
2634
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2635
|
+
should not be set.
|
|
2636
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2637
|
+
should be retried.
|
|
2638
|
+
timeout (float): The timeout for this request.
|
|
2639
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2640
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2641
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2642
|
+
be of type `bytes`.
|
|
2643
|
+
|
|
2644
|
+
Returns:
|
|
2645
|
+
google.api_core.operation_async.AsyncOperation:
|
|
2646
|
+
An object representing a long-running operation.
|
|
2647
|
+
|
|
2648
|
+
The result type for the operation will be
|
|
2649
|
+
:class:`google.cloud.spanner_admin_database_v1.types.Database`
|
|
2650
|
+
A Cloud Spanner database.
|
|
2651
|
+
|
|
2652
|
+
"""
|
|
2653
|
+
# Create or coerce a protobuf request object.
|
|
2654
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2655
|
+
# gotten any keyword arguments that map to the request.
|
|
2656
|
+
flattened_params = [parent, database_id, backup]
|
|
2657
|
+
has_flattened_params = (
|
|
2658
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2659
|
+
)
|
|
2660
|
+
if request is not None and has_flattened_params:
|
|
2661
|
+
raise ValueError(
|
|
2662
|
+
"If the `request` argument is set, then none of "
|
|
2663
|
+
"the individual field arguments should be set."
|
|
2664
|
+
)
|
|
2665
|
+
|
|
2666
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2667
|
+
# there are no flattened fields), or create one.
|
|
2668
|
+
if not isinstance(request, spanner_database_admin.RestoreDatabaseRequest):
|
|
2669
|
+
request = spanner_database_admin.RestoreDatabaseRequest(request)
|
|
2670
|
+
|
|
2671
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2672
|
+
# request, apply these.
|
|
2673
|
+
if parent is not None:
|
|
2674
|
+
request.parent = parent
|
|
2675
|
+
if database_id is not None:
|
|
2676
|
+
request.database_id = database_id
|
|
2677
|
+
if backup is not None:
|
|
2678
|
+
request.backup = backup
|
|
2679
|
+
|
|
2680
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2681
|
+
# and friendly error handling.
|
|
2682
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2683
|
+
self._client._transport.restore_database
|
|
2684
|
+
]
|
|
2685
|
+
|
|
2686
|
+
# Certain fields should be provided within the metadata header;
|
|
2687
|
+
# add these here.
|
|
2688
|
+
metadata = tuple(metadata) + (
|
|
2689
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2690
|
+
)
|
|
2691
|
+
|
|
2692
|
+
# Validate the universe domain.
|
|
2693
|
+
self._client._validate_universe_domain()
|
|
2694
|
+
|
|
2695
|
+
# Send the request.
|
|
2696
|
+
response = await rpc(
|
|
2697
|
+
request,
|
|
2698
|
+
retry=retry,
|
|
2699
|
+
timeout=timeout,
|
|
2700
|
+
metadata=metadata,
|
|
2701
|
+
)
|
|
2702
|
+
|
|
2703
|
+
# Wrap the response in an operation future.
|
|
2704
|
+
response = operation_async.from_gapic(
|
|
2705
|
+
response,
|
|
2706
|
+
self._client._transport.operations_client,
|
|
2707
|
+
spanner_database_admin.Database,
|
|
2708
|
+
metadata_type=spanner_database_admin.RestoreDatabaseMetadata,
|
|
2709
|
+
)
|
|
2710
|
+
|
|
2711
|
+
# Done; return the response.
|
|
2712
|
+
return response
|
|
2713
|
+
|
|
2714
|
+
async def list_database_operations(
|
|
2715
|
+
self,
|
|
2716
|
+
request: Optional[
|
|
2717
|
+
Union[spanner_database_admin.ListDatabaseOperationsRequest, dict]
|
|
2718
|
+
] = None,
|
|
2719
|
+
*,
|
|
2720
|
+
parent: Optional[str] = None,
|
|
2721
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2722
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2723
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2724
|
+
) -> pagers.ListDatabaseOperationsAsyncPager:
|
|
2725
|
+
r"""Lists database
|
|
2726
|
+
[longrunning-operations][google.longrunning.Operation]. A
|
|
2727
|
+
database operation has a name of the form
|
|
2728
|
+
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation>``.
|
|
2729
|
+
The long-running operation
|
|
2730
|
+
[metadata][google.longrunning.Operation.metadata] field type
|
|
2731
|
+
``metadata.type_url`` describes the type of the metadata.
|
|
2732
|
+
Operations returned include those that have
|
|
2733
|
+
completed/failed/canceled within the last 7 days, and pending
|
|
2734
|
+
operations.
|
|
2735
|
+
|
|
2736
|
+
.. code-block:: python
|
|
2737
|
+
|
|
2738
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2739
|
+
# code template only.
|
|
2740
|
+
# It will require modifications to work:
|
|
2741
|
+
# - It may require correct/in-range values for request initialization.
|
|
2742
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2743
|
+
# client as shown in:
|
|
2744
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2745
|
+
from google.cloud import spanner_admin_database_v1
|
|
2746
|
+
|
|
2747
|
+
async def sample_list_database_operations():
|
|
2748
|
+
# Create a client
|
|
2749
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2750
|
+
|
|
2751
|
+
# Initialize request argument(s)
|
|
2752
|
+
request = spanner_admin_database_v1.ListDatabaseOperationsRequest(
|
|
2753
|
+
parent="parent_value",
|
|
2754
|
+
)
|
|
2755
|
+
|
|
2756
|
+
# Make the request
|
|
2757
|
+
page_result = client.list_database_operations(request=request)
|
|
2758
|
+
|
|
2759
|
+
# Handle the response
|
|
2760
|
+
async for response in page_result:
|
|
2761
|
+
print(response)
|
|
2762
|
+
|
|
2763
|
+
Args:
|
|
2764
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest, dict]]):
|
|
2765
|
+
The request object. The request for
|
|
2766
|
+
[ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
|
|
2767
|
+
parent (:class:`str`):
|
|
2768
|
+
Required. The instance of the database operations.
|
|
2769
|
+
Values are of the form
|
|
2770
|
+
``projects/<project>/instances/<instance>``.
|
|
2771
|
+
|
|
2772
|
+
This corresponds to the ``parent`` field
|
|
2773
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2774
|
+
should not be set.
|
|
2775
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2776
|
+
should be retried.
|
|
2777
|
+
timeout (float): The timeout for this request.
|
|
2778
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2779
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2780
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2781
|
+
be of type `bytes`.
|
|
2782
|
+
|
|
2783
|
+
Returns:
|
|
2784
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabaseOperationsAsyncPager:
|
|
2785
|
+
The response for
|
|
2786
|
+
[ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
|
|
2787
|
+
|
|
2788
|
+
Iterating over this object will yield results and
|
|
2789
|
+
resolve additional pages automatically.
|
|
2790
|
+
|
|
2791
|
+
"""
|
|
2792
|
+
# Create or coerce a protobuf request object.
|
|
2793
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2794
|
+
# gotten any keyword arguments that map to the request.
|
|
2795
|
+
flattened_params = [parent]
|
|
2796
|
+
has_flattened_params = (
|
|
2797
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2798
|
+
)
|
|
2799
|
+
if request is not None and has_flattened_params:
|
|
2800
|
+
raise ValueError(
|
|
2801
|
+
"If the `request` argument is set, then none of "
|
|
2802
|
+
"the individual field arguments should be set."
|
|
2803
|
+
)
|
|
2804
|
+
|
|
2805
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2806
|
+
# there are no flattened fields), or create one.
|
|
2807
|
+
if not isinstance(
|
|
2808
|
+
request, spanner_database_admin.ListDatabaseOperationsRequest
|
|
2809
|
+
):
|
|
2810
|
+
request = spanner_database_admin.ListDatabaseOperationsRequest(request)
|
|
2811
|
+
|
|
2812
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2813
|
+
# request, apply these.
|
|
2814
|
+
if parent is not None:
|
|
2815
|
+
request.parent = parent
|
|
2816
|
+
|
|
2817
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2818
|
+
# and friendly error handling.
|
|
2819
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2820
|
+
self._client._transport.list_database_operations
|
|
2821
|
+
]
|
|
2822
|
+
|
|
2823
|
+
# Certain fields should be provided within the metadata header;
|
|
2824
|
+
# add these here.
|
|
2825
|
+
metadata = tuple(metadata) + (
|
|
2826
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2827
|
+
)
|
|
2828
|
+
|
|
2829
|
+
# Validate the universe domain.
|
|
2830
|
+
self._client._validate_universe_domain()
|
|
2831
|
+
|
|
2832
|
+
# Send the request.
|
|
2833
|
+
response = await rpc(
|
|
2834
|
+
request,
|
|
2835
|
+
retry=retry,
|
|
2836
|
+
timeout=timeout,
|
|
2837
|
+
metadata=metadata,
|
|
2838
|
+
)
|
|
2839
|
+
|
|
2840
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
2841
|
+
# an `__aiter__` convenience method.
|
|
2842
|
+
response = pagers.ListDatabaseOperationsAsyncPager(
|
|
2843
|
+
method=rpc,
|
|
2844
|
+
request=request,
|
|
2845
|
+
response=response,
|
|
2846
|
+
retry=retry,
|
|
2847
|
+
timeout=timeout,
|
|
2848
|
+
metadata=metadata,
|
|
2849
|
+
)
|
|
2850
|
+
|
|
2851
|
+
# Done; return the response.
|
|
2852
|
+
return response
|
|
2853
|
+
|
|
2854
|
+
async def list_backup_operations(
|
|
2855
|
+
self,
|
|
2856
|
+
request: Optional[Union[backup.ListBackupOperationsRequest, dict]] = None,
|
|
2857
|
+
*,
|
|
2858
|
+
parent: Optional[str] = None,
|
|
2859
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2860
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2861
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2862
|
+
) -> pagers.ListBackupOperationsAsyncPager:
|
|
2863
|
+
r"""Lists the backup [long-running
|
|
2864
|
+
operations][google.longrunning.Operation] in the given instance.
|
|
2865
|
+
A backup operation has a name of the form
|
|
2866
|
+
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>``.
|
|
2867
|
+
The long-running operation
|
|
2868
|
+
[metadata][google.longrunning.Operation.metadata] field type
|
|
2869
|
+
``metadata.type_url`` describes the type of the metadata.
|
|
2870
|
+
Operations returned include those that have
|
|
2871
|
+
completed/failed/canceled within the last 7 days, and pending
|
|
2872
|
+
operations. Operations returned are ordered by
|
|
2873
|
+
``operation.metadata.value.progress.start_time`` in descending
|
|
2874
|
+
order starting from the most recently started operation.
|
|
2875
|
+
|
|
2876
|
+
.. code-block:: python
|
|
2877
|
+
|
|
2878
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2879
|
+
# code template only.
|
|
2880
|
+
# It will require modifications to work:
|
|
2881
|
+
# - It may require correct/in-range values for request initialization.
|
|
2882
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2883
|
+
# client as shown in:
|
|
2884
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2885
|
+
from google.cloud import spanner_admin_database_v1
|
|
2886
|
+
|
|
2887
|
+
async def sample_list_backup_operations():
|
|
2888
|
+
# Create a client
|
|
2889
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
2890
|
+
|
|
2891
|
+
# Initialize request argument(s)
|
|
2892
|
+
request = spanner_admin_database_v1.ListBackupOperationsRequest(
|
|
2893
|
+
parent="parent_value",
|
|
2894
|
+
)
|
|
2895
|
+
|
|
2896
|
+
# Make the request
|
|
2897
|
+
page_result = client.list_backup_operations(request=request)
|
|
2898
|
+
|
|
2899
|
+
# Handle the response
|
|
2900
|
+
async for response in page_result:
|
|
2901
|
+
print(response)
|
|
2902
|
+
|
|
2903
|
+
Args:
|
|
2904
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest, dict]]):
|
|
2905
|
+
The request object. The request for
|
|
2906
|
+
[ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
|
|
2907
|
+
parent (:class:`str`):
|
|
2908
|
+
Required. The instance of the backup operations. Values
|
|
2909
|
+
are of the form
|
|
2910
|
+
``projects/<project>/instances/<instance>``.
|
|
2911
|
+
|
|
2912
|
+
This corresponds to the ``parent`` field
|
|
2913
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2914
|
+
should not be set.
|
|
2915
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
2916
|
+
should be retried.
|
|
2917
|
+
timeout (float): The timeout for this request.
|
|
2918
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2919
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2920
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2921
|
+
be of type `bytes`.
|
|
2922
|
+
|
|
2923
|
+
Returns:
|
|
2924
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupOperationsAsyncPager:
|
|
2925
|
+
The response for
|
|
2926
|
+
[ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
|
|
2927
|
+
|
|
2928
|
+
Iterating over this object will yield results and
|
|
2929
|
+
resolve additional pages automatically.
|
|
2930
|
+
|
|
2931
|
+
"""
|
|
2932
|
+
# Create or coerce a protobuf request object.
|
|
2933
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2934
|
+
# gotten any keyword arguments that map to the request.
|
|
2935
|
+
flattened_params = [parent]
|
|
2936
|
+
has_flattened_params = (
|
|
2937
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2938
|
+
)
|
|
2939
|
+
if request is not None and has_flattened_params:
|
|
2940
|
+
raise ValueError(
|
|
2941
|
+
"If the `request` argument is set, then none of "
|
|
2942
|
+
"the individual field arguments should be set."
|
|
2943
|
+
)
|
|
2944
|
+
|
|
2945
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2946
|
+
# there are no flattened fields), or create one.
|
|
2947
|
+
if not isinstance(request, backup.ListBackupOperationsRequest):
|
|
2948
|
+
request = backup.ListBackupOperationsRequest(request)
|
|
2949
|
+
|
|
2950
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2951
|
+
# request, apply these.
|
|
2952
|
+
if parent is not None:
|
|
2953
|
+
request.parent = parent
|
|
2954
|
+
|
|
2955
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2956
|
+
# and friendly error handling.
|
|
2957
|
+
rpc = self._client._transport._wrapped_methods[
|
|
2958
|
+
self._client._transport.list_backup_operations
|
|
2959
|
+
]
|
|
2960
|
+
|
|
2961
|
+
# Certain fields should be provided within the metadata header;
|
|
2962
|
+
# add these here.
|
|
2963
|
+
metadata = tuple(metadata) + (
|
|
2964
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2965
|
+
)
|
|
2966
|
+
|
|
2967
|
+
# Validate the universe domain.
|
|
2968
|
+
self._client._validate_universe_domain()
|
|
2969
|
+
|
|
2970
|
+
# Send the request.
|
|
2971
|
+
response = await rpc(
|
|
2972
|
+
request,
|
|
2973
|
+
retry=retry,
|
|
2974
|
+
timeout=timeout,
|
|
2975
|
+
metadata=metadata,
|
|
2976
|
+
)
|
|
2977
|
+
|
|
2978
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
2979
|
+
# an `__aiter__` convenience method.
|
|
2980
|
+
response = pagers.ListBackupOperationsAsyncPager(
|
|
2981
|
+
method=rpc,
|
|
2982
|
+
request=request,
|
|
2983
|
+
response=response,
|
|
2984
|
+
retry=retry,
|
|
2985
|
+
timeout=timeout,
|
|
2986
|
+
metadata=metadata,
|
|
2987
|
+
)
|
|
2988
|
+
|
|
2989
|
+
# Done; return the response.
|
|
2990
|
+
return response
|
|
2991
|
+
|
|
2992
|
+
async def list_database_roles(
|
|
2993
|
+
self,
|
|
2994
|
+
request: Optional[
|
|
2995
|
+
Union[spanner_database_admin.ListDatabaseRolesRequest, dict]
|
|
2996
|
+
] = None,
|
|
2997
|
+
*,
|
|
2998
|
+
parent: Optional[str] = None,
|
|
2999
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3000
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3001
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3002
|
+
) -> pagers.ListDatabaseRolesAsyncPager:
|
|
3003
|
+
r"""Lists Cloud Spanner database roles.
|
|
3004
|
+
|
|
3005
|
+
.. code-block:: python
|
|
3006
|
+
|
|
3007
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3008
|
+
# code template only.
|
|
3009
|
+
# It will require modifications to work:
|
|
3010
|
+
# - It may require correct/in-range values for request initialization.
|
|
3011
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3012
|
+
# client as shown in:
|
|
3013
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3014
|
+
from google.cloud import spanner_admin_database_v1
|
|
3015
|
+
|
|
3016
|
+
async def sample_list_database_roles():
|
|
3017
|
+
# Create a client
|
|
3018
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3019
|
+
|
|
3020
|
+
# Initialize request argument(s)
|
|
3021
|
+
request = spanner_admin_database_v1.ListDatabaseRolesRequest(
|
|
3022
|
+
parent="parent_value",
|
|
3023
|
+
)
|
|
3024
|
+
|
|
3025
|
+
# Make the request
|
|
3026
|
+
page_result = client.list_database_roles(request=request)
|
|
3027
|
+
|
|
3028
|
+
# Handle the response
|
|
3029
|
+
async for response in page_result:
|
|
3030
|
+
print(response)
|
|
3031
|
+
|
|
3032
|
+
Args:
|
|
3033
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseRolesRequest, dict]]):
|
|
3034
|
+
The request object. The request for
|
|
3035
|
+
[ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
|
|
3036
|
+
parent (:class:`str`):
|
|
3037
|
+
Required. The database whose roles should be listed.
|
|
3038
|
+
Values are of the form
|
|
3039
|
+
``projects/<project>/instances/<instance>/databases/<database>``.
|
|
3040
|
+
|
|
3041
|
+
This corresponds to the ``parent`` field
|
|
3042
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3043
|
+
should not be set.
|
|
3044
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3045
|
+
should be retried.
|
|
3046
|
+
timeout (float): The timeout for this request.
|
|
3047
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3048
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3049
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3050
|
+
be of type `bytes`.
|
|
3051
|
+
|
|
3052
|
+
Returns:
|
|
3053
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabaseRolesAsyncPager:
|
|
3054
|
+
The response for
|
|
3055
|
+
[ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
|
|
3056
|
+
|
|
3057
|
+
Iterating over this object will yield results and
|
|
3058
|
+
resolve additional pages automatically.
|
|
3059
|
+
|
|
3060
|
+
"""
|
|
3061
|
+
# Create or coerce a protobuf request object.
|
|
3062
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3063
|
+
# gotten any keyword arguments that map to the request.
|
|
3064
|
+
flattened_params = [parent]
|
|
3065
|
+
has_flattened_params = (
|
|
3066
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3067
|
+
)
|
|
3068
|
+
if request is not None and has_flattened_params:
|
|
3069
|
+
raise ValueError(
|
|
3070
|
+
"If the `request` argument is set, then none of "
|
|
3071
|
+
"the individual field arguments should be set."
|
|
3072
|
+
)
|
|
3073
|
+
|
|
3074
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3075
|
+
# there are no flattened fields), or create one.
|
|
3076
|
+
if not isinstance(request, spanner_database_admin.ListDatabaseRolesRequest):
|
|
3077
|
+
request = spanner_database_admin.ListDatabaseRolesRequest(request)
|
|
3078
|
+
|
|
3079
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3080
|
+
# request, apply these.
|
|
3081
|
+
if parent is not None:
|
|
3082
|
+
request.parent = parent
|
|
3083
|
+
|
|
3084
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3085
|
+
# and friendly error handling.
|
|
3086
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3087
|
+
self._client._transport.list_database_roles
|
|
3088
|
+
]
|
|
3089
|
+
|
|
3090
|
+
# Certain fields should be provided within the metadata header;
|
|
3091
|
+
# add these here.
|
|
3092
|
+
metadata = tuple(metadata) + (
|
|
3093
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
3094
|
+
)
|
|
3095
|
+
|
|
3096
|
+
# Validate the universe domain.
|
|
3097
|
+
self._client._validate_universe_domain()
|
|
3098
|
+
|
|
3099
|
+
# Send the request.
|
|
3100
|
+
response = await rpc(
|
|
3101
|
+
request,
|
|
3102
|
+
retry=retry,
|
|
3103
|
+
timeout=timeout,
|
|
3104
|
+
metadata=metadata,
|
|
3105
|
+
)
|
|
3106
|
+
|
|
3107
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
3108
|
+
# an `__aiter__` convenience method.
|
|
3109
|
+
response = pagers.ListDatabaseRolesAsyncPager(
|
|
3110
|
+
method=rpc,
|
|
3111
|
+
request=request,
|
|
3112
|
+
response=response,
|
|
3113
|
+
retry=retry,
|
|
3114
|
+
timeout=timeout,
|
|
3115
|
+
metadata=metadata,
|
|
3116
|
+
)
|
|
3117
|
+
|
|
3118
|
+
# Done; return the response.
|
|
3119
|
+
return response
|
|
3120
|
+
|
|
3121
|
+
async def add_split_points(
|
|
3122
|
+
self,
|
|
3123
|
+
request: Optional[
|
|
3124
|
+
Union[spanner_database_admin.AddSplitPointsRequest, dict]
|
|
3125
|
+
] = None,
|
|
3126
|
+
*,
|
|
3127
|
+
database: Optional[str] = None,
|
|
3128
|
+
split_points: Optional[
|
|
3129
|
+
MutableSequence[spanner_database_admin.SplitPoints]
|
|
3130
|
+
] = None,
|
|
3131
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3132
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3133
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3134
|
+
) -> spanner_database_admin.AddSplitPointsResponse:
|
|
3135
|
+
r"""Adds split points to specified tables, indexes of a
|
|
3136
|
+
database.
|
|
3137
|
+
|
|
3138
|
+
.. code-block:: python
|
|
3139
|
+
|
|
3140
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3141
|
+
# code template only.
|
|
3142
|
+
# It will require modifications to work:
|
|
3143
|
+
# - It may require correct/in-range values for request initialization.
|
|
3144
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3145
|
+
# client as shown in:
|
|
3146
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3147
|
+
from google.cloud import spanner_admin_database_v1
|
|
3148
|
+
|
|
3149
|
+
async def sample_add_split_points():
|
|
3150
|
+
# Create a client
|
|
3151
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3152
|
+
|
|
3153
|
+
# Initialize request argument(s)
|
|
3154
|
+
request = spanner_admin_database_v1.AddSplitPointsRequest(
|
|
3155
|
+
database="database_value",
|
|
3156
|
+
)
|
|
3157
|
+
|
|
3158
|
+
# Make the request
|
|
3159
|
+
response = await client.add_split_points(request=request)
|
|
3160
|
+
|
|
3161
|
+
# Handle the response
|
|
3162
|
+
print(response)
|
|
3163
|
+
|
|
3164
|
+
Args:
|
|
3165
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.AddSplitPointsRequest, dict]]):
|
|
3166
|
+
The request object. The request for
|
|
3167
|
+
[AddSplitPoints][google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints].
|
|
3168
|
+
database (:class:`str`):
|
|
3169
|
+
Required. The database on whose tables/indexes split
|
|
3170
|
+
points are to be added. Values are of the form
|
|
3171
|
+
``projects/<project>/instances/<instance>/databases/<database>``.
|
|
3172
|
+
|
|
3173
|
+
This corresponds to the ``database`` field
|
|
3174
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3175
|
+
should not be set.
|
|
3176
|
+
split_points (:class:`MutableSequence[google.cloud.spanner_admin_database_v1.types.SplitPoints]`):
|
|
3177
|
+
Required. The split points to add.
|
|
3178
|
+
This corresponds to the ``split_points`` field
|
|
3179
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3180
|
+
should not be set.
|
|
3181
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3182
|
+
should be retried.
|
|
3183
|
+
timeout (float): The timeout for this request.
|
|
3184
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3185
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3186
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3187
|
+
be of type `bytes`.
|
|
3188
|
+
|
|
3189
|
+
Returns:
|
|
3190
|
+
google.cloud.spanner_admin_database_v1.types.AddSplitPointsResponse:
|
|
3191
|
+
The response for
|
|
3192
|
+
[AddSplitPoints][google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints].
|
|
3193
|
+
|
|
3194
|
+
"""
|
|
3195
|
+
# Create or coerce a protobuf request object.
|
|
3196
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3197
|
+
# gotten any keyword arguments that map to the request.
|
|
3198
|
+
flattened_params = [database, split_points]
|
|
3199
|
+
has_flattened_params = (
|
|
3200
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3201
|
+
)
|
|
3202
|
+
if request is not None and has_flattened_params:
|
|
3203
|
+
raise ValueError(
|
|
3204
|
+
"If the `request` argument is set, then none of "
|
|
3205
|
+
"the individual field arguments should be set."
|
|
3206
|
+
)
|
|
3207
|
+
|
|
3208
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3209
|
+
# there are no flattened fields), or create one.
|
|
3210
|
+
if not isinstance(request, spanner_database_admin.AddSplitPointsRequest):
|
|
3211
|
+
request = spanner_database_admin.AddSplitPointsRequest(request)
|
|
3212
|
+
|
|
3213
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3214
|
+
# request, apply these.
|
|
3215
|
+
if database is not None:
|
|
3216
|
+
request.database = database
|
|
3217
|
+
if split_points:
|
|
3218
|
+
request.split_points.extend(split_points)
|
|
3219
|
+
|
|
3220
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3221
|
+
# and friendly error handling.
|
|
3222
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3223
|
+
self._client._transport.add_split_points
|
|
3224
|
+
]
|
|
3225
|
+
|
|
3226
|
+
# Certain fields should be provided within the metadata header;
|
|
3227
|
+
# add these here.
|
|
3228
|
+
metadata = tuple(metadata) + (
|
|
3229
|
+
gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
|
|
3230
|
+
)
|
|
3231
|
+
|
|
3232
|
+
# Validate the universe domain.
|
|
3233
|
+
self._client._validate_universe_domain()
|
|
3234
|
+
|
|
3235
|
+
# Send the request.
|
|
3236
|
+
response = await rpc(
|
|
3237
|
+
request,
|
|
3238
|
+
retry=retry,
|
|
3239
|
+
timeout=timeout,
|
|
3240
|
+
metadata=metadata,
|
|
3241
|
+
)
|
|
3242
|
+
|
|
3243
|
+
# Done; return the response.
|
|
3244
|
+
return response
|
|
3245
|
+
|
|
3246
|
+
async def create_backup_schedule(
|
|
3247
|
+
self,
|
|
3248
|
+
request: Optional[
|
|
3249
|
+
Union[gsad_backup_schedule.CreateBackupScheduleRequest, dict]
|
|
3250
|
+
] = None,
|
|
3251
|
+
*,
|
|
3252
|
+
parent: Optional[str] = None,
|
|
3253
|
+
backup_schedule: Optional[gsad_backup_schedule.BackupSchedule] = None,
|
|
3254
|
+
backup_schedule_id: Optional[str] = None,
|
|
3255
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3256
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3257
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3258
|
+
) -> gsad_backup_schedule.BackupSchedule:
|
|
3259
|
+
r"""Creates a new backup schedule.
|
|
3260
|
+
|
|
3261
|
+
.. code-block:: python
|
|
3262
|
+
|
|
3263
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3264
|
+
# code template only.
|
|
3265
|
+
# It will require modifications to work:
|
|
3266
|
+
# - It may require correct/in-range values for request initialization.
|
|
3267
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3268
|
+
# client as shown in:
|
|
3269
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3270
|
+
from google.cloud import spanner_admin_database_v1
|
|
3271
|
+
|
|
3272
|
+
async def sample_create_backup_schedule():
|
|
3273
|
+
# Create a client
|
|
3274
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3275
|
+
|
|
3276
|
+
# Initialize request argument(s)
|
|
3277
|
+
request = spanner_admin_database_v1.CreateBackupScheduleRequest(
|
|
3278
|
+
parent="parent_value",
|
|
3279
|
+
backup_schedule_id="backup_schedule_id_value",
|
|
3280
|
+
)
|
|
3281
|
+
|
|
3282
|
+
# Make the request
|
|
3283
|
+
response = await client.create_backup_schedule(request=request)
|
|
3284
|
+
|
|
3285
|
+
# Handle the response
|
|
3286
|
+
print(response)
|
|
3287
|
+
|
|
3288
|
+
Args:
|
|
3289
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CreateBackupScheduleRequest, dict]]):
|
|
3290
|
+
The request object. The request for
|
|
3291
|
+
[CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule].
|
|
3292
|
+
parent (:class:`str`):
|
|
3293
|
+
Required. The name of the database
|
|
3294
|
+
that this backup schedule applies to.
|
|
3295
|
+
|
|
3296
|
+
This corresponds to the ``parent`` field
|
|
3297
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3298
|
+
should not be set.
|
|
3299
|
+
backup_schedule (:class:`google.cloud.spanner_admin_database_v1.types.BackupSchedule`):
|
|
3300
|
+
Required. The backup schedule to
|
|
3301
|
+
create.
|
|
3302
|
+
|
|
3303
|
+
This corresponds to the ``backup_schedule`` field
|
|
3304
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3305
|
+
should not be set.
|
|
3306
|
+
backup_schedule_id (:class:`str`):
|
|
3307
|
+
Required. The Id to use for the backup schedule. The
|
|
3308
|
+
``backup_schedule_id`` appended to ``parent`` forms the
|
|
3309
|
+
full backup schedule name of the form
|
|
3310
|
+
``projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>``.
|
|
3311
|
+
|
|
3312
|
+
This corresponds to the ``backup_schedule_id`` field
|
|
3313
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3314
|
+
should not be set.
|
|
3315
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3316
|
+
should be retried.
|
|
3317
|
+
timeout (float): The timeout for this request.
|
|
3318
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3319
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3320
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3321
|
+
be of type `bytes`.
|
|
3322
|
+
|
|
3323
|
+
Returns:
|
|
3324
|
+
google.cloud.spanner_admin_database_v1.types.BackupSchedule:
|
|
3325
|
+
BackupSchedule expresses the
|
|
3326
|
+
automated backup creation specification
|
|
3327
|
+
for a Spanner database. Next ID: 10
|
|
3328
|
+
|
|
3329
|
+
"""
|
|
3330
|
+
# Create or coerce a protobuf request object.
|
|
3331
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3332
|
+
# gotten any keyword arguments that map to the request.
|
|
3333
|
+
flattened_params = [parent, backup_schedule, backup_schedule_id]
|
|
3334
|
+
has_flattened_params = (
|
|
3335
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3336
|
+
)
|
|
3337
|
+
if request is not None and has_flattened_params:
|
|
3338
|
+
raise ValueError(
|
|
3339
|
+
"If the `request` argument is set, then none of "
|
|
3340
|
+
"the individual field arguments should be set."
|
|
3341
|
+
)
|
|
3342
|
+
|
|
3343
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3344
|
+
# there are no flattened fields), or create one.
|
|
3345
|
+
if not isinstance(request, gsad_backup_schedule.CreateBackupScheduleRequest):
|
|
3346
|
+
request = gsad_backup_schedule.CreateBackupScheduleRequest(request)
|
|
3347
|
+
|
|
3348
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3349
|
+
# request, apply these.
|
|
3350
|
+
if parent is not None:
|
|
3351
|
+
request.parent = parent
|
|
3352
|
+
if backup_schedule is not None:
|
|
3353
|
+
request.backup_schedule = backup_schedule
|
|
3354
|
+
if backup_schedule_id is not None:
|
|
3355
|
+
request.backup_schedule_id = backup_schedule_id
|
|
3356
|
+
|
|
3357
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3358
|
+
# and friendly error handling.
|
|
3359
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3360
|
+
self._client._transport.create_backup_schedule
|
|
3361
|
+
]
|
|
3362
|
+
|
|
3363
|
+
# Certain fields should be provided within the metadata header;
|
|
3364
|
+
# add these here.
|
|
3365
|
+
metadata = tuple(metadata) + (
|
|
3366
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
3367
|
+
)
|
|
3368
|
+
|
|
3369
|
+
# Validate the universe domain.
|
|
3370
|
+
self._client._validate_universe_domain()
|
|
3371
|
+
|
|
3372
|
+
# Send the request.
|
|
3373
|
+
response = await rpc(
|
|
3374
|
+
request,
|
|
3375
|
+
retry=retry,
|
|
3376
|
+
timeout=timeout,
|
|
3377
|
+
metadata=metadata,
|
|
3378
|
+
)
|
|
3379
|
+
|
|
3380
|
+
# Done; return the response.
|
|
3381
|
+
return response
|
|
3382
|
+
|
|
3383
|
+
async def get_backup_schedule(
|
|
3384
|
+
self,
|
|
3385
|
+
request: Optional[Union[backup_schedule.GetBackupScheduleRequest, dict]] = None,
|
|
3386
|
+
*,
|
|
3387
|
+
name: Optional[str] = None,
|
|
3388
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3389
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3390
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3391
|
+
) -> backup_schedule.BackupSchedule:
|
|
3392
|
+
r"""Gets backup schedule for the input schedule name.
|
|
3393
|
+
|
|
3394
|
+
.. code-block:: python
|
|
3395
|
+
|
|
3396
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3397
|
+
# code template only.
|
|
3398
|
+
# It will require modifications to work:
|
|
3399
|
+
# - It may require correct/in-range values for request initialization.
|
|
3400
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3401
|
+
# client as shown in:
|
|
3402
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3403
|
+
from google.cloud import spanner_admin_database_v1
|
|
3404
|
+
|
|
3405
|
+
async def sample_get_backup_schedule():
|
|
3406
|
+
# Create a client
|
|
3407
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3408
|
+
|
|
3409
|
+
# Initialize request argument(s)
|
|
3410
|
+
request = spanner_admin_database_v1.GetBackupScheduleRequest(
|
|
3411
|
+
name="name_value",
|
|
3412
|
+
)
|
|
3413
|
+
|
|
3414
|
+
# Make the request
|
|
3415
|
+
response = await client.get_backup_schedule(request=request)
|
|
3416
|
+
|
|
3417
|
+
# Handle the response
|
|
3418
|
+
print(response)
|
|
3419
|
+
|
|
3420
|
+
Args:
|
|
3421
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetBackupScheduleRequest, dict]]):
|
|
3422
|
+
The request object. The request for
|
|
3423
|
+
[GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule].
|
|
3424
|
+
name (:class:`str`):
|
|
3425
|
+
Required. The name of the schedule to retrieve. Values
|
|
3426
|
+
are of the form
|
|
3427
|
+
``projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>``.
|
|
3428
|
+
|
|
3429
|
+
This corresponds to the ``name`` field
|
|
3430
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3431
|
+
should not be set.
|
|
3432
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3433
|
+
should be retried.
|
|
3434
|
+
timeout (float): The timeout for this request.
|
|
3435
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3436
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3437
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3438
|
+
be of type `bytes`.
|
|
3439
|
+
|
|
3440
|
+
Returns:
|
|
3441
|
+
google.cloud.spanner_admin_database_v1.types.BackupSchedule:
|
|
3442
|
+
BackupSchedule expresses the
|
|
3443
|
+
automated backup creation specification
|
|
3444
|
+
for a Spanner database. Next ID: 10
|
|
3445
|
+
|
|
3446
|
+
"""
|
|
3447
|
+
# Create or coerce a protobuf request object.
|
|
3448
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3449
|
+
# gotten any keyword arguments that map to the request.
|
|
3450
|
+
flattened_params = [name]
|
|
3451
|
+
has_flattened_params = (
|
|
3452
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3453
|
+
)
|
|
3454
|
+
if request is not None and has_flattened_params:
|
|
3455
|
+
raise ValueError(
|
|
3456
|
+
"If the `request` argument is set, then none of "
|
|
3457
|
+
"the individual field arguments should be set."
|
|
3458
|
+
)
|
|
3459
|
+
|
|
3460
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3461
|
+
# there are no flattened fields), or create one.
|
|
3462
|
+
if not isinstance(request, backup_schedule.GetBackupScheduleRequest):
|
|
3463
|
+
request = backup_schedule.GetBackupScheduleRequest(request)
|
|
3464
|
+
|
|
3465
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3466
|
+
# request, apply these.
|
|
3467
|
+
if name is not None:
|
|
3468
|
+
request.name = name
|
|
3469
|
+
|
|
3470
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3471
|
+
# and friendly error handling.
|
|
3472
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3473
|
+
self._client._transport.get_backup_schedule
|
|
3474
|
+
]
|
|
3475
|
+
|
|
3476
|
+
# Certain fields should be provided within the metadata header;
|
|
3477
|
+
# add these here.
|
|
3478
|
+
metadata = tuple(metadata) + (
|
|
3479
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3480
|
+
)
|
|
3481
|
+
|
|
3482
|
+
# Validate the universe domain.
|
|
3483
|
+
self._client._validate_universe_domain()
|
|
3484
|
+
|
|
3485
|
+
# Send the request.
|
|
3486
|
+
response = await rpc(
|
|
3487
|
+
request,
|
|
3488
|
+
retry=retry,
|
|
3489
|
+
timeout=timeout,
|
|
3490
|
+
metadata=metadata,
|
|
3491
|
+
)
|
|
3492
|
+
|
|
3493
|
+
# Done; return the response.
|
|
3494
|
+
return response
|
|
3495
|
+
|
|
3496
|
+
async def update_backup_schedule(
|
|
3497
|
+
self,
|
|
3498
|
+
request: Optional[
|
|
3499
|
+
Union[gsad_backup_schedule.UpdateBackupScheduleRequest, dict]
|
|
3500
|
+
] = None,
|
|
3501
|
+
*,
|
|
3502
|
+
backup_schedule: Optional[gsad_backup_schedule.BackupSchedule] = None,
|
|
3503
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
3504
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3505
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3506
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3507
|
+
) -> gsad_backup_schedule.BackupSchedule:
|
|
3508
|
+
r"""Updates a backup schedule.
|
|
3509
|
+
|
|
3510
|
+
.. code-block:: python
|
|
3511
|
+
|
|
3512
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3513
|
+
# code template only.
|
|
3514
|
+
# It will require modifications to work:
|
|
3515
|
+
# - It may require correct/in-range values for request initialization.
|
|
3516
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3517
|
+
# client as shown in:
|
|
3518
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3519
|
+
from google.cloud import spanner_admin_database_v1
|
|
3520
|
+
|
|
3521
|
+
async def sample_update_backup_schedule():
|
|
3522
|
+
# Create a client
|
|
3523
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3524
|
+
|
|
3525
|
+
# Initialize request argument(s)
|
|
3526
|
+
request = spanner_admin_database_v1.UpdateBackupScheduleRequest(
|
|
3527
|
+
)
|
|
3528
|
+
|
|
3529
|
+
# Make the request
|
|
3530
|
+
response = await client.update_backup_schedule(request=request)
|
|
3531
|
+
|
|
3532
|
+
# Handle the response
|
|
3533
|
+
print(response)
|
|
3534
|
+
|
|
3535
|
+
Args:
|
|
3536
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupScheduleRequest, dict]]):
|
|
3537
|
+
The request object. The request for
|
|
3538
|
+
[UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule].
|
|
3539
|
+
backup_schedule (:class:`google.cloud.spanner_admin_database_v1.types.BackupSchedule`):
|
|
3540
|
+
Required. The backup schedule to update.
|
|
3541
|
+
``backup_schedule.name``, and the fields to be updated
|
|
3542
|
+
as specified by ``update_mask`` are required. Other
|
|
3543
|
+
fields are ignored.
|
|
3544
|
+
|
|
3545
|
+
This corresponds to the ``backup_schedule`` field
|
|
3546
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3547
|
+
should not be set.
|
|
3548
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
3549
|
+
Required. A mask specifying which
|
|
3550
|
+
fields in the BackupSchedule resource
|
|
3551
|
+
should be updated. This mask is relative
|
|
3552
|
+
to the BackupSchedule resource, not to
|
|
3553
|
+
the request message. The field mask must
|
|
3554
|
+
always be specified; this prevents any
|
|
3555
|
+
future fields from being erased
|
|
3556
|
+
accidentally.
|
|
3557
|
+
|
|
3558
|
+
This corresponds to the ``update_mask`` field
|
|
3559
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3560
|
+
should not be set.
|
|
3561
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3562
|
+
should be retried.
|
|
3563
|
+
timeout (float): The timeout for this request.
|
|
3564
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3565
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3566
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3567
|
+
be of type `bytes`.
|
|
3568
|
+
|
|
3569
|
+
Returns:
|
|
3570
|
+
google.cloud.spanner_admin_database_v1.types.BackupSchedule:
|
|
3571
|
+
BackupSchedule expresses the
|
|
3572
|
+
automated backup creation specification
|
|
3573
|
+
for a Spanner database. Next ID: 10
|
|
3574
|
+
|
|
3575
|
+
"""
|
|
3576
|
+
# Create or coerce a protobuf request object.
|
|
3577
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3578
|
+
# gotten any keyword arguments that map to the request.
|
|
3579
|
+
flattened_params = [backup_schedule, update_mask]
|
|
3580
|
+
has_flattened_params = (
|
|
3581
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3582
|
+
)
|
|
3583
|
+
if request is not None and has_flattened_params:
|
|
3584
|
+
raise ValueError(
|
|
3585
|
+
"If the `request` argument is set, then none of "
|
|
3586
|
+
"the individual field arguments should be set."
|
|
3587
|
+
)
|
|
3588
|
+
|
|
3589
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3590
|
+
# there are no flattened fields), or create one.
|
|
3591
|
+
if not isinstance(request, gsad_backup_schedule.UpdateBackupScheduleRequest):
|
|
3592
|
+
request = gsad_backup_schedule.UpdateBackupScheduleRequest(request)
|
|
3593
|
+
|
|
3594
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3595
|
+
# request, apply these.
|
|
3596
|
+
if backup_schedule is not None:
|
|
3597
|
+
request.backup_schedule = backup_schedule
|
|
3598
|
+
if update_mask is not None:
|
|
3599
|
+
request.update_mask = update_mask
|
|
3600
|
+
|
|
3601
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3602
|
+
# and friendly error handling.
|
|
3603
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3604
|
+
self._client._transport.update_backup_schedule
|
|
3605
|
+
]
|
|
3606
|
+
|
|
3607
|
+
# Certain fields should be provided within the metadata header;
|
|
3608
|
+
# add these here.
|
|
3609
|
+
metadata = tuple(metadata) + (
|
|
3610
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
3611
|
+
(("backup_schedule.name", request.backup_schedule.name),)
|
|
3612
|
+
),
|
|
3613
|
+
)
|
|
3614
|
+
|
|
3615
|
+
# Validate the universe domain.
|
|
3616
|
+
self._client._validate_universe_domain()
|
|
3617
|
+
|
|
3618
|
+
# Send the request.
|
|
3619
|
+
response = await rpc(
|
|
3620
|
+
request,
|
|
3621
|
+
retry=retry,
|
|
3622
|
+
timeout=timeout,
|
|
3623
|
+
metadata=metadata,
|
|
3624
|
+
)
|
|
3625
|
+
|
|
3626
|
+
# Done; return the response.
|
|
3627
|
+
return response
|
|
3628
|
+
|
|
3629
|
+
async def delete_backup_schedule(
|
|
3630
|
+
self,
|
|
3631
|
+
request: Optional[
|
|
3632
|
+
Union[backup_schedule.DeleteBackupScheduleRequest, dict]
|
|
3633
|
+
] = None,
|
|
3634
|
+
*,
|
|
3635
|
+
name: Optional[str] = None,
|
|
3636
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3637
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3638
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3639
|
+
) -> None:
|
|
3640
|
+
r"""Deletes a backup schedule.
|
|
3641
|
+
|
|
3642
|
+
.. code-block:: python
|
|
3643
|
+
|
|
3644
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3645
|
+
# code template only.
|
|
3646
|
+
# It will require modifications to work:
|
|
3647
|
+
# - It may require correct/in-range values for request initialization.
|
|
3648
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3649
|
+
# client as shown in:
|
|
3650
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3651
|
+
from google.cloud import spanner_admin_database_v1
|
|
3652
|
+
|
|
3653
|
+
async def sample_delete_backup_schedule():
|
|
3654
|
+
# Create a client
|
|
3655
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3656
|
+
|
|
3657
|
+
# Initialize request argument(s)
|
|
3658
|
+
request = spanner_admin_database_v1.DeleteBackupScheduleRequest(
|
|
3659
|
+
name="name_value",
|
|
3660
|
+
)
|
|
3661
|
+
|
|
3662
|
+
# Make the request
|
|
3663
|
+
await client.delete_backup_schedule(request=request)
|
|
3664
|
+
|
|
3665
|
+
Args:
|
|
3666
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupScheduleRequest, dict]]):
|
|
3667
|
+
The request object. The request for
|
|
3668
|
+
[DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule].
|
|
3669
|
+
name (:class:`str`):
|
|
3670
|
+
Required. The name of the schedule to delete. Values are
|
|
3671
|
+
of the form
|
|
3672
|
+
``projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>``.
|
|
3673
|
+
|
|
3674
|
+
This corresponds to the ``name`` field
|
|
3675
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3676
|
+
should not be set.
|
|
3677
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3678
|
+
should be retried.
|
|
3679
|
+
timeout (float): The timeout for this request.
|
|
3680
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3681
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3682
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3683
|
+
be of type `bytes`.
|
|
3684
|
+
"""
|
|
3685
|
+
# Create or coerce a protobuf request object.
|
|
3686
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3687
|
+
# gotten any keyword arguments that map to the request.
|
|
3688
|
+
flattened_params = [name]
|
|
3689
|
+
has_flattened_params = (
|
|
3690
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3691
|
+
)
|
|
3692
|
+
if request is not None and has_flattened_params:
|
|
3693
|
+
raise ValueError(
|
|
3694
|
+
"If the `request` argument is set, then none of "
|
|
3695
|
+
"the individual field arguments should be set."
|
|
3696
|
+
)
|
|
3697
|
+
|
|
3698
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3699
|
+
# there are no flattened fields), or create one.
|
|
3700
|
+
if not isinstance(request, backup_schedule.DeleteBackupScheduleRequest):
|
|
3701
|
+
request = backup_schedule.DeleteBackupScheduleRequest(request)
|
|
3702
|
+
|
|
3703
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3704
|
+
# request, apply these.
|
|
3705
|
+
if name is not None:
|
|
3706
|
+
request.name = name
|
|
3707
|
+
|
|
3708
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3709
|
+
# and friendly error handling.
|
|
3710
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3711
|
+
self._client._transport.delete_backup_schedule
|
|
3712
|
+
]
|
|
3713
|
+
|
|
3714
|
+
# Certain fields should be provided within the metadata header;
|
|
3715
|
+
# add these here.
|
|
3716
|
+
metadata = tuple(metadata) + (
|
|
3717
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3718
|
+
)
|
|
3719
|
+
|
|
3720
|
+
# Validate the universe domain.
|
|
3721
|
+
self._client._validate_universe_domain()
|
|
3722
|
+
|
|
3723
|
+
# Send the request.
|
|
3724
|
+
await rpc(
|
|
3725
|
+
request,
|
|
3726
|
+
retry=retry,
|
|
3727
|
+
timeout=timeout,
|
|
3728
|
+
metadata=metadata,
|
|
3729
|
+
)
|
|
3730
|
+
|
|
3731
|
+
async def list_backup_schedules(
|
|
3732
|
+
self,
|
|
3733
|
+
request: Optional[
|
|
3734
|
+
Union[backup_schedule.ListBackupSchedulesRequest, dict]
|
|
3735
|
+
] = None,
|
|
3736
|
+
*,
|
|
3737
|
+
parent: Optional[str] = None,
|
|
3738
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3739
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3740
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3741
|
+
) -> pagers.ListBackupSchedulesAsyncPager:
|
|
3742
|
+
r"""Lists all the backup schedules for the database.
|
|
3743
|
+
|
|
3744
|
+
.. code-block:: python
|
|
3745
|
+
|
|
3746
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
3747
|
+
# code template only.
|
|
3748
|
+
# It will require modifications to work:
|
|
3749
|
+
# - It may require correct/in-range values for request initialization.
|
|
3750
|
+
# - It may require specifying regional endpoints when creating the service
|
|
3751
|
+
# client as shown in:
|
|
3752
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
3753
|
+
from google.cloud import spanner_admin_database_v1
|
|
3754
|
+
|
|
3755
|
+
async def sample_list_backup_schedules():
|
|
3756
|
+
# Create a client
|
|
3757
|
+
client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
|
|
3758
|
+
|
|
3759
|
+
# Initialize request argument(s)
|
|
3760
|
+
request = spanner_admin_database_v1.ListBackupSchedulesRequest(
|
|
3761
|
+
parent="parent_value",
|
|
3762
|
+
)
|
|
3763
|
+
|
|
3764
|
+
# Make the request
|
|
3765
|
+
page_result = client.list_backup_schedules(request=request)
|
|
3766
|
+
|
|
3767
|
+
# Handle the response
|
|
3768
|
+
async for response in page_result:
|
|
3769
|
+
print(response)
|
|
3770
|
+
|
|
3771
|
+
Args:
|
|
3772
|
+
request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListBackupSchedulesRequest, dict]]):
|
|
3773
|
+
The request object. The request for
|
|
3774
|
+
[ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
|
|
3775
|
+
parent (:class:`str`):
|
|
3776
|
+
Required. Database is the parent
|
|
3777
|
+
resource whose backup schedules should
|
|
3778
|
+
be listed. Values are of the form
|
|
3779
|
+
projects/<project>/instances/<instance>/databases/<database>
|
|
3780
|
+
|
|
3781
|
+
This corresponds to the ``parent`` field
|
|
3782
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
3783
|
+
should not be set.
|
|
3784
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
3785
|
+
should be retried.
|
|
3786
|
+
timeout (float): The timeout for this request.
|
|
3787
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3788
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3789
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3790
|
+
be of type `bytes`.
|
|
3791
|
+
|
|
3792
|
+
Returns:
|
|
3793
|
+
google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupSchedulesAsyncPager:
|
|
3794
|
+
The response for
|
|
3795
|
+
[ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
|
|
3796
|
+
|
|
3797
|
+
Iterating over this object will yield results and
|
|
3798
|
+
resolve additional pages automatically.
|
|
3799
|
+
|
|
3800
|
+
"""
|
|
3801
|
+
# Create or coerce a protobuf request object.
|
|
3802
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
3803
|
+
# gotten any keyword arguments that map to the request.
|
|
3804
|
+
flattened_params = [parent]
|
|
3805
|
+
has_flattened_params = (
|
|
3806
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
3807
|
+
)
|
|
3808
|
+
if request is not None and has_flattened_params:
|
|
3809
|
+
raise ValueError(
|
|
3810
|
+
"If the `request` argument is set, then none of "
|
|
3811
|
+
"the individual field arguments should be set."
|
|
3812
|
+
)
|
|
3813
|
+
|
|
3814
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
3815
|
+
# there are no flattened fields), or create one.
|
|
3816
|
+
if not isinstance(request, backup_schedule.ListBackupSchedulesRequest):
|
|
3817
|
+
request = backup_schedule.ListBackupSchedulesRequest(request)
|
|
3818
|
+
|
|
3819
|
+
# If we have keyword arguments corresponding to fields on the
|
|
3820
|
+
# request, apply these.
|
|
3821
|
+
if parent is not None:
|
|
3822
|
+
request.parent = parent
|
|
3823
|
+
|
|
3824
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3825
|
+
# and friendly error handling.
|
|
3826
|
+
rpc = self._client._transport._wrapped_methods[
|
|
3827
|
+
self._client._transport.list_backup_schedules
|
|
3828
|
+
]
|
|
3829
|
+
|
|
3830
|
+
# Certain fields should be provided within the metadata header;
|
|
3831
|
+
# add these here.
|
|
3832
|
+
metadata = tuple(metadata) + (
|
|
3833
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
3834
|
+
)
|
|
3835
|
+
|
|
3836
|
+
# Validate the universe domain.
|
|
3837
|
+
self._client._validate_universe_domain()
|
|
3838
|
+
|
|
3839
|
+
# Send the request.
|
|
3840
|
+
response = await rpc(
|
|
3841
|
+
request,
|
|
3842
|
+
retry=retry,
|
|
3843
|
+
timeout=timeout,
|
|
3844
|
+
metadata=metadata,
|
|
3845
|
+
)
|
|
3846
|
+
|
|
3847
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
3848
|
+
# an `__aiter__` convenience method.
|
|
3849
|
+
response = pagers.ListBackupSchedulesAsyncPager(
|
|
3850
|
+
method=rpc,
|
|
3851
|
+
request=request,
|
|
3852
|
+
response=response,
|
|
3853
|
+
retry=retry,
|
|
3854
|
+
timeout=timeout,
|
|
3855
|
+
metadata=metadata,
|
|
3856
|
+
)
|
|
3857
|
+
|
|
3858
|
+
# Done; return the response.
|
|
3859
|
+
return response
|
|
3860
|
+
|
|
3861
|
+
async def list_operations(
|
|
3862
|
+
self,
|
|
3863
|
+
request: Optional[operations_pb2.ListOperationsRequest] = None,
|
|
3864
|
+
*,
|
|
3865
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3866
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3867
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3868
|
+
) -> operations_pb2.ListOperationsResponse:
|
|
3869
|
+
r"""Lists operations that match the specified filter in the request.
|
|
3870
|
+
|
|
3871
|
+
Args:
|
|
3872
|
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
|
3873
|
+
The request object. Request message for
|
|
3874
|
+
`ListOperations` method.
|
|
3875
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
3876
|
+
if any, should be retried.
|
|
3877
|
+
timeout (float): The timeout for this request.
|
|
3878
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3879
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3880
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3881
|
+
be of type `bytes`.
|
|
3882
|
+
Returns:
|
|
3883
|
+
~.operations_pb2.ListOperationsResponse:
|
|
3884
|
+
Response message for ``ListOperations`` method.
|
|
3885
|
+
"""
|
|
3886
|
+
# Create or coerce a protobuf request object.
|
|
3887
|
+
# The request isn't a proto-plus wrapped type,
|
|
3888
|
+
# so it must be constructed via keyword expansion.
|
|
3889
|
+
if isinstance(request, dict):
|
|
3890
|
+
request = operations_pb2.ListOperationsRequest(**request)
|
|
3891
|
+
|
|
3892
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3893
|
+
# and friendly error handling.
|
|
3894
|
+
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
|
|
3895
|
+
|
|
3896
|
+
# Certain fields should be provided within the metadata header;
|
|
3897
|
+
# add these here.
|
|
3898
|
+
metadata = tuple(metadata) + (
|
|
3899
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3900
|
+
)
|
|
3901
|
+
|
|
3902
|
+
# Validate the universe domain.
|
|
3903
|
+
self._client._validate_universe_domain()
|
|
3904
|
+
|
|
3905
|
+
# Send the request.
|
|
3906
|
+
response = await rpc(
|
|
3907
|
+
request,
|
|
3908
|
+
retry=retry,
|
|
3909
|
+
timeout=timeout,
|
|
3910
|
+
metadata=metadata,
|
|
3911
|
+
)
|
|
3912
|
+
|
|
3913
|
+
# Done; return the response.
|
|
3914
|
+
return response
|
|
3915
|
+
|
|
3916
|
+
async def get_operation(
|
|
3917
|
+
self,
|
|
3918
|
+
request: Optional[operations_pb2.GetOperationRequest] = None,
|
|
3919
|
+
*,
|
|
3920
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3921
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3922
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3923
|
+
) -> operations_pb2.Operation:
|
|
3924
|
+
r"""Gets the latest state of a long-running operation.
|
|
3925
|
+
|
|
3926
|
+
Args:
|
|
3927
|
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
|
3928
|
+
The request object. Request message for
|
|
3929
|
+
`GetOperation` method.
|
|
3930
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
3931
|
+
if any, should be retried.
|
|
3932
|
+
timeout (float): The timeout for this request.
|
|
3933
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3934
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3935
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3936
|
+
be of type `bytes`.
|
|
3937
|
+
Returns:
|
|
3938
|
+
~.operations_pb2.Operation:
|
|
3939
|
+
An ``Operation`` object.
|
|
3940
|
+
"""
|
|
3941
|
+
# Create or coerce a protobuf request object.
|
|
3942
|
+
# The request isn't a proto-plus wrapped type,
|
|
3943
|
+
# so it must be constructed via keyword expansion.
|
|
3944
|
+
if isinstance(request, dict):
|
|
3945
|
+
request = operations_pb2.GetOperationRequest(**request)
|
|
3946
|
+
|
|
3947
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3948
|
+
# and friendly error handling.
|
|
3949
|
+
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
|
|
3950
|
+
|
|
3951
|
+
# Certain fields should be provided within the metadata header;
|
|
3952
|
+
# add these here.
|
|
3953
|
+
metadata = tuple(metadata) + (
|
|
3954
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3955
|
+
)
|
|
3956
|
+
|
|
3957
|
+
# Validate the universe domain.
|
|
3958
|
+
self._client._validate_universe_domain()
|
|
3959
|
+
|
|
3960
|
+
# Send the request.
|
|
3961
|
+
response = await rpc(
|
|
3962
|
+
request,
|
|
3963
|
+
retry=retry,
|
|
3964
|
+
timeout=timeout,
|
|
3965
|
+
metadata=metadata,
|
|
3966
|
+
)
|
|
3967
|
+
|
|
3968
|
+
# Done; return the response.
|
|
3969
|
+
return response
|
|
3970
|
+
|
|
3971
|
+
async def delete_operation(
|
|
3972
|
+
self,
|
|
3973
|
+
request: Optional[operations_pb2.DeleteOperationRequest] = None,
|
|
3974
|
+
*,
|
|
3975
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3976
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3977
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3978
|
+
) -> None:
|
|
3979
|
+
r"""Deletes a long-running operation.
|
|
3980
|
+
|
|
3981
|
+
This method indicates that the client is no longer interested
|
|
3982
|
+
in the operation result. It does not cancel the operation.
|
|
3983
|
+
If the server doesn't support this method, it returns
|
|
3984
|
+
`google.rpc.Code.UNIMPLEMENTED`.
|
|
3985
|
+
|
|
3986
|
+
Args:
|
|
3987
|
+
request (:class:`~.operations_pb2.DeleteOperationRequest`):
|
|
3988
|
+
The request object. Request message for
|
|
3989
|
+
`DeleteOperation` method.
|
|
3990
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
3991
|
+
if any, should be retried.
|
|
3992
|
+
timeout (float): The timeout for this request.
|
|
3993
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3994
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3995
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3996
|
+
be of type `bytes`.
|
|
3997
|
+
Returns:
|
|
3998
|
+
None
|
|
3999
|
+
"""
|
|
4000
|
+
# Create or coerce a protobuf request object.
|
|
4001
|
+
# The request isn't a proto-plus wrapped type,
|
|
4002
|
+
# so it must be constructed via keyword expansion.
|
|
4003
|
+
if isinstance(request, dict):
|
|
4004
|
+
request = operations_pb2.DeleteOperationRequest(**request)
|
|
4005
|
+
|
|
4006
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
4007
|
+
# and friendly error handling.
|
|
4008
|
+
rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]
|
|
4009
|
+
|
|
4010
|
+
# Certain fields should be provided within the metadata header;
|
|
4011
|
+
# add these here.
|
|
4012
|
+
metadata = tuple(metadata) + (
|
|
4013
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
4014
|
+
)
|
|
4015
|
+
|
|
4016
|
+
# Validate the universe domain.
|
|
4017
|
+
self._client._validate_universe_domain()
|
|
4018
|
+
|
|
4019
|
+
# Send the request.
|
|
4020
|
+
await rpc(
|
|
4021
|
+
request,
|
|
4022
|
+
retry=retry,
|
|
4023
|
+
timeout=timeout,
|
|
4024
|
+
metadata=metadata,
|
|
4025
|
+
)
|
|
4026
|
+
|
|
4027
|
+
async def cancel_operation(
|
|
4028
|
+
self,
|
|
4029
|
+
request: Optional[operations_pb2.CancelOperationRequest] = None,
|
|
4030
|
+
*,
|
|
4031
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
4032
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
4033
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
4034
|
+
) -> None:
|
|
4035
|
+
r"""Starts asynchronous cancellation on a long-running operation.
|
|
4036
|
+
|
|
4037
|
+
The server makes a best effort to cancel the operation, but success
|
|
4038
|
+
is not guaranteed. If the server doesn't support this method, it returns
|
|
4039
|
+
`google.rpc.Code.UNIMPLEMENTED`.
|
|
4040
|
+
|
|
4041
|
+
Args:
|
|
4042
|
+
request (:class:`~.operations_pb2.CancelOperationRequest`):
|
|
4043
|
+
The request object. Request message for
|
|
4044
|
+
`CancelOperation` method.
|
|
4045
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
4046
|
+
if any, should be retried.
|
|
4047
|
+
timeout (float): The timeout for this request.
|
|
4048
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
4049
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
4050
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
4051
|
+
be of type `bytes`.
|
|
4052
|
+
Returns:
|
|
4053
|
+
None
|
|
4054
|
+
"""
|
|
4055
|
+
# Create or coerce a protobuf request object.
|
|
4056
|
+
# The request isn't a proto-plus wrapped type,
|
|
4057
|
+
# so it must be constructed via keyword expansion.
|
|
4058
|
+
if isinstance(request, dict):
|
|
4059
|
+
request = operations_pb2.CancelOperationRequest(**request)
|
|
4060
|
+
|
|
4061
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
4062
|
+
# and friendly error handling.
|
|
4063
|
+
rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]
|
|
4064
|
+
|
|
4065
|
+
# Certain fields should be provided within the metadata header;
|
|
4066
|
+
# add these here.
|
|
4067
|
+
metadata = tuple(metadata) + (
|
|
4068
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
4069
|
+
)
|
|
4070
|
+
|
|
4071
|
+
# Validate the universe domain.
|
|
4072
|
+
self._client._validate_universe_domain()
|
|
4073
|
+
|
|
4074
|
+
# Send the request.
|
|
4075
|
+
await rpc(
|
|
4076
|
+
request,
|
|
4077
|
+
retry=retry,
|
|
4078
|
+
timeout=timeout,
|
|
4079
|
+
metadata=metadata,
|
|
4080
|
+
)
|
|
4081
|
+
|
|
4082
|
+
async def __aenter__(self) -> "DatabaseAdminAsyncClient":
|
|
4083
|
+
return self
|
|
4084
|
+
|
|
4085
|
+
async def __aexit__(self, exc_type, exc, tb):
|
|
4086
|
+
await self.transport.close()
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
4090
|
+
gapic_version=package_version.__version__
|
|
4091
|
+
)
|
|
4092
|
+
|
|
4093
|
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
4094
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
__all__ = ("DatabaseAdminAsyncClient",)
|