Parent

Class/Module Index [+]

Quicksearch

HammerCLIForeman::Command

Public Class Methods

build_options(builder_params={}) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 123
def self.build_options(builder_params={})
  builder_params[:resource_mapping] ||= resource_name_mapping
  builder_params = HammerCLIForeman::BuildParams.new(builder_params)
  yield(builder_params) if block_given?

  super(builder_params.to_hash, &nil)
end
connection_name(resource_class) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 89
def self.connection_name(resource_class)
  CONNECTION_NAME
end
create_option_builder() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 109
def self.create_option_builder
  configurator = BuilderConfigurator.new(searchables, dependency_resolver)

  builder = ForemanOptionBuilder.new(searchables)
  builder.builders = []
  builder.builders += configurator.builders_for(resource, resource.action(action)) if resource_defined?
  builder.builders += super.builders
  builder
end
dependency_resolver() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 154
def self.dependency_resolver
  HammerCLIForeman::DependencyResolver.new
end
resolver() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 149
def self.resolver
  api = HammerCLI::Connection.get("foreman").api
  HammerCLIForeman::IdResolver.new(api, HammerCLIForeman::Searchables.new)
end
resource_config() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 93
def self.resource_config
  super.merge(HammerCLIForeman.resource_config)
end
resource_name_mapping() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 119
def self.resource_name_mapping
  HammerCLIForeman::RESOURCE_NAME_MAPPING
end
searchables() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 158
def self.searchables
  @searchables ||= HammerCLIForeman::Searchables.new
  @searchables
end

Public Instance Methods

customized_options() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 167
def customized_options
  params = options
  # resolve all '<resource_name>_id' parameters if they are defined as options
  # (they can be skipped using .without or .expand.except)
  IdParamsFilter.new(:only_required => false).for_action(resource.action(action)).each do |api_param|
    param_resource = HammerCLIForeman.param_to_resource(api_param.name)
    if param_resource && respond_to?(HammerCLI.option_accessor_name("#{param_resource.singular_name}_id"))
      resource_id = get_resource_id(param_resource, :scoped => true, :required => api_param.required?)
      params[HammerCLI.option_accessor_name(api_param.name)] = resource_id if resource_id
    end
  end
  # resolve 'id' parameter if it's defined as an option
  id_option_name = HammerCLI.option_accessor_name('id')
  params[id_option_name] ||= get_identifier if respond_to?(id_option_name)
  params
end
dependency_resolver() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 101
def dependency_resolver
  self.class.dependency_resolver
end
get_identifier() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 131
def get_identifier
  @identifier ||= get_resource_id(resource)
  @identifier
end
get_resource_id(resource, options={}) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 136
def get_resource_id(resource, options={})
  if options[:scoped]
    opts = resolver.scoped_options(resource.singular_name, all_options)
  else
    opts = all_options
  end
  begin
    resolver.send("#{resource.singular_name}_id", opts)
  rescue HammerCLIForeman::MissingSeachOptions => e
    raise e unless (options[:required] == false)
  end
end
request_params() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 184
def request_params
  params = customized_options
  params_pruned = method_options(params)

  # Options defined manualy in commands are removed in method_options.
  # Manual ids are common so its handling is covered here
  id_option_name = HammerCLI.option_accessor_name('id')
  params_pruned['id'] = params[id_option_name] if params[id_option_name]
  params_pruned
end
resolver() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 97
def resolver
  self.class.resolver
end
searchables() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 105
def searchables
  self.class.searchables
end
send_request() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 163
def send_request
  HammerCLIForeman.record_to_common_format(super)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.