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
@@ -680,7 +680,6 @@ async def delete_namespace(
680680 r"""Deletes a namespace. This also deletes all services
681681 and endpoints in the namespace.
682682
683-
684683 .. code-block:: python
685684
686685 from google.cloud import servicedirectory_v1
@@ -1204,7 +1203,6 @@ async def delete_service(
12041203 r"""Deletes a service. This also deletes all endpoints
12051204 associated with the service.
12061205
1207-
12081206 .. code-block:: python
12091207
12101208 from google.cloud import servicedirectory_v1
@@ -1806,17 +1804,17 @@ async def get_iam_policy(
18061804 r"""Gets the IAM Policy for a resource (namespace or
18071805 service only).
18081806
1809-
18101807 .. code-block:: python
18111808
18121809 from google.cloud import servicedirectory_v1
1810+ from google.iam.v1 import iam_policy_pb2 # type: ignore
18131811
18141812 def sample_get_iam_policy():
18151813 # Create a client
18161814 client = servicedirectory_v1.RegistrationServiceClient()
18171815
18181816 # Initialize request argument(s)
1819- request = servicedirectory_v1 .GetIamPolicyRequest(
1817+ request = iam_policy_pb2 .GetIamPolicyRequest(
18201818 resource="resource_value",
18211819 )
18221820
@@ -1838,21 +1836,26 @@ def sample_get_iam_policy():
18381836
18391837 Returns:
18401838 google.iam.v1.policy_pb2.Policy:
1841- Defines an Identity and Access Management (IAM) policy. It is used to
1842- specify access control policies for Cloud Platform
1843- resources.
1839+ An Identity and Access Management (IAM) policy, which specifies access
1840+ controls for Google Cloud resources.
18441841
18451842 A Policy is a collection of bindings. A binding binds
1846- one or more members to a single role. Members can be
1847- user accounts, service accounts, Google groups, and
1848- domains (such as G Suite). A role is a named list of
1849- permissions (defined by IAM or configured by users).
1850- A binding can optionally specify a condition, which
1851- is a logic expression that further constrains the
1852- role binding based on attributes about the request
1853- and/or target resource.
1854-
1855- **JSON Example**
1843+ one or more members, or principals, to a single role.
1844+ Principals can be user accounts, service accounts,
1845+ Google groups, and domains (such as G Suite). A role
1846+ is a named list of permissions; each role can be an
1847+ IAM predefined role or a user-created custom role.
1848+
1849+ For some types of Google Cloud resources, a binding
1850+ can also specify a condition, which is a logical
1851+ expression that allows access to a resource only if
1852+ the expression evaluates to true. A condition can add
1853+ constraints based on attributes of the request, the
1854+ resource, or both. To learn which resources support
1855+ conditions in their IAM policies, see the [IAM
1856+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1857+
1858+ **JSON example:**
18561859
18571860 {
18581861 "bindings": [
@@ -1867,17 +1870,17 @@ def sample_get_iam_policy():
18671870
18681871 }, { "role":
18691872 "roles/resourcemanager.organizationViewer",
1870- "members": ["user:eve@example.com"],
1873+ "members": [ "user:eve@example.com" ],
18711874 "condition": { "title": "expirable access",
18721875 "description": "Does not grant access after
18731876 Sep 2020", "expression": "request.time <
18741877 timestamp('2020-10-01T00:00:00.000Z')", } }
18751878
1876- ]
1879+ ], "etag": "BwWWja0YfJA=", "version": 3
18771880
18781881 }
18791882
1880- **YAML Example **
1883+ **YAML example: **
18811884
18821885 bindings: - members: - user:\ mike@example.com -
18831886 group:\ admins@example.com - domain:google.com -
@@ -1888,11 +1891,12 @@ def sample_get_iam_policy():
18881891 condition: title: expirable access description:
18891892 Does not grant access after Sep 2020 expression:
18901893 request.time <
1891- timestamp('2020-10-01T00:00:00.000Z')
1894+ timestamp('2020-10-01T00:00:00.000Z') etag:
1895+ BwWWja0YfJA= version: 3
18921896
18931897 For a description of IAM and its features, see the
1894- [IAM developer's
1895- guide ](\ https://cloud.google.com/iam/docs).
1898+ [IAM
1899+ documentation ](\ https://cloud.google.com/iam/docs/ ).
18961900
18971901 """
18981902 # Create or coerce a protobuf request object.
@@ -1937,17 +1941,17 @@ async def set_iam_policy(
19371941 r"""Sets the IAM Policy for a resource (namespace or
19381942 service only).
19391943
1940-
19411944 .. code-block:: python
19421945
19431946 from google.cloud import servicedirectory_v1
1947+ from google.iam.v1 import iam_policy_pb2 # type: ignore
19441948
19451949 def sample_set_iam_policy():
19461950 # Create a client
19471951 client = servicedirectory_v1.RegistrationServiceClient()
19481952
19491953 # Initialize request argument(s)
1950- request = servicedirectory_v1 .SetIamPolicyRequest(
1954+ request = iam_policy_pb2 .SetIamPolicyRequest(
19511955 resource="resource_value",
19521956 )
19531957
@@ -1969,21 +1973,26 @@ def sample_set_iam_policy():
19691973
19701974 Returns:
19711975 google.iam.v1.policy_pb2.Policy:
1972- Defines an Identity and Access Management (IAM) policy. It is used to
1973- specify access control policies for Cloud Platform
1974- resources.
1976+ An Identity and Access Management (IAM) policy, which specifies access
1977+ controls for Google Cloud resources.
19751978
19761979 A Policy is a collection of bindings. A binding binds
1977- one or more members to a single role. Members can be
1978- user accounts, service accounts, Google groups, and
1979- domains (such as G Suite). A role is a named list of
1980- permissions (defined by IAM or configured by users).
1981- A binding can optionally specify a condition, which
1982- is a logic expression that further constrains the
1983- role binding based on attributes about the request
1984- and/or target resource.
1985-
1986- **JSON Example**
1980+ one or more members, or principals, to a single role.
1981+ Principals can be user accounts, service accounts,
1982+ Google groups, and domains (such as G Suite). A role
1983+ is a named list of permissions; each role can be an
1984+ IAM predefined role or a user-created custom role.
1985+
1986+ For some types of Google Cloud resources, a binding
1987+ can also specify a condition, which is a logical
1988+ expression that allows access to a resource only if
1989+ the expression evaluates to true. A condition can add
1990+ constraints based on attributes of the request, the
1991+ resource, or both. To learn which resources support
1992+ conditions in their IAM policies, see the [IAM
1993+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1994+
1995+ **JSON example:**
19871996
19881997 {
19891998 "bindings": [
@@ -1998,17 +2007,17 @@ def sample_set_iam_policy():
19982007
19992008 }, { "role":
20002009 "roles/resourcemanager.organizationViewer",
2001- "members": ["user:eve@example.com"],
2010+ "members": [ "user:eve@example.com" ],
20022011 "condition": { "title": "expirable access",
20032012 "description": "Does not grant access after
20042013 Sep 2020", "expression": "request.time <
20052014 timestamp('2020-10-01T00:00:00.000Z')", } }
20062015
2007- ]
2016+ ], "etag": "BwWWja0YfJA=", "version": 3
20082017
20092018 }
20102019
2011- **YAML Example **
2020+ **YAML example: **
20122021
20132022 bindings: - members: - user:\ mike@example.com -
20142023 group:\ admins@example.com - domain:google.com -
@@ -2019,11 +2028,12 @@ def sample_set_iam_policy():
20192028 condition: title: expirable access description:
20202029 Does not grant access after Sep 2020 expression:
20212030 request.time <
2022- timestamp('2020-10-01T00:00:00.000Z')
2031+ timestamp('2020-10-01T00:00:00.000Z') etag:
2032+ BwWWja0YfJA= version: 3
20232033
20242034 For a description of IAM and its features, see the
2025- [IAM developer's
2026- guide ](\ https://cloud.google.com/iam/docs).
2035+ [IAM
2036+ documentation ](\ https://cloud.google.com/iam/docs/ ).
20272037
20282038 """
20292039 # Create or coerce a protobuf request object.
@@ -2068,17 +2078,17 @@ async def test_iam_permissions(
20682078 r"""Tests IAM permissions for a resource (namespace or
20692079 service only).
20702080
2071-
20722081 .. code-block:: python
20732082
20742083 from google.cloud import servicedirectory_v1
2084+ from google.iam.v1 import iam_policy_pb2 # type: ignore
20752085
20762086 def sample_test_iam_permissions():
20772087 # Create a client
20782088 client = servicedirectory_v1.RegistrationServiceClient()
20792089
20802090 # Initialize request argument(s)
2081- request = servicedirectory_v1 .TestIamPermissionsRequest(
2091+ request = iam_policy_pb2 .TestIamPermissionsRequest(
20822092 resource="resource_value",
20832093 permissions=['permissions_value_1', 'permissions_value_2'],
20842094 )
0 commit comments