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
@@ -253,17 +253,17 @@ async def set_iam_policy(
253
253
``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for
254
254
occurrences.
255
255
256
-
257
256
.. code-block:: python
258
257
259
258
from google.cloud.devtools import containeranalysis_v1
259
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
260
260
261
261
def sample_set_iam_policy():
262
262
# Create a client
263
263
client = containeranalysis_v1.ContainerAnalysisClient()
264
264
265
265
# Initialize request argument(s)
266
- request = containeranalysis_v1 .SetIamPolicyRequest(
266
+ request = iam_policy_pb2 .SetIamPolicyRequest(
267
267
resource="resource_value",
268
268
)
269
269
@@ -294,21 +294,26 @@ def sample_set_iam_policy():
294
294
295
295
Returns:
296
296
google.iam.v1.policy_pb2.Policy:
297
- Defines an Identity and Access Management (IAM) policy. It is used to
298
- specify access control policies for Cloud Platform
299
- resources.
297
+ An Identity and Access Management (IAM) policy, which specifies access
298
+ controls for Google Cloud resources.
300
299
301
300
A Policy is a collection of bindings. A binding binds
302
- one or more members to a single role. Members can be
303
- user accounts, service accounts, Google groups, and
304
- domains (such as G Suite). A role is a named list of
305
- permissions (defined by IAM or configured by users).
306
- A binding can optionally specify a condition, which
307
- is a logic expression that further constrains the
308
- role binding based on attributes about the request
309
- and/or target resource.
310
-
311
- **JSON Example**
301
+ one or more members, or principals, to a single role.
302
+ Principals can be user accounts, service accounts,
303
+ Google groups, and domains (such as G Suite). A role
304
+ is a named list of permissions; each role can be an
305
+ IAM predefined role or a user-created custom role.
306
+
307
+ For some types of Google Cloud resources, a binding
308
+ can also specify a condition, which is a logical
309
+ expression that allows access to a resource only if
310
+ the expression evaluates to true. A condition can add
311
+ constraints based on attributes of the request, the
312
+ resource, or both. To learn which resources support
313
+ conditions in their IAM policies, see the [IAM
314
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
315
+
316
+ **JSON example:**
312
317
313
318
{
314
319
"bindings": [
@@ -323,17 +328,17 @@ def sample_set_iam_policy():
323
328
324
329
}, { "role":
325
330
"roles/resourcemanager.organizationViewer",
326
- "members": ["user:[email protected] "],
331
+ "members": [ "user:[email protected] " ],
327
332
"condition": { "title": "expirable access",
328
333
"description": "Does not grant access after
329
334
Sep 2020", "expression": "request.time <
330
335
timestamp('2020-10-01T00:00:00.000Z')", } }
331
336
332
- ]
337
+ ], "etag": "BwWWja0YfJA=", "version": 3
333
338
334
339
}
335
340
336
- **YAML Example **
341
+ **YAML example: **
337
342
338
343
bindings: - members: - user:\ [email protected] -
339
344
group:\ [email protected] - domain:google.com -
@@ -344,11 +349,12 @@ def sample_set_iam_policy():
344
349
condition: title: expirable access description:
345
350
Does not grant access after Sep 2020 expression:
346
351
request.time <
347
- timestamp('2020-10-01T00:00:00.000Z')
352
+ timestamp('2020-10-01T00:00:00.000Z') etag:
353
+ BwWWja0YfJA= version: 3
348
354
349
355
For a description of IAM and its features, see the
350
- [IAM developer's
351
- guide ](\ https://cloud.google.com/iam/docs).
356
+ [IAM
357
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
352
358
353
359
"""
354
360
# Create or coerce a protobuf request object.
@@ -414,17 +420,17 @@ async def get_iam_policy(
414
420
``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for
415
421
occurrences.
416
422
417
-
418
423
.. code-block:: python
419
424
420
425
from google.cloud.devtools import containeranalysis_v1
426
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
421
427
422
428
def sample_get_iam_policy():
423
429
# Create a client
424
430
client = containeranalysis_v1.ContainerAnalysisClient()
425
431
426
432
# Initialize request argument(s)
427
- request = containeranalysis_v1 .GetIamPolicyRequest(
433
+ request = iam_policy_pb2 .GetIamPolicyRequest(
428
434
resource="resource_value",
429
435
)
430
436
@@ -455,21 +461,26 @@ def sample_get_iam_policy():
455
461
456
462
Returns:
457
463
google.iam.v1.policy_pb2.Policy:
458
- Defines an Identity and Access Management (IAM) policy. It is used to
459
- specify access control policies for Cloud Platform
460
- resources.
464
+ An Identity and Access Management (IAM) policy, which specifies access
465
+ controls for Google Cloud resources.
461
466
462
467
A Policy is a collection of bindings. A binding binds
463
- one or more members to a single role. Members can be
464
- user accounts, service accounts, Google groups, and
465
- domains (such as G Suite). A role is a named list of
466
- permissions (defined by IAM or configured by users).
467
- A binding can optionally specify a condition, which
468
- is a logic expression that further constrains the
469
- role binding based on attributes about the request
470
- and/or target resource.
471
-
472
- **JSON Example**
468
+ one or more members, or principals, to a single role.
469
+ Principals can be user accounts, service accounts,
470
+ Google groups, and domains (such as G Suite). A role
471
+ is a named list of permissions; each role can be an
472
+ IAM predefined role or a user-created custom role.
473
+
474
+ For some types of Google Cloud resources, a binding
475
+ can also specify a condition, which is a logical
476
+ expression that allows access to a resource only if
477
+ the expression evaluates to true. A condition can add
478
+ constraints based on attributes of the request, the
479
+ resource, or both. To learn which resources support
480
+ conditions in their IAM policies, see the [IAM
481
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
482
+
483
+ **JSON example:**
473
484
474
485
{
475
486
"bindings": [
@@ -484,17 +495,17 @@ def sample_get_iam_policy():
484
495
485
496
}, { "role":
486
497
"roles/resourcemanager.organizationViewer",
487
- "members": ["user:[email protected] "],
498
+ "members": [ "user:[email protected] " ],
488
499
"condition": { "title": "expirable access",
489
500
"description": "Does not grant access after
490
501
Sep 2020", "expression": "request.time <
491
502
timestamp('2020-10-01T00:00:00.000Z')", } }
492
503
493
- ]
504
+ ], "etag": "BwWWja0YfJA=", "version": 3
494
505
495
506
}
496
507
497
- **YAML Example **
508
+ **YAML example: **
498
509
499
510
bindings: - members: - user:\ [email protected] -
500
511
group:\ [email protected] - domain:google.com -
@@ -505,11 +516,12 @@ def sample_get_iam_policy():
505
516
condition: title: expirable access description:
506
517
Does not grant access after Sep 2020 expression:
507
518
request.time <
508
- timestamp('2020-10-01T00:00:00.000Z')
519
+ timestamp('2020-10-01T00:00:00.000Z') etag:
520
+ BwWWja0YfJA= version: 3
509
521
510
522
For a description of IAM and its features, see the
511
- [IAM developer's
512
- guide ](\ https://cloud.google.com/iam/docs).
523
+ [IAM
524
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
513
525
514
526
"""
515
527
# Create or coerce a protobuf request object.
@@ -575,17 +587,17 @@ async def test_iam_permissions(
575
587
``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for
576
588
occurrences.
577
589
578
-
579
590
.. code-block:: python
580
591
581
592
from google.cloud.devtools import containeranalysis_v1
593
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
582
594
583
595
def sample_test_iam_permissions():
584
596
# Create a client
585
597
client = containeranalysis_v1.ContainerAnalysisClient()
586
598
587
599
# Initialize request argument(s)
588
- request = containeranalysis_v1 .TestIamPermissionsRequest(
600
+ request = iam_policy_pb2 .TestIamPermissionsRequest(
589
601
resource="resource_value",
590
602
permissions=['permissions_value_1', 'permissions_value_2'],
591
603
)
@@ -688,7 +700,6 @@ async def get_vulnerability_occurrences_summary(
688
700
r"""Gets a summary of the number and severity of
689
701
occurrences.
690
702
691
-
692
703
.. code-block:: python
693
704
694
705
from google.cloud.devtools import containeranalysis_v1
0 commit comments