class HammerCLIForeman::ReportTemplate::ScheduleCommand

Public Instance Methods

execute() click to toggle source
# File lib/hammer_cli_foreman/report_template.rb, line 96
def execute
  data = send_request
  if option_wait?
    poll_for_report(data)
  else
    print_message(_('The report has been scheduled. Job ID: %{job_id}') % { job_id: data['job_id'] })
  end
  HammerCLI::EX_OK
end
request_params() click to toggle source
# File lib/hammer_cli_foreman/report_template.rb, line 90
def request_params
  params = super
  params['input_values'] = option_inputs || {}
  params
end

Private Instance Methods

build_report_data_args(schedule_data) click to toggle source
# File lib/hammer_cli_foreman/report_template.rb, line 120
def build_report_data_args(schedule_data)
  [
    '--id', option_id,
    '--job-id', schedule_data['job_id'],
    '--path', option_path
  ]
end
poll_for_report(schedule_data) click to toggle source
# File lib/hammer_cli_foreman/report_template.rb, line 110
def poll_for_report(schedule_data)
  report_data_args = build_report_data_args(schedule_data)
  report_command = ReportDataCommand.new(invocation_path, context)
  report_command.parse(report_data_args)
  begin
    response = report_command.send_request
  end while response && response.code == 204
  report_command.handle_success(response)
end