From 4941d15424a5722ad53123b49598baf7b745384b Mon Sep 17 00:00:00 2001 From: Wesley Beary Date: Sun, 7 Jun 2009 01:55:52 -0700 Subject: [PATCH] add remaining bucket meta gets --- lib/fog/aws/s3.rb | 38 +++++++++++++++++++++++++ lib/fog/aws/s3/parsers.rb | 22 ++++++++++++++ spec/aws/s3/get_location_spec.rb | 10 +++++++ spec/aws/s3/get_request_payment_spec.rb | 10 +++++++ spec/aws/s3/put_request_payment_spec.rb | 10 +++++++ 5 files changed, 90 insertions(+) create mode 100644 spec/aws/s3/get_location_spec.rb create mode 100644 spec/aws/s3/get_request_payment_spec.rb create mode 100644 spec/aws/s3/put_request_payment_spec.rb diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index cf262f3c3..8d16eb696 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -70,6 +70,26 @@ module Fog ) end + # Change who pays for requests to an S3 bucket + # + # ==== Parameters + # bucket_name<~String>:: name of bucket to modify + # payer<~String>:: valid values are BucketOwner or Requester + def put_request_payment(bucket_name, payer) + data = <<-DATA + + #{payer} + + DATA + request( + 'PUT', + url(bucket_name), + Fog::Parsers::AWS::S3::BasicParser.new, + {}, + data + ) + end + # List information about objects in an S3 bucket # # ==== Parameters @@ -96,6 +116,24 @@ module Fog ) end + # Get configured payer for an S3 bucket + def get_request_payment(bucket_name) + request( + 'GET', + url(bucket_name, '?requestpayment'), + Fog::Parsers::AWS::S3::GetRequestPayment.new + ) + end + + # Get location constraint for an S3 bucket + def get_location(bucket_name) + request( + 'GET', + url(bucket_name, '?location'), + Fog::Parsers::AWS::S3::GetRequestPayment.new + ) + end + # Delete an S3 bucket # # ==== Parameters diff --git a/lib/fog/aws/s3/parsers.rb b/lib/fog/aws/s3/parsers.rb index 62a18e014..12588eb75 100644 --- a/lib/fog/aws/s3/parsers.rb +++ b/lib/fog/aws/s3/parsers.rb @@ -93,6 +93,28 @@ module Fog end + class GetRequestPayment < Fog::Parsers::AWS::S3::BasicParser + + def end_element(name) + case name + when 'Payer' + @response[:payer] = @value + end + end + + end + + class GetLocation < Fog::Parsers::AWS::S3::BasicParser + + def end_element(name) + case name + when 'LocationConstraint' + @response[:location_constraint] = @value + end + end + + end + end end end diff --git a/spec/aws/s3/get_location_spec.rb b/spec/aws/s3/get_location_spec.rb new file mode 100644 index 000000000..614a3234e --- /dev/null +++ b/spec/aws/s3/get_location_spec.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe 'S3.get_location' do + + it 'should return proper attributes' do + p 'SHOULD CHECK FOR PROPER ATTRIBUTES' + p s3.get_location('foggetlocation') + end + +end \ No newline at end of file diff --git a/spec/aws/s3/get_request_payment_spec.rb b/spec/aws/s3/get_request_payment_spec.rb new file mode 100644 index 000000000..aa8059e61 --- /dev/null +++ b/spec/aws/s3/get_request_payment_spec.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe 'S3.get_request_payment' do + + it 'should return proper attributes' do + p 'SHOULD CHECK FOR PROPER ATTRIBUTES' + p s3.get_request_payment('foggetrequestpayment') + end + +end \ No newline at end of file diff --git a/spec/aws/s3/put_request_payment_spec.rb b/spec/aws/s3/put_request_payment_spec.rb new file mode 100644 index 000000000..fe837b5ee --- /dev/null +++ b/spec/aws/s3/put_request_payment_spec.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe 'S3.put_request_payment' do + + it 'should return proper attributes' do + p 'SHOULD CHECK FOR PROPER ATTRIBUTES' + p s3.put_request_payment('fogputrequestpayment', 'Requester') + end + +end \ No newline at end of file