lib/splash/webadmin/api/routes/commands.rb in prometheus-splash-0.8.4 vs lib/splash/webadmin/api/routes/commands.rb in prometheus-splash-0.8.5
- old
+ new
@@ -14,15 +14,27 @@
WebAdminApp.get '/api/commands/show/:name.?:format?' do
log = get_logger
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
log.call "API : commands, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
- commands_recordset = get_config.commands[params[:name].to_sym]
+ commands_recordset = get_config.commands.select {|command| command[:name] == params[:name].to_sym}.first
unless commands_recordset.nil? then
obj = splash_return case: :quiet_exit
obj[:data] = commands_recordset
else
obj = splash_return case: :not_found, :more => "Command not configured"
end
content_type format
format_response(obj, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
+end
+
+WebAdminApp.get '/api/commands/history/:name.?:format?' do
+ log = get_logger
+ format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
+ log.call "API : commands, verb : GET, route : history, format : #{format}"
+ record = Splash::Commands::CmdRecords::new(params[:name]).get_all_records
+ history = splash_return case: :quiet_exit, :more => "command monitoring history"
+ history[:data] = record
+ content_type format
+ status 201
+ format_response(history, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
end