Class: Katello::Api::V2::DebsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::DebsController
show all
- Includes:
- Concerns::Api::V2::RepositoryContentController
- Defined in:
- app/controllers/katello/api/v2/debs_controller.rb
Instance Method Summary
collapse
#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
#api_version
Instance Method Details
#auto_complete(search) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 13
def auto_complete(search)
page_size = Katello::Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
debs = Deb.in_repositories(@repositories)
col = ''
if search == 'name'
col = "#{Deb.table_name}.name"
elsif search == 'arch'
col = "#{Deb.table_name}.architecture"
end
debs = debs.where("#{col} ILIKE ?", "#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
render :json => debs.pluck(col)
end
|
#auto_complete_arch ⇒ Object
30
31
32
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 30
def auto_complete_arch
auto_complete('architecture')
end
|
#auto_complete_name ⇒ Object
26
27
28
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 26
def auto_complete_name
auto_complete('name')
end
|
#available_for_content_view_version(version) ⇒ Object
84
85
86
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 84
def available_for_content_view_version(version)
version.available_debs
end
|
#custom_index_relation(collection) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 88
def custom_index_relation(collection)
applicable = ::Foreman::Cast.to_bool(params[:packages_restrict_applicable]) || params[:host_id]
upgradable = ::Foreman::Cast.to_bool(params[:packages_restrict_upgradable])
if upgradable
collection = collection.installable_for_hosts(@hosts)
elsif applicable
collection = collection.applicable_to_hosts(@hosts)
end
collection
end
|
#default_sort ⇒ Object
79
80
81
82
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 79
def default_sort
lambda { |query| query.default_sort }
end
|
#filter_by_content_view_filter(filter, collection) ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 64
def filter_by_content_view_filter(filter, collection)
filtered_debs = []
filter.deb_rules.each do |rule|
filtered_debs += filter.query_debs_from_collection(collection, rule).pluck(:id)
end
collection.where(id: filter.applicable_debs.pluck(:id) & filtered_debs)
end
|
#filter_by_content_view_filter_rule(rule, collection) ⇒ Object
73
74
75
76
77
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 73
def filter_by_content_view_filter_rule(rule, collection)
filter = rule.filter
filtered_debs = filter.query_debs_from_collection(collection, rule).pluck(:id)
collection.where(id: filter.applicable_debs.pluck(:id) & filtered_debs)
end
|
#final_custom_index_relation(collection) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 54
def final_custom_index_relation(collection)
collection = Katello::Deb.latest(collection) if ::Foreman::Cast.to_bool(params[:packages_restrict_latest])
collection
end
|
#index ⇒ Object
50
51
52
|
# File 'app/controllers/katello/api/v2/debs_controller.rb', line 50
def index
super
end
|