2011-02-18 15:06:51 -05:00
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class AWS
|
2011-02-18 15:06:51 -05:00
|
|
|
class Real
|
|
|
|
|
|
|
|
# Change website configuration for an S3 bucket
|
|
|
|
#
|
2013-01-13 20:32:23 -05:00
|
|
|
# @param bucket_name [String] name of bucket to modify
|
|
|
|
# @param suffix [String] suffix to append to requests for the bucket
|
|
|
|
# @param options [Hash]
|
|
|
|
# @option options key [String] key to use for 4XX class errors
|
2011-02-18 15:06:51 -05:00
|
|
|
#
|
2013-01-13 20:32:23 -05:00
|
|
|
# @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html
|
2011-02-18 15:06:51 -05:00
|
|
|
|
|
|
|
def put_bucket_website(bucket_name, suffix, options = {})
|
|
|
|
data =
|
|
|
|
<<-DATA
|
|
|
|
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
|
|
<IndexDocument>
|
|
|
|
<Suffix>#{suffix}</Suffix>
|
|
|
|
</IndexDocument>
|
|
|
|
DATA
|
|
|
|
|
|
|
|
if options[:key]
|
|
|
|
data <<
|
|
|
|
<<-DATA
|
|
|
|
<ErrorDocument>
|
|
|
|
<Key>#{options[:key]}</Key>
|
|
|
|
</ErrorDocument>
|
|
|
|
DATA
|
|
|
|
end
|
|
|
|
|
|
|
|
data << '</WebsiteConfiguration>'
|
|
|
|
request({
|
|
|
|
:body => data,
|
|
|
|
:expects => 200,
|
|
|
|
:headers => {},
|
2013-04-12 06:31:10 -04:00
|
|
|
:bucket_name => bucket_name,
|
2011-02-18 15:06:51 -05:00
|
|
|
:method => 'PUT',
|
|
|
|
:query => {'website' => nil}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-01-07 21:08:56 -05:00
|
|
|
|
|
|
|
class Mock # :nodoc:all
|
|
|
|
|
|
|
|
def put_bucket_website(bucket_name, suffix, options = {})
|
|
|
|
response = Excon::Response.new
|
|
|
|
if self.data[:buckets][bucket_name]
|
|
|
|
response.status = 200
|
|
|
|
else
|
2012-02-05 15:29:59 -05:00
|
|
|
response.status = 404
|
2012-01-07 21:08:56 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
|
|
|
end
|
|
|
|
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-02-18 15:06:51 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|