Class: WavefrontCli::Proxy

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

Overview

CLI coverage for the v2 ‘proxy’ 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

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, #descriptive_name, #dispatch, #display, #display_api_error, #display_class, #display_no_api_response, #do_describe, #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, #item_dump_call, #load_display_class, #matching_method, #method_word_list, #mk_creds, #mk_opts, #name_of_do_method, #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_exception, #validator_method, #warning_message

Constructor Details

This class inherits a constructor from WavefrontCli::Base

Instance Method Details

#do_deleteObject



24
25
26
# File 'lib/wavefront-cli/proxy.rb', line 24

def do_delete
  smart_delete
end

#do_listObject



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

def do_list
  options[:all] = true if options[:active]
  super
end

#do_renameObject



19
20
21
22
# File 'lib/wavefront-cli/proxy.rb', line 19

def do_rename
  wf_string?(options[:'<name>'])
  wf.rename(options[:'<id>'], options[:'<name>'])
end

#do_shutdownObject



35
36
37
# File 'lib/wavefront-cli/proxy.rb', line 35

def do_shutdown
  wf.shutdown(options[:'<id>'])
end

#do_versionsObject



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

def do_versions
  raw = wf.list(0, :all)
  exit if options[:noop]

  version_info(raw).sort_by { |p| Gem::Version.new(p[:version]) }.reverse
end

#extra_validationObject



45
46
47
48
49
50
51
52
53
# File 'lib/wavefront-cli/proxy.rb', line 45

def extra_validation
  return unless options[:'<name>']

  begin
    wf_string?(options[:'<name>'])
  rescue Wavefront::Exception::InvalidString
    abort "'#{options[:'<name>']}' is not a valid proxy name."
  end
end

#no_api_responseObject



15
16
17
# File 'lib/wavefront-cli/proxy.rb', line 15

def no_api_response
  %w[do_versions]
end

#version_info(raw) ⇒ Object



39
40
41
42
43
# File 'lib/wavefront-cli/proxy.rb', line 39

def version_info(raw)
  raw.response.items.map do |i|
    { id: i.id, version: i.version, name: i.name }
  end
end