Class: Api::V2::JobTemplatesController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V2::JobTemplatesController
- 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
- #clone ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #export ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #resource_name(nested_resource = nil) ⇒ Object
- #revision ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#clone ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
94 95 96 |
# File 'app/controllers/api/v2/job_templates_controller.rb', line 94 def destroy process_response @job_template.destroy end |
#export ⇒ Object
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 |
#import ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/api/v2/job_templates_controller.rb', line 28 def import = params[:overwrite] ? { :update => true } : { :build_new => true } @job_template = JobTemplate.import_raw(params[:template], ) @job_template ||= JobTemplate.new process_response @job_template.save end |
#index ⇒ Object
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 |
#revision ⇒ Object
87 88 89 90 |
# File 'app/controllers/api/v2/job_templates_controller.rb', line 87 def revision audit = Audit.(:view_audit_logs).find(params[:version]) render :json => audit.revision.template end |
#show ⇒ Object
45 46 |
# File 'app/controllers/api/v2/job_templates_controller.rb', line 45 def show end |
#update ⇒ Object
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 |