|
19 | 19 |
|
20 | 20 |
|
21 | 21 | def quickstart(project_id: str, member: str) -> None: |
22 | | - """Gets a policy, adds a member, prints their permissions, and removes the member. |
| 22 | + """Gets a policy, adds a principal, prints their permissions, and removes the principal. |
23 | 23 |
|
24 | 24 | project_id: ID or number of the Google Cloud project you want to use. |
25 | | - member: The principals requesting the access. |
| 25 | + member: The principal requesting the access. |
26 | 26 | """ |
27 | 27 |
|
28 | 28 | # Role to be granted. |
29 | 29 | role = "roles/logging.logWriter" |
30 | 30 | crm_service = resourcemanager_v3.ProjectsClient() |
31 | 31 |
|
32 | | - # Grants your member the 'Log Writer' role for the project. |
| 32 | + # Grants your principal the 'Log Writer' role for the project. |
33 | 33 | modify_policy_add_role(crm_service, project_id, role, member) |
34 | 34 |
|
35 | | - # Gets the project's policy and prints all members with the 'Log Writer' role. |
| 35 | + # Gets the project's policy and prints all principals with the 'Log Writer' role. |
36 | 36 | policy = get_policy(crm_service, project_id) |
37 | 37 | binding = next(b for b in policy.bindings if b.role == role) |
38 | 38 | print(f"Role: {(binding.role)}") |
39 | 39 | print("Members: ") |
40 | 40 | for m in binding.members: |
41 | 41 | print(f"[{m}]") |
42 | 42 |
|
43 | | - # Removes the member from the 'Log Writer' role. |
| 43 | + # Removes the principal from the 'Log Writer' role. |
44 | 44 | modify_policy_remove_member(crm_service, project_id, role, member) |
45 | 45 |
|
46 | 46 |
|
@@ -115,7 +115,8 @@ def modify_policy_remove_member( |
115 | 115 | if __name__ == "__main__": |
116 | 116 | # TODO: replace with your project ID |
117 | 117 | project_id = "your-project-id" |
118 | | - # TODO: Replace with the ID of your member in the form 'user:member@example.com'. |
119 | | - member = "your-member" |
| 118 | + # TODO: Replace with the ID of your principal. |
| 119 | + # For examples, see https://cloud.google.com/iam/docs/principal-identifiers |
| 120 | + member = "your-principal" |
120 | 121 | quickstart(project_id, member) |
121 | 122 | # [END iam_quickstart] |
0 commit comments