Module: HammerCLIForeman::Template::TemplateCreateUpdateCommons

Included in:
CreateCommand, UpdateCommand
Defined in:
lib/hammer_cli_foreman/template.rb

Instance Method Summary collapse

Instance Method Details

#kindsObject



22
23
24
25
# File 'lib/hammer_cli_foreman/template.rb', line 22

def kinds
  HammerCLIForeman.collection_to_common_format(
    HammerCLIForeman.foreman_resource!(:template_kinds).call(:index))
end

#option_snippetObject



9
10
11
# File 'lib/hammer_cli_foreman/template.rb', line 9

def option_snippet
  option_type && (option_type == "snippet")
end

#option_template_kind_idObject



13
14
15
16
17
18
19
20
# File 'lib/hammer_cli_foreman/template.rb', line 13

def option_template_kind_id
  table = kinds.inject({}){ |result, k| result.update(k["name"] => k["id"]) }
  if option_snippet == false && table[option_type].nil?
    signal_usage_error _("unknown template kind")
  else
    table[option_type]
  end
end