Sha256: d7d8d59939c4fd3b5b99c0b3abb4d33af83e4cdfa5a408ac03024c0b94f0e91d

Contents?: true

Size: 1.24 KB

Versions: 25

Compression:

Stored size: 1.24 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class S3

        # Delete an S3 bucket
        #
        # ==== Parameters
        # * bucket_name<~String> - name of bucket to delete
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * status<~Integer> - 204
        def delete_bucket(bucket_name)
          request({
            :expects  => 204,
            :headers  => {},
            :host     => "#{bucket_name}.#{@host}",
            :method   => 'DELETE'
          })
        end

      end
    end
  end

else

  module Fog
    module AWS
      class S3

        def delete_bucket(bucket_name)
          response = Excon::Response.new
          if Fog::AWS::S3.data[:buckets][bucket_name].nil?
            response.status = 404
            raise(Excon::Errors.status_error({:expects => 204}, response))
          elsif Fog::AWS::S3.data[:buckets][bucket_name] && !Fog::AWS::S3.data[:buckets][bucket_name][:objects].empty?
            response.status = 409
            raise(Excon::Errors.status_error({:expects => 204}, response))
          else
            Fog::AWS::S3.data[:buckets].delete(bucket_name)
            response.status = 204
          end
          response
        end

      end
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
fog-0.0.56 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.55 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.54 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.53 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.52 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.51 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.50 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.49 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.48 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.47 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.46 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.45 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.44 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.43 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.42 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.41 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.40 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.39 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.38 lib/fog/aws/requests/s3/delete_bucket.rb
fog-0.0.37 lib/fog/aws/requests/s3/delete_bucket.rb