1616from collections import OrderedDict
1717import functools
1818import re
19- from typing import Dict , Optional , Sequence , Tuple , Type , Union
19+ from typing import Dict , Mapping , Optional , Sequence , Tuple , Type , Union
2020import pkg_resources
2121
2222from google .api_core .client_options import ClientOptions
@@ -371,7 +371,6 @@ async def create_database(
371371 is [Database][google.spanner.admin.database.v1.Database], if
372372 successful.
373373
374-
375374 .. code-block:: python
376375
377376 from google.cloud import spanner_admin_database_v1
@@ -611,7 +610,6 @@ async def update_database_ddl(
611610 [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
612611 The operation has no response.
613612
614-
615613 .. code-block:: python
616614
617615 from google.cloud import spanner_admin_database_v1
@@ -770,7 +768,6 @@ async def drop_database(
770768 ``expire_time``. Note: Cloud Spanner might continue to accept
771769 requests for a few seconds after the database has been deleted.
772770
773-
774771 .. code-block:: python
775772
776773 from google.cloud import spanner_admin_database_v1
@@ -865,7 +862,6 @@ async def get_database_ddl(
865862 schema updates, those may be queried using the
866863 [Operations][google.longrunning.Operations] API.
867864
868-
869865 .. code-block:: python
870866
871867 from google.cloud import spanner_admin_database_v1
@@ -980,17 +976,17 @@ async def set_iam_policy(
980976 permission on
981977 [resource][google.iam.v1.SetIamPolicyRequest.resource].
982978
983-
984979 .. code-block:: python
985980
986981 from google.cloud import spanner_admin_database_v1
982+ from google.iam.v1 import iam_policy_pb2 # type: ignore
987983
988984 def sample_set_iam_policy():
989985 # Create a client
990986 client = spanner_admin_database_v1.DatabaseAdminClient()
991987
992988 # Initialize request argument(s)
993- request = spanner_admin_database_v1 .SetIamPolicyRequest(
989+ request = iam_policy_pb2 .SetIamPolicyRequest(
994990 resource="resource_value",
995991 )
996992
@@ -1021,21 +1017,26 @@ def sample_set_iam_policy():
10211017
10221018 Returns:
10231019 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.
10271022
10281023 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:**
10391040
10401041 {
10411042 "bindings": [
@@ -1050,17 +1051,17 @@ def sample_set_iam_policy():
10501051
10511052 }, { "role":
10521053 "roles/resourcemanager.organizationViewer",
1053- "members": ["user:eve@example.com"],
1054+ "members": [ "user:eve@example.com" ],
10541055 "condition": { "title": "expirable access",
10551056 "description": "Does not grant access after
10561057 Sep 2020", "expression": "request.time <
10571058 timestamp('2020-10-01T00:00:00.000Z')", } }
10581059
1059- ]
1060+ ], "etag": "BwWWja0YfJA=", "version": 3
10601061
10611062 }
10621063
1063- **YAML Example **
1064+ **YAML example: **
10641065
10651066 bindings: - members: - user:\ mike@example.com -
10661067 group:\ admins@example.com - domain:google.com -
@@ -1071,11 +1072,12 @@ def sample_set_iam_policy():
10711072 condition: title: expirable access description:
10721073 Does not grant access after Sep 2020 expression:
10731074 request.time <
1074- timestamp('2020-10-01T00:00:00.000Z')
1075+ timestamp('2020-10-01T00:00:00.000Z') etag:
1076+ BwWWja0YfJA= version: 3
10751077
10761078 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/ ).
10791081
10801082 """
10811083 # Create or coerce a protobuf request object.
@@ -1142,17 +1144,17 @@ async def get_iam_policy(
11421144 permission on
11431145 [resource][google.iam.v1.GetIamPolicyRequest.resource].
11441146
1145-
11461147 .. code-block:: python
11471148
11481149 from google.cloud import spanner_admin_database_v1
1150+ from google.iam.v1 import iam_policy_pb2 # type: ignore
11491151
11501152 def sample_get_iam_policy():
11511153 # Create a client
11521154 client = spanner_admin_database_v1.DatabaseAdminClient()
11531155
11541156 # Initialize request argument(s)
1155- request = spanner_admin_database_v1 .GetIamPolicyRequest(
1157+ request = iam_policy_pb2 .GetIamPolicyRequest(
11561158 resource="resource_value",
11571159 )
11581160
@@ -1183,21 +1185,26 @@ def sample_get_iam_policy():
11831185
11841186 Returns:
11851187 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.
11891190
11901191 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:**
12011208
12021209 {
12031210 "bindings": [
@@ -1212,17 +1219,17 @@ def sample_get_iam_policy():
12121219
12131220 }, { "role":
12141221 "roles/resourcemanager.organizationViewer",
1215- "members": ["user:eve@example.com"],
1222+ "members": [ "user:eve@example.com" ],
12161223 "condition": { "title": "expirable access",
12171224 "description": "Does not grant access after
12181225 Sep 2020", "expression": "request.time <
12191226 timestamp('2020-10-01T00:00:00.000Z')", } }
12201227
1221- ]
1228+ ], "etag": "BwWWja0YfJA=", "version": 3
12221229
12231230 }
12241231
1225- **YAML Example **
1232+ **YAML example: **
12261233
12271234 bindings: - members: - user:\ mike@example.com -
12281235 group:\ admins@example.com - domain:google.com -
@@ -1233,11 +1240,12 @@ def sample_get_iam_policy():
12331240 condition: title: expirable access description:
12341241 Does not grant access after Sep 2020 expression:
12351242 request.time <
1236- timestamp('2020-10-01T00:00:00.000Z')
1243+ timestamp('2020-10-01T00:00:00.000Z') etag:
1244+ BwWWja0YfJA= version: 3
12371245
12381246 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/ ).
12411249
12421250 """
12431251 # Create or coerce a protobuf request object.
@@ -1315,17 +1323,17 @@ async def test_iam_permissions(
13151323 in a NOT_FOUND error if the user has ``spanner.backups.list``
13161324 permission on the containing instance.
13171325
1318-
13191326 .. code-block:: python
13201327
13211328 from google.cloud import spanner_admin_database_v1
1329+ from google.iam.v1 import iam_policy_pb2 # type: ignore
13221330
13231331 def sample_test_iam_permissions():
13241332 # Create a client
13251333 client = spanner_admin_database_v1.DatabaseAdminClient()
13261334
13271335 # Initialize request argument(s)
1328- request = spanner_admin_database_v1 .TestIamPermissionsRequest(
1336+ request = iam_policy_pb2 .TestIamPermissionsRequest(
13291337 resource="resource_value",
13301338 permissions=['permissions_value_1', 'permissions_value_2'],
13311339 )
@@ -1438,7 +1446,6 @@ async def create_backup(
14381446 backup creation per database. Backup creation of different
14391447 databases can run concurrently.
14401448
1441-
14421449 .. code-block:: python
14431450
14441451 from google.cloud import spanner_admin_database_v1
@@ -1588,7 +1595,6 @@ async def copy_backup(
15881595 copying and delete the backup. Concurrent CopyBackup requests
15891596 can run on the same source backup.
15901597
1591-
15921598 .. code-block:: python
15931599
15941600 from google.cloud import spanner_admin_database_v1
@@ -1741,7 +1747,6 @@ async def get_backup(
17411747 r"""Gets metadata on a pending or completed
17421748 [Backup][google.spanner.admin.database.v1.Backup].
17431749
1744-
17451750 .. code-block:: python
17461751
17471752 from google.cloud import spanner_admin_database_v1
@@ -1847,7 +1852,6 @@ async def update_backup(
18471852 r"""Updates a pending or completed
18481853 [Backup][google.spanner.admin.database.v1.Backup].
18491854
1850-
18511855 .. code-block:: python
18521856
18531857 from google.cloud import spanner_admin_database_v1
@@ -1971,7 +1975,6 @@ async def delete_backup(
19711975 r"""Deletes a pending or completed
19721976 [Backup][google.spanner.admin.database.v1.Backup].
19731977
1974-
19751978 .. code-block:: python
19761979
19771980 from google.cloud import spanner_admin_database_v1
@@ -2068,7 +2071,6 @@ async def list_backups(
20682071 ordered by ``create_time`` in descending order, starting from
20692072 the most recent ``create_time``.
20702073
2071-
20722074 .. code-block:: python
20732075
20742076 from google.cloud import spanner_admin_database_v1
@@ -2207,7 +2209,6 @@ async def restore_database(
22072209 without waiting for the optimize operation associated with the
22082210 first restore to complete.
22092211
2210-
22112212 .. code-block:: python
22122213
22132214 from google.cloud import spanner_admin_database_v1
@@ -2356,7 +2357,6 @@ async def list_database_operations(
23562357 completed/failed/canceled within the last 7 days, and pending
23572358 operations.
23582359
2359-
23602360 .. code-block:: python
23612361
23622362 from google.cloud import spanner_admin_database_v1
@@ -2487,7 +2487,6 @@ async def list_backup_operations(
24872487 ``operation.metadata.value.progress.start_time`` in descending
24882488 order starting from the most recently started operation.
24892489
2490-
24912490 .. code-block:: python
24922491
24932492 from google.cloud import spanner_admin_database_v1
0 commit comments