summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/alert_management/http_integration/create.rb
blob: ff165d7f30232f5722a68232443eeaacc3ab8da7 (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
49
50
# frozen_string_literal: true

module Mutations
  module AlertManagement
    module HttpIntegration
      class Create < HttpIntegrationBase
        include ResolvesProject

        graphql_name 'HttpIntegrationCreate'

        argument :project_path, GraphQL::ID_TYPE,
                 required: true,
                 description: 'The project to create the integration in.'

        argument :name, GraphQL::STRING_TYPE,
                 required: true,
                 description: 'The name of the integration.'

        argument :active, GraphQL::BOOLEAN_TYPE,
                 required: true,
                 description: 'Whether the integration is receiving alerts.'

        def resolve(args)
          @project = authorized_find!(full_path: args[:project_path])

          response ::AlertManagement::HttpIntegrations::CreateService.new(
            project,
            current_user,
            http_integration_params(args)
          ).execute
        end

        private

        attr_reader :project

        def find_object(full_path:)
          resolve_project(full_path: full_path)
        end

        # overriden in EE
        def http_integration_params(args)
          args.slice(:name, :active)
        end
      end
    end
  end
end

Mutations::AlertManagement::HttpIntegration::Create.prepend_if_ee('::EE::Mutations::AlertManagement::HttpIntegration::Create')