Sha256: 5f2dfe9dbd70e8446ff244d958a6c6d83ead3cb9d437fe57e9d8dda404363178

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

module Fog
  module AWS
    class S3

      class Bucket < Fog::Model

        identity  :name,          'Name'

        attribute :creation_date, 'CreationDate'
        attribute :owner

        def destroy
          connection.delete_bucket(@name)
          true
        rescue Fog::Errors::NotFound
          false
        end

        def location
          data = connection.get_bucket_location(@name)
          data.body['LocationConstraint']
        end

        def location=(new_location)
          @location = new_location
        end

        def objects
          @objects ||= begin
            Fog::AWS::S3::Objects.new(
              :bucket       => self,
              :connection   => connection
            )
          end
        end

        def payer
          data = connection.get_request_payment(@name)
          data.body['Payer']
        end

        def payer=(new_payer)
          connection.put_request_payment(@name, new_payer)
          @payer = new_payer
        end

        def save
          options = {}
          if @location
            options['LocationConstraint'] = @location
          end
          connection.put_bucket(@name, options)
          true
        end

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.0.29 lib/fog/aws/models/s3/bucket.rb
fog-0.0.28 lib/fog/aws/models/s3/bucket.rb
fog-0.0.27 lib/fog/aws/models/s3/bucket.rb
fog-0.0.26 lib/fog/aws/models/s3/bucket.rb