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
@@ -222,7 +222,6 @@ async def list_queues(
222222 r"""Lists queues.
223223 Queues are returned in lexicographical order.
224224
225-
226225 .. code-block:: python
227226
228227 from google.cloud import tasks_v2
@@ -461,7 +460,6 @@ async def create_queue(
461460 queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
462461 before using this method.
463462
464-
465463 .. code-block:: python
466464
467465 from google.cloud import tasks_v2
@@ -591,7 +589,6 @@ async def update_queue(
591589 queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
592590 before using this method.
593591
594-
595592 .. code-block:: python
596593
597594 from google.cloud import tasks_v2
@@ -722,7 +719,6 @@ async def delete_queue(
722719 queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
723720 before using this method.
724721
725-
726722 .. code-block:: python
727723
728724 from google.cloud import tasks_v2
@@ -821,7 +817,6 @@ async def purge_queue(
821817 effect. Tasks might be dispatched before the purge takes
822818 effect. A purge is irreversible.
823819
824-
825820 .. code-block:: python
826821
827822 from google.cloud import tasks_v2
@@ -928,7 +923,6 @@ async def pause_queue(
928923 paused if its [state][google.cloud.tasks.v2.Queue.state] is
929924 [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED].
930925
931-
932926 .. code-block:: python
933927
934928 from google.cloud import tasks_v2
@@ -1042,7 +1036,6 @@ async def resume_queue(
10421036 Scaling
10431037 Risks <https://cloud.google.com/tasks/docs/manage-cloud-task-scaling>`__.
10441038
1045-
10461039 .. code-block:: python
10471040
10481041 from google.cloud import tasks_v2
@@ -1150,17 +1143,17 @@ async def get_iam_policy(
11501143
11511144 - ``cloudtasks.queues.getIamPolicy``
11521145
1153-
11541146 .. code-block:: python
11551147
11561148 from google.cloud import tasks_v2
1149+ from google.iam.v1 import iam_policy_pb2 # type: ignore
11571150
11581151 def sample_get_iam_policy():
11591152 # Create a client
11601153 client = tasks_v2.CloudTasksClient()
11611154
11621155 # Initialize request argument(s)
1163- request = tasks_v2 .GetIamPolicyRequest(
1156+ request = iam_policy_pb2 .GetIamPolicyRequest(
11641157 resource="resource_value",
11651158 )
11661159
@@ -1191,21 +1184,26 @@ def sample_get_iam_policy():
11911184
11921185 Returns:
11931186 google.iam.v1.policy_pb2.Policy:
1194- Defines an Identity and Access Management (IAM) policy. It is used to
1195- specify access control policies for Cloud Platform
1196- resources.
1187+ An Identity and Access Management (IAM) policy, which specifies access
1188+ controls for Google Cloud resources.
11971189
11981190 A Policy is a collection of bindings. A binding binds
1199- one or more members to a single role. Members can be
1200- user accounts, service accounts, Google groups, and
1201- domains (such as G Suite). A role is a named list of
1202- permissions (defined by IAM or configured by users).
1203- A binding can optionally specify a condition, which
1204- is a logic expression that further constrains the
1205- role binding based on attributes about the request
1206- and/or target resource.
1207-
1208- **JSON Example**
1191+ one or more members, or principals, to a single role.
1192+ Principals can be user accounts, service accounts,
1193+ Google groups, and domains (such as G Suite). A role
1194+ is a named list of permissions; each role can be an
1195+ IAM predefined role or a user-created custom role.
1196+
1197+ For some types of Google Cloud resources, a binding
1198+ can also specify a condition, which is a logical
1199+ expression that allows access to a resource only if
1200+ the expression evaluates to true. A condition can add
1201+ constraints based on attributes of the request, the
1202+ resource, or both. To learn which resources support
1203+ conditions in their IAM policies, see the [IAM
1204+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1205+
1206+ **JSON example:**
12091207
12101208 {
12111209 "bindings": [
@@ -1220,17 +1218,17 @@ def sample_get_iam_policy():
12201218
12211219 }, { "role":
12221220 "roles/resourcemanager.organizationViewer",
1223- "members": ["user:eve@example.com"],
1221+ "members": [ "user:eve@example.com" ],
12241222 "condition": { "title": "expirable access",
12251223 "description": "Does not grant access after
12261224 Sep 2020", "expression": "request.time <
12271225 timestamp('2020-10-01T00:00:00.000Z')", } }
12281226
1229- ]
1227+ ], "etag": "BwWWja0YfJA=", "version": 3
12301228
12311229 }
12321230
1233- **YAML Example **
1231+ **YAML example: **
12341232
12351233 bindings: - members: - user:\ mike@example.com -
12361234 group:\ admins@example.com - domain:google.com -
@@ -1241,11 +1239,12 @@ def sample_get_iam_policy():
12411239 condition: title: expirable access description:
12421240 Does not grant access after Sep 2020 expression:
12431241 request.time <
1244- timestamp('2020-10-01T00:00:00.000Z')
1242+ timestamp('2020-10-01T00:00:00.000Z') etag:
1243+ BwWWja0YfJA= version: 3
12451244
12461245 For a description of IAM and its features, see the
1247- [IAM developer's
1248- guide ](\ https://cloud.google.com/iam/docs).
1246+ [IAM
1247+ documentation ](\ https://cloud.google.com/iam/docs/ ).
12491248
12501249 """
12511250 # Create or coerce a protobuf request object.
@@ -1325,17 +1324,17 @@ async def set_iam_policy(
13251324
13261325 - ``cloudtasks.queues.setIamPolicy``
13271326
1328-
13291327 .. code-block:: python
13301328
13311329 from google.cloud import tasks_v2
1330+ from google.iam.v1 import iam_policy_pb2 # type: ignore
13321331
13331332 def sample_set_iam_policy():
13341333 # Create a client
13351334 client = tasks_v2.CloudTasksClient()
13361335
13371336 # Initialize request argument(s)
1338- request = tasks_v2 .SetIamPolicyRequest(
1337+ request = iam_policy_pb2 .SetIamPolicyRequest(
13391338 resource="resource_value",
13401339 )
13411340
@@ -1366,21 +1365,26 @@ def sample_set_iam_policy():
13661365
13671366 Returns:
13681367 google.iam.v1.policy_pb2.Policy:
1369- Defines an Identity and Access Management (IAM) policy. It is used to
1370- specify access control policies for Cloud Platform
1371- resources.
1368+ An Identity and Access Management (IAM) policy, which specifies access
1369+ controls for Google Cloud resources.
13721370
13731371 A Policy is a collection of bindings. A binding binds
1374- one or more members to a single role. Members can be
1375- user accounts, service accounts, Google groups, and
1376- domains (such as G Suite). A role is a named list of
1377- permissions (defined by IAM or configured by users).
1378- A binding can optionally specify a condition, which
1379- is a logic expression that further constrains the
1380- role binding based on attributes about the request
1381- and/or target resource.
1382-
1383- **JSON Example**
1372+ one or more members, or principals, to a single role.
1373+ Principals can be user accounts, service accounts,
1374+ Google groups, and domains (such as G Suite). A role
1375+ is a named list of permissions; each role can be an
1376+ IAM predefined role or a user-created custom role.
1377+
1378+ For some types of Google Cloud resources, a binding
1379+ can also specify a condition, which is a logical
1380+ expression that allows access to a resource only if
1381+ the expression evaluates to true. A condition can add
1382+ constraints based on attributes of the request, the
1383+ resource, or both. To learn which resources support
1384+ conditions in their IAM policies, see the [IAM
1385+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1386+
1387+ **JSON example:**
13841388
13851389 {
13861390 "bindings": [
@@ -1395,17 +1399,17 @@ def sample_set_iam_policy():
13951399
13961400 }, { "role":
13971401 "roles/resourcemanager.organizationViewer",
1398- "members": ["user:eve@example.com"],
1402+ "members": [ "user:eve@example.com" ],
13991403 "condition": { "title": "expirable access",
14001404 "description": "Does not grant access after
14011405 Sep 2020", "expression": "request.time <
14021406 timestamp('2020-10-01T00:00:00.000Z')", } }
14031407
1404- ]
1408+ ], "etag": "BwWWja0YfJA=", "version": 3
14051409
14061410 }
14071411
1408- **YAML Example **
1412+ **YAML example: **
14091413
14101414 bindings: - members: - user:\ mike@example.com -
14111415 group:\ admins@example.com - domain:google.com -
@@ -1416,11 +1420,12 @@ def sample_set_iam_policy():
14161420 condition: title: expirable access description:
14171421 Does not grant access after Sep 2020 expression:
14181422 request.time <
1419- timestamp('2020-10-01T00:00:00.000Z')
1423+ timestamp('2020-10-01T00:00:00.000Z') etag:
1424+ BwWWja0YfJA= version: 3
14201425
14211426 For a description of IAM and its features, see the
1422- [IAM developer's
1423- guide ](\ https://cloud.google.com/iam/docs).
1427+ [IAM
1428+ documentation ](\ https://cloud.google.com/iam/docs/ ).
14241429
14251430 """
14261431 # Create or coerce a protobuf request object.
@@ -1487,17 +1492,17 @@ async def test_iam_permissions(
14871492 authorization checking. This operation may "fail open" without
14881493 warning.
14891494
1490-
14911495 .. code-block:: python
14921496
14931497 from google.cloud import tasks_v2
1498+ from google.iam.v1 import iam_policy_pb2 # type: ignore
14941499
14951500 def sample_test_iam_permissions():
14961501 # Create a client
14971502 client = tasks_v2.CloudTasksClient()
14981503
14991504 # Initialize request argument(s)
1500- request = tasks_v2 .TestIamPermissionsRequest(
1505+ request = iam_policy_pb2 .TestIamPermissionsRequest(
15011506 resource="resource_value",
15021507 permissions=['permissions_value_1', 'permissions_value_2'],
15031508 )
@@ -1615,7 +1620,6 @@ async def list_tasks(
16151620 The tasks may be returned in any order. The ordering may change
16161621 at any time.
16171622
1618-
16191623 .. code-block:: python
16201624
16211625 from google.cloud import tasks_v2
@@ -1845,7 +1849,6 @@ async def create_task(
18451849
18461850 - The maximum task size is 100KB.
18471851
1848-
18491852 .. code-block:: python
18501853
18511854 from google.cloud import tasks_v2
@@ -1992,7 +1995,6 @@ async def delete_task(
19921995 A task cannot be deleted if it has executed successfully
19931996 or permanently failed.
19941997
1995-
19961998 .. code-block:: python
19971999
19982000 from google.cloud import tasks_v2
@@ -2113,7 +2115,6 @@ async def run_task(
21132115 [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a
21142116 task that has already succeeded or permanently failed.
21152117
2116-
21172118 .. code-block:: python
21182119
21192120 from google.cloud import tasks_v2
0 commit comments