Class: Api::V2::TemplateController

Inherits:
BaseController
  • Object
show all
Includes:
Foreman::Controller::Parameters::TemplateParams
Defined in:
app/controllers/api/v2/template_controller.rb

Instance Method Summary collapse

Methods included from Foreman::Controller::Parameters::TemplateParams

#base_export_params, #base_import_params, #location_params, #log_deprecated_param, #organization_params, #template_export_params, #template_import_params, #transform_lock_param, #ui_template_export_params, #ui_template_import_params

Instance Method Details

#exportObject



39
40
41
42
43
# File 'app/controllers/api/v2/template_controller.rb', line 39

def export
  @result = ForemanTemplates::TemplateExporter.new(template_export_params).export!
  @result[:templates] = @result[:templates].map(&:to_h)
  render :json => { :message => @result }, :status => @result[:error] ? 500 : 200
end

#importObject



26
27
28
29
30
31
32
# File 'app/controllers/api/v2/template_controller.rb', line 26

def import
  verbose = params['verbose']
  @result = ForemanTemplates::TemplateImporter.new(template_import_params).import!
  render :json => { :message => { :templates => @result[:results].map { |res| res.to_h(verbose) },
                                  :repo => @result[:repo],
                                  :branch => @result[:branch] } }
end