Class: HammerCLIForeman::AssociatedResourceListCommand

Inherits:
ListCommand
  • Object
show all
Defined in:
lib/hammer_cli_foreman/commands.rb

Direct Known Subclasses

Host::FactsCommand

Constant Summary

Constants inherited from ListCommand

ListCommand::DEFAULT_PER_PAGE, ListCommand::RETRIEVE_ALL_PER_PAGE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ListCommand

#adapter, command_names, #execute, #extend_data, #help, output, #send_request, #transform_format

Methods inherited from Command

alias_name_for_resource, build_options, connection_name, #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

Class Method Details

.create_option_builderObject



466
467
468
469
470
471
# File 'lib/hammer_cli_foreman/commands.rb', line 466

def self.create_option_builder
  builder = super
  builder.builders << SearchablesOptionBuilder.new(parent_resource, searchables)
  builder.builders << IdOptionBuilder.new(parent_resource)
  builder
end

.parent_resource(name = nil) ⇒ Object



460
461
462
463
464
# File 'lib/hammer_cli_foreman/commands.rb', line 460

def self.parent_resource(name=nil)
  @parent_api_resource = HammerCLIForeman.foreman_resource!(name) unless name.nil?
  return @parent_api_resource if @parent_api_resource
  return superclass.parent_resource if superclass.respond_to? :parent_resource
end

Instance Method Details

#parent_resourceObject



456
457
458
# File 'lib/hammer_cli_foreman/commands.rb', line 456

def parent_resource
  self.class.parent_resource
end

#request_paramsObject



473
474
475
476
477
478
479
# File 'lib/hammer_cli_foreman/commands.rb', line 473

def request_params
  id_param_name = "#{parent_resource.singular_name}_id"

  params = super
  params[id_param_name] = get_resource_id(parent_resource)
  params
end