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
@@ -1280,7 +1280,6 @@ async def modify_cloud_to_device_config(
12801280 eventually sent from the Cloud IoT Core servers. Returns
12811281 the modified configuration version and its metadata.
12821282
1283-
12841283 .. code-block:: python
12851284
12861285 from google.cloud import iot_v1
@@ -1400,7 +1399,6 @@ async def list_device_config_versions(
14001399 r"""Lists the last few versions of the device
14011400 configuration in descending order (i.e.: newest first).
14021401
1403-
14041402 .. code-block:: python
14051403
14061404 from google.cloud import iot_v1
@@ -1507,7 +1505,6 @@ async def list_device_states(
15071505 r"""Lists the last few versions of the device state in
15081506 descending order (i.e.: newest first).
15091507
1510-
15111508 .. code-block:: python
15121509
15131510 from google.cloud import iot_v1
@@ -1613,17 +1610,17 @@ async def set_iam_policy(
16131610 r"""Sets the access control policy on the specified
16141611 resource. Replaces any existing policy.
16151612
1616-
16171613 .. code-block:: python
16181614
16191615 from google.cloud import iot_v1
1616+ from google.iam.v1 import iam_policy_pb2 # type: ignore
16201617
16211618 def sample_set_iam_policy():
16221619 # Create a client
16231620 client = iot_v1.DeviceManagerClient()
16241621
16251622 # Initialize request argument(s)
1626- request = iot_v1 .SetIamPolicyRequest(
1623+ request = iam_policy_pb2 .SetIamPolicyRequest(
16271624 resource="resource_value",
16281625 )
16291626
@@ -1654,21 +1651,26 @@ def sample_set_iam_policy():
16541651
16551652 Returns:
16561653 google.iam.v1.policy_pb2.Policy:
1657- Defines an Identity and Access Management (IAM) policy. It is used to
1658- specify access control policies for Cloud Platform
1659- resources.
1654+ An Identity and Access Management (IAM) policy, which specifies access
1655+ controls for Google Cloud resources.
16601656
16611657 A Policy is a collection of bindings. A binding binds
1662- one or more members to a single role. Members can be
1663- user accounts, service accounts, Google groups, and
1664- domains (such as G Suite). A role is a named list of
1665- permissions (defined by IAM or configured by users).
1666- A binding can optionally specify a condition, which
1667- is a logic expression that further constrains the
1668- role binding based on attributes about the request
1669- and/or target resource.
1670-
1671- **JSON Example**
1658+ one or more members, or principals, to a single role.
1659+ Principals can be user accounts, service accounts,
1660+ Google groups, and domains (such as G Suite). A role
1661+ is a named list of permissions; each role can be an
1662+ IAM predefined role or a user-created custom role.
1663+
1664+ For some types of Google Cloud resources, a binding
1665+ can also specify a condition, which is a logical
1666+ expression that allows access to a resource only if
1667+ the expression evaluates to true. A condition can add
1668+ constraints based on attributes of the request, the
1669+ resource, or both. To learn which resources support
1670+ conditions in their IAM policies, see the [IAM
1671+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1672+
1673+ **JSON example:**
16721674
16731675 {
16741676 "bindings": [
@@ -1683,17 +1685,17 @@ def sample_set_iam_policy():
16831685
16841686 }, { "role":
16851687 "roles/resourcemanager.organizationViewer",
1686- "members": ["user:eve@example.com"],
1688+ "members": [ "user:eve@example.com" ],
16871689 "condition": { "title": "expirable access",
16881690 "description": "Does not grant access after
16891691 Sep 2020", "expression": "request.time <
16901692 timestamp('2020-10-01T00:00:00.000Z')", } }
16911693
1692- ]
1694+ ], "etag": "BwWWja0YfJA=", "version": 3
16931695
16941696 }
16951697
1696- **YAML Example **
1698+ **YAML example: **
16971699
16981700 bindings: - members: - user:\ mike@example.com -
16991701 group:\ admins@example.com - domain:google.com -
@@ -1704,11 +1706,12 @@ def sample_set_iam_policy():
17041706 condition: title: expirable access description:
17051707 Does not grant access after Sep 2020 expression:
17061708 request.time <
1707- timestamp('2020-10-01T00:00:00.000Z')
1709+ timestamp('2020-10-01T00:00:00.000Z') etag:
1710+ BwWWja0YfJA= version: 3
17081711
17091712 For a description of IAM and its features, see the
1710- [IAM developer's
1711- guide ](\ https://cloud.google.com/iam/docs).
1713+ [IAM
1714+ documentation ](\ https://cloud.google.com/iam/docs/ ).
17121715
17131716 """
17141717 # Create or coerce a protobuf request object.
@@ -1768,17 +1771,17 @@ async def get_iam_policy(
17681771 Returns an empty policy if the resource exists and does
17691772 not have a policy set.
17701773
1771-
17721774 .. code-block:: python
17731775
17741776 from google.cloud import iot_v1
1777+ from google.iam.v1 import iam_policy_pb2 # type: ignore
17751778
17761779 def sample_get_iam_policy():
17771780 # Create a client
17781781 client = iot_v1.DeviceManagerClient()
17791782
17801783 # Initialize request argument(s)
1781- request = iot_v1 .GetIamPolicyRequest(
1784+ request = iam_policy_pb2 .GetIamPolicyRequest(
17821785 resource="resource_value",
17831786 )
17841787
@@ -1809,21 +1812,26 @@ def sample_get_iam_policy():
18091812
18101813 Returns:
18111814 google.iam.v1.policy_pb2.Policy:
1812- Defines an Identity and Access Management (IAM) policy. It is used to
1813- specify access control policies for Cloud Platform
1814- resources.
1815+ An Identity and Access Management (IAM) policy, which specifies access
1816+ controls for Google Cloud resources.
18151817
18161818 A Policy is a collection of bindings. A binding binds
1817- one or more members to a single role. Members can be
1818- user accounts, service accounts, Google groups, and
1819- domains (such as G Suite). A role is a named list of
1820- permissions (defined by IAM or configured by users).
1821- A binding can optionally specify a condition, which
1822- is a logic expression that further constrains the
1823- role binding based on attributes about the request
1824- and/or target resource.
1825-
1826- **JSON Example**
1819+ one or more members, or principals, to a single role.
1820+ Principals can be user accounts, service accounts,
1821+ Google groups, and domains (such as G Suite). A role
1822+ is a named list of permissions; each role can be an
1823+ IAM predefined role or a user-created custom role.
1824+
1825+ For some types of Google Cloud resources, a binding
1826+ can also specify a condition, which is a logical
1827+ expression that allows access to a resource only if
1828+ the expression evaluates to true. A condition can add
1829+ constraints based on attributes of the request, the
1830+ resource, or both. To learn which resources support
1831+ conditions in their IAM policies, see the [IAM
1832+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1833+
1834+ **JSON example:**
18271835
18281836 {
18291837 "bindings": [
@@ -1838,17 +1846,17 @@ def sample_get_iam_policy():
18381846
18391847 }, { "role":
18401848 "roles/resourcemanager.organizationViewer",
1841- "members": ["user:eve@example.com"],
1849+ "members": [ "user:eve@example.com" ],
18421850 "condition": { "title": "expirable access",
18431851 "description": "Does not grant access after
18441852 Sep 2020", "expression": "request.time <
18451853 timestamp('2020-10-01T00:00:00.000Z')", } }
18461854
1847- ]
1855+ ], "etag": "BwWWja0YfJA=", "version": 3
18481856
18491857 }
18501858
1851- **YAML Example **
1859+ **YAML example: **
18521860
18531861 bindings: - members: - user:\ mike@example.com -
18541862 group:\ admins@example.com - domain:google.com -
@@ -1859,11 +1867,12 @@ def sample_get_iam_policy():
18591867 condition: title: expirable access description:
18601868 Does not grant access after Sep 2020 expression:
18611869 request.time <
1862- timestamp('2020-10-01T00:00:00.000Z')
1870+ timestamp('2020-10-01T00:00:00.000Z') etag:
1871+ BwWWja0YfJA= version: 3
18631872
18641873 For a description of IAM and its features, see the
1865- [IAM developer's
1866- guide ](\ https://cloud.google.com/iam/docs).
1874+ [IAM
1875+ documentation ](\ https://cloud.google.com/iam/docs/ ).
18671876
18681877 """
18691878 # Create or coerce a protobuf request object.
@@ -1924,17 +1933,17 @@ async def test_iam_permissions(
19241933 If the resource does not exist, this will return an empty set of
19251934 permissions, not a NOT_FOUND error.
19261935
1927-
19281936 .. code-block:: python
19291937
19301938 from google.cloud import iot_v1
1939+ from google.iam.v1 import iam_policy_pb2 # type: ignore
19311940
19321941 def sample_test_iam_permissions():
19331942 # Create a client
19341943 client = iot_v1.DeviceManagerClient()
19351944
19361945 # Initialize request argument(s)
1937- request = iot_v1 .TestIamPermissionsRequest(
1946+ request = iam_policy_pb2 .TestIamPermissionsRequest(
19381947 resource="resource_value",
19391948 permissions=['permissions_value_1', 'permissions_value_2'],
19401949 )
@@ -2051,7 +2060,6 @@ async def send_command_to_device(
20512060 guaranteed; for QoS 0, no acknowledgment will be expected
20522061 from the device.
20532062
2054-
20552063 .. code-block:: python
20562064
20572065 from google.cloud import iot_v1
@@ -2303,7 +2311,6 @@ async def unbind_device_from_gateway(
23032311 r"""Deletes the association between the device and the
23042312 gateway.
23052313
2306-
23072314 .. code-block:: python
23082315
23092316 from google.cloud import iot_v1
0 commit comments