flapjack-diner 1.4.0 → 2.0.0.a4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/README.md +620 -413
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner/argument_validator.rb +77 -7
- data/lib/flapjack-diner/configuration.rb +409 -0
- data/lib/flapjack-diner/index_range.rb +42 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +47 -251
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/lib/flapjack-diner.rb +54 -20
- data/spec/argument_validator_spec.rb +87 -28
- data/spec/flapjack-diner_spec.rb +42 -64
- data/spec/relationships_spec.rb +211 -0
- data/spec/resources/checks_spec.rb +219 -79
- data/spec/resources/contacts_spec.rb +179 -151
- data/spec/resources/events_spec.rb +208 -0
- data/spec/resources/maintenance_periods_spec.rb +177 -565
- data/spec/resources/media_spec.rb +157 -171
- data/spec/resources/metrics_spec.rb +45 -0
- data/spec/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +93 -0
- data/spec/resources/statistics_spec.rb +53 -0
- data/spec/resources/tags_spec.rb +243 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fixture_data.rb +541 -0
- metadata +33 -31
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/checks.rb +0 -64
- data/lib/flapjack-diner/resources/contacts.rb +0 -70
- data/lib/flapjack-diner/resources/entities.rb +0 -68
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
- data/lib/flapjack-diner/resources/media.rb +0 -61
- data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
- data/lib/flapjack-diner/resources/notifications.rb +0 -28
- data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
- data/lib/flapjack-diner/resources/reports.rb +0 -33
- data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
- data/spec/resources/entities_spec.rb +0 -181
- data/spec/resources/notification_rules_spec.rb +0 -341
- data/spec/resources/notifications_spec.rb +0 -208
- data/spec/resources/pagerduty_credentials_spec.rb +0 -237
- data/spec/resources/reports_spec.rb +0 -255
data/spec/spec_helper.rb
CHANGED
@@ -21,6 +21,19 @@ require 'pact/consumer/rspec'
|
|
21
21
|
|
22
22
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
23
23
|
|
24
|
+
# Requires supporting files with custom matchers and macros, etc,
|
25
|
+
# in ./support/ and its subdirectories.
|
26
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
27
|
+
|
28
|
+
# ISO8601_RE = %r{^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$}
|
29
|
+
|
30
|
+
ISO8601_PAT = "(?:[1-9][0-9]*)?[0-9]{4}-" \
|
31
|
+
"(?:1[0-2]|0[1-9])-" \
|
32
|
+
"(?:3[0-1]|0[1-9]|[1-2][0-9])T" \
|
33
|
+
"(?:2[0-3]|[0-1][0-9]):" \
|
34
|
+
"[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?" \
|
35
|
+
"(?:Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?"
|
36
|
+
|
24
37
|
Pact.service_consumer 'flapjack-diner' do
|
25
38
|
|
26
39
|
has_pact_with "flapjack" do
|
@@ -40,4 +53,7 @@ RSpec.configure do |config|
|
|
40
53
|
# the seed, which is printed after each run.
|
41
54
|
# --seed 1234
|
42
55
|
config.order = 'random'
|
56
|
+
|
57
|
+
config.include ::FixtureData
|
58
|
+
|
43
59
|
end
|
@@ -0,0 +1,541 @@
|
|
1
|
+
module FixtureData
|
2
|
+
|
3
|
+
# Not RSpec shared context, so it can be used in the pact provider too
|
4
|
+
|
5
|
+
def default_tear_down
|
6
|
+
Flapjack.logger.messages.clear
|
7
|
+
Flapjack.redis.flushdb
|
8
|
+
end
|
9
|
+
|
10
|
+
def api_host
|
11
|
+
'example.org'
|
12
|
+
end
|
13
|
+
|
14
|
+
def fixture_time
|
15
|
+
@fixture_time ||= Time.now
|
16
|
+
end
|
17
|
+
|
18
|
+
def resultify(data)
|
19
|
+
ret = nil
|
20
|
+
case data
|
21
|
+
when Array
|
22
|
+
ret = data.inject([]) do |memo, d|
|
23
|
+
attrs = d[:attributes] || {}
|
24
|
+
d.each_pair do |k, v|
|
25
|
+
next if :attributes.eql?(k)
|
26
|
+
attrs.update(k => v)
|
27
|
+
end
|
28
|
+
memo += [attrs]
|
29
|
+
memo
|
30
|
+
end
|
31
|
+
when Hash
|
32
|
+
ret = data[:attributes] || {}
|
33
|
+
data.each_pair do |k, v|
|
34
|
+
next if :attributes.eql?(k)
|
35
|
+
ret.update(k => v)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
ret = data
|
39
|
+
end
|
40
|
+
ret
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_data
|
44
|
+
@check_data ||= {
|
45
|
+
:id => '1ed80833-6d28-4aba-8603-d81c249b8c23',
|
46
|
+
:name => 'www.example.com:SSH',
|
47
|
+
:enabled => true
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_2_data
|
52
|
+
@check_2_data ||= {
|
53
|
+
:id => '29e913cf-29ea-4ae5-94f6-7069cf4a1514',
|
54
|
+
:name => 'www2.example.com:PING',
|
55
|
+
:enabled => true
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def check_json(ch_data)
|
60
|
+
id = ch_data[:id]
|
61
|
+
{
|
62
|
+
:id => id,
|
63
|
+
:type => 'check',
|
64
|
+
:attributes => ch_data.reject {|k,v| :id.eql?(k) }
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def check_rel(ch_data)
|
69
|
+
id = ch_data[:id]
|
70
|
+
{
|
71
|
+
:alerting_media => {
|
72
|
+
:links => {
|
73
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/alerting_media",
|
74
|
+
:related => "http://#{api_host}/checks/#{id}/alerting_media"
|
75
|
+
}
|
76
|
+
},
|
77
|
+
:contacts => {
|
78
|
+
:links => {
|
79
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/contacts",
|
80
|
+
:related => "http://#{api_host}/checks/#{id}/contacts"
|
81
|
+
}
|
82
|
+
},
|
83
|
+
:current_scheduled_maintenances => {
|
84
|
+
:links => {
|
85
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/current_scheduled_maintenances",
|
86
|
+
:related => "http://#{api_host}/checks/#{id}/current_scheduled_maintenances"
|
87
|
+
}
|
88
|
+
},
|
89
|
+
:current_state => {
|
90
|
+
:links => {
|
91
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/current_state",
|
92
|
+
:related => "http://#{api_host}/checks/#{id}/current_state"
|
93
|
+
}
|
94
|
+
},
|
95
|
+
:current_unscheduled_maintenance => {
|
96
|
+
:links => {
|
97
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/current_unscheduled_maintenance",
|
98
|
+
:related => "http://#{api_host}/checks/#{id}/current_unscheduled_maintenance"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
:latest_notifications => {
|
102
|
+
:links => {
|
103
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/latest_notifications",
|
104
|
+
:related => "http://#{api_host}/checks/#{id}/latest_notifications"
|
105
|
+
}
|
106
|
+
},
|
107
|
+
:scheduled_maintenances => {
|
108
|
+
:links => {
|
109
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/scheduled_maintenances",
|
110
|
+
:related => "http://#{api_host}/checks/#{id}/scheduled_maintenances"
|
111
|
+
}
|
112
|
+
},
|
113
|
+
:states => {
|
114
|
+
:links => {
|
115
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/states",
|
116
|
+
:related => "http://#{api_host}/checks/#{id}/states"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
:tags => {
|
120
|
+
:links => {
|
121
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/tags",
|
122
|
+
:related => "http://#{api_host}/checks/#{id}/tags"
|
123
|
+
}
|
124
|
+
},
|
125
|
+
:unscheduled_maintenances => {
|
126
|
+
:links => {
|
127
|
+
:self => "http://#{api_host}/checks/#{id}/relationships/unscheduled_maintenances",
|
128
|
+
:related => "http://#{api_host}/checks/#{id}/unscheduled_maintenances"
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def contact_data
|
135
|
+
@contact_data ||= {
|
136
|
+
:id => 'c248da6f-ab16-4ce3-9b32-afd4e5f5270e',
|
137
|
+
:name => 'Jim Smith',
|
138
|
+
:timezone => 'UTC',
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
def contact_2_data
|
143
|
+
@contact_2_data ||= {
|
144
|
+
:id => 'ff41bfbb-0d04-45e3-a4d2-579ed1655fb8',
|
145
|
+
:name => 'Joan Smith'
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def contact_json(co_data)
|
150
|
+
id = co_data[:id]
|
151
|
+
{
|
152
|
+
:id => id,
|
153
|
+
:type => 'contact',
|
154
|
+
:attributes => co_data.reject {|k,v| :id.eql?(k) }
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def contact_rel(co_data)
|
159
|
+
id = co_data[:id]
|
160
|
+
{
|
161
|
+
:checks => {
|
162
|
+
:links => {
|
163
|
+
:self => "http://#{api_host}/contacts/#{id}/relationships/checks",
|
164
|
+
:related => "http://#{api_host}/contacts/#{id}/checks"
|
165
|
+
}
|
166
|
+
},
|
167
|
+
:media => {
|
168
|
+
:links => {
|
169
|
+
:self => "http://#{api_host}/contacts/#{id}/relationships/media",
|
170
|
+
:related => "http://#{api_host}/contacts/#{id}/media"
|
171
|
+
}
|
172
|
+
},
|
173
|
+
:rules => {
|
174
|
+
:links => {
|
175
|
+
:self => "http://#{api_host}/contacts/#{id}/relationships/rules",
|
176
|
+
:related => "http://#{api_host}/contacts/#{id}/rules"
|
177
|
+
}
|
178
|
+
},
|
179
|
+
:tags => {
|
180
|
+
:links => {
|
181
|
+
:self => "http://#{api_host}/contacts/#{id}/relationships/tags",
|
182
|
+
:related => "http://#{api_host}/contacts/#{id}/tags"
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
def scheduled_maintenance_data
|
189
|
+
@scheduled_maintenance_data ||= {
|
190
|
+
:id => '9b7a7af4-8251-4216-8e86-2d4068447ae4',
|
191
|
+
:start_time => fixture_time.iso8601,
|
192
|
+
:end_time => (fixture_time + 3_600).iso8601,
|
193
|
+
:summary => 'working'
|
194
|
+
}
|
195
|
+
end
|
196
|
+
|
197
|
+
def scheduled_maintenance_2_data
|
198
|
+
@scheduled_maintenance_2_data ||= {
|
199
|
+
:id => '5a84c82b-0acb-4703-a27e-0b0db50b298a',
|
200
|
+
:start_time => (fixture_time + 7_200).iso8601,
|
201
|
+
:end_time => (fixture_time + 10_800).iso8601,
|
202
|
+
:summary => 'working'
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
def unscheduled_maintenance_data
|
207
|
+
@unscheduled_maintenance_data ||= {
|
208
|
+
:id => '9b7a7af4-8251-4216-8e86-2d4068447ae4',
|
209
|
+
:start_time => fixture_time.iso8601,
|
210
|
+
:end_time => (fixture_time + 3_600).iso8601,
|
211
|
+
:summary => 'working'
|
212
|
+
}
|
213
|
+
end
|
214
|
+
|
215
|
+
def unscheduled_maintenance_2_data
|
216
|
+
@unscheduled_maintenance_2_data ||= {
|
217
|
+
:id => '41895714-9b77-48a9-a373-5f6005b1ce95',
|
218
|
+
:start_time => (fixture_time + 4_700).iso8601,
|
219
|
+
:end_time => (fixture_time + 5_400).iso8601,
|
220
|
+
:summary => 'partly working'
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
def maintenance_json(type, m_data)
|
225
|
+
{
|
226
|
+
:id => m_data[:id],
|
227
|
+
:type => "#{type}_maintenance",
|
228
|
+
:attributes => m_data.reject {|k,v| :id.eql?(k) }
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
def maintenance_rel(type, m_data)
|
233
|
+
id = m_data[:id]
|
234
|
+
{
|
235
|
+
:check => {
|
236
|
+
:links => {
|
237
|
+
:self => "http://#{api_host}/#{type}_maintenances/#{id}/relationships/check",
|
238
|
+
:related => "http://#{api_host}/#{type}_maintenances/#{id}/check"
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
244
|
+
def sms_data
|
245
|
+
@sms_data ||= {
|
246
|
+
:id => 'e2e09943-ed6c-476a-a8a5-ec165426f298',
|
247
|
+
:transport => 'sms',
|
248
|
+
:address => '0123456789',
|
249
|
+
:interval => 300,
|
250
|
+
:rollup_threshold => 5,
|
251
|
+
:pagerduty_subdomain => nil,
|
252
|
+
:pagerduty_token => nil,
|
253
|
+
:pagerduty_ack_duration => nil
|
254
|
+
}
|
255
|
+
end
|
256
|
+
|
257
|
+
def email_data
|
258
|
+
@email_data ||= {
|
259
|
+
:id => '9156de3c-ddc6-4637-b1cc-bd035fd61dd3',
|
260
|
+
:transport => 'email',
|
261
|
+
:address => 'ablated@example.org',
|
262
|
+
:interval => 180,
|
263
|
+
:rollup_threshold => 3,
|
264
|
+
:pagerduty_subdomain => nil,
|
265
|
+
:pagerduty_token => nil,
|
266
|
+
:pagerduty_ack_duration => nil
|
267
|
+
}
|
268
|
+
end
|
269
|
+
|
270
|
+
def medium_json(me_data)
|
271
|
+
id = me_data[:id]
|
272
|
+
{
|
273
|
+
:id => id,
|
274
|
+
:type => 'medium',
|
275
|
+
:attributes => me_data.reject {|k,v| :id.eql?(k) }
|
276
|
+
}
|
277
|
+
end
|
278
|
+
|
279
|
+
def medium_rel(me_data)
|
280
|
+
id = me_data[:id]
|
281
|
+
{
|
282
|
+
:alerting_checks => {
|
283
|
+
:links => {
|
284
|
+
:self => "http://#{api_host}/media/#{id}/relationships/alerting_checks",
|
285
|
+
:related => "http://#{api_host}/media/#{id}/alerting_checks"
|
286
|
+
}
|
287
|
+
},
|
288
|
+
:contact => {
|
289
|
+
:links => {
|
290
|
+
:self => "http://#{api_host}/media/#{id}/relationships/contact",
|
291
|
+
:related => "http://#{api_host}/media/#{id}/contact"
|
292
|
+
}
|
293
|
+
},
|
294
|
+
:rules => {
|
295
|
+
:links => {
|
296
|
+
:self => "http://#{api_host}/media/#{id}/relationships/rules",
|
297
|
+
:related => "http://#{api_host}/media/#{id}/rules"
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
end
|
302
|
+
|
303
|
+
def rule_data
|
304
|
+
@rule_data ||= {
|
305
|
+
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
306
|
+
:enabled => true,
|
307
|
+
:blackhole => false,
|
308
|
+
:strategy => 'all_tags',
|
309
|
+
:conditions_list => 'critical'
|
310
|
+
}
|
311
|
+
end
|
312
|
+
|
313
|
+
def rule_2_data
|
314
|
+
@rule_2_data ||= {
|
315
|
+
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
316
|
+
:enabled => true,
|
317
|
+
:blackhole => true,
|
318
|
+
:strategy => 'all_tags',
|
319
|
+
:conditions_list => 'warning'
|
320
|
+
}
|
321
|
+
end
|
322
|
+
|
323
|
+
def rule_json(ru_data)
|
324
|
+
{
|
325
|
+
:id => ru_data[:id],
|
326
|
+
:type => 'rule',
|
327
|
+
:attributes => ru_data.reject {|k,v| :id.eql?(k) }
|
328
|
+
}
|
329
|
+
end
|
330
|
+
|
331
|
+
def rule_rel(ru_data)
|
332
|
+
id = ru_data[:id]
|
333
|
+
{
|
334
|
+
:contact => {
|
335
|
+
:links => {
|
336
|
+
:self => "http://#{api_host}/rules/#{id}/relationships/contact",
|
337
|
+
:related => "http://#{api_host}/rules/#{id}/contact"
|
338
|
+
}
|
339
|
+
},
|
340
|
+
:media => {
|
341
|
+
:links => {
|
342
|
+
:self => "http://#{api_host}/rules/#{id}/relationships/media",
|
343
|
+
:related => "http://#{api_host}/rules/#{id}/media"
|
344
|
+
}
|
345
|
+
},
|
346
|
+
:tags => {
|
347
|
+
:links => {
|
348
|
+
:self => "http://#{api_host}/rules/#{id}/relationships/tags",
|
349
|
+
:related => "http://#{api_host}/rules/#{id}/tags"
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
def state_data
|
356
|
+
@state_data ||= {
|
357
|
+
:id => '142acf62-31e7-4074-ada9-a30ae73d880d',
|
358
|
+
:created_at => (fixture_time - 30).iso8601,
|
359
|
+
:updated_at => (fixture_time - 30).iso8601,
|
360
|
+
:condition => 'critical',
|
361
|
+
}
|
362
|
+
end
|
363
|
+
|
364
|
+
def state_2_data
|
365
|
+
@state_2_data ||= {
|
366
|
+
:id => '008d78fc-1c72-4c2a-8057-0d44b64c6f3d',
|
367
|
+
:created_at => (fixture_time - 10).iso8601,
|
368
|
+
:updated_at => (fixture_time - 10).iso8601,
|
369
|
+
:condition => 'ok',
|
370
|
+
}
|
371
|
+
end
|
372
|
+
|
373
|
+
def state_json(st_data)
|
374
|
+
id = st_data[:id]
|
375
|
+
{
|
376
|
+
:id => id,
|
377
|
+
:type => 'state',
|
378
|
+
:attributes => st_data.reject {|k,v| :id.eql?(k) }
|
379
|
+
}
|
380
|
+
end
|
381
|
+
|
382
|
+
def state_rel(st_data)
|
383
|
+
id = st_data[:id]
|
384
|
+
{
|
385
|
+
:check => {
|
386
|
+
:links => {
|
387
|
+
:self => "http://#{api_host}/states/#{id}/relationships/check",
|
388
|
+
:related => "http://#{api_host}/states/#{id}/check"
|
389
|
+
}
|
390
|
+
}
|
391
|
+
}
|
392
|
+
end
|
393
|
+
|
394
|
+
def tag_data
|
395
|
+
@tag_data ||= {
|
396
|
+
:id => '1850b8d7-1055-4a6e-9c96-f8f50e55bd0f',
|
397
|
+
:name => 'database',
|
398
|
+
}
|
399
|
+
end
|
400
|
+
|
401
|
+
def tag_2_data
|
402
|
+
@tag_2_data ||= {
|
403
|
+
:id => 'c7a12328-8902-4974-8efa-68ec3e284507',
|
404
|
+
:name => 'physical',
|
405
|
+
}
|
406
|
+
end
|
407
|
+
|
408
|
+
def tag_json(ta_data)
|
409
|
+
id = ta_data[:id]
|
410
|
+
{
|
411
|
+
:id => id,
|
412
|
+
:type => 'tag',
|
413
|
+
:attributes => ta_data.reject {|k,v| :id.eql?(k) }
|
414
|
+
}
|
415
|
+
end
|
416
|
+
|
417
|
+
def tag_rel(ta_data)
|
418
|
+
id = ta_data[:id]
|
419
|
+
{
|
420
|
+
:checks => {
|
421
|
+
:links => {
|
422
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/checks",
|
423
|
+
:related => "http://#{api_host}/tags/#{id}/checks"
|
424
|
+
}
|
425
|
+
},
|
426
|
+
:contacts => {
|
427
|
+
:links => {
|
428
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/contacts",
|
429
|
+
:related => "http://#{api_host}/tags/#{id}/contacts"
|
430
|
+
}
|
431
|
+
},
|
432
|
+
:rules => {
|
433
|
+
:links => {
|
434
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/rules",
|
435
|
+
:related => "http://#{api_host}/tags/#{id}/rules"
|
436
|
+
}
|
437
|
+
},
|
438
|
+
:scheduled_maintenances => {
|
439
|
+
:links => {
|
440
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/scheduled_maintenances",
|
441
|
+
:related => "http://#{api_host}/tags/#{id}/scheduled_maintenances"
|
442
|
+
}
|
443
|
+
},
|
444
|
+
:states => {
|
445
|
+
:links => {
|
446
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/states",
|
447
|
+
:related => "http://#{api_host}/tags/#{id}/states"
|
448
|
+
}
|
449
|
+
},
|
450
|
+
:unscheduled_maintenances => {
|
451
|
+
:links => {
|
452
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/unscheduled_maintenances",
|
453
|
+
:related => "http://#{api_host}/tags/#{id}/unscheduled_maintenances"
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
end
|
458
|
+
|
459
|
+
def metrics_data
|
460
|
+
@metrics_data ||= {
|
461
|
+
# :total_keys => 0, # test behaviour is inconsistent
|
462
|
+
:processed_events => {
|
463
|
+
:all_events => 0,
|
464
|
+
:ok_events => 0,
|
465
|
+
:failure_events => 0,
|
466
|
+
:action_events => 0,
|
467
|
+
:invalid_events => 0
|
468
|
+
},
|
469
|
+
:event_queue_length => 0,
|
470
|
+
:check_freshness => {:"0" => 0, :"60" => 0, :"300" => 0, :"900" => 0, :"3600" => 0},
|
471
|
+
:check_counts => {:all => 0, :enabled => 0, :failing => 0}
|
472
|
+
}
|
473
|
+
end
|
474
|
+
|
475
|
+
def metrics_json(met_data)
|
476
|
+
{
|
477
|
+
:type => 'metrics',
|
478
|
+
:attributes => met_data.reject {|k,v| :id.eql?(k) }
|
479
|
+
}
|
480
|
+
end
|
481
|
+
|
482
|
+
def global_statistics_data
|
483
|
+
@global_statistics_data ||= {
|
484
|
+
:id => 'c63f8029-7c2b-4a33-b9f9-fbb2228c8037',
|
485
|
+
:instance_name => 'global',
|
486
|
+
:created_at => fixture_time.iso8601,
|
487
|
+
:all_events => 0,
|
488
|
+
:ok_events => 0,
|
489
|
+
:failure_events => 0,
|
490
|
+
:action_events => 0,
|
491
|
+
:invalid_events => 0
|
492
|
+
}
|
493
|
+
end
|
494
|
+
|
495
|
+
def global_statistics_json
|
496
|
+
{
|
497
|
+
:id => global_statistics_data[:id],
|
498
|
+
:type => 'statistic',
|
499
|
+
:attributes => global_statistics_data.reject {|k,v| :id.eql?(k) }
|
500
|
+
}
|
501
|
+
end
|
502
|
+
|
503
|
+
def acknowledgement_data
|
504
|
+
@acknowledgement_data ||= {
|
505
|
+
:id => '31b9378f-ae1c-4c78-ad34-2b35407c8bbd',
|
506
|
+
:duration => 2 * 60 * 60,
|
507
|
+
:summary => 'Giraffe'
|
508
|
+
}
|
509
|
+
end
|
510
|
+
|
511
|
+
def acknowledgement_json(ack_data)
|
512
|
+
{
|
513
|
+
:id => ack_data[:id],
|
514
|
+
:type => 'acknowledgement',
|
515
|
+
:attributes => ack_data.reject {|k,v| :id.eql?(k) }
|
516
|
+
}
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_notification_data
|
520
|
+
@test_notification_data ||= {
|
521
|
+
:id => '8f78b421-4e89-4423-ab09-c0d76b4a698c',
|
522
|
+
:summary => 'Rhinoceros'
|
523
|
+
}
|
524
|
+
end
|
525
|
+
|
526
|
+
def test_notification_2_data
|
527
|
+
@test_notification_2_data ||= {
|
528
|
+
:id => 'a56c6ca5-c3c0-453d-96da-d09d459615e4',
|
529
|
+
:summary => 'Tapir'
|
530
|
+
}
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_notification_json(tn_data)
|
534
|
+
{
|
535
|
+
:id => tn_data[:id],
|
536
|
+
:type => 'test_notification',
|
537
|
+
:attributes => tn_data.reject {|k,v| :id.eql?(k) }
|
538
|
+
}
|
539
|
+
end
|
540
|
+
|
541
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack-diner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.a4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.13.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.13.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,8 +47,6 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
50
|
-
- ".rubocop.yml"
|
51
|
-
- ".rubocop_todo.yml"
|
52
50
|
- ".travis.yml"
|
53
51
|
- Gemfile
|
54
52
|
- LICENSE
|
@@ -57,31 +55,33 @@ files:
|
|
57
55
|
- flapjack-diner.gemspec
|
58
56
|
- lib/flapjack-diner.rb
|
59
57
|
- lib/flapjack-diner/argument_validator.rb
|
60
|
-
- lib/flapjack-diner/
|
61
|
-
- lib/flapjack-diner/
|
62
|
-
- lib/flapjack-diner/
|
63
|
-
- lib/flapjack-diner/
|
64
|
-
- lib/flapjack-diner/
|
65
|
-
- lib/flapjack-diner/
|
66
|
-
- lib/flapjack-diner/resources
|
67
|
-
- lib/flapjack-diner/
|
68
|
-
- lib/flapjack-diner/resources/reports.rb
|
58
|
+
- lib/flapjack-diner/configuration.rb
|
59
|
+
- lib/flapjack-diner/index_range.rb
|
60
|
+
- lib/flapjack-diner/log_formatter.rb
|
61
|
+
- lib/flapjack-diner/query.rb
|
62
|
+
- lib/flapjack-diner/relationships.rb
|
63
|
+
- lib/flapjack-diner/request.rb
|
64
|
+
- lib/flapjack-diner/resources.rb
|
65
|
+
- lib/flapjack-diner/response.rb
|
69
66
|
- lib/flapjack-diner/tools.rb
|
67
|
+
- lib/flapjack-diner/utility.rb
|
70
68
|
- lib/flapjack-diner/version.rb
|
71
69
|
- log/.gitkeep
|
72
70
|
- spec/argument_validator_spec.rb
|
73
71
|
- spec/flapjack-diner_spec.rb
|
74
|
-
- spec/
|
72
|
+
- spec/relationships_spec.rb
|
75
73
|
- spec/resources/checks_spec.rb
|
76
74
|
- spec/resources/contacts_spec.rb
|
77
|
-
- spec/resources/
|
75
|
+
- spec/resources/events_spec.rb
|
78
76
|
- spec/resources/maintenance_periods_spec.rb
|
79
77
|
- spec/resources/media_spec.rb
|
80
|
-
- spec/resources/
|
81
|
-
- spec/resources/
|
82
|
-
- spec/resources/
|
83
|
-
- spec/resources/
|
78
|
+
- spec/resources/metrics_spec.rb
|
79
|
+
- spec/resources/rules_spec.rb
|
80
|
+
- spec/resources/states_spec.rb
|
81
|
+
- spec/resources/statistics_spec.rb
|
82
|
+
- spec/resources/tags_spec.rb
|
84
83
|
- spec/spec_helper.rb
|
84
|
+
- spec/support/fixture_data.rb
|
85
85
|
homepage: https://github.com/flapjack/flapjack-diner
|
86
86
|
licenses: []
|
87
87
|
metadata: {}
|
@@ -96,9 +96,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - ">"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 1.3.1
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
104
|
rubygems_version: 2.4.5.1
|
@@ -108,14 +108,16 @@ summary: Access the API of a Flapjack system monitoring server
|
|
108
108
|
test_files:
|
109
109
|
- spec/argument_validator_spec.rb
|
110
110
|
- spec/flapjack-diner_spec.rb
|
111
|
-
- spec/
|
111
|
+
- spec/relationships_spec.rb
|
112
112
|
- spec/resources/checks_spec.rb
|
113
113
|
- spec/resources/contacts_spec.rb
|
114
|
-
- spec/resources/
|
114
|
+
- spec/resources/events_spec.rb
|
115
115
|
- spec/resources/maintenance_periods_spec.rb
|
116
116
|
- spec/resources/media_spec.rb
|
117
|
-
- spec/resources/
|
118
|
-
- spec/resources/
|
119
|
-
- spec/resources/
|
120
|
-
- spec/resources/
|
117
|
+
- spec/resources/metrics_spec.rb
|
118
|
+
- spec/resources/rules_spec.rb
|
119
|
+
- spec/resources/states_spec.rb
|
120
|
+
- spec/resources/statistics_spec.rb
|
121
|
+
- spec/resources/tags_spec.rb
|
121
122
|
- spec/spec_helper.rb
|
123
|
+
- spec/support/fixture_data.rb
|