Class: WavefrontDisplay::Role
- Inherits:
-
Base
- Object
- Base
- WavefrontDisplay::Role
show all
- Defined in:
- lib/wavefront-cli/display/role.rb
Overview
Format human-readable output for role command
Constant Summary
WavefrontCli::Constants::ALL_PAGE_SIZE, WavefrontCli::Constants::DEFAULT_CONFIG, WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::EVENT_STATE_DIR, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS, WavefrontCli::Constants::SEARCH_SPLIT
Instance Attribute Summary
Attributes inherited from Base
#data, #options, #raw
Instance Method Summary
collapse
Methods inherited from Base
#_prioritize_keys, #display_brief_freetext_results, #do_delete, #do_import, #do_list, #do_list_fields, #do_queries, #do_search, #do_search_brief, #do_search_fields, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_pathsearch, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #filter_data, #filter_fields_as_arr, #freetext_keys, #friendly_name, #human_time, #index_of_final_item, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #prioritize_keys, #priority_keys, #quoted, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #search_display_keys, #search_identifier_key, #time_formats
Instance Method Details
#do_accounts ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/wavefront-cli/display/role.rb', line 18
def do_accounts
if data.empty?
puts "No accounts have role '#{options[:'<id>']}'."
else
multicolumn(:identifier)
end
end
|
#do_give_to ⇒ Object
54
55
56
57
58
|
# File 'lib/wavefront-cli/display/role.rb', line 54
def do_give_to
puts format("Gave '%<role>s' to %<members>s.",
members: quoted(options[:'<member>']),
role: options[:'<id>']).fold(TW, 0)
end
|
#do_grant ⇒ Object
42
43
44
45
46
|
# File 'lib/wavefront-cli/display/role.rb', line 42
def do_grant
puts format("Granted '%<perm>s' permission to '%<id>s'.",
perm: options[:'<permission>'],
id: options[:'<id>'])
end
|
#do_groups ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/wavefront-cli/display/role.rb', line 26
def do_groups
if data.empty?
puts "No groups have role '#{options[:'<id>']}'."
else
multicolumn(:id, :name)
end
end
|
#do_list_brief ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/wavefront-cli/display/role.rb', line 10
def do_list_brief
data.map! do |d|
d.merge(acct_count: "#{d[:linkedAccountsCount]} accounts",
group_count: "#{d[:linkedGroupsCount]} groups")
end
multicolumn(:id, :name, :acct_count, :group_count)
end
|
#do_permissions ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/wavefront-cli/display/role.rb', line 34
def do_permissions
if data[:permissions].empty?
puts "Role '#{options[:'<id>']}' has no permissions."
else
puts data[:permissions]
end
end
|
#do_revoke ⇒ Object
48
49
50
51
52
|
# File 'lib/wavefront-cli/display/role.rb', line 48
def do_revoke
puts format("Revoked '%<perm>s' permission from '%<id>s'.",
perm: options[:'<permission>'],
id: options[:'<id>'])
end
|
#do_take_from ⇒ Object
60
61
62
63
64
|
# File 'lib/wavefront-cli/display/role.rb', line 60
def do_take_from
puts format("Took '%<role>s' from %<members>s.",
members: quoted(options[:'<member>']),
role: options[:'<id>']).fold(TW, 0)
end
|