class Wavefront::Dashboards
Wrappers around the v1 dashboards API
Constants
- DEFAULT_PATH
Attributes
endpoint[R]
headers[R]
noop[R]
verbose[R]
Public Class Methods
new(token, host = DEFAULT_HOST, debug = false, options = {})
click to toggle source
# File lib/wavefront/dashboards.rb, line 20 def initialize(token, host = DEFAULT_HOST, debug = false, options = {}) # # Following existing convention, 'host' is the Wavefront API endpoint. # @headers = { :'X-AUTH-TOKEN' => token } @endpoint = host debug(debug) @noop = options[:noop] @verbose = options[:verbose] end
Public Instance Methods
clone(source_id, dest_id, dest_name, source_ver = nil)
click to toggle source
# File lib/wavefront/dashboards.rb, line 39 def clone(source_id, dest_id, dest_name, source_ver = nil) # # Clone a dashboard. If source_ver is not truthy, the latest # version of the source is used. # qs = hash_to_qs(name: dest_name, url: dest_id) qs.<< "&v=#{source_ver}" if source_ver call_post(create_uri(path: uri_concat(source_id, 'clone')), qs, 'application/x-www-form-urlencoded') end
create(id, name)
click to toggle source
# File lib/wavefront/dashboards.rb, line 81 def create(id, name) call_post(create_uri(path: uri_concat([id, 'create'])), "name=#{URI.encode(name)}", 'application/x-www-form-urlencoded') end
create_uri(options = {})
click to toggle source
# File lib/wavefront/dashboards.rb, line 87 def create_uri(options = {}) # # Build the URI we use to send a 'create' request. # options[:host] ||= endpoint options[:path] ||= '' options[:qs] ||= nil URI::HTTPS.build( host: options[:host], path: uri_concat(DEFAULT_PATH, options[:path]), query: options[:qs] ) end
debug(enabled)
click to toggle source
# File lib/wavefront/dashboards.rb, line 102 def debug(enabled) RestClient.log = 'stdout' if enabled end
delete(id)
click to toggle source
# File lib/wavefront/dashboards.rb, line 71 def delete(id) call_post(create_uri(path: uri_concat(id, 'delete'))) end
export(id, version = nil)
click to toggle source
# File lib/wavefront/dashboards.rb, line 75 def export(id, version = nil) path = version ? uri_concat(id, version) : id resp = call_get(create_uri(path: path)) || '{}' JSON.parse(resp) end
history(id, start = 100, limit = nil)
click to toggle source
# File lib/wavefront/dashboards.rb, line 51 def history(id, start = 100, limit = nil) qs = "start=#{start}" qs.<< "&limit=#{limit}" if limit call_get(create_uri(path: uri_concat(id, 'history'), qs: qs)) end
import(schema, force = false)
click to toggle source
# File lib/wavefront/dashboards.rb, line 31 def import(schema, force = false) # # Imports a dashboard described as a JSON string (schema) # qs = force ? nil : 'rejectIfExists=true' call_post(create_uri(qs: qs), schema, 'application/json') end
list(opts = {})
click to toggle source
# File lib/wavefront/dashboards.rb, line 58 def list(opts = {}) qs = [] opts[:private].map { |t| qs.<< "userTag=#{t}" } if opts[:private] opts[:shared].map { |t| qs.<< "customerTag=#{t}" } if opts[:shared] call_get(create_uri(qs: qs.join('&'))) end
undelete(id)
click to toggle source
# File lib/wavefront/dashboards.rb, line 67 def undelete(id) call_post(create_uri(path: uri_concat(id, 'undelete'))) end