2009-08-02 16:37:54 -07:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class S3
|
|
|
|
|
|
|
|
class Bucket < Fog::Model
|
|
|
|
|
2009-08-14 09:19:40 -07:00
|
|
|
attr_accessor :creation_date,
|
2009-08-18 21:26:13 -07:00
|
|
|
:location,
|
|
|
|
:name,
|
|
|
|
:owner
|
2009-08-04 10:51:54 -07:00
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
remap_attributes(attributes, {
|
|
|
|
'CreationDate' => :creation_date,
|
|
|
|
'Name' => :name
|
|
|
|
})
|
|
|
|
super
|
|
|
|
end
|
2009-08-03 22:50:52 -07:00
|
|
|
|
|
|
|
def delete
|
|
|
|
connection.delete_bucket(name)
|
2009-08-27 20:47:01 -07:00
|
|
|
true
|
2009-08-03 22:50:52 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def location
|
2009-08-18 21:26:13 -07:00
|
|
|
data = s3.get_bucket_location(name)
|
|
|
|
data.body['LocationConstraint']
|
2009-08-03 22:50:52 -07:00
|
|
|
end
|
|
|
|
|
2009-08-12 22:48:17 -07:00
|
|
|
def objects
|
2009-08-17 17:06:25 -07:00
|
|
|
Fog::AWS::S3::Objects.new(
|
|
|
|
:bucket => self,
|
|
|
|
:connection => connection
|
|
|
|
)
|
2009-08-12 22:48:17 -07:00
|
|
|
end
|
|
|
|
|
2009-08-03 22:50:52 -07:00
|
|
|
def payer
|
2009-08-18 21:26:13 -07:00
|
|
|
data = connection.get_request_payment(name)
|
|
|
|
data.body['Payer']
|
2009-08-03 22:50:52 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def payer=(new_payer)
|
|
|
|
connection.put_request_payment(name, new_payer)
|
2009-08-03 22:54:34 -07:00
|
|
|
@payer = new_payer
|
2009-08-03 22:50:52 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
options = {}
|
|
|
|
if @location
|
|
|
|
options['LocationConstraint'] = @location
|
|
|
|
end
|
|
|
|
connection.put_bucket(name, options)
|
2009-08-27 20:47:01 -07:00
|
|
|
true
|
2009-08-03 22:50:52 -07:00
|
|
|
end
|
2009-08-02 16:37:54 -07:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|