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
@@ -347,7 +347,6 @@ async def create_secret(
347
347
containing no
348
348
[SecretVersions][google.cloud.secretmanager.v1.SecretVersion].
349
349
350
-
351
350
.. code-block:: python
352
351
353
352
from google.cloud import secretmanager_v1
@@ -477,7 +476,6 @@ async def add_secret_version(
477
476
containing secret data and attaches it to an existing
478
477
[Secret][google.cloud.secretmanager.v1.Secret].
479
478
480
-
481
479
.. code-block:: python
482
480
483
481
from google.cloud import secretmanager_v1
@@ -586,7 +584,6 @@ async def get_secret(
586
584
r"""Gets metadata for a given
587
585
[Secret][google.cloud.secretmanager.v1.Secret].
588
586
589
-
590
587
.. code-block:: python
591
588
592
589
from google.cloud import secretmanager_v1
@@ -690,7 +687,6 @@ async def update_secret(
690
687
r"""Updates metadata of an existing
691
688
[Secret][google.cloud.secretmanager.v1.Secret].
692
689
693
-
694
690
.. code-block:: python
695
691
696
692
from google.cloud import secretmanager_v1
@@ -887,7 +883,6 @@ async def list_secret_versions(
887
883
[SecretVersions][google.cloud.secretmanager.v1.SecretVersion].
888
884
This call does not return secret data.
889
885
890
-
891
886
.. code-block:: python
892
887
893
888
from google.cloud import secretmanager_v1
@@ -1004,7 +999,6 @@ async def get_secret_version(
1004
999
recently created
1005
1000
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
1006
1001
1007
-
1008
1002
.. code-block:: python
1009
1003
1010
1004
from google.cloud import secretmanager_v1
@@ -1111,7 +1105,6 @@ async def access_secret_version(
1111
1105
recently created
1112
1106
[SecretVersion][google.cloud.secretmanager.v1.SecretVersion].
1113
1107
1114
-
1115
1108
.. code-block:: python
1116
1109
1117
1110
from google.cloud import secretmanager_v1
@@ -1229,7 +1222,6 @@ async def disable_secret_version(
1229
1222
to
1230
1223
[DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED].
1231
1224
1232
-
1233
1225
.. code-block:: python
1234
1226
1235
1227
from google.cloud import secretmanager_v1
@@ -1334,7 +1326,6 @@ async def enable_secret_version(
1334
1326
to
1335
1327
[ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED].
1336
1328
1337
-
1338
1329
.. code-block:: python
1339
1330
1340
1331
from google.cloud import secretmanager_v1
@@ -1440,7 +1431,6 @@ async def destroy_secret_version(
1440
1431
[DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED]
1441
1432
and irrevocably destroys the secret data.
1442
1433
1443
-
1444
1434
.. code-block:: python
1445
1435
1446
1436
from google.cloud import secretmanager_v1
@@ -1543,17 +1533,17 @@ async def set_iam_policy(
1543
1533
are enforced according to the policy set on the associated
1544
1534
[Secret][google.cloud.secretmanager.v1.Secret].
1545
1535
1546
-
1547
1536
.. code-block:: python
1548
1537
1549
1538
from google.cloud import secretmanager_v1
1539
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1550
1540
1551
1541
def sample_set_iam_policy():
1552
1542
# Create a client
1553
1543
client = secretmanager_v1.SecretManagerServiceClient()
1554
1544
1555
1545
# Initialize request argument(s)
1556
- request = secretmanager_v1 .SetIamPolicyRequest(
1546
+ request = iam_policy_pb2 .SetIamPolicyRequest(
1557
1547
resource="resource_value",
1558
1548
)
1559
1549
@@ -1575,21 +1565,26 @@ def sample_set_iam_policy():
1575
1565
1576
1566
Returns:
1577
1567
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.
1581
1570
1582
1571
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:**
1593
1588
1594
1589
{
1595
1590
"bindings": [
@@ -1604,17 +1599,17 @@ def sample_set_iam_policy():
1604
1599
1605
1600
}, { "role":
1606
1601
"roles/resourcemanager.organizationViewer",
1607
- "members": ["user:[email protected] "],
1602
+ "members": [ "user:[email protected] " ],
1608
1603
"condition": { "title": "expirable access",
1609
1604
"description": "Does not grant access after
1610
1605
Sep 2020", "expression": "request.time <
1611
1606
timestamp('2020-10-01T00:00:00.000Z')", } }
1612
1607
1613
- ]
1608
+ ], "etag": "BwWWja0YfJA=", "version": 3
1614
1609
1615
1610
}
1616
1611
1617
- **YAML Example **
1612
+ **YAML example: **
1618
1613
1619
1614
bindings: - members: - user:\ [email protected] -
1620
1615
group:\ [email protected] - domain:google.com -
@@ -1625,11 +1620,12 @@ def sample_set_iam_policy():
1625
1620
condition: title: expirable access description:
1626
1621
Does not grant access after Sep 2020 expression:
1627
1622
request.time <
1628
- timestamp('2020-10-01T00:00:00.000Z')
1623
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1624
+ BwWWja0YfJA= version: 3
1629
1625
1630
1626
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/ ).
1633
1629
1634
1630
"""
1635
1631
# Create or coerce a protobuf request object.
@@ -1675,17 +1671,17 @@ async def get_iam_policy(
1675
1671
Returns empty policy if the secret exists and does not
1676
1672
have a policy set.
1677
1673
1678
-
1679
1674
.. code-block:: python
1680
1675
1681
1676
from google.cloud import secretmanager_v1
1677
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1682
1678
1683
1679
def sample_get_iam_policy():
1684
1680
# Create a client
1685
1681
client = secretmanager_v1.SecretManagerServiceClient()
1686
1682
1687
1683
# Initialize request argument(s)
1688
- request = secretmanager_v1 .GetIamPolicyRequest(
1684
+ request = iam_policy_pb2 .GetIamPolicyRequest(
1689
1685
resource="resource_value",
1690
1686
)
1691
1687
@@ -1707,21 +1703,26 @@ def sample_get_iam_policy():
1707
1703
1708
1704
Returns:
1709
1705
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.
1713
1708
1714
1709
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:**
1725
1726
1726
1727
{
1727
1728
"bindings": [
@@ -1736,17 +1737,17 @@ def sample_get_iam_policy():
1736
1737
1737
1738
}, { "role":
1738
1739
"roles/resourcemanager.organizationViewer",
1739
- "members": ["user:[email protected] "],
1740
+ "members": [ "user:[email protected] " ],
1740
1741
"condition": { "title": "expirable access",
1741
1742
"description": "Does not grant access after
1742
1743
Sep 2020", "expression": "request.time <
1743
1744
timestamp('2020-10-01T00:00:00.000Z')", } }
1744
1745
1745
- ]
1746
+ ], "etag": "BwWWja0YfJA=", "version": 3
1746
1747
1747
1748
}
1748
1749
1749
- **YAML Example **
1750
+ **YAML example: **
1750
1751
1751
1752
bindings: - members: - user:\ [email protected] -
1752
1753
group:\ [email protected] - domain:google.com -
@@ -1757,11 +1758,12 @@ def sample_get_iam_policy():
1757
1758
condition: title: expirable access description:
1758
1759
Does not grant access after Sep 2020 expression:
1759
1760
request.time <
1760
- timestamp('2020-10-01T00:00:00.000Z')
1761
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1762
+ BwWWja0YfJA= version: 3
1761
1763
1762
1764
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/ ).
1765
1767
1766
1768
"""
1767
1769
# Create or coerce a protobuf request object.
@@ -1812,17 +1814,17 @@ async def test_iam_permissions(
1812
1814
authorization checking. This operation may "fail open" without
1813
1815
warning.
1814
1816
1815
-
1816
1817
.. code-block:: python
1817
1818
1818
1819
from google.cloud import secretmanager_v1
1820
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1819
1821
1820
1822
def sample_test_iam_permissions():
1821
1823
# Create a client
1822
1824
client = secretmanager_v1.SecretManagerServiceClient()
1823
1825
1824
1826
# Initialize request argument(s)
1825
- request = secretmanager_v1 .TestIamPermissionsRequest(
1827
+ request = iam_policy_pb2 .TestIamPermissionsRequest(
1826
1828
resource="resource_value",
1827
1829
permissions=['permissions_value_1', 'permissions_value_2'],
1828
1830
)
0 commit comments