class WavefrontCli::Dashboard

CLI coverage for the v2 'dashboard' API.

Public Instance Methods

do_delete() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 25
def do_delete
  smart_delete
end
do_describe() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 21
def do_describe
  wf.describe(options[:'<id>'], options[:version])
end
do_fav() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 50
def do_fav
  wf.favorite(options[:'<id>'])
  do_favs
end
do_favs() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 43
def do_favs
  require 'wavefront-sdk/search'
  wfs = Wavefront::Search.new(mk_creds, mk_opts)
  query = conds_to_query(['favorite=true'])
  wfs.search(:dashboard, query, limit: :all, sort_field: :id)
end
do_history() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 29
def do_history
  wf.history(options[:'<id>'])
end
do_queries() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 33
def do_queries
  resp, data = one_or_all

  queries = data.each_with_object({}) do |d, a|
    a[d.id] = extract_values(d, 'query')
  end

  resp.tap { |r| r.response.items = queries }
end
do_unfav() click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 55
def do_unfav
  wf.unfavorite(options[:'<id>'])
  do_favs
end
list_filter(list) click to toggle source
# File lib/wavefront-cli/dashboard.rb, line 15
def list_filter(list)
  return list unless options[:nosystem]

  list.tap { |l| l.response.items.delete_if { |d| d[:systemOwned] } }
end
preprocess_rawfile(raw) click to toggle source

Dashboards are, AFAIK, unique in that they do NOT require an ID. They can have a URL instead: the two are equivalent. The easiest workaround for this is to copy the URL to the ID if we only have the former.

# File lib/wavefront-cli/dashboard.rb, line 65
def preprocess_rawfile(raw)
  raw[:id] = raw[:url] if raw.key?(:url) && !raw.key?(:id)
  raw
end