public Policy listBucketIamMembers ( String bucketName ) { // [START view_bucket_iam_members] // Initialize a Cloud Storage client Storage storage = StorageOptions . getDefaultInstance ( ) . getService ( ) ; // Get IAM Policy for a bucket Policy policy = storage . getIamPolicy ( bucketName ) ; // Print Roles and its identities Map < Role , Set < Identity > > policyBindings = policy . getBindings ( ) ; for ( Map . Entry < Role , Set < Identity > > entry : policyBindings . entrySet ( ) ) { System . out . printf ( "Role: %s Identities: %s\n" , entry . getKey ( ) , entry . getValue ( ) ) ; } // [END view_bucket_iam_members] return policy ; }
Example of listing the Bucket - Level IAM Roles and Members