Sha256: a929018ba10c7c41523930e07b8492f62a3a12e94f0738e2713f11ecbf6c385c

Contents?: true

Size: 1.63 KB

Versions: 45

Compression:

Stored size: 1.63 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  => {},
            :bucket_name => bucket_name,
            :idempotent => true,
            :method   => 'GET',
            :parser   => Fog::Parsers::Storage::AWS::GetBucketLocation.new,
            :query    => {'location' => nil},
            :path_style => true
          })
        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

45 entries across 43 versions & 3 rubygems

Version Path
fog-aws-3.1.0 lib/fog/aws/requests/storage/get_bucket_location.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/storage/get_bucket_location.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/storage/get_bucket_location.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-3.0.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-2.0.1 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-2.0.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.4.1 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.4.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.3.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.2.1 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.2.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.1.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-1.0.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.13.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.12.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.11.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.10.0 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.9.4 lib/fog/aws/requests/storage/get_bucket_location.rb
fog-aws-0.9.3 lib/fog/aws/requests/storage/get_bucket_location.rb