@@ -34,8 +34,9 @@ public static void main(String[] args) throws IOException {
34
34
String projectId = "your-project" ;
35
35
// TODO: Replace with your service account name.
36
36
String serviceAccount = "your-service-account" ;
37
- // TODO: Replace with the ID of your member in the form "user:member@example.com"
38
- String member = "your-member" ;
37
+ // TODO: Replace with the ID of your principal.
38
+ // For examples, see https://cloud.google.com/iam/docs/principal-identifiers
39
+ String member = "your-principal" ;
39
40
// The role to be granted.
40
41
String role = "roles/logging.logWriter" ;
41
42
@@ -56,10 +57,10 @@ public static void quickstart(String projectId, String serviceAccount,
56
57
// This client only needs to be created once, and can be reused for multiple requests.
57
58
try (IAMClient iamClient = IAMClient .create ()) {
58
59
59
- // Grants your member the "Log writer" role for your project.
60
+ // Grants your principal the "Log writer" role for your project.
60
61
addBinding (iamClient , projectId , serviceAccount , member , role );
61
62
62
- // Get the project's policy and print all members with the "Log Writer" role
63
+ // Get the project's policy and print all principals with the "Log Writer" role
63
64
Policy policy = getPolicy (iamClient , projectId , serviceAccount );
64
65
65
66
Binding binding = null ;
@@ -80,7 +81,7 @@ public static void quickstart(String projectId, String serviceAccount,
80
81
}
81
82
System .out .println ();
82
83
83
- // Removes member from the "Log writer" role.
84
+ // Removes principal from the "Log writer" role.
84
85
removeMember (iamClient , projectId , serviceAccount , member , role );
85
86
}
86
87
}
@@ -107,7 +108,7 @@ public static void addBinding(IAMClient iamClient, String projectId, String serv
107
108
}
108
109
109
110
if (binding != null ) {
110
- // If binding already exists, adds member to binding.
111
+ // If binding already exists, adds principal to binding.
111
112
binding .getMembersList ().add (member );
112
113
} else {
113
114
// If binding does not exist, adds binding to policy.
@@ -127,7 +128,7 @@ public static void removeMember(IAMClient iamClient, String projectId, String se
127
128
// Gets the project's policy.
128
129
Policy .Builder policy = getPolicy (iamClient , projectId , serviceAccount ).toBuilder ();
129
130
130
- // Removes the member from the role.
131
+ // Removes the principal from the role.
131
132
Binding binding = null ;
132
133
for (Binding b : policy .getBindingsList ()) {
133
134
if (b .getRole ().equals (role )) {
0 commit comments