Class: InsightsCloud::HitsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- InsightsCloud::HitsController
- Includes:
- Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/insights_cloud/hits_controller.rb
Instance Method Summary collapse
- #action_permission ⇒ Object
- #controller_permission ⇒ Object
- #index ⇒ Object
- #model_of_controller ⇒ Object
- #resolutions ⇒ Object
- #resource_class ⇒ Object
- #show ⇒ Object
Instance Method Details
#action_permission ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 56 def case params[:action] when 'resolutions' 'view' else super end end |
#controller_permission ⇒ Object
52 53 54 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 52 def :insights_hits end |
#index ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 5 def index hits = resource_base_search_and_page.preload(:host, :rule) render json: { hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?, host_uuid: hit.host_uuid) }, itemCount: hits.count, }, status: :ok end |
#model_of_controller ⇒ Object
44 45 46 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 44 def model_of_controller ::InsightsHit end |
#resolutions ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 29 def resolutions if remediation_all_selected_param hits = resource_base.with_playbook.search_for(params[:query]) else hits = resource_base_search_and_page.with_playbook.where(id: remediation_ids_param) end hits.preload(:host, rule: :resolutions) render json: { hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, resolutions: hit.rule.resolutions.map(&:attributes), reboot: hit.rule.reboot_required) }, itemCount: hits.count, }, status: :ok end |
#resource_class ⇒ Object
48 49 50 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 48 def resource_class ::InsightsHit end |
#show ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/insights_cloud/hits_controller.rb', line 14 def show host = Host.where(id: host_id_param).first hits = host.insights&.hits unless hits return render json: { error: 'No recommendations were found for this host', }, status: :not_found end render json: { hits: hits, }, status: :ok end |