Class: IncidentManagement::LinkAlerts::CreateService

Inherits:
BaseService show all
Defined in:
app/services/incident_management/link_alerts/create_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

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

Instance Method Summary collapse

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(incident, current_user, alert_references) ⇒ CreateService

Returns a new instance of CreateService.

Parameters:

  • incident (Issue)

    an incident to link alerts

  • current_user (User)
  • alert_references ([String])

    a list of alert references. Can be either a short reference or URL Examples:

    "^alert#IID"
    "https://gitlab.com/company/project/-/alert_management/IID/details"
    


12
13
14
15
16
17
18
# File 'app/services/incident_management/link_alerts/create_service.rb', line 12

def initialize(incident, current_user, alert_references)
  @incident = incident
  @current_user = current_user
  @alert_references = alert_references

  super(project: incident.project, current_user: current_user)
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
# File 'app/services/incident_management/link_alerts/create_service.rb', line 20

def execute
  return error_no_permissions unless allowed?

  references = extract_alerts_from_references
  incident.alert_management_alerts << references if references.present?

  success
end