Class: Fog::AWS::S3::Buckets
Instance Method Summary
collapse
Methods inherited from Collection
aliases, attribute, attributes, #attributes, #initialize, #inspect, #merge_attributes
Instance Method Details
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/fog/aws/models/s3/buckets.rb', line 11
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(:connection => connection)
data['Buckets'].each do |bucket|
buckets << Fog::AWS::S3::Bucket.new({
:buckets => buckets,
:connection => connection,
:owner => owner
}.merge!(bucket))
end
buckets
end
|
#create(attributes = {}) ⇒ Object
25
26
27
28
29
|
# File 'lib/fog/aws/models/s3/buckets.rb', line 25
def create(attributes = {})
bucket = new(attributes)
bucket.save
bucket
end
|
#get(name, options = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/fog/aws/models/s3/buckets.rb', line 31
def get(name, options = {})
remap_attributes(options, {
:max_keys => 'max-keys',
})
data = connection.get_bucket(name, options).body
bucket = Fog::AWS::S3::Bucket.new({
:buckets => self,
:connection => connection,
:name => data['Name']
})
options = {}
for key, value in data
if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
options[key] = value
end
end
bucket.objects.merge_attributes(options)
data['Contents'].each do |object|
owner = Fog::AWS::S3::Owner.new(object.delete('Owner').merge!(:connection => connection))
bucket.objects << Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection,
:objects => self,
:owner => owner
}.merge!(object))
end
bucket
rescue Fog::Errors::NotFound
nil
end
|
#new(attributes = {}) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/fog/aws/models/s3/buckets.rb', line 62
def new(attributes = {})
Fog::AWS::S3::Bucket.new(
attributes.merge!(
:connection => connection,
:buckets => self
)
)
end
|
71
72
73
|
# File 'lib/fog/aws/models/s3/buckets.rb', line 71
def reload
all
end
|