Skip to content

Update modify_policy_add_member.py#13070

Merged
melaniedejong merged 1 commit intomelaniedejong-patch-2from
melaniedejong-patch-2-1
Jan 16, 2025
Merged

Update modify_policy_add_member.py#13070
melaniedejong merged 1 commit intomelaniedejong-patch-2from
melaniedejong-patch-2-1

Conversation

@melaniedejong
Copy link
Collaborator

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

@melaniedejong melaniedejong requested review from a team as code owners January 16, 2025 23:38
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 16, 2025
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi team,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request updates the modify_policy_add_member.py sample script. The intent is to improve the clarity and accuracy of the code by renaming the member parameter to principal.

Here's a breakdown of the changes:

  • File Changed: iam/cloud-client/snippets/modify_policy_add_member.py
  • Changes: The parameter member in the modify_policy_add_member function and its usage in the example code snippet has been renamed to principal. This change aligns the parameter name with the more accurate and widely used term for identifying IAM principals. The change is reflected in both the function definition (lines 21-23 and 37) and the example usage (lines 52-55).

The updated parameter name enhances readability and consistency with Google Cloud IAM documentation, making the sample code easier to understand and use.

I'll be providing a more detailed review shortly.


A little haiku to brighten your day:

Code flows like a stream,
Clarity found in each change,
Bugs flee in the night.

@product-auto-label product-auto-label bot added the api: iam Issues related to the Identity and Access Management API. label Jan 16, 2025
@melaniedejong melaniedejong merged commit 58adc09 into melaniedejong-patch-2 Jan 16, 2025
3 checks passed
@melaniedejong melaniedejong deleted the melaniedejong-patch-2-1 branch January 16, 2025 23:38
melaniedejong added a commit that referenced this pull request Jan 16, 2025
… additional places (#13071)

* Update modify_policy_remove_member.py

Per code review suggestions, replace additional instances of "member" with "principal"

* Update modify_policy_add_member.py (#13070)
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request renames the member parameter to principal in the modify_policy_add_member function and its usage. This change improves clarity by using a more accurate term for the entity being granted access. However, there's a minor issue in the test case that needs to be addressed. I've also included some suggestions based on the Google Python Style Guide to enhance code readability and maintainability.


def modify_policy_add_member(
project_id: str, role: str, member: str
project_id: str, role: str, principal: str
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Per the Google Python Style Guide, there should be two blank lines between top-level functions. Add a blank line after the import statements to improve readability.

22:

member = f"serviceAccount:test-service-account@{project_id}.iam.gserviceaccount.com"

modify_policy_add_member(project_id, role, member)
modify_policy_add_member(project_id, role, principal)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The variable principal is not defined in this scope. It seems like this should be member based on the previous version of the code. Consider renaming member to principal consistently throughout the code if that's the intended change.

55:    modify_policy_add_member(project_id, role, member)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: iam Issues related to the Identity and Access Management API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants