Class: Api::V2::OmahaReportsController

Inherits:
V2::BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::SmartProxyAuth
Defined in:
app/controllers/api/v2/omaha_reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



44
45
46
47
48
49
# File 'app/controllers/api/v2/omaha_reports_controller.rb', line 44

def create
  @omaha_report = resource_class.import(params.to_unsafe_h[:omaha_report], detected_proxy.try(:id))
  process_response @omaha_report.errors.empty?
rescue ::Foreman::Exception => e
  render_message(e.to_s, :status => :unprocessable_entity)
end

#destroyObject



54
55
56
# File 'app/controllers/api/v2/omaha_reports_controller.rb', line 54

def destroy
  process_response @omaha_report.destroy
end

#indexObject



31
32
33
34
# File 'app/controllers/api/v2/omaha_reports_controller.rb', line 31

def index
  @omaha_reports = resource_scope_for_index.my_reports
  @total = resource_scope_for_index.my_reports.count
end

#lastObject



62
63
64
65
66
67
# File 'app/controllers/api/v2/omaha_reports_controller.rb', line 62

def last
  conditions = params[:host_id].present? ? { :host_id => resource_finder(Host.authorized(:view_hosts), params[:host_id]).try(:id) } : nil
  max_id = resource_scope.where(conditions).maximum(:id)
  @omaha_report = resource_scope.find(max_id)
  render :show
end

#showObject



39
# File 'app/controllers/api/v2/omaha_reports_controller.rb', line 39

def show; end