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/directory.rb

68 lines
1.4 KiB
Ruby
Raw Normal View History

2010-03-13 13:37:24 -08:00
require 'fog/model'
require 'fog/aws/models/s3/files'
2009-08-02 16:37:54 -07:00
module Fog
module AWS
2010-03-13 13:37:24 -08:00
module S3
2009-08-02 16:37:54 -07:00
2010-01-14 20:44:39 -08:00
class Directory < Fog::Model
2009-08-02 16:37:54 -07:00
identity :name, 'Name'
attribute :creation_date, 'CreationDate'
2009-08-04 10:51:54 -07:00
2009-08-30 14:14:11 -07:00
def destroy
requires :name
connection.delete_bucket(@name)
true
rescue Excon::Errors::NotFound
false
2009-08-03 22:50:52 -07:00
end
def location
requires :name
2009-09-04 17:25:41 -07:00
data = connection.get_bucket_location(@name)
data.body['LocationConstraint']
2009-08-03 22:50:52 -07:00
end
def location=(new_location)
@location = new_location
end
2010-01-14 20:44:39 -08:00
def files
@files ||= begin
Fog::AWS::S3::Files.new(
:directory => self,
:connection => connection
)
end
2009-08-12 22:48:17 -07:00
end
2009-08-03 22:50:52 -07:00
def payer
requires :name
data = connection.get_request_payment(@name)
data.body['Payer']
2009-08-03 22:50:52 -07:00
end
def payer=(new_payer)
requires :name
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
requires :name
2009-08-03 22:50:52 -07:00
options = {}
if @location
options['LocationConstraint'] = @location
end
connection.put_bucket(@name, options)
true
2009-08-03 22:50:52 -07:00
end
2009-08-02 16:37:54 -07:00
end
end
end
end