blob: 58c3a062910c87b198e825dc95840f31afc98f80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# frozen_string_literal: true
module IncidentManagement
module PagerDuty
class CreateIncidentIssueService < BaseService
include IncidentManagement::Settings
def initialize(project, incident_payload)
super(project, Users::Internal.alert_bot, incident_payload)
end
def execute
return forbidden unless webhook_available?
create_incident
end
private
alias_method :incident_payload, :params
def create_incident
::IncidentManagement::Incidents::CreateService.new(
project,
current_user,
title: issue_title,
description: issue_description
).execute
end
def webhook_available?
incident_management_setting.pagerduty_active?
end
def forbidden
ServiceResponse.error(message: 'Forbidden', http_status: :forbidden)
end
def issue_title
incident_payload['title']
end
def issue_description
Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription.new(incident_payload).to_s
end
end
end
end
|