Sha256: 58d93c1c5e30710669289abd800c2ef511e1d405b256bb58de383a94f3c57010

Contents?: true

Size: 1.62 KB

Versions: 10

Compression:

Stored size: 1.62 KB

Contents

module Fog
  module Storage
    class AWS
      class Real

        require 'fog/aws/parsers/storage/get_bucket_location'

        # Get location constraint for an S3 bucket
        #
        # @param bucket_name [String] name of bucket to get location constraint for
        #
        # @return [Excon::Response] response:
        #   * body [Hash]:
        #     * LocationConstraint [String] - Location constraint of the bucket
        #
        # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETlocation.html

        def get_bucket_location(bucket_name)
          request({
            :expects  => 200,
            :headers  => {},
            :host     => "#{bucket_name}.#{@host}",
            :idempotent => true,
            :method   => 'GET',
            :parser   => Fog::Parsers::Storage::AWS::GetBucketLocation.new,
            :query    => {'location' => nil}
          })
        end

      end

      class Mock # :nodoc:all

        def get_bucket_location(bucket_name)
          response = Excon::Response.new
          if bucket = self.data[:buckets][bucket_name]
            location_constraint = case bucket['LocationConstraint']
            when 'us-east-1'
              nil
            when 'eu-east-1'
              'EU'
            else
              bucket['LocationConstraint']
            end

            response.status = 200
            response.body = {'LocationConstraint' => location_constraint }
          else
            response.status = 404
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
hpfog-0.0.20 lib/fog/aws/requests/storage/get_bucket_location.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/requests/storage/get_bucket_location.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/requests/storage/get_bucket_location.rb
fog-1.10.1 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-test-me-1.10.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-1.10.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-1.9.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/aws/requests/storage/get_bucket_location.rb