class Chef::Knife::RunsShow

Constants

HEADERS
PROTOCOL_VERSION

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/runs_show.rb, line 39
def run
  rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url])

  run_id = name_args[0]

  if run_id.nil?
    show_usage
    exit 1
  elsif uuid?(run_id)
    puts "Run ID should be a Chef Client Run ID, e.g: 11111111-1111-1111-1111-111111111111"
    exit 1
  end

  query_string = "reports/org/runs/#{run_id}"

  runs = rest.get(query_string, HEADERS)

  if runs['run_detail']['updated_res_count'] > runs['run_resources'].length
    all_query = "#{query_string}?start=0&rows=#{runs['run_detail']['updated_res_count']}"
    runs = rest.get(all_query, HEADERS)
  end
  output(runs)
end