Class: HammerCLIForemanTemplates::ImportCommand

Inherits:
HammerCLIForeman::Command
  • Object
show all
Defined in:
lib/hammer_cli_foreman_templates/import.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hammer_cli_foreman_templates/import.rb', line 29

def execute
  templates = send_request['templates']
  if option_verbose
    templates.each do |template|
      if template['validation_errors'].empty?
        template['validation_errors'] = nil
      else
        validation_errors = []
        template['validation_errors'].each do |key, value|
          validation_errors << "#{key.capitalize}: #{value}"
        end
        template['validation_errors'] = validation_errors
      end
    end
  else
    templates = []
  end
  print_data(templates)
  HammerCLI::EX_OK
end