Skip to content

Commit

Permalink
Expose MiqEvent/EmsEvent group/levels in event stream OPTIONS
Browse files Browse the repository at this point in the history
The timeline_events key in the response body 'data' field contains information
on the type of events, their descriptions, group levels, group names, etc.

Currently, we only support EmsEvent and MiqEvent from event_streams.

Part of ManageIQ#1090
  • Loading branch information
jrafanie committed Nov 22, 2021
1 parent 73bcdc2 commit 83c6c48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/api/event_streams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
module Api
class EventStreamsController < BaseController
def options
render_options(@req.collection, build_additional_fields)
end

private

def build_additional_fields
{:timeline_events => EventStream.timeline_options}
end
end
end
20 changes: 20 additions & 0 deletions spec/requests/event_streams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,24 @@
expect(response).to have_http_status(:forbidden)
end
end

describe 'OPTIONS /api/event_streams' do
it 'returns expected and additional attributes' do
MiqEventDefinitionSet.seed
options(api_event_streams_url)

expect_options_results(:event_streams)

body = response.parsed_body
expect(body["data"].keys).to eq(["timeline_events"])
expect(body["data"]["timeline_events"].keys.sort).to eq(%w[EmsEvent MiqEvent])
expect(body["data"]["timeline_events"]["EmsEvent"].keys.sort).to eq(%w[description group_levels group_names])
expect(body["data"]["timeline_events"]["EmsEvent"]["group_names"].keys.sort).to include("addition", "other")
expect(body["data"]["timeline_events"]["EmsEvent"]["group_levels"].keys.sort).to eq(%w[critical detail warning])

expect(body["data"]["timeline_events"]["MiqEvent"].keys.sort).to eq(%w[description group_levels group_names])
expect(body["data"]["timeline_events"]["MiqEvent"]["group_names"].keys.sort).to include("auth_validation", "other")
expect(body["data"]["timeline_events"]["MiqEvent"]["group_levels"].keys.sort).to eq(%w[detail failure success])
end
end
end

0 comments on commit 83c6c48

Please sign in to comment.