Class: WavefrontCli::Dashboard
- Defined in:
- lib/wavefront-cli/dashboard.rb
Overview
CLI coverage for the v2 ‘dashboard’ API.
Constant Summary
Constants included from Constants
Constants::ALL_PAGE_SIZE, 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
- #do_delete ⇒ Object
- #do_describe ⇒ Object
- #do_history ⇒ Object
- #do_queries ⇒ Object
- #extract_values(obj, key, aggr = []) ⇒ Array
Methods inherited from Base
#_sdk_class, #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, #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, #options_and_exit, #parseable_output, #range_hash, #run, #search_key, #validate_id, #validate_input, #validate_opts, #validate_tags, #validator_exception, #validator_method
Constructor Details
This class inherits a constructor from WavefrontCli::Base
Instance Method Details
#do_delete ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wavefront-cli/dashboard.rb', line 12 def do_delete word = if wf.describe([:'<id>']).status.code == 200 'Soft' else 'Permanently' end puts "#{word} deleting dashboard '#{[:'<id>']}'." wf.delete([:'<id>']) end |
#do_describe ⇒ Object
8 9 10 |
# File 'lib/wavefront-cli/dashboard.rb', line 8 def do_describe wf.describe([:'<id>'], [:version]) end |
#do_history ⇒ Object
23 24 25 |
# File 'lib/wavefront-cli/dashboard.rb', line 23 def do_history wf.history([:'<id>']) end |
#do_queries ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/wavefront-cli/dashboard.rb', line 27 def do_queries resp = wf.list(0, :all) queries = resp.response.items.each_with_object({}) do |d, a| a[d.id] = extract_values(d, 'query') end resp.tap { |r| r.response.items = queries } end |
#extract_values(obj, key, aggr = []) ⇒ Array
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wavefront-cli/dashboard.rb', line 42 def extract_values(obj, key, aggr = []) if obj.is_a?(Hash) obj.each_pair do |k, v| if k == key && !v.to_s.empty? aggr.<< v else extract_values(v, key, aggr) end end elsif obj.is_a?(Array) obj.each { |e| extract_values(e, key, aggr) } end aggr end |