Class: Katello::Api::V2::ErrataController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ErrataController
show all
- Includes:
- Concerns::Api::V2::RepositoryContentController
- Defined in:
- app/controllers/katello/api/v2/errata_controller.rb
Instance Method Summary
collapse
#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #resource_class, #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
#api_version
Instance Method Details
#all_for_content_view_filter(filter, _collection) ⇒ Object
37
38
39
40
41
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 37
def all_for_content_view_filter(filter, _collection)
available_ids = Erratum.joins(:repositories).merge(filter.applicable_repos)&.pluck(:errata_id) || []
added_ids = filter&.erratum_rules&.pluck(:errata_id) || []
Erratum.where(errata_id: available_ids + added_ids)
end
|
#available_for_content_view_filter(filter, collection) ⇒ Object
30
31
32
33
34
35
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 30
def available_for_content_view_filter(filter, collection)
collection = filter_by_content_view(filter, collection)
ids = Katello::ContentViewErratumFilterRule.where(:content_view_filter_id => filter.id).pluck("errata_id")
collection = collection.where("errata_id not in (?)", ids) unless ids.empty?
collection
end
|
#available_for_content_view_version(version) ⇒ Object
26
27
28
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 26
def available_for_content_view_version(version)
version.available_errata
end
|
#custom_index_relation(collection) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 43
def custom_index_relation(collection)
collection = filter_by_cve(params[:cve], collection) if params[:cve]
applicable = ::Foreman::Cast.to_bool(params[:errata_restrict_applicable]) || @host
installable = ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
if applicable || installable
hosts = @host ? ::Host::Managed.where(:id => @host.id) : ::Host::Managed.authorized("view_hosts")
hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
if installable
collection = collection.where(:id => Erratum.ids_installable_for_hosts(hosts))
elsif applicable
collection = collection.applicable_to_hosts(hosts)
end
end
date_type = params[:date_type].present? ? params[:date_type] : ContentViewErratumFilterRule::UPDATED
unless ContentViewErratumFilterRule::DATE_TYPES.include?(date_type)
msg = _("Invalid params provided - date_type must be one of %s" % ContentViewErratumFilterRule::DATE_TYPES.join(","))
fail HttpErrors::UnprocessableEntity, msg
end
collection = collection.where("#{date_type} >= ?", params[:start_date]) if params[:start_date]
collection = collection.where("#{date_type} <= ?", params[:end_date]) if params[:end_date]
collection = collection.of_type(params[:types]) if params[:types]
collection
end
|
#index ⇒ Object
22
23
24
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 22
def index
super
end
|