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:
commit
52fd80dcc7
5 changed files with 107 additions and 4 deletions
|
@ -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
|
||||
|
|
32
lib/fog/storage/requests/aws/delete_bucket_policy.rb
Normal file
32
lib/fog/storage/requests/aws/delete_bucket_policy.rb
Normal 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
|
|
@ -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
|
||||
|
|
37
lib/fog/storage/requests/aws/get_bucket_policy.rb
Normal file
37
lib/fog/storage/requests/aws/get_bucket_policy.rb
Normal 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
|
30
lib/fog/storage/requests/aws/put_bucket_policy.rb
Normal file
30
lib/fog/storage/requests/aws/put_bucket_policy.rb
Normal 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
|
||||
|
Loading…
Reference in a new issue