lib/splash/webadmin/api/routes/config.rb in prometheus-splash-0.8.4 vs lib/splash/webadmin/api/routes/config.rb in prometheus-splash-0.8.5
- old
+ new
@@ -28,10 +28,11 @@
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
log.call "API : config, verb : POST, route : addlog, format : #{format}"
res = get_config.add_record :record => YAML::load(request.body.read), :key => :label, :type => :logs, :clean => true
case res[:status]
when :success
+ rehash_daemon
addlog = splash_return case: :quiet_exit, :more => "add log done"
when :already_exist
addlog = splash_return case: :already_exist, :more => "add log twice nto allowed"
when :failure
addlog = splash_return case: :configuration_error, :more => "add log failed"
@@ -47,10 +48,11 @@
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
log.call "API : config, verb : POST, route : addprocess, format : #{format}"
res = get_config.add_record :record => YAML::load(request.body.read), :type => :processes, :key => :process, :clean => true
case res[:status]
when :success
+ rehash_daemon
addprocess = splash_return case: :quiet_exit, :more => "add process done"
when :already_exist
addprocess = splash_return case: :already_exist, :more => "add process twice not allowed"
when :failure
addprocess = splash_return case: :configuration_error, :more => "add process failed"
@@ -58,22 +60,43 @@
end
content_type format
format_response(addprocess, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
end
+WebAdminApp.post '/api/config/addcommand.?:format?' do
+ log = get_logger
+ addcommand = {}
+ format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
+ log.call "API : config, verb : POST, route : addcommand, format : #{format}"
+ res = get_config.add_record :record => YAML::load(request.body.read), :type => :commands, :key => :name, :clean => true
+ case res[:status]
+ when :success
+ rehash_daemon
+ addcommand = splash_return case: :quiet_exit, :more => "add command done"
+ when :already_exist
+ addcommand = splash_return case: :already_exist, :more => "add command twice not allowed"
+ when :failure
+ addpraddcommandocess = splash_return case: :configuration_error, :more => "add command failed"
+ addcommand[:data] = res
+ end
+ content_type format
+ format_response(addcommand, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
+end
+
WebAdminApp.delete '/api/config/deletelog/:label.?:format?' do
log = get_logger
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
log.call "API : config, verb : DELETE, route : deletelog, format : #{format}"
deletelog = {}
logsrec = Splash::Logs::LogsRecords::new params[:label].to_sym
logsrec.clear
res = get_config.delete_record :type => :logs, key: :label, label: params[:label].to_sym
case res[:status]
when :success
+ rehash_daemon
deletelog = splash_return case: :quiet_exit, :more => "delete log done"
when :not_found
deletelog = splash_return case: :not_found, :more => "nothing done for logs"
else
deletelog = splash_return case: :configuration_error, :more => "delete log failed"
@@ -90,14 +113,36 @@
procrec = Splash::Processes::ProcessRecords::new params[:process].to_sym
procrec.clear
res = get_config.delete_record :type => :processes, :key => :process, process: params[:process].to_sym
case res[:status]
when :success
+ rehash_daemon
deleteprocess = splash_return case: :quiet_exit, :more => "delete process done"
when :not_found
deleteprocess = splash_return case: :not_found, :more => "nothing done for processes"
else
deleteprocess = splash_return case: :configuration_error, :more => "delete process failed"
end
content_type format
format_response(deleteprocess, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
+end
+
+WebAdminApp.delete '/api/config/deletecommand/:command.?:format?' do
+ log = get_logger
+ format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
+ log.call "API : config, verb : DELETE, route : deletecommand, format : #{format}"
+ deletecommand = {}
+ cmdrec = Splash::Commands::CmdRecords::new params[:command].to_sym
+ cmdrec.clear
+ res = get_config.delete_record :type => :commands, :key => :name, name: params[:command].to_sym
+ case res[:status]
+ when :success
+ rehash_daemon
+ deletecommand = splash_return case: :quiet_exit, :more => "delete command done"
+ when :not_found
+ deletecommand = splash_return case: :not_found, :more => "nothing done for commands"
+ else
+ deletecommand = splash_return case: :configuration_error, :more => "delete command failed"
+ end
+ content_type format
+ format_response(deletecommand, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
end