1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge remote branch 'mlinderm/aws-bucket-policies'

This commit is contained in:
geemus 2011-05-27 11:56:16 -07:00
commit 52fd80dcc7
5 changed files with 107 additions and 4 deletions

View file

@ -17,6 +17,7 @@ module Fog
request :complete_multipart_upload
request :copy_object
request :delete_bucket
request :delete_bucket_policy
request :delete_bucket_website
request :delete_object
request :get_bucket
@ -24,6 +25,7 @@ module Fog
request :get_bucket_location
request :get_bucket_logging
request :get_bucket_object_versions
request :get_bucket_policy
request :get_bucket_versioning
request :get_bucket_website
request :get_object
@ -40,6 +42,7 @@ module Fog
request :put_bucket
request :put_bucket_acl
request :put_bucket_logging
request :put_bucket_policy
request :put_bucket_versioning
request :put_bucket_website
request :put_object

View file

@ -0,0 +1,32 @@
module Fog
module AWS
class Storage
class Real
# Delete policy for a bucket
#
# ==== Parameters
# * bucket_name<~String> - name of bucket to delete policy from
#
# ==== Returns
# * response<~Excon::Response>:
# * status<~Integer> - 204
#
# ==== See Also
# http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETEpolicy.html
def delete_bucket_policy(bucket_name)
request({
:expects => 204,
:headers => {},
:host => "#{bucket_name}.#{@host}",
:method => 'DELETE',
:query => {'policy' => nil}
})
end
end
end
end
end

View file

@ -16,10 +16,11 @@ module Fog
# ==== See Also
# http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectDELETE.html
def delete_object(bucket_name, object_name)
request({
def delete_object(bucket_name, object_name, options = {})
headers = options
request({
:expects => 204,
:headers => {},
:headers => headers,
:host => "#{bucket_name}.#{@host}",
:idempotent => true,
:method => 'DELETE',
@ -31,7 +32,7 @@ module Fog
class Mock # :nodoc:all
def delete_object(bucket_name, object_name)
def delete_object(bucket_name, object_name, options = {})
response = Excon::Response.new
if bucket = self.data[:buckets][bucket_name]
response.status = 204

View file

@ -0,0 +1,37 @@
module Fog
module AWS
class Storage
class Real
# Get bucket policy for an S3 bucket
#
# ==== Parameters
# * bucket_name<~String> - name of bucket to get policy for
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash> - policy document
#
# ==== See Also
# http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETpolicy.html
def get_bucket_policy(bucket_name)
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}
})
response.body = JSON.parse(response.body) unless response.body.nil?
end
end
end
end
end

View file

@ -0,0 +1,30 @@
module Fog
module AWS
class Storage
class Real
# Change bucket policy for an S3 bucket
#
# ==== Parameters
# * bucket_name<~String> - name of bucket to modify
# * policy<~Hash> - policy document
#
# ==== See Also
# http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTpolicy.html
def put_bucket_policy(bucket_name, policy)
request({
:body => policy.to_json,
:expects => 204,
:headers => {},
:host => "#{bucket_name}.#{@host}",
:method => 'PUT',
:query => {'policy' => nil}
})
end
end
end
end
end