Module: DTK::Client::ActionResultHandler

Defined in:
lib/commands/common/thor/action_result_handler.rb

Instance Method Summary collapse

Instance Method Details

#action_results(action_results_id, number_of_retries = 8) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/commands/common/thor/action_result_handler.rb', line 45

def action_results(action_results_id, number_of_retries=8)
  action_body = {
    :action_results_id => action_results_id,
    :return_only_if_complete => true,
    :disable_post_processing => true
  }
  response = nil

  number_of_retries.times do
    response = post(rest_url("assembly/get_action_results"),action_body)

    # server has found an error
    unless response.data(:results).nil?
      if response.data(:results)['error']
        raise DTK::Client::DtkError, response.data(:results)['error']
      end
    end

    break if response.data(:is_complete)

    sleep(1.5)
  end

  response

end


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/commands/common/thor/action_result_handler.rb', line 22

def print_action_results(action_results_id, number_of_retries=8)
  response = action_results(action_results_id, number_of_retries)

  if response.ok? && response.data['results']
    response.data['results'].each do |k,v|
      if v['error']
        OsUtil.print("#{v['error']} (#{k})", :red)
      else
        OsUtil.print("#{v['message']} (#{k})", :yellow)
      end
    end
  else
    OsUtil.print("Not able to process given request, we apologise for inconvenience", :red)
  end

  nil
end


40
41
42
43
# File 'lib/commands/common/thor/action_result_handler.rb', line 40

def print_simple_results(action_results_id, number_of_retries=8)
  response = action_results(action_results_id, number_of_retries)
  pp response
end