Class: EmbCartEventsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- EmbCartEventsController
- Defined in:
- app/controllers/emb_cart_events_controller.rb
Constant Summary
Constants inherited from BaseController
BaseController::API_VERSION, BaseController::SUPPORTED_API_VERSIONS
Instance Method Summary collapse
-
#create ⇒ Object
POST /domain//applications//cartridges//events.
Methods inherited from BaseController
Methods included from UserActionLogger
#get_action_logger, #log_action
Instance Method Details
#create ⇒ Object
POST /domain//applications//cartridges//events
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/emb_cart_events_controller.rb', line 6 def create domain_id = params[:domain_id] id = params[:application_id] cartridge = params[:cartridge_id] event = params[:event] domain = Domain.get(@cloud_user, domain_id) return render_error(:not_found, "Domain #{domain_id} not found", 127, "CARTRIDGE_EVENT") if !domain || !domain.hasAccess?(@cloud_user) @domain_name = domain.namespace application = get_application(id) return render_error(:not_found, "Application '#{id}' not found for domain '#{domain_id}'", 101, "CARTRIDGE_EVENT") unless application @application_name = application.name @application_uuid = application.uuid return render_error(:bad_request, "Cartridge #{cartridge} not embedded within application #{id}", 129, "CARTRIDGE_EVENT") if !application. or !application..has_key?(cartridge) begin case event when 'start' application.start(cartridge) when 'stop' application.stop(cartridge) when 'restart' application.restart(cartridge) when 'reload' application.reload(cartridge) else return render_error(:bad_request, "Invalid event '#{event}' for embedded cartridge #{cartridge} within application '#{id}'", 126, "CARTRIDGE_EVENT") end rescue Exception => e return render_exception(e, "CARTRIDGE_EVENT") end application = get_application(id) if $requested_api_version >= 1.2 app = RestApplication12.new(application, get_url, nolinks) else app = RestApplication10.new(application, get_url, nolinks) end render_success(:ok, "application", app, "CARTRIDGE_EVENT", "Added #{event} on #{cartridge} for application #{id}", true) end |