summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/alert_management/http_integration/update.rb
blob: 309c45b04ac0bdf492133df43c4003947942670d (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
# frozen_string_literal: true

module Mutations
  module AlertManagement
    module HttpIntegration
      class Update < HttpIntegrationBase
        graphql_name 'HttpIntegrationUpdate'

        argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration],
                 required: true,
                 description: "The id of the integration to mutate"

        argument :name, GraphQL::STRING_TYPE,
                 required: false,
                 description: "The name of the integration"

        argument :active, GraphQL::BOOLEAN_TYPE,
                 required: false,
                 description: "Whether the integration is receiving alerts"

        def resolve(args)
          integration = authorized_find!(id: args[:id])

          response ::AlertManagement::HttpIntegrations::UpdateService.new(
            integration,
            current_user,
            args.slice(:name, :active)
          ).execute
        end
      end
    end
  end
end