Class: HammerCLICsv::CsvCommand::SettingsCommand
- Inherits:
-
BaseCommand
- Object
- HammerCLI::Apipie::Command
- BaseCommand
- HammerCLICsv::CsvCommand::SettingsCommand
show all
- Defined in:
- lib/hammer_cli_csv/settings.rb
Constant Summary
collapse
- VALUE =
'Value'
Constants inherited
from BaseCommand
BaseCommand::COUNT, BaseCommand::NAME
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#apipie_check_param, #associate_locations, #associate_organizations, #authenticate_request, #build_os_name, #check_server_status, #collect_column, #count, #execute, #export_column, #foreman_architecture, #foreman_container, #foreman_domain, #foreman_environment, #foreman_filter, #foreman_host, #foreman_hostgroup, #foreman_location, #foreman_medium, #foreman_operatingsystem, #foreman_organization, #foreman_partitiontable, #foreman_permission, #foreman_provisioning_template, #foreman_role, #foreman_smart_proxy, #foreman_template_kind, #hammer, #hammer_context, #help, help_columns, #katello_contentview, #katello_contentviewversion, #katello_hostcollection, #katello_product, #katello_repository, #labelize, #lifecycle_environment, #namify, #pluralize, #split_os_name, #supported?, #thread_import
#api_connection
Class Method Details
.supported? ⇒ Boolean
9
10
11
|
# File 'lib/hammer_cli_csv/settings.rb', line 9
def self.supported?
true
end
|
Instance Method Details
#create_settings_from_csv(line) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/hammer_cli_csv/settings.rb', line 31
def create_settings_from_csv(line)
count(line[COUNT]).times do |number|
name = namify(line[NAME], number)
params = { 'id' => get_setting_id(name),
'setting' => {
'value' => line[VALUE]
}
}
print "Updating setting '#{name}'..." if option_verbose?
@api.resource(:settings).call(:update, params)
end
print "done\n" if option_verbose?
end
|
#export(csv) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/hammer_cli_csv/settings.rb', line 13
def export(csv)
csv << [NAME, VALUE]
@api.resource(:settings).call(:index, {
'per_page' => 999999,
'search' => option_search
})['results'].each do |setting|
csv << [setting['name'], setting['value']]
end
end
|
#import ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/hammer_cli_csv/settings.rb', line 23
def import
@existing = {}
thread_import do |line|
create_settings_from_csv(line)
end
end
|