Class: WavefrontDisplay::User
- Inherits:
-
Base
- Object
- Base
- WavefrontDisplay::User
show all
- Defined in:
- lib/wavefront-cli/display/user.rb
Overview
Format human-readable output for user management.
Constant Summary
WavefrontCli::Constants::ALL_PAGE_SIZE, WavefrontCli::Constants::DEFAULT_CONFIG, WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS
Instance Attribute Summary
Attributes inherited from Base
#data, #options, #raw
Instance Method Summary
collapse
Methods inherited from Base
#_prioritize_keys, #do_import, #do_list, #do_list_fields, #do_queries, #do_search, #do_search_brief, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #filter_data, #filter_fields_as_arr, #friendly_name, #human_time, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #prioritize_keys, #priority_keys, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #time_formats
Instance Method Details
#do_create ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/wavefront-cli/display/user.rb', line 20
def do_create
puts format("Created user '%s'.\nPermission groups\n%s\n" \
"User groups\n%s",
data.response[:identifier],
groups_as_string(data.response.groups),
user_groups_as_string(data.response.userGroups))
end
|
#do_delete ⇒ Object
38
39
40
|
# File 'lib/wavefront-cli/display/user.rb', line 38
def do_delete
puts format('Deleted %s', options[:'<user>'].join(', '))
end
|
#do_groups ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/wavefront-cli/display/user.rb', line 12
def do_groups
if data.userGroups.empty?
puts 'User does not belong to any groups.'
else
data.userGroups.each { |u| puts format('%s (%s)', u[:id], u[:name]) }
end
end
|
#do_list_brief ⇒ Object
8
9
10
|
# File 'lib/wavefront-cli/display/user.rb', line 8
def do_list_brief
data.each { |user| puts user[:identifier] }
end
|
#groups_as_string(groups) ⇒ Object
28
29
30
31
|
# File 'lib/wavefront-cli/display/user.rb', line 28
def groups_as_string(groups)
return ' <none>' if groups.empty?
data.response.groups.map { |g| format(' %s', g) }.join("\n ")
end
|
#user_groups_as_string(groups) ⇒ Object
33
34
35
36
|
# File 'lib/wavefront-cli/display/user.rb', line 33
def user_groups_as_string(groups)
return ' <none>' if groups.empty?
groups.map { |g| format(' %s (%s)', g[:name], g[:id]) }.join("\n")
end
|