Method: Fog::Storage::Softlayer::Mock#get_container

Defined in:
lib/fog/softlayer/requests/storage/get_container.rb

#get_container(container, options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/softlayer/requests/storage/get_container.rb', line 5

def get_container(container, options = {})
  if @containers[container]
    response = Excon::Response.new
    response.body = @containers[container].map do |name, object|
      {
          'hash' => object.respond_to?(:to_s) ? Digest::MD5.hexdigest(object.to_s) : 'e4d909c290d0fb1ca068ffaddf22cbd0',
          'last_modified' => Time.now,
          'bytes' => Memory.analyze(container).bytes,
          'content/type' => 'application/json'
      }
    end
    response.status = 200
    response
  else
    response = Excon::Response.new
    response.body = '<html><h1>Not Found</h1><p>The resource could not be found.</p></html>'
    response.status = 404
    response.headers = {"Content-Length"=>"70", "Content-Type"=>"text/html; charset=UTF-8", "X-Trans-Id"=>"abcdefghijklmnopqrstuvwx-0123456789", "Date"=>Time.now}
    response
  end
end