| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Changes Unknown when pulling 6ec2d3c on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
Sorry, something went wrong.
| /** | ||
| * Example of listing the Bucket-Level IAM Roles and Members | ||
| */ | ||
|
|
| 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()); |
| // Update the bucket IAM Policy | ||
| storage.setIamPolicy(bucketName, updatedPolicy); | ||
|
|
||
| System.out.printf("Added %s with role %s to %s\n", identity, role, bucketName); |
| /* | ||
| * EDITING INSTRUCTIONS | ||
| * This file is referenced in Storage's javadoc. Any change to this file should be reflected in | ||
| * Storage's javadoc. |
|
Thanks @shinfan! I have updated my PR to reflect your comments. PTAL |
Sorry, something went wrong.
|
Changes Unknown when pulling b21740b on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
Sorry, something went wrong.
|
Changes Unknown when pulling 873b8ff on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
Sorry, something went wrong.
|
Changes Unknown when pulling 8b49ff9 on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
@shinfan do I need to wait for Garrett's LGTM as well or can I merge? |
Sorry, something went wrong.
|
@garrettjonesgoogle Do you wanna take another look? |
Sorry, something went wrong.
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.
Sorry, something went wrong.
| System.out.printf("Added %s with role %s to %s\n", identity, role, bucketName); | ||
| } | ||
| // [END add_bucket_iam_member] | ||
| } |
| System.out.printf("Removed %s with role %s from %s\n", identity, role, bucketName); | ||
| } | ||
| // [END remove_bucket_iam_member] | ||
| } |
| @Test | ||
| public void testAddBucketIamMemeber() { | ||
| // Test a member is added to Bucket-level IAM | ||
| Policy policy = storage.getIamPolicy(BUCKET); |
|
|
||
| @Test | ||
| public void testRemoveBucketIamMember() { | ||
| // Test a member is removed from Bucket-level IAM |
| @Test | ||
| public void testListBucketIamMembers() { | ||
| // Test an added Bucket-level IAM member is listed | ||
| Policy policy = storage.getIamPolicy(BUCKET); |
| assertNull(policy.getBindings().get(StorageRoles.admin())); | ||
| storage.setIamPolicy(BUCKET, policy.toBuilder().addIdentity(StorageRoles.admin(), | ||
| Identity.user(USER_EMAIL)).build()); | ||
| policy = storage.getIamPolicy(BUCKET); |
|
Changes Unknown when pulling 00555f3 on frankyn:storage-iam-snippets into ** on GoogleCloudPlatform:master**. |
Sorry, something went wrong.
|
Thanks @lesv, I have applied changes. PTAL |
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry I wasn't thinking expressively yesterday.
What I would do is:
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.
Sorry, something went wrong.
| 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()). |
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
| 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))); |
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
| Policy policy = storage.getIamPolicy(BUCKET); | ||
| policy = storage.setIamPolicy(BUCKET, | ||
| policy.toBuilder().removeRole(StorageRoles.admin()).build()); | ||
| assertNull(policy.getBindings().get(StorageRoles.admin())); |
| 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))); |
|
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. |
Sorry, something went wrong.
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.
Sorry, something went wrong.
🤖 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).
| Back | FazBrowse Home | New Git URL |
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 members
add_bucket_iam_member -- add a bucket-level iam member
remove_bucket_iam_member -- remove a bucket-level iam member
I copied the existing file BucketSnippets.java to keep consistency, and because ACL and Bucket-level IAM have a conflicting class name com.google.cloud.storage.Acl.Role and com.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!