Uh oh!
There was an error while loading. Please reload this page.
[Storage] Bucket-level IAM Samples - #2008
Conversation
coveralls
commented
Apr 26, 2017
Changes Unknown when pulling 6ec2d3c on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
| /** | ||
| * Example of listing the Bucket-Level IAM Roles and Members | ||
| */ | ||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Map<Role, Set<Identity>> policyBindings = policy.getBindings(); | ||
| for(Map.Entry<Role, Set<Identity>> entry : policyBindings.entrySet()) { | ||
| System.out.printf("Role: %s", entry.getKey()); | ||
| System.out.printf(" Identities: %s\n", entry.getValue()); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| // Update the bucket IAM Policy | ||
| storage.setIamPolicy(bucketName, updatedPolicy); | ||
| System.out.printf("Added %s with role %s to %s\n", identity, role, bucketName); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| /* | ||
| * EDITING INSTRUCTIONS | ||
| * This file is referenced in Storage's javadoc. Any change to this file should be reflected in | ||
| * Storage's javadoc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
frankyn
commented
Apr 27, 2017
Thanks @shinfan! I have updated my PR to reflect your comments. PTAL |
coveralls
commented
Apr 27, 2017
Changes Unknown when pulling b21740b on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
b3753a3 to
873b8ffComparecoveralls
commented
Apr 27, 2017
Changes Unknown when pulling 873b8ff on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
coveralls
commented
Apr 27, 2017
Changes Unknown when pulling 8b49ff9 on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
frankyn
commented
Apr 27, 2017
@shinfan do I need to wait for Garrett's LGTM as well or can I merge? |
shinfan
commented
Apr 27, 2017
@garrettjonesgoogle Do you wanna take another look? |
garrettjonesgoogle
commented
Apr 27, 2017
Adding @lesv for final review |
lesv
left a comment
There was a problem hiding this comment.
The snippets are good, but you might wish to return updatedPolicy for the last two.
You might run into propagation issues with this, so your tests should be a bit less brittle.
| System.out.printf("Added %s with role %s to %s\n", identity, role, bucketName); | ||
| } | ||
| // [END add_bucket_iam_member] | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| System.out.printf("Removed %s with role %s from %s\n", identity, role, bucketName); | ||
| } | ||
| // [END remove_bucket_iam_member] | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| @Test | ||
| public void testAddBucketIamMemeber() { | ||
| // Test a member is added to Bucket-level IAM | ||
| Policy policy = storage.getIamPolicy(BUCKET); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| @Test | ||
| public void testRemoveBucketIamMember() { | ||
| // Test a member is removed from Bucket-level IAM |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| @Test | ||
| public void testListBucketIamMembers() { | ||
| // Test an added Bucket-level IAM member is listed | ||
| Policy policy = storage.getIamPolicy(BUCKET); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| assertNull(policy.getBindings().get(StorageRoles.admin())); | ||
| storage.setIamPolicy(BUCKET, policy.toBuilder().addIdentity(StorageRoles.admin(), | ||
| Identity.user(USER_EMAIL)).build()); | ||
| policy = storage.getIamPolicy(BUCKET); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coveralls
commented
Apr 28, 2017
Changes Unknown when pulling 00555f3 on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
frankyn
commented
Apr 28, 2017
Thanks @lesv, I have applied changes. PTAL |
lesv
left a comment
There was a problem hiding this comment.
Sorry I wasn't thinking expressively yesterday.
What I would do is:
- In your create bucket, I would add several policies, so all of them are done.
- I would test myAddBucketIAM first
- Then I run myRemoveBucketIAMMember final.
- I would test myListBucketIAM.
Use lots of email addresses, not just one. Deal with the fact that you might not see yours.
You have a good chance to see the initial add's (setup) by the time you do your list. (but no guarantee).
The key point is Eventual Consistency -- I think it's a part of everything we deal with.
| Identity.user(USER_EMAIL)).build()); | ||
| assertTrue(policy.getBindings().get(StorageRoles.admin()).contains(Identity.user(USER_EMAIL))); | ||
| Policy snippetPolicy = bucketIamSnippets.listBucketIamMembers(BUCKET); | ||
| assertTrue(snippetPolicy.getBindings().get(StorageRoles.admin()). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| assertNull(policy.getBindings().get(StorageRoles.admin())); | ||
| policy = storage.setIamPolicy(BUCKET, policy.toBuilder().addIdentity(StorageRoles.admin(), | ||
| Identity.user(USER_EMAIL)).build()); | ||
| assertTrue(policy.getBindings().get(StorageRoles.admin()).contains(Identity.user(USER_EMAIL))); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| assertNull(policy.getBindings().get(StorageRoles.admin())); | ||
| policy = storage.setIamPolicy(BUCKET, policy.toBuilder().addIdentity(StorageRoles.admin(), | ||
| Identity.user(USER_EMAIL)).build()); | ||
| assertTrue(policy.getBindings().get(StorageRoles.admin()).contains(Identity.user(USER_EMAIL))); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
lesv
commented
Apr 29, 2017
I'm going to improve several of the tests by hand, then approve this PR as Frank had something come up and this needs to be published on Monday. |
lesv
left a comment
There was a problem hiding this comment.
I think these might be more brittle than I'd like, but for now, it's working. I'll ask Frank to update later.
🤖 I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
…e to v3.30.7 (#2008) Co-authored-by: Tom Andersen <tom-andersen@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [2.30.0](https://togithub.com/googleapis/java-bigtable/compare/v2.29.1...v2.30.0) (2023-12-05) ### Features * Client sends routing cookie back to server ([googleapis#1888](https://togithub.com/googleapis/java-bigtable/issues/1888)) ([52572a5](https://togithub.com/googleapis/java-bigtable/commit/52572a55471e5d83f7ad579a5e19dc20ef9a69f2)) ### Dependencies * Update dependency org.junit.vintage:junit-vintage-engine to v5.10.1 ([googleapis#1990](https://togithub.com/googleapis/java-bigtable/issues/1990)) ([43775db](https://togithub.com/googleapis/java-bigtable/commit/43775dbce02dbf22f5d33300974601d719a6e74e)) * Update shared dependencies ([googleapis#2016](https://togithub.com/googleapis/java-bigtable/issues/2016)) ([3d17fb1](https://togithub.com/googleapis/java-bigtable/commit/3d17fb1d93f6dee77bbb92c4cb8186d700ac85c6)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Hi Garrett,
PR Summary:
This pull request will add the following samples to google-cloud-examples:
view_bucket_iam_members-- list bucket-level iam roles and their membersadd_bucket_iam_member-- add a bucket-level iam memberremove_bucket_iam_member-- remove a bucket-level iam memberI copied the existing file
BucketSnippets.javato keep consistency, and because ACL and Bucket-level IAM have a conflicting class namecom.google.cloud.storage.Acl.Roleandcom.google.cloud.Role.What additional work do I need to include in this PR to satisfy this line "This file is referenced in Storage's javadoc. Any change to this file should be reflected in Storage's javadoc.".?
Thank you!