flapjack-diner 0.12

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p125
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: "bundle exec rspec"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flapjack-diner.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ali Graham
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,1054 @@
1
+ # Flapjack::Diner
2
+
3
+ [![Travis CI Status][id_travis_img]][id_travis_link]
4
+
5
+ [id_travis_link]: https://secure.travis-ci.org/#!/flpjck/flapjack-diner
6
+ [id_travis_img]: https://secure.travis-ci.org/flpjck/flapjack-diner.png
7
+
8
+ Access the API of a [Flapjack](http://flapjack-project.com/) system monitoring server.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'flapjack-diner', :git => 'git://github.com/flpjck/flapjack-diner.git'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ ## Usage
21
+
22
+ Set the URI of the Flapjack server:
23
+
24
+ ```ruby
25
+ Flapjack::Diner.base_uri('127.0.0.1:5000')
26
+ ```
27
+
28
+ Optionally, set a logger to log requests & responses:
29
+
30
+ ```ruby
31
+ Flapjack::Diner.logger = Logger.new('logs/flapjack_diner.log')
32
+ ```
33
+
34
+ ## Functions
35
+
36
+ * [entities](#entities)
37
+ * [checks](#checks)
38
+ * status ([single check](#status_check) / [all checks](#status) / [bulk](#status_bulk))
39
+ * scheduled maintentance periods ([single check](#scheduled_maintenance_check) / [all checks](#scheduled_maintenance) / [bulk](#scheduled_maintenance_bulk))
40
+ * unscheduled maintentance periods ([single check](#unscheduled_maintenance_check) / [all checks](#unscheduled_maintenance) / [bulk](#unscheduled_maintenance_bulk))
41
+ * outages ([single check](#outages_check) / [all checks](#outages) / [bulk](#outages_bulk))
42
+ * downtimes ([single check](#downtimes_check) / [all checks](#downtimes) / [bulk](#downtimes_bulk))
43
+ * create scheduled maintenance period ([single check](#create_scheduled_maintenance) / [bulk](#create_scheduled_maintenance_bulk))
44
+ * delete scheduled maintenance period ([single check](#delete_scheduled_maintenance) / [bulk](#delete_scheduled_maintenance_bulk))
45
+ * acknowledge ([single check](#acknowledge) / [bulk](#acknowledge_bulk))
46
+ * delete unscheduled maintenance period ([single check](#delete_unscheduled_maintenance) / [bulk](#delete_unscheduled_maintenance_bulk))
47
+ * test notifications ([single check](#test_notifications) / [bulk](#test_notifications_bulk))
48
+ * [get entity tags](#get_entity_tags)
49
+ * [add entity tags](#add_entity_tags)
50
+ * [delete entity tags](#delete_entity_tags)
51
+ * [get contact tags](#get_contact_tags)
52
+ * [add contact tags](#add_contact_tags)
53
+ * [delete contact tags](#delete_contact_tags)
54
+ * [get tags for contact's linked entities](#get_contact_entitytags)
55
+ * [add tags to contact's linked entities](#add_contact_entitytags)
56
+ * [delete tags from contact's linked entities](#delete_contact_entitytags)
57
+ * [contacts](#contacts)
58
+ * [contact](#contact)
59
+ * [notification rules](#notification_rules)
60
+ * [notification rule](#notification_rule)
61
+ * [create notification rule](#create_notification_rule)
62
+ * [update notification rule](#update_notification_rule)
63
+ * [delete notification rule](#delete_notification_rule)
64
+ * [notification media](#notification_media)
65
+ * [notification medium](#notification_medium)
66
+ * [update notification medium](#update_notification_medium)
67
+ * [delete notification medium](#delete_notification_medium)
68
+ * [contact timezone](#contact_timezone)
69
+ * [update contact timezone](#update_contact_timezone)
70
+ * [delete contact timezone](#delete_contact_timezone)
71
+
72
+ ---
73
+
74
+ <a name="entities">&nbsp;</a>
75
+ Return an array of monitored entities, and their statuses for all associated checks:
76
+
77
+ ```ruby
78
+ Flapjack::Diner.entities
79
+ ```
80
+
81
+ The data is returned as an array where each element is a hash representing an entity.
82
+
83
+ ```
84
+ // ID is an integer, to hold e.g. database id from an external system
85
+ // NAME is a string
86
+ // STATUS is a hash with the format returned from Flapjack::Diner.status(entity, check)
87
+ [{'id' => ID,
88
+ 'name' => NAME,
89
+ 'checks' => [STATUS, STATUS, ...]},
90
+ {},
91
+ ...]
92
+ ```
93
+
94
+ ---
95
+
96
+ <a name="checks">&nbsp;</a>
97
+ Return an array of checks for an entity:
98
+
99
+ ```ruby
100
+ Flapjack::Diner.checks('example.com')
101
+ ```
102
+
103
+ The data is returned as an array of strings, where each element is a check name for the provided entity.
104
+
105
+ ```
106
+ // CHECK is a string, e.g. 'ssh', 'ping'
107
+ [CHECK, CHECK, ...]
108
+ ```
109
+
110
+ ---
111
+ <a name="status_check">&nbsp;</a>
112
+ Return the status for a check on an entity
113
+
114
+ ```ruby
115
+ Flapjack::Diner.status('example.com', :check => 'ping')
116
+ ```
117
+
118
+ The data is returned as a hash:
119
+
120
+ ```
121
+ // CHECK is a string, e.g. 'ssh', 'ping'
122
+ // STATE is a string, one of 'critical', 'warning', 'ok', 'unknown'
123
+ // the TIMESTAMPs are integers representing UTC times for the named events
124
+ {'name' => CHECK,
125
+ 'state' => STATE,
126
+ 'in_unscheduled_maintenance' => BOOLEAN,
127
+ 'in_scheduled_maintenance' => BOOLEAN,
128
+ 'last_update' => TIMESTAMP,
129
+ 'last_problem_notification' => TIMESTAMP,
130
+ 'last_recovery_notification' => TIMESTAMP,
131
+ 'last_acknowledgement_notification' => TIMESTAMP}
132
+ ```
133
+
134
+ ---
135
+ <a name="status">&nbsp;</a>
136
+ Return the statuses for all checks on an entity
137
+
138
+ ```ruby
139
+ Flapjack::Diner.status('example.com')
140
+ ```
141
+
142
+ The data is returned as an array of checks, where each element is a hash with the format returned from Flapjack::Diner.status(entity, check)
143
+
144
+ ```
145
+ // STATUS is a hash with the format returned from Flapjack::Diner.status(entity, check)
146
+ [STATUS, STATUS, ...]
147
+ ```
148
+
149
+ ---
150
+ <a name="status_bulk">&nbsp;</a>
151
+ Return the statuses for all checks on some entities and specified checks on others.
152
+
153
+ ```ruby
154
+ # :entity - optional, may be a String or an Array of Strings (entity names)
155
+ # :check - optional, Hash, keys are Strings (entity names), values are Strings or Arrays of Strings (check names)
156
+ # At least one of the :entity or :check arguments must be provided
157
+ Flapjack::Diner.bulk_status(:entity => 'example.com',
158
+ :check => {'example2.com' => ['PING', 'SSH'],
159
+ 'example3.com' => 'PING'})
160
+ ```
161
+
162
+ The data is returned as an array, where each element is a hash with the format
163
+
164
+ ```
165
+ // ENTITY is a string, one of the entity names provided in the entity or check arguments.
166
+ // CHECK is a string, e.g. 'ssh', 'ping'
167
+ // STATUS is a hash with the format returned from Flapjack::Diner.status(entity, check)
168
+ {'entity' => ENTITY
169
+ 'check' => CHECK,
170
+ 'status' => STATUS}
171
+ ```
172
+
173
+ ---
174
+ <a name="scheduled_maintenance_check">&nbsp;</a>
175
+ Return an array of scheduled maintenance periods for a check on an entity:
176
+
177
+ ```ruby
178
+ # start time (Time object, optional)
179
+ # end time (Time object, optional)
180
+ Flapjack::Diner.scheduled_maintenances('example.com', :check => 'ping',
181
+ :start_time => Time.local(2012, 08, 01),
182
+ :end_time => Time.local(2012, 09, 01))
183
+ ```
184
+
185
+ The data is returned as an array of scheduled maintenance periods, with each element of the array being a hash containing data about that maintenance period.
186
+
187
+ ```
188
+ // the TIMESTAMPs are integers representing UTC times for the named events
189
+ // DURATION is an integer representing the length of the period in seconds
190
+ // SUMMARY is a string providing a description of the period, may be empty
191
+ [{'start_time' => TIMESTAMP,
192
+ 'duration' => DURATION,
193
+ 'summary' => SUMMARY,
194
+ 'end_time' => TIMESTAMP},
195
+ {...},
196
+ ...]
197
+ ```
198
+
199
+ ---
200
+ <a name="scheduled_maintenance">&nbsp;</a>
201
+ Return lists of scheduled maintenance periods for all checks on an entity:
202
+
203
+ ```ruby
204
+ # start time (Time object, optional)
205
+ # end time (Time object, optional)
206
+ Flapjack::Diner.scheduled_maintenances('example.com',
207
+ :start_time => Time.local(2012, 08, 01),
208
+ :end_time => Time.local(2012, 09, 01))
209
+ ```
210
+
211
+ The data is returned as an array of hashes, where each hash represents the scheduled maintenance periods for a check under the entity :
212
+
213
+ ```
214
+ // CHECK is a string, e.g. 'ssh', 'ping'
215
+ // SCHED_MAINT is a hash with the same format as an individual element of
216
+ // the array returned from Flapjack::Diner.scheduled_maintenances(entity, check)
217
+ [{'check' => CHECK,
218
+ 'scheduled_maintenance' => [SCHED_MAINT, ...]
219
+ },
220
+ {'check' => CHECK,
221
+ 'scheduled_maintenance' => [SCHED_MAINT, ...]
222
+ }]
223
+ ```
224
+
225
+ ---
226
+ <a name="scheduled_maintenance_bulk">&nbsp;</a>
227
+ Return lists of scheduled maintenance periods for all checks on some entities and specified checks on others.
228
+
229
+ ```ruby
230
+ # :entity - optional, may be a String or an Array of Strings (entity names)
231
+ # :check - optional, Hash, keys are Strings (entity names), values are Strings
232
+ # or Arrays of Strings (check names)
233
+ # At least one of the :entity or :check arguments must be provided
234
+ Flapjack::Diner.bulk_scheduled_maintenances(:entity => 'example.com',
235
+ :check => {'example2.com' => ['PING', 'SSH'],
236
+ 'example3.com' => 'PING'})
237
+ ```
238
+
239
+ The data is returned as an array, where each element is a hash with the format
240
+
241
+ ```
242
+ // ENTITY is a string, one of the entity names provided in the entity or check arguments
243
+ // CHECK is a string, e.g. 'ssh', 'ping'
244
+ // SCHED_MAINT is a hash with the same format as an individual element of the array returned from Flapjack::Diner.scheduled_maintenances(entity, check)
245
+ {'entity' => ENTITY
246
+ 'check' => CHECK,
247
+ 'scheduled_maintenances' => [SCHED_MAINT, ...]}
248
+ ```
249
+
250
+ Please note the plural for the 'scheduled_maintenances' hash key, which is different to
251
+ the other methods.
252
+
253
+ ---
254
+ <a name="unscheduled_maintenance_check">&nbsp;</a>
255
+ Return an array of unscheduled maintenance periods for a check on an entity:
256
+
257
+ ```ruby
258
+ # start time (Time object, optional)
259
+ # end time (Time object, optional)
260
+ Flapjack::Diner.unscheduled_maintenances('example.com', :check => 'ping',
261
+ :start_time => Time.local(2012, 08, 01),
262
+ :end_time => Time.local(2012, 09, 01))
263
+ ```
264
+
265
+ The data is returned as an array of unscheduled maintenance periods, with each element of the array being a hash containing data about that maintenance period.
266
+
267
+ ```
268
+ // the TIMESTAMPs are integers representing UTC times for the named events
269
+ // DURATION is an integer representing the length of the period in seconds
270
+ // SUMMARY is a string providing a description of the period, may be empty
271
+ [{'start_time' => TIMESTAMP,
272
+ 'duration' => DURATION,
273
+ 'summary' => SUMMARY,
274
+ 'end_time' => TIMESTAMP},
275
+ {...},
276
+ ...]
277
+ ```
278
+
279
+ ---
280
+ <a name="unscheduled_maintenance">&nbsp;</a>
281
+ Return lists of unscheduled maintenance periods for all checks on an entity:
282
+
283
+ ```ruby
284
+ # start time (Time object, optional)
285
+ # end time (Time object, optional)
286
+ Flapjack::Diner.unscheduled_maintenances('example.com',
287
+ :start_time => Time.local(2012, 08, 01),
288
+ :end_time => Time.local(2012, 09, 01))
289
+ ```
290
+
291
+ The data is returned as an array of hashes, where each hash represents the unscheduled maintenance periods for a check under the entity:
292
+
293
+ ```
294
+ // CHECK is a string, e.g. 'ssh', 'ping'
295
+ // UNSCHED_MAINT is a hash with the same format as an individual element of
296
+ // the array returned from Flapjack::Diner.unscheduled_maintenances(entity, check)
297
+ [{'check' => CHECK,
298
+ 'unscheduled_maintenance' => [UNSCHED_MAINT, ...]
299
+ },
300
+ {'check' => CHECK,
301
+ 'unscheduled_maintenance' => [UNSCHED_MAINT, ...]
302
+ }]
303
+ ```
304
+
305
+ ---
306
+ <a name="unscheduled_maintenance_bulk">&nbsp;</a>
307
+ Return lists of unscheduled maintenance periods for all checks on some entities and specified checks on others.
308
+
309
+ ```ruby
310
+ # :entity - optional, may be a String or an Array of Strings (entity names)
311
+ # :check - optional, Hash, keys are Strings (entity names), values are Strings
312
+ # or Arrays of Strings (check names)
313
+ # At least one of the :entity or :check arguments must be provided
314
+ Flapjack::Diner.bulk_unscheduled_maintenances(:entity => 'example.com',
315
+ :check => {'example2.com' => ['PING', 'SSH'],
316
+ 'example3.com' => 'PING'})
317
+ ```
318
+
319
+ The data is returned as an array, where each element is a hash with the format
320
+
321
+ ```
322
+ // ENTITY is a string, one of the entity names provided in the entity or check arguments
323
+ // CHECK is a string, e.g. 'ssh', 'ping'
324
+ // UNSCHED_MAINT is a hash with the same format as an individual element of the
325
+ // array returned from Flapjack::Diner.unscheduled_maintenances(entity, check)
326
+ {'entity' => ENTITY
327
+ 'check' => CHECK,
328
+ 'unscheduled_maintenances' => [UNSCHED_MAINT, ...]
329
+ }
330
+ ```
331
+
332
+ Please note the plural for the 'unscheduled_maintenances' hash key, which is different to
333
+ the other methods.
334
+
335
+ ---
336
+ <a name="outages_check">&nbsp;</a>
337
+ Return an array of outages for a check on an entity (all times for which the check was failing):
338
+
339
+ ```ruby
340
+ # start time (Time object, optional)
341
+ # end time (Time object, optional)
342
+ Flapjack::Diner.outages('example.com', :check => 'ping',
343
+ :start_time => Time.local(2012, 08, 01),
344
+ :end_time => Time.local(2012, 09, 01))
345
+ ```
346
+
347
+ The data is returned as an array of outage periods, with each element of the array being a hash containing data about that outage period.
348
+
349
+ ```
350
+ // STATE is a string, one of 'critical', 'warning', 'ok', 'unknown'
351
+ // the TIMESTAMPs are integers representing UTC times for the named events
352
+ // SUMMARY is a string providing a description of the period, may be empty
353
+ [{'state' => STATE,
354
+ 'start_time' => TIMESTAMP,
355
+ 'end_time' => TIMESTAMP,
356
+ 'summary' => SUMMARY},
357
+ {...},
358
+ ...]
359
+ ```
360
+
361
+ ---
362
+ <a name="outages">&nbsp;</a>
363
+ Return lists of outages for all checks on an entity (all times for which said checks were failing):
364
+
365
+ ```ruby
366
+ # start time (Time object, optional)
367
+ # end time (Time object, optional)
368
+ Flapjack::Diner.outages('example.com', :start_time => Time.local(2012, 08, 01),
369
+ :end_time => Time.local(2012, 09, 01))
370
+ ```
371
+
372
+ The data is returned as an array of hashes, where each hash represents the outages for a check under the entity:
373
+
374
+ ```
375
+ // CHECK is a string, e.g. 'ssh', 'ping'
376
+ // OUTAGE is a hash with the same format as an individual element of the array returned from Flapjack::Diner.outages(entity, check)
377
+ [{'check' => CHECK,
378
+ 'outages' => [OUTAGE, ...]
379
+ },
380
+ {'check' => CHECK,
381
+ 'outages' => [OUTAGE, ...]
382
+ }]
383
+ ```
384
+
385
+ ---
386
+ <a name="outages_bulk">&nbsp;</a>
387
+ Return lists of outages for all checks on some entities and specified checks on others.
388
+
389
+ ```ruby
390
+ # :entity - optional, may be a String or an Array of Strings (entity names)
391
+ # :check - optional, Hash, keys are Strings (entity names), values are Strings
392
+ # or Arrays of Strings (check names)
393
+ # At least one of the :entity or :check arguments must be provided
394
+ Flapjack::Diner.bulk_outages(:entity => 'example.com',
395
+ :check => {'example2.com' => ['PING', 'SSH'],
396
+ 'example3.com' => 'PING'})
397
+ ```
398
+
399
+ The data is returned as an array, where each element is a hash with the format
400
+
401
+ ```
402
+ // ENTITY is a string, one of the entity names provided in the entity or check arguments
403
+ // CHECK is a string, e.g. 'ssh', 'ping'
404
+ // OUTAGE is a hash with the same format as an individual element of the array
405
+ // returned from Flapjack::Diner.outages(entity, check)
406
+ {'entity' => ENTITY
407
+ 'check' => CHECK,
408
+ 'outages' => [OUTAGE, ...]
409
+ }
410
+ ```
411
+
412
+ ---
413
+ <a name="downtimes_check">&nbsp;</a>
414
+ Return an array of downtimes for a check on an entity (outages outside of scheduled maintenance periods):
415
+
416
+ ```ruby
417
+ # start time (Time object, optional)
418
+ # end time (Time object, optional)
419
+ Flapjack::Diner.downtime('example.com', :check => 'ping',
420
+ :start_time => Time.local(2012, 08, 01),
421
+ :end_time => Time.local(2012, 09, 01))
422
+ ```
423
+
424
+ Returns a hash with some statistics about the downtimes, including an array of the downtimes themselves. This may not be the same as would be returned from the 'outages' call for the same time period, as if scheduled maintenance periods overlap any of those times then they will be reduced, split or discarded to fit.
425
+
426
+ ```
427
+ // TOTAL SECONDS gives the sum of the time spent in that state for each check state.
428
+ // PERCENTAGES represents the proportion of the total time that the check was
429
+ // in each state. Will be null if either start or end time were not provided
430
+ // in the request.
431
+ // OUTAGE is a hash with the same format as an individual element of the array
432
+ // returned from Flapjack::Diner.outages(entity, check).
433
+ {'total_seconds' => {STATE => INTEGER, ...},
434
+ 'percentages' => {STATE => INTEGER, ...},
435
+ 'downtime' => [OUTAGE, ...]
436
+ }
437
+ ```
438
+
439
+ ---
440
+ <a name="downtimes">&nbsp;</a>
441
+ Return an array of downtimes for all checks on an entity (outages outside of scheduled maintenance periods):
442
+
443
+ ```ruby
444
+ # start time (Time object, optional)
445
+ # end time (Time object, optional)
446
+ Flapjack::Diner.downtime('example.com', :start_time => Time.local(2012, 08, 01),
447
+ :end_time => Time.local(2012, 09, 01))
448
+ ```
449
+
450
+ The data is returned as an array of hashes, where each hash represents a downtime report for a check under the entity:
451
+
452
+ ```
453
+ // CHECK is a string, e.g. 'ssh', 'ping'
454
+ // DOWNTIME is a hash with the same format those returned from
455
+ // Flapjack::Diner.downtime(entity, check)
456
+ [{'check' => CHECK,
457
+ 'downtime' => [DOWNTIME, ...]
458
+ },
459
+ {'check' => CHECK,
460
+ 'downtime' => [DOWNTIME, ...]
461
+ }]
462
+ ```
463
+
464
+ ---
465
+ <a name="downtimes_bulk">&nbsp;</a>
466
+
467
+ Return lists of downtimes for all checks on some entities and specified checks on others.
468
+
469
+ ```ruby
470
+ # :entity - optional, may be a String or an Array of Strings (entity names)
471
+ # :check - optional, Hash, keys are Strings (entity names), values are Strings
472
+ # or Arrays of Strings (check names)
473
+ # At least one of the :entity or :check arguments must be provided
474
+ Flapjack::Diner.bulk_downtime(:entity => ['example.com', 'example4.com'],
475
+ :check => {'example2.com' => ['PING', 'SSH'],
476
+ 'example3.com' => 'PING'})
477
+ ```
478
+
479
+ The data is returned as an array, where each element is a hash with the format
480
+
481
+ ```
482
+ // ENTITY is a string, one of the entity names provided in the entity or check arguments
483
+ // CHECK is a string, e.g. 'ssh', 'ping'
484
+ // DOWNTIME is a hash with the same format as an individual element of the array
485
+ // returned from Flapjack::Diner.downtime(entity, check)
486
+ {'entity' => ENTITY
487
+ 'check' => CHECK,
488
+ 'downtime' => [DOWNTIME, ...]
489
+ }
490
+ ```
491
+
492
+ ---
493
+ <a name="create_scheduled_maintenance">&nbsp;</a>
494
+ Create a scheduled maintenance period for a check on an entity:
495
+
496
+ ```ruby
497
+ # start_time (Time object, required)
498
+ # duration (Integer, required) is measured in seconds
499
+ # summary (String, optional)
500
+ Flapjack::Diner.create_scheduled_maintenance!('example.com', 'ping',
501
+ :start_time => Time.local(2012, 12, 01), :duration => (60 * 60),
502
+ :summary => 'changing stuff')
503
+ ```
504
+
505
+ Returns a boolean value representing the success or otherwise of the creation of the scheduled maintenance period by the server.
506
+
507
+ ---
508
+ <a name="create_scheduled_maintenance_bulk">&nbsp;</a>
509
+ Create scheduled maintenance periods for all checks on some entities and specified checks on others.
510
+
511
+ ```ruby
512
+ # start_time (Time object, required)
513
+ # duration (Integer, required) is measured in seconds
514
+ # summary (String, optional)
515
+ Flapjack::Diner.bulk_create_scheduled_maintenance!(:entity => ['example.com', 'example2.com'],
516
+ :check => {'example3.com' => 'ping'}, :start_time => Time.local(2012, 12, 01),
517
+ :duration => (60 * 60), :summary => 'changing stuff')
518
+ ```
519
+
520
+ Returns a boolean value representing the success or otherwise of the creation of the scheduled maintenance periods by the server.
521
+
522
+ ---
523
+ <a name="delete_scheduled_maintenance">&nbsp;</a>
524
+ Delete a scheduled maintenance period for a check on an entity:
525
+
526
+ ```ruby
527
+ # end_time (Time object, optional)
528
+ Flapjack::Diner.delete_scheduled_maintenance!('example.com', 'ping',
529
+ :end_time => Time.local(2012, 12, 01))
530
+ ```
531
+
532
+ Returns a boolean value representing the success or otherwise of the deletion of the scheduled maintenance periods by the server.
533
+
534
+ ---
535
+ <a name="delete_scheduled_maintenance_bulk">&nbsp;</a>
536
+ Delete a scheduled maintenance period for all checks on some entities and specified checks on others.
537
+
538
+ ```ruby
539
+ # end_time (Time object, optional)
540
+ Flapjack::Diner.bulk_delete_scheduled_maintenance!(:check => {'example.com' => ['ping', 'ssh']},
541
+ :end_time => Time.local(2012, 12, 01))
542
+ ```
543
+
544
+ Returns a boolean value representing the success or otherwise of the deletion of the scheduled maintenance periods by the server.
545
+
546
+ ---
547
+ <a name="acknowledge">&nbsp;</a>
548
+ Acknowledge the current state for a check on an entity:
549
+
550
+ ```ruby
551
+ # summary (String, optional)
552
+ Flapjack::Diner.acknowledge!('example.com', 'ping', :summary => 'ack')
553
+ ```
554
+
555
+ Returns a boolean value representing the success or otherwise of the creation of the acknowledgement by the server.
556
+
557
+ ---
558
+ <a name="acknowledge_bulk">&nbsp;</a>
559
+ Acknowledge the current state for all checks on some entities and specified checks on others.
560
+
561
+ ```ruby
562
+ # summary (String, optional)
563
+ Flapjack::Diner.bulk_acknowledge!(:entity => 'example.com',
564
+ :check => {'example2.com' => 'ping'}, :summary => 'ack')
565
+ ```
566
+
567
+ Returns a boolean value representing the success or otherwise of the creation of the acknowledgements by the server.
568
+
569
+ ---
570
+ <a name="delete_unscheduled_maintenance">&nbsp;</a>
571
+ Delete an unscheduled maintenance period for a check on an entity:
572
+
573
+ ```ruby
574
+ # end_time (Time object, optional)
575
+ Flapjack::Diner.delete_unscheduled_maintenance!('example.com', 'ping',
576
+ :end_time => Time.local(2012, 12, 01))
577
+ ```
578
+
579
+ Returns a boolean value representing the success or otherwise of the deletion of the scheduled maintenance periods by the server.
580
+
581
+ ---
582
+ <a name="delete_unscheduled_maintenance_bulk">&nbsp;</a>
583
+ Delete unscheduled maintenance periods for all checks on some entities and specified checks on others.
584
+
585
+ ```ruby
586
+ # end_time (Time object, optional)
587
+ Flapjack::Diner.bulk_delete_unscheduled_maintenance!(:check => {'example.com' => ['ping', 'ssh']},
588
+ :end_time => Time.local(2012, 12, 01))
589
+ ```
590
+
591
+ Returns a boolean value representing the success or otherwise of the deletion of the scheduled maintenance periods by the server.
592
+
593
+ ---
594
+ <a name="test_notifications">&nbsp;</a>
595
+ Generate test notifications for a check on an entity:
596
+
597
+ ```ruby
598
+ # summary (String, optional)
599
+ Flapjack::Diner.test_notifications!('example.com', 'HOST',
600
+ :summary => 'Testing notifications to all contacts interested in the HOST check on example.com')
601
+ ```
602
+
603
+ Returns a boolean value representing the success or otherwise of the creation of the notifications by the server.
604
+
605
+ ---
606
+ <a name="test_notifications_bulk">&nbsp;</a>
607
+ Generate test notifications for all checks on some entities and specified checks on others.
608
+
609
+ ```ruby
610
+ # summary (String, optional)
611
+ Flapjack::Diner.bulk_test_notifications!(:entity => 'example.com',
612
+ :check => {'example2.com' => 'ping'}, :summary => 'Testing notifications')
613
+ ```
614
+
615
+ Returns a boolean value representing the success or otherwise of the creation of the notifications by the server.
616
+
617
+ ---
618
+ <a name="get_entity_tags">&nbsp;</a>
619
+ Get all tags for an entity.
620
+
621
+ ```ruby
622
+ # entity name (String, required)
623
+ Flapjack::Diner.entity_tags('example.com')
624
+ ```
625
+
626
+ The data is returned as an array of strings; each string is a named tag set on the entity. The array may be empty.
627
+
628
+ ---
629
+ <a name="add_entity_tags">&nbsp;</a>
630
+ Add one or more tags to an entity.
631
+
632
+ ```ruby
633
+ # entity name (String, required)
634
+ # *tags (at least one String)
635
+ Flapjack::Diner.add_entity_tags!('example.com', 'tag1', 'tag2')
636
+ ```
637
+
638
+ The data is returned as an array of strings; each string is a named tag set on the entity. The array will, at a minimum, contain the tag(s) added by the request.
639
+
640
+ ---
641
+ <a name="delete_entity tags">&nbsp;</a>
642
+ Delete one or more tags from an entity.
643
+
644
+ ```ruby
645
+ # entity name (String, required)
646
+ # *tags (at least one String)
647
+ Flapjack::Diner.delete_entity_tags!('example.com', 'tag1')
648
+ ```
649
+
650
+ Returns a boolean representing the success (or otherwise) of the tag deletion.
651
+
652
+ ---
653
+ <a name="get_contact_tags">&nbsp;</a>
654
+ Get all tags for a contact.
655
+
656
+ ```ruby
657
+ # contact ID (String, required)
658
+ Flapjack::Diner.contact_tags('21')
659
+ ```
660
+
661
+ The data is returned as an array of strings; each string is a named tag set on the contact. The array may be empty.
662
+
663
+ ---
664
+ <a name="add_contact_tags">&nbsp;</a>
665
+ Add one or more tags to a contact.
666
+
667
+ ```ruby
668
+ # contact ID (String, required)
669
+ # *tags (at least one String)
670
+ Flapjack::Diner.add_contact_tags!('21', 'tag1', 'tag2')
671
+ ```
672
+
673
+ The data is returned as an array of strings; each string is a named tag set on the contact. The array will, at a minimum, contain the tag(s) added by the request.
674
+
675
+ ---
676
+ <a name="delete_contact_tags">&nbsp;</a>
677
+ Delete one or more tags from a contact.
678
+
679
+ ```ruby
680
+ # contact ID (String, required)
681
+ # *tags (at least one String)
682
+ Flapjack::Diner.delete_contact_tags!('21', 'tag1')
683
+ ```
684
+
685
+ Returns a boolean representing the success (or otherwise) of the tag deletion.
686
+
687
+ ---
688
+ <a name="get_contact_entitytags">&nbsp;</a>
689
+ Get all tags for entities linked to a contact.
690
+
691
+ ```ruby
692
+ # contact ID (String, required)
693
+ Flapjack::Diner.contact_entitytags('21')
694
+ ```
695
+
696
+ The data is returned as a Hash, with String keys representing entity names, and Arrays of String values representing the tags for each named entity.
697
+
698
+ ```
699
+ {
700
+ ENTITY => [TAG, ...],
701
+ ENTITY => [TAG, ...],
702
+ ...
703
+ }
704
+ ```
705
+
706
+ ---
707
+ <a name="add_contact_entitytags">&nbsp;</a>
708
+ Add one or more tags to entities linked to a contact.
709
+
710
+ ```ruby
711
+ # contact ID (String, required)
712
+ # entity_tags (Hash, required - similar format as returned by 'contact_entitytags')
713
+ Flapjack::Diner.add_contact_entitytags!('21', {'entity1' => ['web'], 'entity2' => ['app']})
714
+ ```
715
+
716
+ The data is returned as a Hash, reflecting the current tags for the contact's linked entities. This is in the same format as the ```contact_entitytags``` call returns.
717
+
718
+ ---
719
+ <a name="delete_contact_entitytags">&nbsp;</a>
720
+ Delete one or more tags from entities linked to a contact.
721
+
722
+ ```ruby
723
+ # contact ID (String, required)
724
+ # entity_tags (Hash, required - similar format as returned by 'contact_entitytags')
725
+ Flapjack::Diner.add_contact_entitytags!('21', {'entity1' => ['web'], 'entity2' => ['app']})
726
+ ```
727
+
728
+ Returns a boolean representing the success (or otherwise) of the tag deletion.
729
+
730
+ ---
731
+ <a name="contacts">&nbsp;</a>
732
+ Gets all contact records.
733
+
734
+ ```ruby
735
+ Flapjack::Diner.contacts
736
+ ```
737
+
738
+ The data is returned as an array of hashes, where each hash represents a contact. The tags array will be empty if the associated contact has no tags.
739
+
740
+ ```ruby
741
+ [
742
+ {
743
+ 'id' => STRING,
744
+ 'first_name' => STRING,
745
+ 'last_name' => STRING,
746
+ 'email' => STRING,
747
+ 'tags' => [STRING, ...]
748
+ },
749
+ ...
750
+ ]
751
+ ```
752
+
753
+ ---
754
+ <a name="contact">&nbsp;</a>
755
+ Get a single contact record.
756
+
757
+ ```ruby
758
+ # contact_id (String, required)
759
+ Flapjack::Diner.contact('contact23')
760
+ ```
761
+
762
+ The contact record is returned as a hash (a singular instance of what is returned in the full contact list). The tags array will be empty if the contact has no tags
763
+
764
+ ```ruby
765
+ {
766
+ 'id' => STRING,
767
+ 'first_name' => STRING,
768
+ 'last_name' => STRING,
769
+ 'email' => STRING,
770
+ 'tags' => [STRING, ...]
771
+ }
772
+ ```
773
+
774
+ ---
775
+ <a name="notification_rules">&nbsp;</a>
776
+ Gets the notification rules belonging to a contact.
777
+
778
+ ```ruby
779
+ # contact_id (String, required)
780
+ Flapjack::Diner.notification_rules('contact23')
781
+ ```
782
+
783
+ Returns an array of hashes, where a single hash represents a notification rule record. NB 'time_restrictions' have not yet been implemented, but we're noting the use of the field name here as it will be meaningful in the future.
784
+
785
+ ```ruby
786
+ # contact_id (String, as provided in the request)
787
+ # rule_id (String, allocated on creation, immutable)
788
+ [
789
+ {
790
+ 'id' => RULE_ID,
791
+ 'contact_id' => CONTACT_ID,
792
+ 'entity_tags' => [STRING, ...]
793
+ 'entities' => [STRING, ...],
794
+ 'time_restrictions' => [],
795
+ 'warning_media' => [STRING, ...],
796
+ 'critical_media' => [STRING, ...],
797
+ 'warning_blackhole' => BOOLEAN,
798
+ 'critical_blackhole' => BOOLEAN
799
+ },
800
+ ...
801
+ ]
802
+ ```
803
+
804
+ ---
805
+ <a name="notification_rule">&nbsp;</a>
806
+ Gets a single notification rule belonging to a contact.
807
+
808
+ ```ruby
809
+ # rule_id (String, required)
810
+ Flapjack::Diner.notification_rule('08f607c7-618d-460a-b3fe-868464eb6045')
811
+ ```
812
+
813
+ Returns a hash representing a notification rule record (a singular instance of what is returned in a list of a contact's notification rules). NB 'time_restrictions' have not yet been implemented, but we're noting the use of the field name here as it will be meaningful in the future.
814
+
815
+ ```ruby
816
+ # RULE_ID (String, as provided in the request)
817
+ # CONTACT_ID (String)
818
+ {
819
+ 'id' => RULE_ID,
820
+ 'contact_id' => CONTACT_ID,
821
+ 'entity_tags' => [STRING, ...]
822
+ 'entities' => [STRING, ...],
823
+ 'time_restrictions' => [],
824
+ 'warning_media' => [STRING, ...],
825
+ 'critical_media' => [STRING, ...],
826
+ 'warning_blackhole' => BOOLEAN,
827
+ 'critical_blackhole' => BOOLEAN
828
+ }
829
+ ```
830
+
831
+ ---
832
+ <a name="create_notification_rule">&nbsp;</a>
833
+ Creates a notification rule for a contact.
834
+
835
+ ```ruby
836
+ # rule_data (Hash, will be converted via to_json)
837
+ # contact_id (String, required)
838
+ # entity_tags (Array of Strings, may be empty; either this or 'entities' must have some content)
839
+ # entities (Array of Strings, may be empty; either this or 'entity_tags' must have some content)
840
+ # time_restrictions (TBD)
841
+ # warning_media (Array of Strings, may be empty; each represents a media type)
842
+ # critical_media (Array of Strings, may be empty; each represents a media type)
843
+ # warning_blackhole (Boolean, required)
844
+ # critical_blackhole (Boolean, required)
845
+ Flapjack::Diner.create_notification_rule!({
846
+ 'contact_id' => 'contact23',
847
+ 'entity_tags' => ['database'],
848
+ 'entities' => ['app-1.example.com']
849
+ 'time_restrictions' => [],
850
+ 'warning_media' => ['email'],
851
+ 'critical_media' => ['email', 'sms'],
852
+ 'warning_blackhole' => false,
853
+ 'critical_blackhole' => false
854
+ }
855
+ })
856
+ ```
857
+
858
+ Returns a hash represeting the created notification rule. This is the same data you would receive from ```Flapjack::Diner.notification_rule(rule_id)```.
859
+
860
+ ```ruby
861
+ # RULE_ID (String, as provided in the request)
862
+ # CONTACT_ID (String)
863
+ {
864
+ 'id' => RULE_ID,
865
+ 'contact_id' => CONTACT_ID,
866
+ 'entity_tags' => [STRING, ...]
867
+ 'entities' => [STRING, ...],
868
+ 'time_restrictions' => [],
869
+ 'warning_media' => [STRING, ...],
870
+ 'critical_media' => [STRING, ...],
871
+ 'warning_blackhole' => BOOLEAN,
872
+ 'critical_blackhole' => BOOLEAN
873
+ }
874
+ ```
875
+
876
+ ---
877
+ <a name="update_notification_rule">&nbsp;</a>
878
+ Updates a notification rule for a contact.
879
+
880
+ ```ruby
881
+ # rule_id (String, required)
882
+ # rule_data (Hash, will be converted via to_json)
883
+ # contact_id (String, required)
884
+ # entity_tags (Array of Strings, may be empty; either this or 'entities' must have some content)
885
+ # entities (Array of Strings, may be empty; either this or 'entity_tags' must have some content)
886
+ # time_restrictions (TBD)
887
+ # warning_media (Array of Strings, may be empty; each represents a media type)
888
+ # critical_media (Array of Strings, may be empty; each represents a media type)
889
+ # warning_blackhole (Boolean, required)
890
+ # critical_blackhole (Boolean, required)
891
+ Flapjack::Diner.update_notification_rule!('08f607c7-618d-460a-b3fe-868464eb6045', {
892
+ 'contact_id' => 'contact23',
893
+ 'entity_tags' => ['database'],
894
+ 'entities' => ['app-1.example.com']
895
+ 'time_restrictions' => [],
896
+ 'warning_media' => ['email'],
897
+ 'critical_media' => ['email', 'sms'],
898
+ 'warning_blackhole' => false,
899
+ 'critical_blackhole' => false
900
+ })
901
+ ```
902
+
903
+ Returns a hash represeting the updated notification rule. This is the same data you would receive from ```Flapjack::Diner.notification_rule(rule_id)```.
904
+
905
+ ```ruby
906
+ # RULE_ID (String, as provided in the request)
907
+ # CONTACT_ID (String)
908
+ {
909
+ 'id' => RULE_ID,
910
+ 'contact_id' => CONTACT_ID,
911
+ 'entity_tags' => [STRING, ...]
912
+ 'entities' => [STRING, ...],
913
+ 'time_restrictions' => [],
914
+ 'warning_media' => [STRING, ...],
915
+ 'critical_media' => [STRING, ...],
916
+ 'warning_blackhole' => BOOLEAN,
917
+ 'critical_blackhole' => BOOLEAN
918
+ }
919
+ ```
920
+
921
+ ---
922
+ <a name="delete_notification_rule">&nbsp;</a>
923
+ Deletes a notification rule from a contact.
924
+
925
+ ```ruby
926
+ # rule_id (String, required)
927
+ Flapjack::Diner.delete_notification_rule!('08f607c7-618d-460a-b3fe-868464eb6045')
928
+ ```
929
+
930
+ Returns a boolean value representing the success or otherwise of the deletion of the notification rule.
931
+
932
+ ---
933
+ <a name="notification_media">&nbsp;</a>
934
+ Return a list of a contact's notification media values.
935
+
936
+ ```ruby
937
+ # contact_id (String, required)
938
+ Flapjack::Diner.contact_media('contact23')
939
+ ```
940
+
941
+ Returns a hash of hashes, where the first layer of keys are the media types (e.g. 'email', 'sms') and the
942
+ hashes for each of those media type keys contain address and notification interval values.
943
+
944
+ ```ruby
945
+ # interval (Integer, in seconds - notifications will not be sent more often than this through this medium)
946
+ {
947
+ MEDIA_TYPE => { 'address' => STRING,
948
+ 'interval' => INTEGER },
949
+ ...
950
+ }
951
+ ```
952
+
953
+ ---
954
+ <a name="notification_medium">&nbsp;</a>
955
+ Get the values for a contact's notification medium.
956
+
957
+ ```ruby
958
+ # contact_id (String, required)
959
+ # media_type (String, required)
960
+ Flapjack::Diner.contact_medium('contact23', 'sms')
961
+ ```
962
+
963
+ Returns a hash corresponding to a single hash of medium values from those returned by ```Flapjack::Diner.contact_media()```.
964
+
965
+ ```ruby
966
+ # interval (Integer, in seconds - notifications will not be sent more often than this through this medium)
967
+ { 'address' => STRING,
968
+ 'interval' => INTEGER },
969
+ ```
970
+
971
+ ---
972
+ <a name="update_notification_medium">&nbsp;</a>
973
+ Update the values for a contact's notification medium.
974
+
975
+ ```ruby
976
+ # contact_id (String, required)
977
+ # media_type (String, required)
978
+ Flapjack::Diner.update_contact_medium!('contact23', 'email', {
979
+ 'address' => 'example@example.com',
980
+ 'interval' => 300
981
+ })
982
+ ```
983
+
984
+ Returns the hash that was submitted.
985
+
986
+ ```ruby
987
+ # interval (Integer, in seconds - notifications will not be sent more often than this through this medium)
988
+ { 'address' => STRING,
989
+ 'interval' => INTEGER },
990
+ ```
991
+
992
+ ---
993
+ <a name="delete_notification_medium">&nbsp;</a>
994
+ Delete a contact's notification medium.
995
+
996
+ ```ruby
997
+ # contact_id (String, required)
998
+ # media_type (String, required)
999
+ Flapjack::Diner.delete_contact_medium!('contact23', 'sms')
1000
+ ```
1001
+
1002
+ Returns a boolean value representing the success or otherwise of the deletion of the notification medium values.
1003
+
1004
+ ---
1005
+ <a name="contact_timezone">&nbsp;</a>
1006
+ Get a contact's timezone.
1007
+
1008
+ ```ruby
1009
+ # contact_id (String, required)
1010
+ Flapjack::Diner.contact_timezone('contact23')
1011
+ ```
1012
+
1013
+ Returns a timezone string, as defined in the [timezone database](http://www.twinsun.com/tz/tz-link.htm).
1014
+
1015
+ ```ruby
1016
+ 'Australia/Perth'
1017
+ ```
1018
+
1019
+ ---
1020
+ <a name="update_contact_timezone">&nbsp;</a>
1021
+ Update a contact's timezone.
1022
+
1023
+ ```ruby
1024
+ # contact_id (String, required)
1025
+ # timezone (String, required)
1026
+ Flapjack::Diner.update_contact_timezone!('contact23', 'Australia/Sydney')
1027
+ ```
1028
+
1029
+ Returns the timezone string provided as a parameter.
1030
+
1031
+ ```ruby
1032
+ 'Australia/Sydney'
1033
+ ```
1034
+
1035
+ ---
1036
+ <a name="delete_contact_timezone">&nbsp;</a>
1037
+ Delete a contact's timezone. (If a contact's timezone is unknown they will be assumed to share the Flapjack server's timezone.)
1038
+
1039
+ ```ruby
1040
+ # contact_id (String, required)
1041
+ Flapjack::Diner.delete_contact_timezone!('contact_23')
1042
+ ```
1043
+
1044
+ Returns a boolean value representing the success or otherwise of the deletion of the contact's timezone.
1045
+
1046
+ ---
1047
+
1048
+ ## Contributing
1049
+
1050
+ 1. Fork it
1051
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
1052
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
1053
+ 4. Push to the branch (`git push origin my-new-feature`)
1054
+ 5. Create new Pull Request