Class: Wavefront::Alerting
- Inherits:
-
Object
- Object
- Wavefront::Alerting
show all
- Includes:
- Constants
- Defined in:
- lib/wavefront/alerting.rb
Constant Summary
collapse
- DEFAULT_PATH =
'/api/alert/'
Constants included
from Constants
Constants::DEFAULT_FORMAT, Constants::DEFAULT_HOST, Constants::DEFAULT_PERIOD_SECONDS, Constants::DEFAULT_PREFIX_LENGTH, Constants::DEFAULT_STRICT, Constants::FORMATS, Constants::GRANULARITIES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(token, debug = false) ⇒ Alerting
Returns a new instance of Alerting.
31
32
33
34
|
# File 'lib/wavefront/alerting.rb', line 31
def initialize(token, debug=false)
@token = token
debug(debug)
end
|
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
29
30
31
|
# File 'lib/wavefront/alerting.rb', line 29
def token
@token
end
|
Instance Method Details
#active(options = {}) ⇒ Object
36
37
38
|
# File 'lib/wavefront/alerting.rb', line 36
def active(options={})
get_alerts('active', options)
end
|
#affected_by_maintenance(options = {}) ⇒ Object
52
53
54
|
# File 'lib/wavefront/alerting.rb', line 52
def affected_by_maintenance(options={})
get_alerts('affected_by_maintenance', options)
end
|
#all(options = {}) ⇒ Object
40
41
42
|
# File 'lib/wavefront/alerting.rb', line 40
def all(options={})
get_alerts('all', options)
end
|
#get_alerts(path, options = {}) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/wavefront/alerting.rb', line 56
def get_alerts(path, options={})
options[:host] ||= DEFAULT_HOST
options[:path] ||= DEFAULT_PATH
query = "t=#{@token}"
if options[:shared_tags]
tags = options[:shared_tags].class == Array ? options[:shared_tags] : [ options[:shared_tags] ] query += "&#{tags.map{|t| "customerTag=#{t}"}.join('&')}"
end
if options[:private_tags]
tags = options[:private_tags].class == Array ? options[:private_tags] : [ options[:private_tags] ] query += "&#{tags.map{|t| "userTag=#{t}"}.join('&')}"
end
uri = URI::HTTPS.build(
host: options[:host],
path: File.join(options[:path], path),
query: query
)
RestClient.get(uri.to_s)
end
|
#invalid(options = {}) ⇒ Object
44
45
46
|
# File 'lib/wavefront/alerting.rb', line 44
def invalid(options={})
get_alerts('invalid', options)
end
|
#snoozed(options = {}) ⇒ Object
48
49
50
|
# File 'lib/wavefront/alerting.rb', line 48
def snoozed(options={})
get_alerts('snoozed', options)
end
|