Class: Visor::Image::GetImagesDetail

Inherits:
Goliath::API
  • Object
show all
Includes:
Common::Exception, Common::Util
Defined in:
lib/image/routes/get_images_detail.rb

Overview

Get detailed information about all public images.

Instance Method Summary collapse

Instance Method Details

#exit_error(code, message) ⇒ Array

Produce an HTTP response with an error code and message.

Parameters:

  • code (Fixnum)

    The error code.

  • message (String)

    The error message.

Returns:

  • (Array)

    The HTTP response containing an error code and its message.



50
51
52
53
# File 'lib/image/routes/get_images_detail.rb', line 50

def exit_error(code, message)
  logger.error message
  [code, {}, {code: code, message: message}]
end

#on_headers(env, headers) ⇒ Object

Pre-process headers as they arrive and load them into a environment variable.

Parameters:

  • env (Object)

    The Goliath environment variables.

  • headers (Object)

    The incoming request HTTP headers.



18
19
20
21
# File 'lib/image/routes/get_images_detail.rb', line 18

def on_headers(env, headers)
  logger.debug "Received headers: #{headers.inspect}"
  env['headers'] = headers
end

#response(env) ⇒ Array

Query database to retrieve the public images detailed meta and return it in request body.

Parameters:

  • env (Object)

    The Goliath environment variables.

Returns:

  • (Array)

    The HTTP response containing the images metadata or an error code and its messages if anything was raised.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/image/routes/get_images_detail.rb', line 30

def response(env)
  access_key = authorize(env, vas)
  meta = vms.get_images_detail(params, access_key)
  env.params.delete('format')
  [200, {}, {images: meta}]
rescue Forbidden => e
  exit_error(403, e.message)
rescue NotFound => e
  exit_error(404, e.message)
rescue InternalError => e
  exit_error(503, e.message)
end