Class: S3Secure::Policy::List
- Inherits:
-
Base
- Object
- AbstractBase
- Base
- S3Secure::Policy::List
- Defined in:
- lib/s3_secure/policy/list.rb
Instance Method Summary collapse
- #get_policy(bucket) ⇒ Object
- #run ⇒ Object
-
#set_s3(client) ⇒ Object
Useful when calling List outside of the list CLI.
Methods inherited from AbstractBase
Methods included from AwsServices
#new_s3_regional_client, #s3_client, #s3_regional_client
Constructor Details
This class inherits a constructor from S3Secure::AbstractBase
Instance Method Details
#get_policy(bucket) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/s3_secure/policy/list.rb', line 17 def get_policy(bucket) resp = @s3.get_bucket_policy(bucket: bucket) data = JSON.load(resp.policy.read) # String JSON.pretty_generate(data) rescue Aws::S3::Errors::NoSuchBucketPolicy end |
#run ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/s3_secure/policy/list.rb', line 3 def run buckets.each do |bucket| @s3 = s3_regional_client(bucket) puts "Policy for bucket #{bucket.color(:green)}" policy = get_policy(bucket) if policy puts policy else puts "Bucket does not have a bucket policy" end end end |
#set_s3(client) ⇒ Object
Useful when calling List outside of the list CLI
25 26 27 |
# File 'lib/s3_secure/policy/list.rb', line 25 def set_s3(client) @s3 = client end |