Method: Fog::Storage::AWS::Mock#get_bucket_location

Defined in:
lib/fog/aws/requests/storage/get_bucket_location.rb

#get_bucket_location(bucket_name) ⇒ Object

[View source]

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/aws/requests/storage/get_bucket_location.rb', line 37

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