Class: ForemanStatistics::Api::V2::TrendsController
- Inherits:
-
Api::V2::BaseController
- Object
- Api::V2::BaseController
- ForemanStatistics::Api::V2::TrendsController
- Includes:
- Parameters::Trend
- Defined in:
- app/controllers/foreman_statistics/api/v2/trends_controller.rb
Constant Summary collapse
- TRENDABLE_TYPES =
%w[ Environment Operatingsystem Model FactName Hostgroup ComputeResource ].freeze
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #resource_scope(options = {}) ⇒ Object
-
#resource_scope_for_index(options = {}) ⇒ Object
Overload this method to avoid using search_for method.
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 33 def create @trend = ForemanStatistics::Trend.build_trend(trend_params) if @trend.save process_success else process_resource_error end end |
#destroy ⇒ Object
44 45 46 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 44 def destroy process_response @trend.destroy end |
#index ⇒ Object
21 22 23 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 21 def index @trends = resource_scope_for_index end |
#resource_scope(options = {}) ⇒ Object
53 54 55 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 53 def resource_scope( = {}) @resource_scope ||= scope_for(ForemanStatistics::Trend.types, ) end |
#resource_scope_for_index(options = {}) ⇒ Object
Overload this method to avoid using search_for method
49 50 51 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 49 def resource_scope_for_index( = {}) resource_scope().paginate() end |
#show ⇒ Object
27 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 27 def show; end |