Class: WavefrontCli::ServiceAccount

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

Overview

CLI coverage for the v2 ‘serviceaccount’ API.

Constant Summary

Constants included from Constants

Constants::ALL_PAGE_SIZE, Constants::DEFAULT_CONFIG, Constants::DEFAULT_OPTS, Constants::EVENT_STATE_DIR, Constants::HUMAN_TIME_FORMAT, Constants::HUMAN_TIME_FORMAT_MS, Constants::SEARCH_SPLIT

Instance Attribute Summary collapse

Attributes inherited from Base

#klass, #klass_word, #options, #wf

Instance Method Summary collapse

Methods inherited from Base

#_sdk_class, #cannot_noop!, #check_response_blocks, #check_status, #cli_output_class, #conds_to_query, #dispatch, #display, #display_api_error, #display_class, #display_no_api_response, #do_dump, #do_import, #do_search, #do_set, #do_undelete, #dump_json, #dump_yaml, #extract_values, #failed_validation_message, #format_var, #handle_error, #handle_response, #hcl_fields, #import_to_create, #initialize, #load_display_class, #matching_method, #method_word_list, #mk_creds, #mk_opts, #name_of_do_method, #no_api_response, #ok_exit, #one_or_all, #options_and_exit, #parseable_output, #range_hash, #require_sdk_class, #run, #search_key, #smart_delete, #smart_delete_message, #status_error_handler, #unsupported_format_message, #validate_id, #validate_input, #validate_opts, #validate_tags, #validator_method, #warning_message

Constructor Details

This class inherits a constructor from WavefrontCli::Base

Instance Attribute Details

#wf_apitokenObject (readonly)

Returns the value of attribute wf_apitoken.



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

def wf_apitoken
  @wf_apitoken
end

Instance Method Details

#do_activateObject



33
34
35
# File 'lib/wavefront-cli/serviceaccount.rb', line 33

def do_activate
  wf.activate(options[:'<id>'])
end

#do_apitoken_createObject



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

def do_apitoken_create
  wf_apitoken.sa_create(options[:'<id>'], options[:name])
end

#do_apitoken_deleteObject



85
86
87
# File 'lib/wavefront-cli/serviceaccount.rb', line 85

def do_apitoken_delete
  wf_apitoken.sa_delete(options[:'<id>'], options[:'<token_id>'])
end

#do_apitoken_listObject



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

def do_apitoken_list
  wf_apitoken.sa_list(options[:'<id>'])
end

#do_apitoken_renameObject



89
90
91
92
93
# File 'lib/wavefront-cli/serviceaccount.rb', line 89

def do_apitoken_rename
  wf_apitoken.sa_rename(options[:'<id>'],
                        options[:'<token_id>'],
                        options[:'<name>'])
end

#do_createObject



28
29
30
31
# File 'lib/wavefront-cli/serviceaccount.rb', line 28

def do_create
  wf_user_id?(options[:'<id>'])
  wf.create(user_body)
end

#do_deactivateObject



37
38
39
# File 'lib/wavefront-cli/serviceaccount.rb', line 37

def do_deactivate
  wf.deactivate(options[:'<id>'])
end

#do_deleteObject



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

def do_delete
  .delete_accounts(options[:'<account>'])
end

#do_describeObject Also known as: do_groups, do_permissions



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

def do_describe
  wf.describe(options[:'<id>'])
end

#do_grantObject



61
62
63
64
65
66
67
# File 'lib/wavefront-cli/serviceaccount.rb', line 61

def do_grant
  cannot_noop!
  wf_permission?(options[:'<permission>'])

  body = add_perm_to_list(current_state, options[:'<permission>'])
  wf.update(options[:'<id>'], body)
end

#do_joinObject



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

def do_join
  cannot_noop!
  options[:'<group>'].each { |g| wf_usergroup_id?(g) }

  body = add_groups_to_list(current_state, options[:'<group>'])
  wf.update(options[:'<id>'], body)
end

#do_leaveObject



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

def do_leave
  cannot_noop!
  options[:'<group>'].each { |g| wf_usergroup_id?(g) }

  body = remove_groups_from_list(current_state, options[:'<group>'])
  wf.update(options[:'<id>'], body)
end

#do_listObject



17
18
19
# File 'lib/wavefront-cli/serviceaccount.rb', line 17

def do_list
  wf.list
end

#do_revokeObject



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

def do_revoke
  cannot_noop!
  wf_permission?(options[:'<permission>'])

  body = remove_perm_from_list(current_state, options[:'<permission>'])
  wf.update(options[:'<id>'], body)
end

#extra_validationObject



95
96
97
98
99
# File 'lib/wavefront-cli/serviceaccount.rb', line 95

def extra_validation
  validate_groups
  validate_tokens
  validate_perms
end

#post_initialize(_options) ⇒ Object



13
14
15
# File 'lib/wavefront-cli/serviceaccount.rb', line 13

def post_initialize(_options)
  @wf_apitoken = Wavefront::ApiToken.new(mk_creds, mk_opts)
end

#validator_exceptionObject



101
102
103
# File 'lib/wavefront-cli/serviceaccount.rb', line 101

def validator_exception
  Wavefront::Exception::InvalidServiceAccountId
end