Class: AlertManagement::HttpIntegrations::CreateService

Inherits:
BaseService show all
Defined in:
app/services/alert_management/http_integrations/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 BaseService

#initialize

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

#group_container?, #initialize, #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

This class inherits a constructor from AlertManagement::HttpIntegrations::BaseService

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/alert_management/http_integrations/create_service.rb', line 6

def execute
  return error_no_permissions unless allowed?

  ::AlertManagement::HttpIntegration.transaction do
    integration = project.alert_management_http_integrations.build(permitted_params)

    if integration.save
      @response = success(integration)

      if too_many_integrations?(integration)
        @response = error_multiple_integrations

        raise ActiveRecord::Rollback
      end
    else
      @response = error_on_save(integration)
    end
  end

  @response
end