Class: WavefrontDisplay::ServiceAccount

Inherits:
Base
  • Object
show all
Defined in:
lib/wavefront-cli/display/serviceaccount.rb

Overview

Format human-readable output for service account commands.

Constant Summary

Constants included from WavefrontCli::Constants

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_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, #quoted, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #search_display_keys, #time_formats

Constructor Details

This class inherits a constructor from WavefrontDisplay::Base

Instance Method Details

#do_activateObject



22
23
24
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 22

def do_activate
  puts format("Activated service account '#{options[:'<id>']}'.")
end

#do_apitoken_deleteObject



67
68
69
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 67

def do_apitoken_delete
  puts format("Deleted API token '#{options[:'<token_id>']}'.")
end

#do_apitoken_listObject



59
60
61
62
63
64
65
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 59

def do_apitoken_list
  if data.empty?
    puts 'Account does not have any API tokens.'
  else
    multicolumn(:tokenID, :tokenName)
  end
end

#do_deactivateObject



26
27
28
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 26

def do_deactivate
  puts format("Deactivated service account '#{options[:'<id>']}'.")
end

#do_deleteObject



71
72
73
74
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 71

def do_delete
  puts format("Deleted #{friendly_name} %<quoted_account>s.",
              quoted_account: quoted(options[:'<account>']))
end

#do_describeObject



10
11
12
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 10

def do_describe
  long_output
end

#do_grantObject



49
50
51
52
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 49

def do_grant
  puts format("Granted '%<perm>s' to '%<account>s'.",
              perm: options[:'<permission>'], account: options[:'<id>'])
end

#do_groupsObject Also known as: do_join, do_leave



30
31
32
33
34
35
36
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 30

def do_groups
  if data[:userGroups].empty?
    puts 'Account does not belong to any groups.'
  else
    data[:userGroups].each { |u| puts format('%<id>s (%<name>s)', u) }
  end
end

#do_list_briefObject



14
15
16
17
18
19
20
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 14

def do_list_brief
  if data.empty?
    puts 'You have no service accounts.'
  else
    multicolumn(:identifier, :description)
  end
end

#do_permissionsObject



41
42
43
44
45
46
47
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 41

def do_permissions
  if data[:groups].empty?
    puts 'Account does not have any Wavefront permissions.'
  else
    puts data[:groups]
  end
end

#do_revokeObject



54
55
56
57
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 54

def do_revoke
  puts format("Revoked '%<perm>s' from '%<account>s'.",
              perm: options[:'<permission>'], account: options[:'<id>'])
end

#priority_keysObject



80
81
82
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 80

def priority_keys
  %i[identifier]
end

#search_identifier_keyObject



76
77
78
# File 'lib/wavefront-cli/display/serviceaccount.rb', line 76

def search_identifier_key
  :identifier
end