Sha256: fa9d96c0f8758af9c89663c99c8cc7e230d492a566ac85e321650c9e01d9f440

Contents?: true

Size: 933 Bytes

Versions: 40

Compression:

Stored size: 933 Bytes

Contents

module Mutations
  module RecurringLogics
    class Cancel < BaseMutation
      graphql_name 'CancelRecurringLogic'
      description 'Cancels recurring logic and all its active tasks'
      resource_class ::ForemanTasks::RecurringLogic

      argument :id, ID, required: true

      field :errors, [Types::AttributeError], null: false
      field :recurring_logic, Types::RecurringLogic, null: true

      def resolve(id:)
        recurring_logic = load_object_by(id: id)
        authorize!(recurring_logic, :edit)
        task_errors = []
        begin
          recurring_logic.cancel
        rescue => e
          task_errors = [{ path: ['tasks'], message: "There has been an error when canceling one of the tasks: #{e}" }]
        end
        errors = recurring_logic.errors.any? ? map_errors_to_path(recurring_logic) : []
        { recurring_logic: recurring_logic, errors: (errors + task_errors) }
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
foreman-tasks-10.0.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-10.0.0 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.2.3 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.2.2 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.2.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.2.0 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.1.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.0.4 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.1.0 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.0.2 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.0.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.3.3 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-9.0.0 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.2.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.1.4 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.3.2 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.3.1 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.1.3 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.3.0 app/graphql/mutations/recurring_logics/cancel.rb
foreman-tasks-8.2.0 app/graphql/mutations/recurring_logics/cancel.rb