Class: ForemanStatistics::Api::V2::TrendsController

Inherits:
Api::V2::BaseController
  • Object
show all
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

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 32

def create
  @trend = ForemanStatistics::Trend.build_trend(trend_params)
  if @trend.save
    process_success
  else
    process_resource_error
  end
end

#destroyObject



43
44
45
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 43

def destroy
  process_response @trend.destroy
end

#indexObject



20
21
22
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 20

def index
  @trends = resource_scope_for_index
end

#resource_scope(options = {}) ⇒ Object



52
53
54
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 52

def resource_scope(options = {})
  @resource_scope ||= scope_for(ForemanStatistics::Trend.types, options)
end

#resource_scope_for_index(options = {}) ⇒ Object

Overload this method to avoid using search_for method



48
49
50
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 48

def resource_scope_for_index(options = {})
  resource_scope(options).paginate(paginate_options)
end

#showObject



26
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 26

def show; end