diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /app/services/incident_management | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'app/services/incident_management')
-rw-r--r-- | app/services/incident_management/issuable_escalation_statuses/create_service.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/services/incident_management/issuable_escalation_statuses/create_service.rb b/app/services/incident_management/issuable_escalation_statuses/create_service.rb new file mode 100644 index 00000000000..e28debf0fa3 --- /dev/null +++ b/app/services/incident_management/issuable_escalation_statuses/create_service.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module IncidentManagement + module IssuableEscalationStatuses + class CreateService < BaseService + def initialize(issue) + @issue = issue + @alert = issue.alert_management_alert + end + + def execute + escalation_status = ::IncidentManagement::IssuableEscalationStatus.new(issue: issue, **alert_params) + + if escalation_status.save + ServiceResponse.success(payload: { escalation_status: escalation_status }) + else + ServiceResponse.error(message: escalation_status.errors&.full_messages) + end + end + + private + + attr_reader :issue, :alert + + def alert_params + return {} unless alert + + { + status_event: alert.status_event_for(alert.status_name) + } + end + end + end +end + +IncidentManagement::IssuableEscalationStatuses::CreateService.prepend_mod |