diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-09 19:43:03 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-09 19:43:03 -0700 |
| commit | 594d37bb40f3e3e0f15553383cf2a305d4d6742e (patch) | |
| tree | 6236972f334d3ad778fbd51948d9635ae1226936 /app/controllers/api/agents | |
| parent | 72a1483c8f546fae6c93dcdf91cfd47c37bc2f90 (diff) | |
extract api.
Diffstat (limited to 'app/controllers/api/agents')
| -rw-r--r-- | app/controllers/api/agents/events_controller.rb | 19 | ||||
| -rw-r--r-- | app/controllers/api/agents/files_controller.rb | 21 |
2 files changed, 40 insertions, 0 deletions
diff --git a/app/controllers/api/agents/events_controller.rb b/app/controllers/api/agents/events_controller.rb new file mode 100644 index 0000000..255a5bc --- /dev/null +++ b/app/controllers/api/agents/events_controller.rb @@ -0,0 +1,19 @@ +module Api + module Agents + class EventsController < ApplicationController + def create + @agent = Agent.find(params[:agent_id]) + message = event_params.merge({agent_id: @agent.id}) + routing_key = "events.#{event_params[:type]}.#{@agent.id}" + Publisher.publish(routing_key, message) + render nothing: true + end + + private + + def event_params + params[:event] + end + end + end +end diff --git a/app/controllers/api/agents/files_controller.rb b/app/controllers/api/agents/files_controller.rb new file mode 100644 index 0000000..fd7410c --- /dev/null +++ b/app/controllers/api/agents/files_controller.rb @@ -0,0 +1,21 @@ +module Api + module Agents + class FilesController < ApplicationController + before_action do + request.format = :json + end + + def show + @agent = Agent.find(params[:agent_id]) + @fingerprint = params[:id] + @file = Disposition.find_by(fingerprint: params[:id]) + message = { + agent_id: params[:id], + type: :lookup, + data: params[:data] + } + Publisher.publish("events.scanned.#{@agent.id}", message) + end + end + end +end |
