Class: Api::V2::WebhookTemplatesController

Inherits:
V2::BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::TemplateImport, ForemanWebhooks::Controller::Parameters::WebhookTemplate
Defined in:
app/controllers/api/v2/webhook_templates_controller.rb

Instance Method Summary collapse

Methods included from ForemanWebhooks::Controller::Parameters::WebhookTemplate

#location_params, #organization_params, #webhook_template_params

Instance Method Details

#cloneObject



78
79
80
81
82
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 78

def clone
  @webhook_template = @webhook_template.dup
  @webhook_template.name = params[:webhook_template][:name]
  process_response @webhook_template.save
end

#createObject



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

def create
  @webhook_template = WebhookTemplate.new(webhook_template_params)
  process_response @webhook_template.save
end

#destroyObject



71
72
73
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 71

def destroy
  process_response @webhook_template.destroy
end

#exportObject



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

def export
  send_data @webhook_template.to_erb, type: 'text/plain',
                                      disposition: 'attachment',
                                      filename: @webhook_template.filename
end

#importObject



57
58
59
60
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 57

def import
  @webhook_template = WebhookTemplate.import!(*import_attrs_for(:webhook_template))
  process_response @webhook_template
end

#indexObject



15
16
17
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 15

def index
  @webhook_templates = resource_scope_for_index
end

#showObject



21
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 21

def show; end

#updateObject



65
66
67
# File 'app/controllers/api/v2/webhook_templates_controller.rb', line 65

def update
  process_response @webhook_template.update(webhook_template_params)
end