10000 Add bucket-level IAM samples by theacodes · Pull Request #919 · GoogleCloudPlatform/python-docs-samples · GitHub
[go: up one dir, main page]

Skip to content

Add bucket-level IAM samples #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2017
Merged

Add bucket-level IAM samples #919

merged 2 commits into from
Apr 28, 2017

Conversation

theacodes
Copy link
Contributor

No description provided.

@theacodes theacodes requested a review from ryanmats April 28, 2017 17:29
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 28, 2017
@theacodes theacodes requested a review from andrewsg April 28, 2017 17:34
policy = bucket.get_iam_policy()

for role in policy:
members = policy[role]
Copy link
Member

Choose a reason for hiding this comment

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

Why iterate over the keys and then do a dictionary lookup, instead of iterating over key, value using items()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Oh, ick.

If beginners like me are likely to read this code, maybe adding a comment about that here would prevent confusion. Up to you though, I don't have a lot of context yet.

bucket.set_iam_policy(policy)

print('Removed {} with role {} from {}.'.format(
role, member, bucket_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

should the order be 'member, role, bucket_name' instead ?

bucket.set_iam_policy(policy)

print('Added {} with role {} to {}.'.format(
role, member, bucket_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

should the order be 'member, role, bucket_name' instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

@theacodes
Copy link
Contributor Author

Failures unrelated (and reported to client library team). Merging.

@theacodes theacodes merged commit 176955d into master Apr 28, 2017
@theacodes theacodes deleted the bucket-iam branch April 28, 2017 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0