Class: Visor::Image::DeleteImage
- Inherits:
-
Goliath::API
- Object
- Goliath::API
- Visor::Image::DeleteImage
- Includes:
- Common::Exception, Common::Util
- Defined in:
- lib/image/routes/delete_image.rb
Overview
Delete the metadata and data of the image with the given id.
Instance Method Summary collapse
-
#exit_error(code, message) ⇒ Array
Produce an HTTP response with an error code and message.
-
#on_headers(env, headers) ⇒ Object
Pre-process headers as they arrive and load them into a environment variable.
-
#response(env) ⇒ Array
Query database to delete the wanted image based on its id.
Instance Method Details
#exit_error(code, message) ⇒ Array
Produce an HTTP response with an error code and message.
57 58 59 60 |
# File 'lib/image/routes/delete_image.rb', line 57 def exit_error(code, ) logger.error [code, {}, {code: code, message: }] end |
#on_headers(env, headers) ⇒ Object
Pre-process headers as they arrive and load them into a environment variable.
18 19 20 21 |
# File 'lib/image/routes/delete_image.rb', line 18 def on_headers(env, headers) logger.debug "Received headers: #{headers.inspect}" env['headers'] = headers end |
#response(env) ⇒ Array
Query database to delete the wanted image based on its id.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/image/routes/delete_image.rb', line 30 def response(env) (env, vas) = vms.delete_image(params[:id]) uri = [:location] name = [:store] if uri && name store = Visor::Image::Store.get_backend(uri, configs) store.delete unless name == 'http' end rescue Forbidden => e exit_error(403, e.) rescue NotFound => e exit_error(404, e.) rescue InternalError => e exit_error(503, e.) else [200, {}, {image: }] end |