2011-02-22 13:13:00 -05:00
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class AWS
|
2011-02-22 13:13:00 -05:00
|
|
|
class Real
|
|
|
|
|
2011-06-15 17:26:43 -04:00
|
|
|
# Get bucket policy for an S3 bucket
|
2011-02-22 13:13:00 -05:00
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * bucket_name<~String> - name of bucket to get policy for
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
2011-06-15 17:26:43 -04:00
|
|
|
# * body<~Hash> - policy document
|
|
|
|
#
|
2011-02-22 13:13:00 -05:00
|
|
|
# ==== See Also
|
|
|
|
# http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETpolicy.html
|
2011-06-15 17:26:43 -04:00
|
|
|
|
|
|
|
def get_bucket_policy(bucket_name)
|
2011-02-22 13:13:00 -05:00
|
|
|
unless bucket_name
|
|
|
|
raise ArgumentError.new('bucket_name is required')
|
|
|
|
end
|
|
|
|
response = request({
|
|
|
|
:expects => 200,
|
|
|
|
:headers => {},
|
|
|
|
:host => "#{bucket_name}.#{@host}",
|
|
|
|
:idempotent => true,
|
|
|
|
:method => 'GET',
|
|
|
|
:query => {'policy' => nil}
|
|
|
|
})
|
2012-04-25 10:31:28 -04:00
|
|
|
response.body = Fog::JSON.decode(response.body) unless response.body.nil?
|
2011-02-22 13:13:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-06-15 17:26:43 -04:00
|
|
|
end
|
2011-02-22 13:13:00 -05:00
|
|
|
end
|
|
|
|
end
|