1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/s3/bucket.rb

71 lines
1.4 KiB
Ruby
Raw Normal View History

2009-08-02 19:37:54 -04:00
module Fog
module AWS
class S3
class Bucket < Fog::Model
attribute :creation_date, 'CreationDate'
attribute :name, 'Name'
attribute :owner
2009-08-04 13:51:54 -04:00
def buckets
@buckets
end
2009-08-30 17:14:11 -04:00
def destroy
connection.delete_bucket(@name)
true
rescue Fog::Errors::NotFound
false
2009-08-04 01:50:52 -04:00
end
def location
2009-09-04 20:25:41 -04:00
data = connection.get_bucket_location(@name)
data.body['LocationConstraint']
2009-08-04 01:50:52 -04:00
end
2009-08-13 01:48:17 -04:00
def objects
@objects ||= begin
Fog::AWS::S3::Objects.new(
:bucket => self,
:connection => connection
)
end
2009-08-13 01:48:17 -04:00
end
2009-08-04 01:50:52 -04:00
def payer
data = connection.get_request_payment(@name)
data.body['Payer']
2009-08-04 01:50:52 -04:00
end
def payer=(new_payer)
connection.put_request_payment(@name, new_payer)
2009-08-04 01:54:34 -04:00
@payer = new_payer
2009-08-04 01:50:52 -04:00
end
2009-08-30 17:14:11 -04:00
def reload
new_attributes = buckets.get(@name).attributes
merge_attributes(new_attributes)
2009-08-30 17:14:11 -04:00
end
2009-08-04 01:50:52 -04:00
def save
options = {}
if @location
options['LocationConstraint'] = @location
end
connection.put_bucket(@name, options)
true
2009-08-04 01:50:52 -04:00
end
2009-08-02 19:37:54 -04:00
private
def buckets=(new_buckets)
@buckets = new_buckets
end
2009-08-02 19:37:54 -04:00
end
end
end
end