16
16
from collections import OrderedDict
17
17
import functools
18
18
import re
19
- from typing import Dict , Optional , Sequence , Tuple , Type , Union
19
+ from typing import Dict , Mapping , Optional , Sequence , Tuple , Type , Union
20
20
import pkg_resources
21
21
22
22
from google .api_core .client_options import ClientOptions
@@ -371,7 +371,6 @@ async def create_database(
371
371
is [Database][google.spanner.admin.database.v1.Database], if
372
372
successful.
373
373
374
-
375
374
.. code-block:: python
376
375
377
376
from google.cloud import spanner_admin_database_v1
@@ -611,7 +610,6 @@ async def update_database_ddl(
611
610
[UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
612
611
The operation has no response.
613
612
614
-
615
613
.. code-block:: python
616
614
617
615
from google.cloud import spanner_admin_database_v1
@@ -770,7 +768,6 @@ async def drop_database(
770
768
``expire_time``. Note: Cloud Spanner might continue to accept
771
769
requests for a few seconds after the database has been deleted.
772
770
773
-
774
771
.. code-block:: python
775
772
776
773
from google.cloud import spanner_admin_database_v1
@@ -865,7 +862,6 @@ async def get_database_ddl(
865
862
schema updates, those may be queried using the
866
863
[Operations][google.longrunning.Operations] API.
867
864
868
-
869
865
.. code-block:: python
870
866
871
867
from google.cloud import spanner_admin_database_v1
@@ -980,17 +976,17 @@ async def set_iam_policy(
980
976
permission on
981
977
[resource][google.iam.v1.SetIamPolicyRequest.resource].
982
978
983
-
984
979
.. code-block:: python
985
980
986
981
from google.cloud import spanner_admin_database_v1
982
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
987
983
988
984
def sample_set_iam_policy():
989
985
# Create a client
990
986
client = spanner_admin_database_v1.DatabaseAdminClient()
991
987
992
988
# Initialize request argument(s)
993
- request = spanner_admin_database_v1 .SetIamPolicyRequest(
989
+ request = iam_policy_pb2 .SetIamPolicyRequest(
994
990
resource="resource_value",
995
991
)
996
992
@@ -1021,21 +1017,26 @@ def sample_set_iam_policy():
1021
1017
1022
1018
Returns:
1023
1019
google.iam.v1.policy_pb2.Policy:
1024
- Defines an Identity and Access Management (IAM) policy. It is used to
1025
- specify access control policies for Cloud Platform
1026
- resources.
1020
+ An Identity and Access Management (IAM) policy, which specifies access
1021
+ controls for Google Cloud resources.
1027
1022
1028
1023
A Policy is a collection of bindings. A binding binds
1029
- one or more members to a single role. Members can be
1030
- user accounts, service accounts, Google groups, and
1031
- domains (such as G Suite). A role is a named list of
1032
- permissions (defined by IAM or configured by users).
1033
- A binding can optionally specify a condition, which
1034
- is a logic expression that further constrains the
1035
- role binding based on attributes about the request
1036
- and/or target resource.
1037
-
1038
- **JSON Example**
1024
+ one or more members, or principals, to a single role.
1025
+ Principals can be user accounts, service accounts,
1026
+ Google groups, and domains (such as G Suite). A role
1027
+ is a named list of permissions; each role can be an
1028
+ IAM predefined role or a user-created custom role.
1029
+
1030
+ For some types of Google Cloud resources, a binding
1031
+ can also specify a condition, which is a logical
1032
+ expression that allows access to a resource only if
1033
+ the expression evaluates to true. A condition can add
1034
+ constraints based on attributes of the request, the
1035
+ resource, or both. To learn which resources support
1036
+ conditions in their IAM policies, see the [IAM
1037
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1038
+
1039
+ **JSON example:**
1039
1040
1040
1041
{
1041
1042
"bindings": [
@@ -1050,17 +1051,17 @@ def sample_set_iam_policy():
1050
1051
1051
1052
}, { "role":
1052
1053
"roles/resourcemanager.organizationViewer",
1053
- "members": ["user:eve@example.com"],
1054
+ "members": [ "user:eve@example.com" ],
1054
1055
"condition": { "title": "expirable access",
1055
1056
"description": "Does not grant access after
1056
1057
Sep 2020", "expression": "request.time <
1057
1058
timestamp('2020-10-01T00:00:00.000Z')", } }
1058
1059
1059
- ]
1060
+ ], "etag": "BwWWja0YfJA=", "version": 3
1060
1061
1061
1062
}
1062
1063
1063
- **YAML Example **
1064
+ **YAML example: **
1064
1065
1065
1066
bindings: - members: - user:\ mike@example.com -
1066
1067
group:\ admins@example.com - domain:google.com -
@@ -1071,11 +1072,12 @@ def sample_set_iam_policy():
1071
1072
condition: title: expirable access description:
1072
1073
Does not grant access after Sep 2020 expression:
1073
1074
request.time <
1074
- timestamp('2020-10-01T00:00:00.000Z')
1075
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1076
+ BwWWja0YfJA= version: 3
1075
1077
1076
1078
For a description of IAM and its features, see the
1077
- [IAM developer's
1078
- guide ](\ https://cloud.google.com/iam/docs).
1079
+ [IAM
1080
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
1079
1081
1080
1082
"""
1081
1083
# Create or coerce a protobuf request object.
@@ -1142,17 +1144,17 @@ async def get_iam_policy(
1142
1144
permission on
1143
1145
[resource][google.iam.v1.GetIamPolicyRequest.resource].
1144
1146
1145
-
1146
1147
.. code-block:: python
1147
1148
1148
1149
from google.cloud import spanner_admin_database_v1
1150
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1149
1151
1150
1152
def sample_get_iam_policy():
1151
1153
# Create a client
1152
1154
client = spanner_admin_database_v1.DatabaseAdminClient()
1153
1155
1154
1156
# Initialize request argument(s)
1155
- request = spanner_admin_database_v1 .GetIamPolicyRequest(
1157
+ request = iam_policy_pb2 .GetIamPolicyRequest(
1156
1158
resource="resource_value",
1157
1159
)
1158
1160
@@ -1183,21 +1185,26 @@ def sample_get_iam_policy():
1183
1185
1184
1186
Returns:
1185
1187
google.iam.v1.policy_pb2.Policy:
1186
- Defines an Identity and Access Management (IAM) policy. It is used to
1187
- specify access control policies for Cloud Platform
1188
- resources.
1188
+ An Identity and Access Management (IAM) policy, which specifies access
1189
+ controls for Google Cloud resources.
1189
1190
1190
1191
A Policy is a collection of bindings. A binding binds
1191
- one or more members to a single role. Members can be
1192
- user accounts, service accounts, Google groups, and
1193
- domains (such as G Suite). A role is a named list of
1194
- permissions (defined by IAM or configured by users).
1195
- A binding can optionally specify a condition, which
1196
- is a logic expression that further constrains the
1197
- role binding based on attributes about the request
1198
- and/or target resource.
1199
-
1200
- **JSON Example**
1192
+ one or more members, or principals, to a single role.
1193
+ Principals can be user accounts, service accounts,
1194
+ Google groups, and domains (such as G Suite). A role
1195
+ is a named list of permissions; each role can be an
1196
+ IAM predefined role or a user-created custom role.
1197
+
1198
+ For some types of Google Cloud resources, a binding
1199
+ can also specify a condition, which is a logical
1200
+ expression that allows access to a resource only if
1201
+ the expression evaluates to true. A condition can add
1202
+ constraints based on attributes of the request, the
1203
+ resource, or both. To learn which resources support
1204
+ conditions in their IAM policies, see the [IAM
1205
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1206
+
1207
+ **JSON example:**
1201
1208
1202
1209
{
1203
1210
"bindings": [
@@ -1212,17 +1219,17 @@ def sample_get_iam_policy():
1212
1219
1213
1220
}, { "role":
1214
1221
"roles/resourcemanager.organizationViewer",
1215
- "members": ["user:eve@example.com"],
1222
+ "members": [ "user:eve@example.com" ],
1216
1223
"condition": { "title": "expirable access",
1217
1224
"description": "Does not grant access after
1218
1225
Sep 2020", "expression": "request.time <
1219
1226
timestamp('2020-10-01T00:00:00.000Z')", } }
1220
1227
1221
- ]
1228
+ ], "etag": "BwWWja0YfJA=", "version": 3
1222
1229
1223
1230
}
1224
1231
1225
- **YAML Example **
1232
+ **YAML example: **
1226
1233
1227
1234
bindings: - members: - user:\ mike@example.com -
1228
1235
group:\ admins@example.com - domain:google.com -
@@ -1233,11 +1240,12 @@ def sample_get_iam_policy():
1233
1240
condition: title: expirable access description:
1234
1241
Does not grant access after Sep 2020 expression:
1235
1242
request.time <
1236
- timestamp('2020-10-01T00:00:00.000Z')
1243
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1244
+ BwWWja0YfJA= version: 3
1237
1245
1238
1246
For a description of IAM and its features, see the
1239
- [IAM developer's
1240
- guide ](\ https://cloud.google.com/iam/docs).
1247
+ [IAM
1248
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
1241
1249
1242
1250
"""
1243
1251
# Create or coerce a protobuf request object.
@@ -1315,17 +1323,17 @@ async def test_iam_permissions(
1315
1323
in a NOT_FOUND error if the user has ``spanner.backups.list``
1316
1324
permission on the containing instance.
1317
1325
1318
-
1319
1326
.. code-block:: python
1320
1327
1321
1328
from google.cloud import spanner_admin_database_v1
1329
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1322
1330
1323
1331
def sample_test_iam_permissions():
1324
1332
# Create a client
1325
1333
client = spanner_admin_database_v1.DatabaseAdminClient()
1326
1334
1327
1335
# Initialize request argument(s)
1328
- request = spanner_admin_database_v1 .TestIamPermissionsRequest(
1336
+ request = iam_policy_pb2 .TestIamPermissionsRequest(
1329
1337
resource="resource_value",
1330
1338
permissions=['permissions_value_1', 'permissions_value_2'],
1331
1339
)
@@ -1438,7 +1446,6 @@ async def create_backup(
1438
1446
backup creation per database. Backup creation of different
1439
1447
databases can run concurrently.
1440
1448
1441
-
1442
1449
.. code-block:: python
1443
1450
1444
1451
from google.cloud import spanner_admin_database_v1
@@ -1588,7 +1595,6 @@ async def copy_backup(
1588
1595
copying and delete the backup. Concurrent CopyBackup requests
1589
1596
can run on the same source backup.
1590
1597
1591
-
1592
1598
.. code-block:: python
1593
1599
1594
1600
from google.cloud import spanner_admin_database_v1
@@ -1741,7 +1747,6 @@ async def get_backup(
1741
1747
r"""Gets metadata on a pending or completed
1742
1748
[Backup][google.spanner.admin.database.v1.Backup].
1743
1749
1744
-
1745
1750
.. code-block:: python
1746
1751
1747
1752
from google.cloud import spanner_admin_database_v1
@@ -1847,7 +1852,6 @@ async def update_backup(
1847
1852
r"""Updates a pending or completed
1848
1853
[Backup][google.spanner.admin.database.v1.Backup].
1849
1854
1850
-
1851
1855
.. code-block:: python
1852
1856
1853
1857
from google.cloud import spanner_admin_database_v1
@@ -1971,7 +1975,6 @@ async def delete_backup(
1971
1975
r"""Deletes a pending or completed
1972
1976
[Backup][google.spanner.admin.database.v1.Backup].
1973
1977
1974
-
1975
1978
.. code-block:: python
1976
1979
1977
1980
from google.cloud import spanner_admin_database_v1
@@ -2068,7 +2071,6 @@ async def list_backups(
2068
2071
ordered by ``create_time`` in descending order, starting from
2069
2072
the most recent ``create_time``.
2070
2073
2071
-
2072
2074
.. code-block:: python
2073
2075
2074
2076
from google.cloud import spanner_admin_database_v1
@@ -2207,7 +2209,6 @@ async def restore_database(
2207
2209
without waiting for the optimize operation associated with the
2208
2210
first restore to complete.
2209
2211
2210
-
2211
2212
.. code-block:: python
2212
2213
2213
2214
from google.cloud import spanner_admin_database_v1
@@ -2356,7 +2357,6 @@ async def list_database_operations(
2356
2357
completed/failed/canceled within the last 7 days, and pending
2357
2358
operations.
2358
2359
2359
-
2360
2360
.. code-block:: python
2361
2361
2362
2362
from google.cloud import spanner_admin_database_v1
@@ -2487,7 +2487,6 @@ async def list_backup_operations(
2487
2487
``operation.metadata.value.progress.start_time`` in descending
2488
2488
order starting from the most recently started operation.
2489
2489
2490
-
2491
2490
.. code-block:: python
2492
2491
2493
2492
from google.cloud import spanner_admin_database_v1
0 commit comments