Module: Msf::WebServices::NoteServlet
- Defined in:
- lib/msf/core/web_services/servlet/note_servlet.rb
Class Method Summary collapse
- .api_path ⇒ Object
- .api_path_with_id ⇒ Object
- .delete_note ⇒ Object
- .get_note ⇒ Object
- .registered(app) ⇒ Object
- .report_note ⇒ Object
- .update_note ⇒ Object
Class Method Details
.api_path ⇒ Object
3 4 5 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 3 def self.api_path '/api/v1/notes' end |
.api_path_with_id ⇒ Object
7 8 9 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 7 def self.api_path_with_id "#{self.api_path}/?:id?" end |
.delete_note ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 63 def self.delete_note lambda { warden.authenticate! begin opts = parse_json_request(request, false) data = get_db.delete_note(opts) set_json_data_response(response: data) rescue => e print_error_and_create_response(error: e, message: 'There was an error deleting the note:', code: 500) end } end |
.get_note ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 23 def self.get_note lambda { warden.authenticate! begin sanitized_params = sanitize_params(params, env['rack.request.query_hash']) data = get_db.notes(sanitized_params) includes = [:host] data = data.first if is_single_object?(data, sanitized_params) set_json_data_response(response: data, includes: includes) rescue => e print_error_and_create_response(error: e, message: 'There was an error retrieving notes:', code: 500) end } end |
.registered(app) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 11 def self.registered(app) app.get self.api_path, &get_note app.get self.api_path_with_id, &get_note app.post self.api_path, &report_note app.put self.api_path_with_id, &update_note app.delete self.api_path, &delete_note end |
.report_note ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 38 def self.report_note lambda { warden.authenticate! job = lambda { |opts| get_db.report_note(opts) } exec_report_job(request, &job) } end |
.update_note ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/msf/core/web_services/servlet/note_servlet.rb', line 48 def self.update_note lambda { warden.authenticate! begin opts = parse_json_request(request, false) tmp_params = sanitize_params(params) opts[:id] = tmp_params[:id] if tmp_params[:id] data = get_db.update_note(opts) set_json_data_response(response: data) rescue => e print_error_and_create_response(error: e, message: 'There was an error updating the note:', code: 500) end } end |