Class: Overseer::TestingControl::Rails::ProbesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/overseer/testing_control/rails/probes_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/overseer/testing_control/rails/probes_controller.rb', line 7

def create
  document = request_document(:probe_request)
  data = document.fetch('data')
  id, version = capability_reference(data)
  probe = find_probe(id, version)
  input = data.fetch('input')
  validate_capability_input!(probe.input_schema, input, label: "probe #{id}@#{version} input")
  projection = ProtocolV3.stringify(probe.handler.call(input, handler_context))
  validate_capability_output!(probe.output_schema, projection, label: "probe #{id}@#{version} output")
  render_data(
    :probe_response,
    {
      'capability' => { 'id' => id, 'version' => version },
      'observedAt' => ProtocolV3.timestamp,
      'projection' => projection
    }
  )
end