Class: Katello::Api::V2::HostErrataController

Inherits:
ApiController
  • Object
show all
Includes:
Concerns::Api::V2::HostErrataExtensions, Concerns::FilteredAutoCompleteSearch
Defined in:
app/controllers/katello/api/v2/host_errata_controller.rb

Constant Summary collapse

TYPES_FROM_PARAMS =
{
  bugfix: Katello::Erratum::BUGZILLA, # ['bugfix', 'recommended']
  security: Katello::Erratum::SECURITY, # ['security']
  enhancement: Katello::Erratum::ENHANCEMENT # ['enhancement', 'optional']
}.freeze

Constants included from Concerns::FilteredAutoCompleteSearch

Concerns::FilteredAutoCompleteSearch::PAGE_SIZE

Instance Method Summary collapse

Methods included from Concerns::FilteredAutoCompleteSearch

#auto_complete_search

Methods inherited from ApiController

#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #scoped_search, #skip_session

Methods included from Rendering

#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template

Methods included from Katello::Api::Version2

#api_version

Instance Method Details

#applicabilityObject



83
84
85
86
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 83

def applicability
  Katello::Host::ContentFacet.trigger_applicability_generation(@host.id)
  respond_for_async :resource => {}
end

#applyObject



67
68
69
70
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 67

def apply
  task = async_task(::Actions::Katello::Host::Erratum::Install, @host, content: @errata_ids)
  respond_for_async :resource => task
end

#indexObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 48

def index
  validate_index_params!

  collection = scoped_search(index_relation, 'updated', 'desc', :resource_class => Erratum, :includes => [:cves])

  @installable_errata_ids = []
  if @host.content_facet
    @installable_errata_ids = @host.content_facet.installable_errata.pluck("#{Katello::Erratum.table_name}.id")
  end

  respond_for_index :collection => collection
end

#resource_classObject



24
25
26
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 24

def resource_class
  Erratum
end

#showObject



75
76
77
78
79
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 75

def show
  errata = Erratum.find_by(:errata_id => params[:id])
  fail HttpErrors::NotFound, _("Couldn't find errata ids '%s'") % params[:id] unless errata
  respond_for_show :resource => errata
end