Class: Dogapi::V1::MonitorService
Constant Summary
collapse
- API_VERSION =
'v1'
Instance Attribute Summary
Attributes inherited from APIService
#api_key, #application_key
Instance Method Summary
collapse
-
#can_delete_monitors(monitor_ids) ⇒ Object
-
#cancel_downtime(downtime_id) ⇒ Object
-
#cancel_downtime_by_scope(scope) ⇒ Object
-
#delete_monitor(monitor_id, options = {}) ⇒ Object
-
#get_all_downtimes(options = {}) ⇒ Object
-
#get_all_monitors(options = {}) ⇒ Object
-
#get_downtime(downtime_id, options = {}) ⇒ Object
-
#get_monitor(monitor_id, options = {}) ⇒ Object
-
#monitor(type, query, options = {}) ⇒ Object
-
#mute_host(hostname, options = {}) ⇒ Object
-
#mute_monitor(monitor_id, options = {}) ⇒ Object
-
#mute_monitors ⇒ Object
-
#resolve_monitors(monitor_groups = [], options = {}, version = nil) ⇒ Object
-
#schedule_downtime(scope, options = {}) ⇒ Object
-
#search_monitor_groups(options = {}) ⇒ Object
-
#search_monitors(options = {}) ⇒ Object
-
#unmute_host(hostname) ⇒ Object
-
#unmute_monitor(monitor_id, options = {}) ⇒ Object
-
#unmute_monitors ⇒ Object
-
#update_downtime(downtime_id, options = {}) ⇒ Object
-
#update_monitor(monitor_id, query = nil, options = {}) ⇒ Object
-
#validate_monitor(type, query, options = {}) ⇒ Object
Methods inherited from APIService
#connect, #handle_redirect, #handle_response, #initialize, #prepare_params, #prepare_request, #request, #should_set_api_and_app_keys_in_params?, #suppress_error_if_silent
Instance Method Details
#can_delete_monitors(monitor_ids) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/dogapi/v1/monitor.rb', line 45
def can_delete_monitors(monitor_ids)
=
if monitor_ids.respond_to?(:join)
{ "monitor_ids" => monitor_ids.join(",") }
else
{ "monitor_ids" => monitor_ids }
end
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/can_delete", , nil, false)
end
|
#cancel_downtime(downtime_id) ⇒ Object
140
141
142
|
# File 'lib/dogapi/v1/monitor.rb', line 140
def cancel_downtime(downtime_id)
request(Net::HTTP::Delete, "/api/#{API_VERSION}/downtime/#{downtime_id}", nil, nil, false)
end
|
#cancel_downtime_by_scope(scope) ⇒ Object
144
145
146
|
# File 'lib/dogapi/v1/monitor.rb', line 144
def cancel_downtime_by_scope(scope)
request(Net::HTTP::Post, "/api/#{API_VERSION}/downtime/cancel/by_scope", nil, { 'scope' => scope }, true)
end
|
#delete_monitor(monitor_id, options = {}) ⇒ Object
56
57
58
|
# File 'lib/dogapi/v1/monitor.rb', line 56
def delete_monitor(monitor_id, options = {})
request(Net::HTTP::Delete, "/api/#{API_VERSION}/monitor/#{monitor_id}", options, nil, false)
end
|
#get_all_downtimes(options = {}) ⇒ Object
148
149
150
|
# File 'lib/dogapi/v1/monitor.rb', line 148
def get_all_downtimes(options = {})
request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime", options, nil, false)
end
|
#get_all_monitors(options = {}) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/dogapi/v1/monitor.rb', line 60
def get_all_monitors(options = {})
= options.clone
if [:group_states].respond_to?(:join)
[:group_states] = [:group_states].join(',')
end
[:tags] = [:tags].join(',') if [:tags].respond_to?(:join)
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor", , nil, false)
end
|
#get_downtime(downtime_id, options = {}) ⇒ Object
136
137
138
|
# File 'lib/dogapi/v1/monitor.rb', line 136
def get_downtime(downtime_id, options = {})
request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime/#{downtime_id}", options, nil, false)
end
|
#get_monitor(monitor_id, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/dogapi/v1/monitor.rb', line 32
def get_monitor(monitor_id, options = {})
= options.clone
if [:group_states].respond_to?(:join)
[:group_states] = [:group_states].join(',')
end
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/#{monitor_id}", , nil, false)
end
|
#monitor(type, query, options = {}) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/dogapi/v1/monitor.rb', line 10
def monitor(type, query, options = {})
body = {
'type' => type,
'query' => query,
}.merge options
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor", nil, body, true)
end
|
#mute_host(hostname, options = {}) ⇒ Object
155
156
157
|
# File 'lib/dogapi/v1/monitor.rb', line 155
def mute_host(hostname, options = {})
request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/mute", nil, options, true)
end
|
#mute_monitor(monitor_id, options = {}) ⇒ Object
94
95
96
|
# File 'lib/dogapi/v1/monitor.rb', line 94
def mute_monitor(monitor_id, options = {})
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/mute", nil, options, true)
end
|
#mute_monitors ⇒ Object
86
87
88
|
# File 'lib/dogapi/v1/monitor.rb', line 86
def mute_monitors
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/mute_all", nil, nil, false)
end
|
#resolve_monitors(monitor_groups = [], options = {}, version = nil) ⇒ Object
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/dogapi/v1/monitor.rb', line 102
def resolve_monitors(monitor_groups = [], options = {}, version = nil)
body = {
'resolve' => monitor_groups
}.merge options
endpoint = version.nil? ? '/api/monitor/bulk_resolve' : "/api/#{version}/monitor/bulk_resolve"
request(Net::HTTP::Post, endpoint, nil, body, true)
end
|
#schedule_downtime(scope, options = {}) ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/dogapi/v1/monitor.rb', line 124
def schedule_downtime(scope, options = {})
body = {
'scope' => scope
}.merge options
request(Net::HTTP::Post, "/api/#{API_VERSION}/downtime", nil, body, true)
end
|
#search_monitor_groups(options = {}) ⇒ Object
117
118
119
|
# File 'lib/dogapi/v1/monitor.rb', line 117
def search_monitor_groups(options = {})
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/groups/search", options, nil, false)
end
|
#search_monitors(options = {}) ⇒ Object
113
114
115
|
# File 'lib/dogapi/v1/monitor.rb', line 113
def search_monitors(options = {})
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/search", options, nil, false)
end
|
#unmute_host(hostname) ⇒ Object
159
160
161
|
# File 'lib/dogapi/v1/monitor.rb', line 159
def unmute_host(hostname)
request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/unmute", nil, {}, true)
end
|
#unmute_monitor(monitor_id, options = {}) ⇒ Object
98
99
100
|
# File 'lib/dogapi/v1/monitor.rb', line 98
def unmute_monitor(monitor_id, options = {})
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/unmute", nil, options, true)
end
|
#unmute_monitors ⇒ Object
90
91
92
|
# File 'lib/dogapi/v1/monitor.rb', line 90
def unmute_monitors
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/unmute_all", nil, nil, false)
end
|
#update_downtime(downtime_id, options = {}) ⇒ Object
132
133
134
|
# File 'lib/dogapi/v1/monitor.rb', line 132
def update_downtime(downtime_id, options = {})
request(Net::HTTP::Put, "/api/#{API_VERSION}/downtime/#{downtime_id}", nil, options, true)
end
|
#update_monitor(monitor_id, query = nil, options = {}) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/dogapi/v1/monitor.rb', line 19
def update_monitor(monitor_id, query = nil, options = {})
body = {}.merge options
unless query.nil?
body = {
'query' => query
}.merge body
warn '[DEPRECATION] query param is not required anymore and should be set to nil.'\
' To update the query, set it in the options parameter instead'
end
request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true)
end
|
#validate_monitor(type, query, options = {}) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/dogapi/v1/monitor.rb', line 77
def validate_monitor(type, query, options = {})
body = {
'type' => type,
'query' => query,
}.merge options
request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/validate", nil, body, true)
end
|