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

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

Constant Summary

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

#full_result_response, #scoped_search

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

#applyObject



38
39
40
41
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 38

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

#indexObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 25

def index
  if  (params[:content_view_id] && params[:environment_id].nil?) || (params[:environment_id] && params[:content_view_id].nil?)
    fail _("Either both parameters 'content_view_id' and 'environment_id' should be specified or neither should be specified")
  end

  collection = scoped_search(index_relation, 'updated_at', 'desc', :resource_class => Erratum, :includes => [:cves])
  @installable_errata_ids = @host.content_facet.installable_errata.pluck("#{Katello::Erratum.table_name}.id")
  respond_for_index :collection => collection
end

#resource_classObject



16
17
18
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 16

def resource_class
  Erratum
end

#showObject



46
47
48
49
50
# File 'app/controllers/katello/api/v2/host_errata_controller.rb', line 46

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