mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
44 lines
1,010 B
Ruby
44 lines
1,010 B
Ruby
module Fog
|
|
module AWS
|
|
class S3
|
|
|
|
def buckets
|
|
Fog::AWS::S3::Buckets.new(:connection => self)
|
|
end
|
|
|
|
class Buckets < Fog::Collection
|
|
|
|
def all
|
|
data = connection.get_service.body
|
|
owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection))
|
|
buckets = Fog::AWS::S3::Buckets.new
|
|
data['Buckets'].each do |bucket|
|
|
buckets << Fog::AWS::S3::Bucket.new({
|
|
:buckets => self
|
|
:connection => connection,
|
|
:owner => owner
|
|
}.merge!(bucket))
|
|
end
|
|
buckets
|
|
end
|
|
|
|
def create(attributes = {})
|
|
bucket = new(attributes)
|
|
bucket.save
|
|
bucket
|
|
end
|
|
|
|
def new(attributes = {})
|
|
Fog::AWS::S3::Bucket.new(
|
|
attributes.merge!(
|
|
:connection => connection,
|
|
:buckets => self
|
|
)
|
|
)
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|