2020-07-13 21:09:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects
|
|
|
|
module IncidentManagement
|
|
|
|
class PagerDutyIncidentsController < Projects::ApplicationController
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
skip_before_action :verify_authenticity_token
|
|
|
|
skip_before_action :project
|
|
|
|
|
|
|
|
prepend_before_action :project_without_auth
|
|
|
|
|
2020-10-08 18:08:32 +00:00
|
|
|
feature_category :incident_management
|
2022-04-21 21:08:43 +00:00
|
|
|
urgency :low
|
2020-10-08 18:08:32 +00:00
|
|
|
|
2020-07-13 21:09:24 +00:00
|
|
|
def create
|
2020-07-15 21:09:26 +00:00
|
|
|
result = webhook_processor.execute(params[:token])
|
2020-07-13 21:09:24 +00:00
|
|
|
|
|
|
|
head result.http_status
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_without_auth
|
|
|
|
@project ||= Project
|
|
|
|
.find_by_full_path("#{params[:namespace_id]}/#{params[:project_id]}")
|
|
|
|
end
|
2020-07-15 21:09:26 +00:00
|
|
|
|
|
|
|
def webhook_processor
|
2020-12-22 15:09:51 +00:00
|
|
|
::IncidentManagement::PagerDuty::ProcessWebhookService.new(project, payload)
|
2020-07-15 21:09:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def payload
|
|
|
|
@payload ||= params.permit![:pager_duty_incident].to_h
|
|
|
|
end
|
2020-07-13 21:09:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|