Class: Katello::Api::V2::ContentViewFilterRulesController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ContentViewFilterRulesController
show all
- Defined in:
- app/controllers/katello/api/v2/content_view_filter_rules_controller.rb
Instance Method Summary
collapse
#full_result_response, #resource_class, #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
#api_version
Instance Method Details
#create ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/katello/api/v2/content_view_filter_rules_controller.rb', line 32
def create
rule_clazz = ContentViewFilter.rule_class_for(@filter)
if rule_params.key?(:errata_ids)
rules = []
rule_params[:errata_ids].each do |errata_id|
rules << rule_clazz.create!({:errata_id => errata_id}.merge(:filter => @filter))
end
else
rule = rule_clazz.create!(rule_params.merge(:filter => @filter))
end
if rules && rule.nil?
respond_for_index(:collection => {:results => rules}, :template => 'index')
else
respond :resource => rule
end
end
|
#destroy ⇒ Object
86
87
88
89
|
# File 'app/controllers/katello/api/v2/content_view_filter_rules_controller.rb', line 86
def destroy
@rule.destroy
respond_for_show :resource => @rule
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/katello/api/v2/content_view_filter_rules_controller.rb', line 8
def index
ids = ContentViewFilter.rule_ids_for(@filter)
results = ids.map { |id| ContentViewFilter.rule_class_for(@filter).find(id) }
collection = {
:results => results.uniq,
:subtotal => results.count,
:total => results.count
}
respond :collection => collection
end
|
#show ⇒ Object
54
55
56
|
# File 'app/controllers/katello/api/v2/content_view_filter_rules_controller.rb', line 54
def show
respond :resource => @rule
end
|
#update ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/katello/api/v2/content_view_filter_rules_controller.rb', line 70
def update
update_params = rule_params
if @rule.filter.content_type == ContentViewPackageFilter::CONTENT_TYPE
update_params[:version] = "" unless rule_params[:version]
update_params[:min_version] = "" unless rule_params[:min_version]
update_params[:max_version] = "" unless rule_params[:max_version]
end
@rule.update_attributes!(update_params)
respond :resource => @rule
end
|