Class: WavefrontCli::DerivedMetric

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

Overview

CLI coverage for the v2 ‘derivedmetric’ API.

Constant Summary

Constants included from Constants

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

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_status, #conds_to_query, #dispatch, #display, #display_api_error, #display_no_api_response, #do_import, #do_list, #do_search, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #do_update, #extract_values, #failed_validation_message, #format_var, #handle_error, #handle_response, #hcl_fields, #import_to_create, #initialize, #load_display_class, #load_file, #load_from_stdin, #mk_creds, #mk_opts, #no_api_response, #ok_exit, #one_or_all, #options_and_exit, #parseable_output, #range_hash, #run, #search_key, #validate_id, #validate_input, #validate_opts, #validate_tags, #validator_method

Constructor Details

This class inherits a constructor from WavefrontCli::Base

Instance Method Details

#build_bodyObject

rubocop:disable Metrics/AbcSize



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/wavefront-cli/derivedmetric.rb', line 42

def build_body
  ret = { query:                  options[:'<query>'],
          name:                   options[:'<name>'],
          minutes:                options[:range].to_i,
          includeObsoleteMetrics: options[:obsolete],
          processRateMinutes:     options[:interval].to_i }

  ret[:additionalInformation] = options[:desc] if options[:desc]
  ret[:tags] = options[:ctag] if valid_tags?
  ret
end

#do_createObject



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

def do_create
  wf.create(build_body)
end

#do_deleteObject

rubocop:disable Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wavefront-cli/derivedmetric.rb', line 17

def do_delete
  cannot_noop!

  word = if wf.describe(options[:'<id>']).status.code == 200
           'Soft'
         else
           'Permanently'
         end

  puts format('%s deleting derived metric definition %s', word,
              options[:'<id>'])

  wf.delete(options[:'<id>'])
end

#do_describeObject



12
13
14
# File 'lib/wavefront-cli/derivedmetric.rb', line 12

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

#do_historyObject

rubocop:enable Metrics/AbcSize



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

def do_history
  wf.history(options[:'<id>'])
end

#valid_tags?Boolean

rubocop:enable Metrics/AbcSize

Returns:

  • (Boolean)


55
56
57
# File 'lib/wavefront-cli/derivedmetric.rb', line 55

def valid_tags?
  !options[:ctag].empty? && validate_tags(options[:ctag])
end

#validator_exceptionObject



8
9
10
# File 'lib/wavefront-cli/derivedmetric.rb', line 8

def validator_exception
  Wavefront::Exception::InvalidDerivedMetricId
end