-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new endpoint for host insights details
- Loading branch information
1 parent
1d61d10
commit e4a1d20
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/controllers/api/v2/insights_advisor/insights_advisor_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Api | ||
module V2 | ||
module InsightsAdvisor | ||
class InsightsAdvisorController < ::Api::V2::BaseController | ||
include ::Api::Version2 | ||
|
||
before_action :find_organization | ||
|
||
def host_details | ||
@hosts = ::Host::Managed.search_for(params[:search] || "", :order => params[:order]).where(:organization_id => @organization.id).includes(:insights) | ||
respond_to do |format| | ||
format.json { render 'api/v2/insights_advisor/host_details' } | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_organization | ||
@organization ||= Organization.find_by(label: params[:organization_label]) if params[:organization_label] | ||
@organization ||= Organization.find_by(label: params[:organization]) if params[:organization] | ||
@organization ||= Organization.find(params[:organization_id]) if params[:organization_id] | ||
raise ::Foreman::Exception.new(N_("Organization not found")) unless @organization | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
collection @hosts | ||
|
||
attributes :name | ||
node :insights_uuid do |host| | ||
host.insights_facet&.uuid | ||
end | ||
node :insights_hit_details do |host| | ||
host&.facts('insights::hit_details')&.values&.first | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters