Sha256: 562ba4620ab2a97c145f140ddb9e48eb73525f79edebcbb52904c377bd8d7e43

Contents?: true

Size: 1.38 KB

Versions: 19

Compression:

Stored size: 1.38 KB

Contents

module Runcible
  module Resources
    # @see https://docs.pulpproject.org/dev-guide/integration/rest-api/dispatch/index.html
    class TaskGroup < Runcible::Base
      # Generates the API path for Tasks
      #
      # @param  [String]  id  the id of the task
      # @return [String]      the task path, may contain the id if passed
      def self.path(id = nil)
        id.nil? ? 'task_groups/' : "task_groups/#{id}/"
      end

      def self.summary_path(id)
        "task_groups/#{id}/state_summary/"
      end

      # summary for the status of a task
      #
      # @param  [String]              id  the id of the task
      # @return [RestClient::Response]
      def summary(id)
        call(:get, self.class.summary_path(id))
      end

      # checks if all tasks in the summary report have completed
      # @param [Hash] the summary report obtained from summary(id) call
      # @return true if tasks in the summary report have completed
      def completed?(summary_report)
        sum = 0
        ["finished", "canceled", "skipped", "suspended", "error"].each do |state|
          sum += summary_report[state] if summary_report[state]
        end
        sum == summary_report["total"]
      end

      # cancel a task group
      # @param  [String] id  the id of the task
      # @return [RestClient::Response]
      def cancel(id)
        call(:delete, path(id))
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
runcible-2.13.1 lib/runcible/resources/task_group.rb
runcible-2.13.0 lib/runcible/resources/task_group.rb
runcible-2.12.1 lib/runcible/resources/task_group.rb
runcible-2.12.0 lib/runcible/resources/task_group.rb
runcible-2.11.1 lib/runcible/resources/task_group.rb
runcible-2.11.0 lib/runcible/resources/task_group.rb
runcible-2.10.1 lib/runcible/resources/task_group.rb
runcible-2.10.0 lib/runcible/resources/task_group.rb
runcible-2.9.0 lib/runcible/resources/task_group.rb
runcible-2.8.1 lib/runcible/resources/task_group.rb
runcible-2.8.0 lib/runcible/resources/task_group.rb
runcible-2.7.0 lib/runcible/resources/task_group.rb
runcible-2.6.0 lib/runcible/resources/task_group.rb
runcible-2.5.0 lib/runcible/resources/task_group.rb
runcible-2.4.0 lib/runcible/resources/task_group.rb
runcible-2.3.0 lib/runcible/resources/task_group.rb
runcible-2.2.0 lib/runcible/resources/task_group.rb
runcible-1.12.0 lib/runcible/resources/task_group.rb
runcible-2.1.0 lib/runcible/resources/task_group.rb