Sha256: d9524d89f0c3d39deb95de374e3a6a75a751b9bacd29ae9404ea58a15250d713

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
runcible-2.0.1 lib/runcible/resources/task_group.rb
runcible-2.0.0 lib/runcible/resources/task_group.rb
runcible-1.11.0 lib/runcible/resources/task_group.rb
runcible-1.10.0 lib/runcible/resources/task_group.rb
runcible-1.9.3 lib/runcible/resources/task_group.rb