Class: HammerCLIForeman::AssociatingCommands::ProvisioningTemplate::AddProvisioningTemplateCommand

Inherits:
HammerCLIForeman::AddAssociatedCommand show all
Defined in:
lib/hammer_cli_foreman/associating_commands.rb

Instance Method Summary collapse

Methods inherited from HammerCLIForeman::AddAssociatedCommand

command_name, desc, failure_message, #get_new_ids, success_message

Methods inherited from HammerCLIForeman::AssociatedCommand

associated_resource, #associated_resource, #association_name, create_option_builder, default_message, #get_associated_identifier, #get_associated_identifiers, #get_current_ids, #get_new_ids

Methods inherited from Command

alias_name_for_resource, build_options, connection_name, create_option_builder, #customized_options, #dependency_resolver, dependency_resolver, #exception_handler_class, #get_identifier, #get_resource_id, #get_resource_ids, resolver, #resolver, resource_alias_name_mapping, resource_config, resource_name_mapping, #searchables, searchables, #send_request, #transform_format

Instance Method Details

#request_paramsObject



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/hammer_cli_foreman/associating_commands.rb', line 221

def request_params
  params = super
  template_ids = params[resource.singular_name]['provisioning_template_ids']
  if options['option_provisioning_template_search']
    templates = HammerCLIForeman.collection_to_common_format(
      associated_resource.call(
        :index,
        :search => "name ~ \"#{options['option_provisioning_template_search']}\"")
    )
    raise ResolverError.new(_("%s not found.") % associated_resource.singular_name, associated_resource) if templates.empty?

    templates.each do |template|
      template_id = template['id']
      template_ids << template_id.to_s
    end
  end
  params[resource.singular_name]['provisioning_template_ids'] = template_ids.uniq
  params
end