Class: Api::V2::JobTemplatesController

Inherits:
BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::Parameters::JobTemplate, Foreman::Controller::ProvisioningTemplates, Foreman::Renderer
Defined in:
app/controllers/api/v2/job_templates_controller.rb

Instance Method Summary collapse

Instance Method Details

#cloneObject



107
108
109
110
111
112
# File 'app/controllers/api/v2/job_templates_controller.rb', line 107

def clone
  @job_template = @job_template.clone
  load_vars_from_template
  @job_template.name = job_template_params[:name]
  process_response @job_template.save
end

#createObject



73
74
75
76
# File 'app/controllers/api/v2/job_templates_controller.rb', line 73

def create
  @job_template = JobTemplate.new(job_template_params)
  process_response @job_template.save
end

#destroyObject



94
95
96
# File 'app/controllers/api/v2/job_templates_controller.rb', line 94

def destroy
  process_response @job_template.destroy
end

#exportObject



38
39
40
41
# File 'app/controllers/api/v2/job_templates_controller.rb', line 38

def export
  Foreman::Deprecation.api_deprecation_warning('Exporting template is provided by Foreman core, please use that endpoint instead')
  send_data @job_template.to_erb, :type => 'text/plain', :disposition => 'attachment', :filename => @job_template.filename
end

#importObject



28
29
30
31
32
33
34
# File 'app/controllers/api/v2/job_templates_controller.rb', line 28

def import
  options = params[:overwrite] ? { :update => true } : { :build_new => true }

  @job_template = JobTemplate.import_raw(params[:template], options)
  @job_template ||= JobTemplate.new
  process_response @job_template.save
end

#indexObject



21
22
23
# File 'app/controllers/api/v2/job_templates_controller.rb', line 21

def index
  @job_templates = resource_scope_for_index
end

#resource_name(nested_resource = nil) ⇒ Object



114
115
116
# File 'app/controllers/api/v2/job_templates_controller.rb', line 114

def resource_name(nested_resource = nil)
  nested_resource || 'job_template'
end

#revisionObject



87
88
89
90
# File 'app/controllers/api/v2/job_templates_controller.rb', line 87

def revision
  audit = Audit.authorized(:view_audit_logs).find(params[:version])
  render :json => audit.revision.template
end

#showObject



45
46
# File 'app/controllers/api/v2/job_templates_controller.rb', line 45

def show
end

#updateObject



81
82
83
# File 'app/controllers/api/v2/job_templates_controller.rb', line 81

def update
  process_response @job_template.update(job_template_params)
end