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
@@ -222,7 +222,6 @@ async def list_queues(
222
222
r"""Lists queues.
223
223
Queues are returned in lexicographical order.
224
224
225
-
226
225
.. code-block:: python
227
226
228
227
from google.cloud import tasks_v2
@@ -461,7 +460,6 @@ async def create_queue(
461
460
queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
462
461
before using this method.
463
462
464
-
465
463
.. code-block:: python
466
464
467
465
from google.cloud import tasks_v2
@@ -591,7 +589,6 @@ async def update_queue(
591
589
queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
592
590
before using this method.
593
591
594
-
595
592
.. code-block:: python
596
593
597
594
from google.cloud import tasks_v2
@@ -722,7 +719,6 @@ async def delete_queue(
722
719
queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`__
723
720
before using this method.
724
721
725
-
726
722
.. code-block:: python
727
723
728
724
from google.cloud import tasks_v2
@@ -821,7 +817,6 @@ async def purge_queue(
821
817
effect. Tasks might be dispatched before the purge takes
822
818
effect. A purge is irreversible.
823
819
824
-
825
820
.. code-block:: python
826
821
827
822
from google.cloud import tasks_v2
@@ -928,7 +923,6 @@ async def pause_queue(
928
923
paused if its [state][google.cloud.tasks.v2.Queue.state] is
929
924
[PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED].
930
925
931
-
932
926
.. code-block:: python
933
927
934
928
from google.cloud import tasks_v2
@@ -1042,7 +1036,6 @@ async def resume_queue(
1042
1036
Scaling
1043
1037
Risks <https://cloud.google.com/tasks/docs/manage-cloud-task-scaling>`__.
1044
1038
1045
-
1046
1039
.. code-block:: python
1047
1040
1048
1041
from google.cloud import tasks_v2
@@ -1150,17 +1143,17 @@ async def get_iam_policy(
1150
1143
1151
1144
- ``cloudtasks.queues.getIamPolicy``
1152
1145
1153
-
1154
1146
.. code-block:: python
1155
1147
1156
1148
from google.cloud import tasks_v2
1149
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1157
1150
1158
1151
def sample_get_iam_policy():
1159
1152
# Create a client
1160
1153
client = tasks_v2.CloudTasksClient()
1161
1154
1162
1155
# Initialize request argument(s)
1163
- request = tasks_v2 .GetIamPolicyRequest(
1156
+ request = iam_policy_pb2 .GetIamPolicyRequest(
1164
1157
resource="resource_value",
1165
1158
)
1166
1159
@@ -1191,21 +1184,26 @@ def sample_get_iam_policy():
1191
1184
1192
1185
Returns:
1193
1186
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.
1197
1189
1198
1190
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:**
1209
1207
1210
1208
{
1211
1209
"bindings": [
@@ -1220,17 +1218,17 @@ def sample_get_iam_policy():
1220
1218
1221
1219
}, { "role":
1222
1220
"roles/resourcemanager.organizationViewer",
1223
- "members": ["user:eve@example.com"],
1221
+ "members": [ "user:eve@example.com" ],
1224
1222
"condition": { "title": "expirable access",
1225
1223
"description": "Does not grant access after
1226
1224
Sep 2020", "expression": "request.time <
1227
1225
timestamp('2020-10-01T00:00:00.000Z')", } }
1228
1226
1229
- ]
1227
+ ], "etag": "BwWWja0YfJA=", "version": 3
1230
1228
1231
1229
}
1232
1230
1233
- **YAML Example **
1231
+ **YAML example: **
1234
1232
1235
1233
bindings: - members: - user:\ mike@example.com -
1236
1234
group:\ admins@example.com - domain:google.com -
@@ -1241,11 +1239,12 @@ def sample_get_iam_policy():
1241
1239
condition: title: expirable access description:
1242
1240
Does not grant access after Sep 2020 expression:
1243
1241
request.time <
1244
- timestamp('2020-10-01T00:00:00.000Z')
1242
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1243
+ BwWWja0YfJA= version: 3
1245
1244
1246
1245
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/ ).
1249
1248
1250
1249
"""
1251
1250
# Create or coerce a protobuf request object.
@@ -1325,17 +1324,17 @@ async def set_iam_policy(
1325
1324
1326
1325
- ``cloudtasks.queues.setIamPolicy``
1327
1326
1328
-
1329
1327
.. code-block:: python
1330
1328
1331
1329
from google.cloud import tasks_v2
1330
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1332
1331
1333
1332
def sample_set_iam_policy():
1334
1333
# Create a client
1335
1334
client = tasks_v2.CloudTasksClient()
1336
1335
1337
1336
# Initialize request argument(s)
1338
- request = tasks_v2 .SetIamPolicyRequest(
1337
+ request = iam_policy_pb2 .SetIamPolicyRequest(
1339
1338
resource="resource_value",
1340
1339
)
1341
1340
@@ -1366,21 +1365,26 @@ def sample_set_iam_policy():
1366
1365
1367
1366
Returns:
1368
1367
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.
1372
1370
1373
1371
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:**
1384
1388
1385
1389
{
1386
1390
"bindings": [
@@ -1395,17 +1399,17 @@ def sample_set_iam_policy():
1395
1399
1396
1400
}, { "role":
1397
1401
"roles/resourcemanager.organizationViewer",
1398
- "members": ["user:eve@example.com"],
1402
+ "members": [ "user:eve@example.com" ],
1399
1403
"condition": { "title": "expirable access",
1400
1404
"description": "Does not grant access after
1401
1405
Sep 2020", "expression": "request.time <
1402
1406
timestamp('2020-10-01T00:00:00.000Z')", } }
1403
1407
1404
- ]
1408
+ ], "etag": "BwWWja0YfJA=", "version": 3
1405
1409
1406
1410
}
1407
1411
1408
- **YAML Example **
1412
+ **YAML example: **
1409
1413
1410
1414
bindings: - members: - user:\ mike@example.com -
1411
1415
group:\ admins@example.com - domain:google.com -
@@ -1416,11 +1420,12 @@ def sample_set_iam_policy():
1416
1420
condition: title: expirable access description:
1417
1421
Does not grant access after Sep 2020 expression:
1418
1422
request.time <
1419
- timestamp('2020-10-01T00:00:00.000Z')
1423
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1424
+ BwWWja0YfJA= version: 3
1420
1425
1421
1426
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/ ).
1424
1429
1425
1430
"""
1426
1431
# Create or coerce a protobuf request object.
@@ -1487,17 +1492,17 @@ async def test_iam_permissions(
1487
1492
authorization checking. This operation may "fail open" without
1488
1493
warning.
1489
1494
1490
-
1491
1495
.. code-block:: python
1492
1496
1493
1497
from google.cloud import tasks_v2
1498
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1494
1499
1495
1500
def sample_test_iam_permissions():
1496
1501
# Create a client
1497
1502
client = tasks_v2.CloudTasksClient()
1498
1503
1499
1504
# Initialize request argument(s)
1500
- request = tasks_v2 .TestIamPermissionsRequest(
1505
+ request = iam_policy_pb2 .TestIamPermissionsRequest(
1501
1506
resource="resource_value",
1502
1507
permissions=['permissions_value_1', 'permissions_value_2'],
1503
1508
)
@@ -1615,7 +1620,6 @@ async def list_tasks(
1615
1620
The tasks may be returned in any order. The ordering may change
1616
1621
at any time.
1617
1622
1618
-
1619
1623
.. code-block:: python
1620
1624
1621
1625
from google.cloud import tasks_v2
@@ -1845,7 +1849,6 @@ async def create_task(
1845
1849
1846
1850
- The maximum task size is 100KB.
1847
1851
1848
-
1849
1852
.. code-block:: python
1850
1853
1851
1854
from google.cloud import tasks_v2
@@ -1992,7 +1995,6 @@ async def delete_task(
1992
1995
A task cannot be deleted if it has executed successfully
1993
1996
or permanently failed.
1994
1997
1995
-
1996
1998
.. code-block:: python
1997
1999
1998
2000
from google.cloud import tasks_v2
@@ -2113,7 +2115,6 @@ async def run_task(
2113
2115
[NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a
2114
2116
task that has already succeeded or permanently failed.
2115
2117
2116
-
2117
2118
.. code-block:: python
2118
2119
2119
2120
from google.cloud import tasks_v2
0 commit comments