Class: HammerCLIForeman::AssociatingCommands::ProvisioningTemplate::RemoveProvisioningTemplateCommand

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

Instance Method Summary collapse

Methods inherited from RemoveAssociatedCommand

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



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/hammer_cli_foreman/associating_commands.rb', line 256

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.delete(template_id.to_s)
    end
  end
  params[resource.singular_name]['provisioning_template_ids'] = template_ids.uniq
  params
end