Class: Fog::AWS::S3::Buckets
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::S3::Buckets
- Defined in:
- lib/fog/aws/models/s3/buckets.rb
Instance Method Summary collapse
- #all ⇒ Object
- #create(attributes = {}) ⇒ Object
- #get(name, options = {}) ⇒ Object
- #new(attributes = {}) ⇒ Object
- #reload ⇒ Object
Methods inherited from Collection
aliases, attribute, attributes, #attributes, #initialize, #inspect, #merge_attributes
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all ⇒ Object
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 61 62 63 |
# File 'lib/fog/aws/models/s3/buckets.rb', line 31 def get(name, = {}) remap_attributes(, { :is_truncated => 'IsTruncated', :marker => 'Marker', :max_keys => 'MaxKeys', :prefix => 'Prefix' }) data = connection.get_bucket(name, ).body bucket = Fog::AWS::S3::Bucket.new({ :buckets => self, :connection => connection, :name => data['Name'] }) objects_data = {} for key, value in data if ['IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key) objects_data[key] = value end end bucket.objects.merge_attributes(objects_data) 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
65 66 67 68 69 70 71 72 |
# File 'lib/fog/aws/models/s3/buckets.rb', line 65 def new(attributes = {}) Fog::AWS::S3::Bucket.new( attributes.merge!( :connection => connection, :buckets => self ) ) end |
#reload ⇒ Object
74 75 76 |
# File 'lib/fog/aws/models/s3/buckets.rb', line 74 def reload all end |