Skip to content

Commit

Permalink
Update QuickStart.cs comments
Browse files Browse the repository at this point in the history
Includes changing "member" to "principal" and linking to principal identifiers page instead of specifying recommended format.
  • Loading branch information
melaniedejong authored and amanda-tarafa committed Dec 20, 2024
1 parent 8c164fe commit cce4b66
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions iam/api/QuickStart/QuickStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ public static void Main(string[] args)
{
// TODO: Replace with your project ID
var projectId = "your-project";
// TODO: Replace with the ID of your member in the form "user:member@example.com"
var member = "your-member";
// TODO: Replace with the ID of your principal.
// For examples, see https://cloud.google.com/iam/docs/principal-identifiers
var member = "your-principal";
// Role to be granted
var role = "roles/logging.logWriter";

// Initialize service
CloudResourceManagerService crmService = InitializeService();

// Grant your member the "Log Writer" role for your project
// Grant your principal the "Log Writer" role for your project
AddBinding(crmService, projectId, member, role);

// Get the project's policy and print all members with the the "Log Writer" role
// Get the project's policy and print all principals with the the "Log Writer" role
var policy = GetPolicy(crmService, projectId);
var binding = policy.Bindings.FirstOrDefault(x => x.Role == role);
Console.WriteLine("Role: " + binding.Role);
Expand All @@ -50,7 +51,7 @@ public static void Main(string[] args)
}
Console.WriteLine();

// Remove member from the "Log Writer" role
// Remove principal from the "Log Writer" role
RemoveMember(crmService, projectId, member, role);
}

Expand Down Expand Up @@ -103,7 +104,7 @@ public static void AddBinding(
// Find binding in policy
var binding = policy.Bindings.FirstOrDefault(x => x.Role == role);

// If binding already exists, add member to binding
// If binding already exists, add principal to binding
if (binding != null)
{
binding.Members.Add(member);
Expand Down Expand Up @@ -132,7 +133,7 @@ public static void RemoveMember(
// Get the project's policy
var policy = GetPolicy(crmService, projectId);

// Remove the member from the role
// Remove the principal from the role
var binding = policy.Bindings.FirstOrDefault(x => x.Role == role);
if (binding == null)
{
Expand Down

0 comments on commit cce4b66

Please sign in to comment.