Module: Msf::WebServices::WorkspaceServlet
- Defined in:
- lib/msf/core/web_services/servlet/workspace_servlet.rb
Class Method Summary collapse
- .add_workspace ⇒ Object
- .api_path ⇒ Object
- .api_path_with_id ⇒ Object
- .delete_workspace ⇒ Object
- .get_workspace ⇒ Object
- .registered(app) ⇒ Object
- .update_workspace ⇒ Object
Class Method Details
.add_workspace ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 39 def self.add_workspace lambda { warden.authenticate! begin opts = parse_json_request(request, true) data = get_db.add_workspace(opts) set_json_data_response(response: data) rescue => e print_error_and_create_response(error: e, message: 'There was an error creating the workspace:', code: 500) end } end |
.api_path ⇒ Object
3 4 5 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 3 def self.api_path '/api/v1/workspaces' end |
.api_path_with_id ⇒ Object
7 8 9 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 7 def self.api_path_with_id "#{self.api_path}/?:id?" end |
.delete_workspace ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 67 def self.delete_workspace lambda { warden.authenticate! begin opts = parse_json_request(request, false) data = get_db.delete_workspaces(opts) set_json_data_response(response: data) rescue => e print_error_and_create_response(error: e, message: 'There was an error deleting the workspaces:', code: 500) end } end |
.get_workspace ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 23 def self.get_workspace lambda { warden.authenticate! begin includes = nil sanitized_params = sanitize_params(params, env['rack.request.query_hash']) data = get_db.workspaces(sanitized_params) 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 workspaces:', code: 500) end } end |
.registered(app) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 11 def self.registered(app) app.get self.api_path, &get_workspace app.get self.api_path_with_id, &get_workspace app.post self.api_path, &add_workspace app.put self.api_path_with_id, &update_workspace app.delete self.api_path, &delete_workspace end |
.update_workspace ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/msf/core/web_services/servlet/workspace_servlet.rb', line 52 def self.update_workspace 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_workspace(opts) set_json_data_response(response: data) rescue => e print_error_and_create_response(error: e, message: 'There was an error updating the workspace:', code: 500) end } end |