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
@@ -347,7 +347,6 @@ async def create_secret(
347347 containing no
348348 [SecretVersions][google.cloud.secretmanager.v1.SecretVersion].
349349
350-
351350 .. code-block:: python
352351
353352 from google.cloud import secretmanager_v1
@@ -477,7 +476,6 @@ async def add_secret_version(
477476 containing secret data and attaches it to an existing
478477 [Secret][google.cloud.secretmanager.v1.Secret].
479478
480-
481479 .. code-block:: python
482480
483481 from google.cloud import secretmanager_v1
@@ -586,7 +584,6 @@ async def get_secret(
586584 r"""Gets metadata for a given
587585 [Secret][google.cloud.secretmanager.v1.Secret].
588586
589-
590587 .. code-block:: python
591588
592589 from google.cloud import secretmanager_v1
@@ -690,7 +687,6 @@ async def update_secret(
690687 r"""Updates metadata of an existing
691688 [Secret][google.cloud.secretmanager.v1.Secret].
692689
693-
694690 .. code-block:: python
695691
696692 from google.cloud import secretmanager_v1
@@ -887,7 +883,6 @@ async def list_secret_versions(
887883 [SecretVersions][google.cloud.secretmanager.v1.SecretVersion].
888884 This call does not return secret data.
889885
890-
891886 .. code-block:: python
892887
893888 from google.cloud import secretmanager_v1
@@ -1004,7 +999,6 @@ async def get_secret_version(
1004999 recently created
10051000 [SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
10061001
1007-
10081002 .. code-block:: python
10091003
10101004 from google.cloud import secretmanager_v1
@@ -1111,7 +1105,6 @@ async def access_secret_version(
11111105 recently created
11121106 [SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
11131107
1114-
11151108 .. code-block:: python
11161109
11171110 from google.cloud import secretmanager_v1
@@ -1229,7 +1222,6 @@ async def disable_secret_version(
12291222 to
12301223 [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED].
12311224
1232-
12331225 .. code-block:: python
12341226
12351227 from google.cloud import secretmanager_v1
@@ -1334,7 +1326,6 @@ async def enable_secret_version(
13341326 to
13351327 [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED].
13361328
1337-
13381329 .. code-block:: python
13391330
13401331 from google.cloud import secretmanager_v1
@@ -1440,7 +1431,6 @@ async def destroy_secret_version(
14401431 [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED]
14411432 and irrevocably destroys the secret data.
14421433
1443-
14441434 .. code-block:: python
14451435
14461436 from google.cloud import secretmanager_v1
@@ -1543,17 +1533,17 @@ async def set_iam_policy(
15431533 are enforced according to the policy set on the associated
15441534 [Secret][google.cloud.secretmanager.v1.Secret].
15451535
1546-
15471536 .. code-block:: python
15481537
15491538 from google.cloud import secretmanager_v1
1539+ from google.iam.v1 import iam_policy_pb2 # type: ignore
15501540
15511541 def sample_set_iam_policy():
15521542 # Create a client
15531543 client = secretmanager_v1.SecretManagerServiceClient()
15541544
15551545 # Initialize request argument(s)
1556- request = secretmanager_v1 .SetIamPolicyRequest(
1546+ request = iam_policy_pb2 .SetIamPolicyRequest(
15571547 resource="resource_value",
15581548 )
15591549
@@ -1575,21 +1565,26 @@ def sample_set_iam_policy():
15751565
15761566 Returns:
15771567 google.iam.v1.policy_pb2.Policy:
1578- Defines an Identity and Access Management (IAM) policy. It is used to
1579- specify access control policies for Cloud Platform
1580- resources.
1568+ An Identity and Access Management (IAM) policy, which specifies access
1569+ controls for Google Cloud resources.
15811570
15821571 A Policy is a collection of bindings. A binding binds
1583- one or more members to a single role. Members can be
1584- user accounts, service accounts, Google groups, and
1585- domains (such as G Suite). A role is a named list of
1586- permissions (defined by IAM or configured by users).
1587- A binding can optionally specify a condition, which
1588- is a logic expression that further constrains the
1589- role binding based on attributes about the request
1590- and/or target resource.
1591-
1592- **JSON Example**
1572+ one or more members, or principals, to a single role.
1573+ Principals can be user accounts, service accounts,
1574+ Google groups, and domains (such as G Suite). A role
1575+ is a named list of permissions; each role can be an
1576+ IAM predefined role or a user-created custom role.
1577+
1578+ For some types of Google Cloud resources, a binding
1579+ can also specify a condition, which is a logical
1580+ expression that allows access to a resource only if
1581+ the expression evaluates to true. A condition can add
1582+ constraints based on attributes of the request, the
1583+ resource, or both. To learn which resources support
1584+ conditions in their IAM policies, see the [IAM
1585+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1586+
1587+ **JSON example:**
15931588
15941589 {
15951590 "bindings": [
@@ -1604,17 +1599,17 @@ def sample_set_iam_policy():
16041599
16051600 }, { "role":
16061601 "roles/resourcemanager.organizationViewer",
1607- "members": ["user:eve@example.com"],
1602+ "members": [ "user:eve@example.com" ],
16081603 "condition": { "title": "expirable access",
16091604 "description": "Does not grant access after
16101605 Sep 2020", "expression": "request.time <
16111606 timestamp('2020-10-01T00:00:00.000Z')", } }
16121607
1613- ]
1608+ ], "etag": "BwWWja0YfJA=", "version": 3
16141609
16151610 }
16161611
1617- **YAML Example **
1612+ **YAML example: **
16181613
16191614 bindings: - members: - user:\ mike@example.com -
16201615 group:\ admins@example.com - domain:google.com -
@@ -1625,11 +1620,12 @@ def sample_set_iam_policy():
16251620 condition: title: expirable access description:
16261621 Does not grant access after Sep 2020 expression:
16271622 request.time <
1628- timestamp('2020-10-01T00:00:00.000Z')
1623+ timestamp('2020-10-01T00:00:00.000Z') etag:
1624+ BwWWja0YfJA= version: 3
16291625
16301626 For a description of IAM and its features, see the
1631- [IAM developer's
1632- guide ](\ https://cloud.google.com/iam/docs).
1627+ [IAM
1628+ documentation ](\ https://cloud.google.com/iam/docs/ ).
16331629
16341630 """
16351631 # Create or coerce a protobuf request object.
@@ -1675,17 +1671,17 @@ async def get_iam_policy(
16751671 Returns empty policy if the secret exists and does not
16761672 have a policy set.
16771673
1678-
16791674 .. code-block:: python
16801675
16811676 from google.cloud import secretmanager_v1
1677+ from google.iam.v1 import iam_policy_pb2 # type: ignore
16821678
16831679 def sample_get_iam_policy():
16841680 # Create a client
16851681 client = secretmanager_v1.SecretManagerServiceClient()
16861682
16871683 # Initialize request argument(s)
1688- request = secretmanager_v1 .GetIamPolicyRequest(
1684+ request = iam_policy_pb2 .GetIamPolicyRequest(
16891685 resource="resource_value",
16901686 )
16911687
@@ -1707,21 +1703,26 @@ def sample_get_iam_policy():
17071703
17081704 Returns:
17091705 google.iam.v1.policy_pb2.Policy:
1710- Defines an Identity and Access Management (IAM) policy. It is used to
1711- specify access control policies for Cloud Platform
1712- resources.
1706+ An Identity and Access Management (IAM) policy, which specifies access
1707+ controls for Google Cloud resources.
17131708
17141709 A Policy is a collection of bindings. A binding binds
1715- one or more members to a single role. Members can be
1716- user accounts, service accounts, Google groups, and
1717- domains (such as G Suite). A role is a named list of
1718- permissions (defined by IAM or configured by users).
1719- A binding can optionally specify a condition, which
1720- is a logic expression that further constrains the
1721- role binding based on attributes about the request
1722- and/or target resource.
1723-
1724- **JSON Example**
1710+ one or more members, or principals, to a single role.
1711+ Principals can be user accounts, service accounts,
1712+ Google groups, and domains (such as G Suite). A role
1713+ is a named list of permissions; each role can be an
1714+ IAM predefined role or a user-created custom role.
1715+
1716+ For some types of Google Cloud resources, a binding
1717+ can also specify a condition, which is a logical
1718+ expression that allows access to a resource only if
1719+ the expression evaluates to true. A condition can add
1720+ constraints based on attributes of the request, the
1721+ resource, or both. To learn which resources support
1722+ conditions in their IAM policies, see the [IAM
1723+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1724+
1725+ **JSON example:**
17251726
17261727 {
17271728 "bindings": [
@@ -1736,17 +1737,17 @@ def sample_get_iam_policy():
17361737
17371738 }, { "role":
17381739 "roles/resourcemanager.organizationViewer",
1739- "members": ["user:eve@example.com"],
1740+ "members": [ "user:eve@example.com" ],
17401741 "condition": { "title": "expirable access",
17411742 "description": "Does not grant access after
17421743 Sep 2020", "expression": "request.time <
17431744 timestamp('2020-10-01T00:00:00.000Z')", } }
17441745
1745- ]
1746+ ], "etag": "BwWWja0YfJA=", "version": 3
17461747
17471748 }
17481749
1749- **YAML Example **
1750+ **YAML example: **
17501751
17511752 bindings: - members: - user:\ mike@example.com -
17521753 group:\ admins@example.com - domain:google.com -
@@ -1757,11 +1758,12 @@ def sample_get_iam_policy():
17571758 condition: title: expirable access description:
17581759 Does not grant access after Sep 2020 expression:
17591760 request.time <
1760- timestamp('2020-10-01T00:00:00.000Z')
1761+ timestamp('2020-10-01T00:00:00.000Z') etag:
1762+ BwWWja0YfJA= version: 3
17611763
17621764 For a description of IAM and its features, see the
1763- [IAM developer's
1764- guide ](\ https://cloud.google.com/iam/docs).
1765+ [IAM
1766+ documentation ](\ https://cloud.google.com/iam/docs/ ).
17651767
17661768 """
17671769 # Create or coerce a protobuf request object.
@@ -1812,17 +1814,17 @@ async def test_iam_permissions(
18121814 authorization checking. This operation may "fail open" without
18131815 warning.
18141816
1815-
18161817 .. code-block:: python
18171818
18181819 from google.cloud import secretmanager_v1
1820+ from google.iam.v1 import iam_policy_pb2 # type: ignore
18191821
18201822 def sample_test_iam_permissions():
18211823 # Create a client
18221824 client = secretmanager_v1.SecretManagerServiceClient()
18231825
18241826 # Initialize request argument(s)
1825- request = secretmanager_v1 .TestIamPermissionsRequest(
1827+ request = iam_policy_pb2 .TestIamPermissionsRequest(
18261828 resource="resource_value",
18271829 permissions=['permissions_value_1', 'permissions_value_2'],
18281830 )
0 commit comments