Class: IncidentManagement::PagerDuty::ProcessWebhookService

Inherits:
BaseProjectService show all
Includes:
Gitlab::Utils::StrongMemoize, Settings
Defined in:
app/services/incident_management/pager_duty/process_webhook_service.rb

Constant Summary collapse

PAGER_DUTY_PAYLOAD_SIZE_LIMIT =
55.kilobytes
PAGER_DUTY_PROCESSABLE_EVENT_TYPES =
%w[incident.triggered].freeze

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods included from Settings

#auto_close_incident?, #incident_management_setting, #process_issues?

Methods inherited from BaseContainerService

#group_container?, #namespace_container?, #project_container?, #project_group

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(project, payload) ⇒ ProcessWebhookService

Returns a new instance of ProcessWebhookService.



15
16
17
18
19
# File 'app/services/incident_management/pager_duty/process_webhook_service.rb', line 15

def initialize(project, payload)
  super(project: project)

  @payload = payload
end

Instance Method Details

#execute(token) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'app/services/incident_management/pager_duty/process_webhook_service.rb', line 21

def execute(token)
  return forbidden unless webhook_setting_active?
  return unauthorized unless valid_token?(token)
  return bad_request unless valid_payload_size?

  process_incidents

  accepted
end