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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/README.md +620 -413
  5. data/flapjack-diner.gemspec +1 -1
  6. data/lib/flapjack-diner/argument_validator.rb +77 -7
  7. data/lib/flapjack-diner/configuration.rb +409 -0
  8. data/lib/flapjack-diner/index_range.rb +42 -0
  9. data/lib/flapjack-diner/log_formatter.rb +22 -0
  10. data/lib/flapjack-diner/query.rb +114 -0
  11. data/lib/flapjack-diner/relationships.rb +180 -0
  12. data/lib/flapjack-diner/request.rb +280 -0
  13. data/lib/flapjack-diner/resources.rb +64 -0
  14. data/lib/flapjack-diner/response.rb +91 -0
  15. data/lib/flapjack-diner/tools.rb +47 -251
  16. data/lib/flapjack-diner/utility.rb +16 -0
  17. data/lib/flapjack-diner/version.rb +1 -1
  18. data/lib/flapjack-diner.rb +54 -20
  19. data/spec/argument_validator_spec.rb +87 -28
  20. data/spec/flapjack-diner_spec.rb +42 -64
  21. data/spec/relationships_spec.rb +211 -0
  22. data/spec/resources/checks_spec.rb +219 -79
  23. data/spec/resources/contacts_spec.rb +179 -151
  24. data/spec/resources/events_spec.rb +208 -0
  25. data/spec/resources/maintenance_periods_spec.rb +177 -565
  26. data/spec/resources/media_spec.rb +157 -171
  27. data/spec/resources/metrics_spec.rb +45 -0
  28. data/spec/resources/rules_spec.rb +278 -0
  29. data/spec/resources/states_spec.rb +93 -0
  30. data/spec/resources/statistics_spec.rb +53 -0
  31. data/spec/resources/tags_spec.rb +243 -0
  32. data/spec/spec_helper.rb +16 -0
  33. data/spec/support/fixture_data.rb +541 -0
  34. metadata +33 -31
  35. data/.rubocop.yml +0 -21
  36. data/.rubocop_todo.yml +0 -135
  37. data/lib/flapjack-diner/resources/checks.rb +0 -64
  38. data/lib/flapjack-diner/resources/contacts.rb +0 -70
  39. data/lib/flapjack-diner/resources/entities.rb +0 -68
  40. data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
  41. data/lib/flapjack-diner/resources/media.rb +0 -61
  42. data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
  43. data/lib/flapjack-diner/resources/notifications.rb +0 -28
  44. data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
  45. data/lib/flapjack-diner/resources/reports.rb +0 -33
  46. data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
  47. data/spec/resources/entities_spec.rb +0 -181
  48. data/spec/resources/notification_rules_spec.rb +0 -341
  49. data/spec/resources/notifications_spec.rb +0 -208
  50. data/spec/resources/pagerduty_credentials_spec.rb +0 -237
  51. data/spec/resources/reports_spec.rb +0 -255
data/README.md CHANGED
@@ -7,8 +7,7 @@
7
7
 
8
8
  Access the JSON API of a [Flapjack](http://flapjack.io/) system monitoring server.
9
9
 
10
- Note that flapjack-diner [releases](https://github.com/flapjack/flapjack-diner/releases) after [1.0.0.rc1](https://github.com/flapjack/flapjack-diner/releases/tag/v1.0.0.rc1) require the [JSONAPI](http://flapjack.io/docs/jsonapi) gateway of Flapjack to connect to. All previous releases (0.x) require the older [API](http://flapjack.io/docs/0.9/API) Flapjack gateway.
11
-
10
+ Please note that the following documentation refers to the `v2.0.0-alpha.3` pre-release of this gem. You may instead be looking for [documentation for the latest stable version](https://github.com/flapjack/flapjack-diner/blob/maint/1.x/README.md).
12
11
 
13
12
  ## Installation
14
13
 
@@ -54,122 +53,199 @@ Flapjack::Diner.return_keys_as_strings = true
54
53
 
55
54
  ## Functions
56
55
 
57
- Parameters for all of **flapjack-diner**'s functions are organised into three categories:
56
+ Options for all of **flapjack-diner**'s functions are organised as either:
58
57
 
59
- * Ids -- One or more String or Integer values
60
- * Query parameters -- Top-level hash values
61
- * Payload data -- Arrays of Hashes
58
+ * Ids &emdash; One or more String or Integer values; or
59
+ * Parameters &emdash; One or more Hashes
62
60
 
63
61
  While these can be passed in in any order, the convention is that they will be ordered as listed above.
64
62
 
65
- If any operation fails (returning nil), `Flapjack::Diner.last_error` will contain an error message regarding the failure.
63
+ If any operation fails (returning nil), the `Flapjack::Diner.last_error` method will return an error message regarding the failure.
64
+
65
+ <a name="contents_section_checks">&nbsp;</a>
66
+ ### <a name="contents_section_checks">&nbsp;</a>[Checks](#section_checks)
67
+
68
+ * <a name="contents_create_checks">&nbsp;</a>[create_checks](#create_checks)
69
+ * <a name="contents_checks">&nbsp;</a>[checks](#get_checks)
70
+ * <a name="contents_update_checks">&nbsp;</a>[update_checks](#update_checks)
71
+ * <a name="contents_delete_checks">&nbsp;</a>[delete_checks](#delete_checks)
72
+
73
+ ### <a name="contents_section_contacts">&nbsp;</a>[Contacts](#section_contacts)
74
+
75
+ * <a name="contents_create_contacts">&nbsp;</a>[create_contacts](#create_contacts)
76
+ * <a name="contents_contacts">&nbsp;</a>[contacts](#get_contacts)
77
+ * <a name="contents_update_contacts">&nbsp;</a>[update_contacts](#update_contacts)
78
+ * <a name="contents_delete_contacts">&nbsp;</a>[delete_contacts](#delete_contacts)
79
+
80
+ ### <a name="contents_section_media">&nbsp;</a>[Media](#section_media)
81
+
82
+ * <a name="contents_create_media">&nbsp;</a>[create_media](#create_media)
83
+ * <a name="contents_media">&nbsp;</a>[media](#get_media)
84
+ * <a name="contents_update_media">&nbsp;</a>[update_media](#update_media)
85
+ * <a name="contents_delete_media">&nbsp;</a>[delete_media](#delete_media)
86
+
87
+ ### <a name="contents_section_acceptors">&nbsp;</a>[Acceptors](#section_acceptors)
88
+
89
+ * <a name="contents_create_acceptors">&nbsp;</a>[create_acceptors](#create_acceptors)
90
+ * <a name="contents_acceptors">&nbsp;</a>[acceptors](#get_acceptors)
91
+ * <a name="contents_update_acceptors">&nbsp;</a>[update_acceptors](#update_acceptors)
92
+ * <a name="contents_delete_acceptors">&nbsp;</a>[delete_acceptors](#delete_acceptors)
93
+
94
+ ### <a name="contents_section_rejectors">&nbsp;</a>[Rejectors](#section_rejectors)
95
+
96
+ * <a name="contents_create_rejectors">&nbsp;</a>[create_rejectors](#create_rejectors)
97
+ * <a name="contents_rejectors">&nbsp;</a>[rejectors](#get_rejectors)
98
+ * <a name="contents_update_rejectors">&nbsp;</a>[update_rejectors](#update_rejectors)
99
+ * <a name="contents_delete_rejectors">&nbsp;</a>[delete_rejectors](#delete_rejectors)
100
+
101
+ ### <a name="contents_section_tags">&nbsp;</a>[Tags](#section_tags)
102
+
103
+ * <a name="contents_create_tags">&nbsp;</a>[create_tags](#create_tags)
104
+ * <a name="contents_tags">&nbsp;</a>[tags](#get_tags)
105
+ * <a name="contents_update_tags">&nbsp;</a>[update_tags](#update_tags)
106
+ * <a name="contents_delete_tags">&nbsp;</a>[delete_tags](#delete_tags)
107
+
108
+ ### <a name="contents_section_maintenance_periods">&nbsp;</a>[Maintenance periods](#section_maintenance_periods)
109
+
110
+ * <a name="contents_create_scheduled_maintenances">&nbsp;</a>[create_scheduled_maintenances](#create_scheduled_maintenances)
111
+ * <a name="contents_scheduled_maintenances">&nbsp;</a>[scheduled_maintenances](#get_scheduled_maintenances)
112
+ * <a name="contents_update_scheduled_maintenances">&nbsp;</a>[update_scheduled_maintenances](#update_scheduled_maintenances)
113
+ * <a name="contents_delete_scheduled_maintenances">&nbsp;</a>[delete_scheduled_maintenances](#delete_scheduled_maintenances)
114
+ * <a name="contents_unscheduled_maintenances">&nbsp;</a>[unscheduled_maintenances](#get_unscheduled_maintenances)
115
+ * <a name="contents_update_unscheduled_maintenances">&nbsp;</a>[update_unscheduled_maintenances](#update_unscheduled_maintenances)
116
+ * <a name="contents_delete_unscheduled_maintenances">&nbsp;</a>[delete_unscheduled_maintenances](#delete_unscheduled_maintenances)
117
+
118
+ ### <a name="contents_section_events">&nbsp;</a>[Events](#section_events)
119
+
120
+ * <a name="contents_create_acknowledgements">&nbsp;</a>[create_acknowledgements](#create_acknowledgements)
121
+ * <a name="contents_create_test_notifications">&nbsp;</a>[create_test_notifications](#create_test_notifications)
122
+
123
+ ### <a name="contents_section_miscellaneous">&nbsp;</a>[Miscellaneous](#section_miscellaneous)
124
+
125
+ * <a name="contents_states">&nbsp;</a>[states](#get_states)
126
+ * <a name="contents_metrics">&nbsp;</a>[metrics](#get_metrics)
127
+ * <a name="contents_statistics">&nbsp;</a>[statistics](#get_statistics)
128
+
129
+ ---
130
+
131
+ <a name="section_checks">&nbsp;</a>
132
+ ### Checks [^](#contents_section_checks)
133
+
134
+ <a name="create_checks">&nbsp;</a>
135
+ ### create_checks
136
+
137
+ Create one or more checks.
66
138
 
67
- ### Contacts
139
+ ```ruby
140
+ Flapjack::Diner.create_checks(CHECK, ...)
141
+ ```
68
142
 
69
- * [create_contacts](#create_contacts)
70
- * [contacts](#contacts)
71
- * [update_contacts](#update_contacts)
72
- * [delete_contacts](#delete_contacts)
143
+ ```
144
+ CHECK
145
+ {
146
+ :id => STRING,
147
+ :name => STRING,
148
+ :enabled => BOOLEAN,
149
+ :tags => [TAG_NAME, ...]
150
+ }
151
+ ```
73
152
 
74
- ### Media
153
+ Returns false if creation failed, or the created object(s) if it succeeded.
75
154
 
76
- * [create_contact_media](#create_contact_media)
77
- * [media](#media)
78
- * [update_media](#update_media)
79
- * [delete_media](#delete_media)
155
+ [^](#contents_create_checks)
80
156
 
81
- ### Pagerduty credentials
157
+ <a name="get_checks">&nbsp;</a>
158
+ ### checks
82
159
 
83
- * [create_contact_pagerduty_credentials](#create_contact_pagerduty_credentials)
84
- * [pagerduty_credentials](#pagerduty_credentials)
85
- * [update_pagerduty_credentials](#update_pagerduty_credentials)
86
- * [delete_pagerduty_credentials](#delete_pagerduty_credentials)
160
+ Return data for one, some or all checks.
87
161
 
88
- ### Notification rules
162
+ ```ruby
163
+ check = Flapjack::Diner.checks(CHECK_ID)
164
+ some_checks = Flapjack::Diner.checks(CHECK_ID, CHECK_ID, ...)
165
+ first_page_of_checks = Flapjack::Diner.checks
166
+ ```
89
167
 
90
- * [create_contact_notification_rules](#create_contact_notification_rules)
91
- * [notification_rules](#notification_rules)
92
- * [update_notification_rules](#update_notification_rules)
93
- * [delete_notification_rules](#delete_notification_rules)
168
+ [^](#contents_checks)
94
169
 
95
- ### Entities
170
+ <a name="update_checks">&nbsp;</a>
171
+ ### update_checks
172
+
173
+ Update data for one or more checks.
96
174
 
97
- * [create_entities](#create_entities)
98
- * [entities](#entities)
99
- * [entities_matching](#entities_matching)
100
- * [update_entities](#update_entities)
175
+ ```ruby
176
+ # update values for one check
177
+ Flapjack::Diner.update_checks(CHECK_ID, KEY => VALUE, ...)
101
178
 
102
- * [create_scheduled_maintenances_entities](#create_scheduled_maintenances_entities)
103
- * [delete_scheduled_maintenances_entities](#delete_scheduled_maintenances_entities)
179
+ # update values for multiple checks
180
+ Flapjack::Diner.update_checks({CHECK_ID, KEY => VALUE, ...}, {CHECK_ID, KEY => VALUE, ...})
181
+ ```
104
182
 
105
- * [create_unscheduled_maintenances_entities](#create_unscheduled_maintenances_entities)
106
- * [update_unscheduled_maintenances_entities](#update_unscheduled_maintenances_entities)
183
+ Acceptable update field keys are
107
184
 
108
- * [create_test_notifications_entities](#create_test_notifications_entities)
185
+ `:enabled`, `:name` and `:tags`
109
186
 
110
- ### Checks
187
+ Returns true if updating succeeded or false if updating failed.
111
188
 
112
- * [create_checks](#create_checks)
113
- * [checks](#checks)
114
- * [update_checks](#update_checks)
189
+ [^](#contents_update_checks)
115
190
 
116
- * [create_scheduled_maintenances_checks](#create_scheduled_maintenances_checks)
117
- * [delete_scheduled_maintenances_checks](#delete_scheduled_maintenances_checks)
191
+ <a name="delete_checks">&nbsp;</a>
192
+ #### delete_checks
118
193
 
119
- * [create_unscheduled_maintenances_checks](#create_unscheduled_maintenances_checks)
120
- * [update_unscheduled_maintenances_checks](#update_unscheduled_maintenances_checks)
194
+ Delete one or more checks.
121
195
 
122
- * [create_test_notifications_checks](#create_test_notifications_checks)
196
+ ```ruby
197
+ # delete one check
198
+ Flapjack::Diner.delete_checks(CHECK_ID)
123
199
 
124
- ### Reports
200
+ # delete multiple check
201
+ Flapjack::Diner.delete_checks(CHECK_ID, CHECK_ID, ...)
202
+ ```
125
203
 
126
- * [status_report_entities](#status_report_entities)
127
- * [scheduled_maintenance_report_entities](#scheduled_maintenance_report_entities)
128
- * [unscheduled_maintenance_report_entities](#unscheduled_maintenance_report_entities)
129
- * [downtime_report_entities](#downtime_report_entities)
130
- * [outage_report_entities](#outage_report_entities)
204
+ Returns true if deletion succeeded or false if deletion failed.
131
205
 
132
- * [status_report_checks](#status_report_checks)
133
- * [scheduled_maintenance_report_checks](#scheduled_maintenance_report_checks)
134
- * [unscheduled_maintenance_report_checks](#unscheduled_maintenance_report_checks)
135
- * [downtime_report_checks](#downtime_report_checks)
136
- * [outage_report_checks](#outage_report_checks)
206
+ [^](#contents_delete_checks)
137
207
 
138
208
  ---
139
209
 
210
+ <a name="section_contacts">&nbsp;</a>
211
+ ### Contacts [^](#contents_section_contacts)
212
+
140
213
  <a name="create_contacts">&nbsp;</a>
141
214
  #### create_contacts
142
215
 
143
216
  Create one or more contacts.
144
217
 
145
218
  ```ruby
146
- Flapjack::Diner.create_contacts([CONTACT, ...])
219
+ Flapjack::Diner.create_contacts(CONTACT, ...)
147
220
  ```
148
221
 
149
222
  ```
150
223
  CONTACT
151
224
  {
152
225
  :id => STRING,
153
- :first_name => STRING,
154
- :last_name => STRING,
155
- :email => STRING,
156
- :tags => [STRING, ...]
226
+ :name => STRING,
227
+ :timezone => STRING,
228
+ :tags => [TAG_NAME, ...]
157
229
  }
158
230
  ```
159
231
 
160
- Returns an array of contact ids if creation succeeded, or false if creation failed.
232
+ Returns false if creation failed, or the created object(s) if it succeeded.
161
233
 
162
- <a name="contacts">&nbsp;</a>
234
+ [^](#contents_create_contacts)
235
+
236
+ <a name="get_contacts">&nbsp;</a>
163
237
  #### contacts
164
238
 
165
239
  Return data for one, some or all contacts.
166
240
 
167
241
  ```ruby
168
- contact = Flapjack::Diner.contacts(ID)
169
- some_contacts = Flapjack::Diner.contacts(ID1, ID2, ...)
170
- all_contacts = Flapjack::Diner.contacts
242
+ contact = Flapjack::Diner.contacts(CONTACT_ID)
243
+ some_contacts = Flapjack::Diner.contacts(CONTACT_ID, CONTACT_ID, ...)
244
+ first_page_of_contacts = Flapjack::Diner.contacts
171
245
  ```
172
246
 
247
+ [^](#contents_contacts)
248
+
173
249
  <a name="update_contacts">&nbsp;</a>
174
250
  #### update_contacts
175
251
 
@@ -177,27 +253,20 @@ Update data for one or more contacts.
177
253
 
178
254
  ```ruby
179
255
  # update values for one contact
180
- Flapjack::Diner.update_contacts(ID, :key => value, ...)
256
+ Flapjack::Diner.update_contacts(CONTACT_ID, KEY => VALUE, ...)
181
257
 
182
258
  # update values for multiple contacts
183
- Flapjack::Diner.update_contacts(ID1, ID2, ..., :key => value, ...)
259
+ Flapjack::Diner.update_contacts({CONTACT_ID, KEY => VALUE, ...}, {CONTACT_ID, KEY => VALUE, ...})
184
260
  ```
185
261
 
186
262
  Acceptable update field keys are
187
263
 
188
- `:first_name`, `:last_name`, `:email`
189
-
190
- as well as the linkage operations
191
-
192
- `:add_entity`, `:remove_entity`
193
- `:add_notification_rule`, `:remove_notification_rule`
194
-
195
- which take the id (for entity and notification rule) of the relevant resource as the value.
196
-
197
- (NB: `:add_medium` and `:remove_medium` are not supported in Flapjack v1.x but will be in future versions.)
264
+ `:name`, `:timezone` and `:tags`
198
265
 
199
266
  Returns true if updating succeeded, false if updating failed.
200
267
 
268
+ [^](#contents_update_contacts)
269
+
201
270
  <a name="delete_contacts">&nbsp;</a>
202
271
  #### delete_contacts
203
272
 
@@ -205,48 +274,64 @@ Delete one or more contacts.
205
274
 
206
275
  ```ruby
207
276
  # delete one contact
208
- Flapjack::Diner.delete_contacts(ID)
277
+ Flapjack::Diner.delete_contacts(CONTACT_ID)
209
278
 
210
279
  # delete multiple contacts
211
- Flapjack::Diner.delete_contacts(ID1, ID2, ...)
280
+ Flapjack::Diner.delete_contacts(CONTACT_ID, CONTACT_ID, ...)
212
281
  ```
213
282
 
214
283
  Returns true if deletion succeeded or false if deletion failed.
215
284
 
285
+ [^](#contents_delete_contacts)
286
+
216
287
  ---
217
288
 
218
- <a name="create_contact_media">&nbsp;</a>
219
- #### create_contact_media
289
+ <a name="section_media">&nbsp;</a>
290
+ ### Media [^](#contents_section_media)
291
+
292
+ <a name="create_media">&nbsp;</a>
293
+ #### create_media
220
294
 
221
295
  Create one or more notification media.
222
296
 
223
297
  ```ruby
224
- Flapjack::Diner.create_contact_media(CONTACT_ID, [MEDIUM, ...])
298
+ Flapjack::Diner.create_media(MEDIUM, MEDIUM, ...)
225
299
  ```
226
300
 
227
- ```
228
- MEDIUM
301
+ ```ruby
302
+ # MEDIUM
229
303
  {
230
- :type => STRING,
231
- :address => STRING,
232
- :interval => INTEGER,
233
- :rollup_threshold => INTEGER
304
+ :id => UUID,
305
+ :transport => STRING, # required
306
+ :address => STRING, # required (context depends on transport)
307
+ :interval => INTEGER, # required (if transport != 'pagerduty')
308
+ :rollup_threshold => INTEGER, # required (if transport != 'pagerduty')
309
+ :pagerduty_subdomain => STRING, # required (if transport == 'pagerduty')
310
+ :pagerduty_token => STRING, # required (if transport == 'pagerduty')
311
+ :pagerduty_ack_duration => INTEGER, # required (if transport == 'pagerduty')
312
+ :contact => CONTACT_ID, # required
313
+ :acceptors => [ACCEPTOR_ID, ACCEPTOR_ID, ...],
314
+ :rejectors => [REJECTOR_ID, REJECTOR_ID, ...]
234
315
  }
235
316
  ```
236
317
 
237
- Returns an array of media ids if creation succeeded, or false if creation failed. (Ids cannot be passed in for media records in Flapjack v1.x.)
318
+ Returns false if creation failed, or the created object(s) if it succeeded.
319
+
320
+ [^](#contents_create_media)
238
321
 
239
- <a name="media">&nbsp;</a>
322
+ <a name="get_media">&nbsp;</a>
240
323
  #### media
241
324
 
242
- Return data for one, some or all notification media. Notification media ids are formed by compounding their linked contact's ID and their type in a string (e.g. '23_sms').
325
+ Return data for one, some or all notification media.
243
326
 
244
327
  ```ruby
245
- medium = Flapjack::Diner.media(ID)
246
- some_media = Flapjack::Diner.media(ID1, ID2, ...)
247
- all_media = Flapjack::Diner.media
328
+ medium = Flapjack::Diner.media(MEDIUM_ID)
329
+ some_media = Flapjack::Diner.media(MEDIUM_ID, MEDIUM_ID, ...)
330
+ first_page_of_media = Flapjack::Diner.media
248
331
  ```
249
332
 
333
+ [^](#contents_media)
334
+
250
335
  <a name="update_media">&nbsp;</a>
251
336
  #### update_media
252
337
 
@@ -254,18 +339,20 @@ Update data for one or more notification media.
254
339
 
255
340
  ```ruby
256
341
  # update values for one medium
257
- Flapjack::Diner.update_media(ID, :key => value, ...)
342
+ Flapjack::Diner.update_media(MEDIUM_ID, KEY => VALUE, ...)
258
343
 
259
344
  # update values for multiple media
260
- Flapjack::Diner.update_media(ID1, ID2, ..., :key => value, ...)
345
+ Flapjack::Diner.update_media({MEDIUM_ID, KEY => VALUE, ...}, {MEDIUM_ID, KEY => VALUE, ...})
261
346
  ```
262
347
 
263
348
  Acceptable update field keys are
264
349
 
265
- `:address`, `:interval`, `:rollup_threshold`
350
+ `:address`, `:interval`, `:rollup_threshold`, `:pagerduty_subdomain`, `:pagerduty_token`, `:pagerduty_ack_duration`, `:acceptors` and `:rejectors`
266
351
 
267
352
  Returns true if updating succeeded or false if updating failed.
268
353
 
354
+ [^](#contents_update_media)
355
+
269
356
  <a name="delete_media">&nbsp;</a>
270
357
  #### delete_media
271
358
 
@@ -273,564 +360,684 @@ Delete one or more notification media.
273
360
 
274
361
  ```ruby
275
362
  # delete one medium
276
- Flapjack::Diner.delete_media(ID)
363
+ Flapjack::Diner.delete_media(MEDIUM_ID)
277
364
 
278
365
  # delete multiple media
279
- Flapjack::Diner.delete_media(ID1, ID2, ...)
366
+ Flapjack::Diner.delete_media(MEDIUM_ID, MEDIUM_ID, ...)
280
367
  ```
281
368
 
282
369
  Returns true if deletion succeeded or false if deletion failed.
283
370
 
371
+ [^](#contents_delete_media)
372
+
284
373
  ---
285
374
 
286
- <a name="create_contact_pagerduty_credentials">&nbsp;</a>
287
- #### create_contact_pagerduty_credentials
375
+ <a name="section_acceptors">&nbsp;</a>
376
+ ### Acceptors [^](#contents_section_acceptors)
377
+
378
+ <a name="create_acceptors">&nbsp;</a>
379
+ #### create_acceptors
288
380
 
289
- Create pagerduty credentials for a contact.
381
+ Create one or more notification acceptors.
290
382
 
291
383
  ```ruby
292
- Flapjack::Diner.create_contact_pagerduty_credentials(CONTACT_ID, PAGERDUTY_CREDENTIALS)
384
+ Flapjack::Diner.create_acceptors(ACCEPTOR, ...)
293
385
  ```
294
386
 
295
- ```
296
- PAGERDUTY_CREDENTIALS
387
+ **FIXME** time_restrictions data structure isn't handled yet
388
+
389
+ ```ruby
390
+ # ACCEPTOR
297
391
  {
298
- :service_key => STRING,
299
- :subdomain => STRING,
300
- :username => STRING,
301
- :password => STRING
392
+ :id => UUID_STRING,
393
+ :name => STRING,
394
+ :all => BOOLEAN, # apply to all checks, ignore tag linkages
395
+ :conditions_list => STRING, # which conditions the acceptor will match;
396
+ # all if empty, or comma-separated subset
397
+ # of 'critical,warning,unknown'
398
+ :contact => CONTACT_ID, # required
399
+ :media => [MEDIUM_ID, ...]
400
+ :tags => [TAG_NAME, ...]
302
401
  }
303
402
  ```
304
403
 
305
- Returns an array of contact ids if creation succeeded, or false if creation failed. (As contacts may only have one set of pagerduty credentials, Flapjack v1.x does not store a separate data model, thus theses objects have no separate ids.)
404
+ Returns false if creation failed, or the created object(s) if it succeeded.
306
405
 
307
- <a name="pagerduty_credentials">&nbsp;</a>
308
- #### pagerduty_credentials
406
+ [^](#contents_create_acceptors)
309
407
 
310
- Return pagerduty credentials for a contact.
408
+ <a name="get_acceptors">&nbsp;</a>
409
+ #### acceptors
410
+
411
+ Return data for one, some or all notification acceptors.
311
412
 
312
413
  ```ruby
313
- pagerduty_credentials = Flapjack::Diner.pagerduty_credentials(CONTACT_ID)
314
- some_pagerduty_credentials = Flapjack::Diner.pagerduty_credentials(CONTACT_ID1, CONTACT_ID2, ...)
315
- all_pagerduty_credentials = Flapjack::Diner.pagerduty_credentials
414
+ acceptor = Flapjack::Diner.acceptors(ACCEPTOR_ID)
415
+ some_acceptors = Flapjack::Diner.acceptors(ACCEPTOR_ID, ACCEPTOR_ID, ...)
416
+ first_page_of_acceptors = Flapjack::Diner.acceptors
316
417
  ```
317
418
 
318
- <a name="update_pagerduty_credentials">&nbsp;</a>
319
- #### update_pagerduty_credentials
419
+ [^](#contents_acceptors)
420
+
421
+ <a name="update_acceptors">&nbsp;</a>
422
+ #### update_acceptors
320
423
 
321
- Update pagerduty credentials for one or more contacts.
424
+ Update data for one or more notification acceptors.
322
425
 
323
426
  ```ruby
324
- # update pagerduty_credentials for one contact
325
- Flapjack::Diner.update_pagerduty_credentials(CONTACT_ID, :key => value, ...)
427
+ # update values for one acceptor
428
+ Flapjack::Diner.update_acceptors(:id => ACCEPTOR_ID, KEY => VALUE, ...)
326
429
 
327
- # update pagerduty_credentials for multiple contacts
328
- Flapjack::Diner.update_pagerduty_credentials(CONTACT_ID1, CONTACT_ID2, ..., :key => value, ...)
430
+ # update values for multiple acceptors
431
+ Flapjack::Diner.update_acceptors({:id => ACCEPTOR_ID, KEY => VALUE, ...}, {:id => ACCEPTOR_ID, KEY => VALUE, ...})
329
432
  ```
330
433
 
331
434
  Acceptable update field keys are
332
435
 
333
- `:service_key`, `:subdomain`, `:username`, `:password`
436
+ `:conditions_list`, `:is_blackhole`, `:media` and `:tags`
334
437
 
335
438
  Returns true if updating succeeded or false if updating failed.
336
439
 
337
- <a name="delete_pagerduty_credentials">&nbsp;</a>
338
- #### delete_pagerduty_credentials
440
+ [^](#contents_update_acceptors)
441
+
442
+ <a name="delete_acceptors">&nbsp;</a>
443
+ #### delete_acceptors
339
444
 
340
- Delete pagerduty credentials for one or more contacts
445
+ Delete one or more notification acceptors.
341
446
 
342
447
  ```ruby
343
- # delete pagerduty_credentials for one contact
344
- Flapjack::Diner.delete_pagerduty_credentials(CONTACT_ID)
448
+ # delete one acceptor
449
+ Flapjack::Diner.delete_acceptors(ACCEPTOR_ID)
345
450
 
346
- # delete pagerduty_credentials for multiple contacts
347
- Flapjack::Diner.delete_pagerduty_credentials(CONTACT_ID1, CONTACT_ID2, ...)
451
+ # delete multiple acceptors
452
+ Flapjack::Diner.delete_acceptors(ACCEPTOR_ID, ACCEPTOR_ID, ...)
348
453
  ```
349
454
 
350
455
  Returns true if deletion succeeded or false if deletion failed.
351
456
 
457
+ [^](#contents_delete_acceptors)
458
+
352
459
  ---
353
460
 
354
- <a name="create_contact_notification_rules">&nbsp;</a>
355
- #### create_contact_notification_rules
461
+ <a name="section_rejectors">&nbsp;</a>
462
+ ### Rules [^](#contents_section_rejectors)
463
+
464
+ <a name="create_rejectors">&nbsp;</a>
465
+ #### create_rejectors
356
466
 
357
- Create one or more notification rules.
467
+ Create one or more notification rejectors.
358
468
 
359
469
  ```ruby
360
- Flapjack::Diner.create_contact_notification_rules(CONTACT_ID, [NOTIFICATION_RULE, ...])
470
+ Flapjack::Diner.create_rejectors(REJECTOR, ...)
361
471
  ```
362
472
 
363
- ```
364
- NOTIFICATION_RULE
473
+ **FIXME** time_restrictions data structure isn't handled yet
474
+
475
+ ```ruby
476
+ # REJECTOR
365
477
  {
366
- :id => STRING,
367
- :entities => [STRING, ...],
368
- :regex_entities => [STRING, ...],
369
- :tags => [STRING, ...],
370
- :regex_tags => [STRING, ...],
371
- :time_restrictions => TODO,
372
- :unknown_media => [STRING, ...],
373
- :warning_media => [STRING, ...],
374
- :critical_media => [STRING, ...],
375
- :unknown_blackhole => BOOLEAN,
376
- :warning_blackhole => BOOLEAN,
377
- :critical_blackhole => BOOLEAN
478
+ :id => UUID_STRING,
479
+ :name => STRING,
480
+ :all => BOOLEAN, # apply to all checks, ignore tag linkages
481
+ :conditions_list => STRING, # which conditions the rejector will match;
482
+ # all if empty, or comma-separated subset
483
+ # of 'critical,warning,unknown'
484
+ :contact => CONTACT_ID, # required
485
+ :media => [MEDIUM_ID, ...]
486
+ :tags => [TAG_NAME, ...]
378
487
  }
379
488
  ```
380
489
 
381
- Returns an array of notification rule ids if creation succeeded, or false if creation failed.
490
+ Returns false if creation failed, or the created object(s) if it succeeded.
382
491
 
383
- <a name="notification_rules">&nbsp;</a>
384
- #### notification_rules
492
+ [^](#contents_create_rejectors)
385
493
 
386
- Return data for one, some or all notification rules.
494
+ <a name="get_rejectors">&nbsp;</a>
495
+ #### rejectors
496
+
497
+ Return data for one, some or all notification rejectors.
387
498
 
388
499
  ```ruby
389
- notification_rule = Flapjack::Diner.notification_rules(ID)
390
- some_notification_rules = Flapjack::Diner.notification_rules(ID1, ID2, ...)
391
- all_notification_rules = Flapjack::Diner.notification_rules
500
+ rejector = Flapjack::Diner.rejectors(REJECTOR_ID)
501
+ some_rejectors = Flapjack::Diner.rejectors(REJECTOR_ID, REJECTOR_ID, ...)
502
+ first_page_of_rejectors = Flapjack::Diner.rejectors
392
503
  ```
393
504
 
394
- <a name="update_notification_rules">&nbsp;</a>
395
- #### update_notification_rules
505
+ [^](#contents_rejectors)
506
+
507
+ <a name="update_rejectors">&nbsp;</a>
508
+ #### update_rejectors
396
509
 
397
- Update data for one or more notification rules.
510
+ Update data for one or more notification rejectors.
398
511
 
399
512
  ```ruby
400
- # update values for one notification rule
401
- Flapjack::Diner.update_notification_rules(ID, :key => value, ...)
513
+ # update values for one rejector
514
+ Flapjack::Diner.update_rejectors(:id => REJECTOR_ID, KEY => VALUE, ...)
402
515
 
403
- # update values for multiple notification rules
404
- Flapjack::Diner.update_notification_rules(ID1, ID2, ..., :key => value, ...)
516
+ # update values for multiple rejectors
517
+ Flapjack::Diner.update_rejectors({:id => REJECTOR_ID, KEY => VALUE, ...}, {:id => REJECTOR_ID, KEY => VALUE, ...})
405
518
  ```
406
519
 
407
520
  Acceptable update field keys are
408
521
 
409
- `:entities`, `:regex_entities`, `:tags`, `:regex_tags`, `:time_restrictions`, `:unknown_media`, `:warning_media`, `:critical_media`, `:unknown_blackhole`, `:warning_blackhole`, and `:critical_blackhole`
522
+ `:conditions_list`, `:is_blackhole`, `:media` and `:tags`
410
523
 
411
524
  Returns true if updating succeeded or false if updating failed.
412
525
 
413
- <a name="delete_notification_rules">&nbsp;</a>
414
- #### delete_notification_rules
526
+ [^](#contents_update_rejectors)
527
+
528
+ <a name="delete_rejectors">&nbsp;</a>
529
+ #### delete_rejectors
415
530
 
416
- Delete one or more notification rules.
531
+ Delete one or more notification rejectors.
417
532
 
418
533
  ```ruby
419
- # delete one medium
420
- Flapjack::Diner.delete_notification_rules(ID)
534
+ # delete one rejector
535
+ Flapjack::Diner.delete_rejectors(REJECTOR_ID)
421
536
 
422
- # delete multiple contacts
423
- Flapjack::Diner.delete_notification_rules(ID1, ID2, ...)
537
+ # delete multiple rejectors
538
+ Flapjack::Diner.delete_rejectors(REJECTOR_ID, REJECTOR_ID, ...)
424
539
  ```
425
540
 
426
541
  Returns true if deletion succeeded or false if deletion failed.
427
542
 
543
+ [^](#contents_delete_rejectors)
544
+
428
545
  ---
429
546
 
430
- <a name="create_entities">&nbsp;</a>
431
- ### create_entities
547
+ <a name="section_tags">&nbsp;</a>
548
+ ### Tags [^](#contents_section_tags)
432
549
 
433
- Create one or more entities.
550
+ <a name="create_tags">&nbsp;</a>
551
+ #### create_tags
552
+
553
+ Create one or more tags.
434
554
 
435
555
  ```ruby
436
- Flapjack::Diner.create_entities([ENTITY, ...])
556
+ Flapjack::Diner.create_tags(TAG, ...)
437
557
  ```
438
558
 
439
- ```
440
- ENTITY
559
+ ```ruby
560
+ # TAG
441
561
  {
442
- :id => STRING,
443
- :name => STRING,
444
- :tags => [STRING, ...]
562
+ :name => STRING, # required
563
+ :checks => [CHECK_ID, ...],
564
+ :contacts => [CONTACT_ID, ...],
565
+ :acceptors => [ACCEPTOR_ID, ...],
566
+ :rejectors => [REJECTOR_ID, ...]
445
567
  }
446
568
  ```
447
569
 
448
- Returns an array of entity ids if creation succeeded, or false if creation failed.
449
-
450
- <a name="entities">&nbsp;</a>
451
- ### entities
570
+ Returns false if creation failed, or the created object(s) if it succeeded.
452
571
 
453
- Return data for one, some or all entities.
454
-
455
- ```ruby
456
- entity = Flapjack::Diner.entities(ID)
457
- some_entities = Flapjack::Diner.entities(ID1, ID2, ...)
458
- all_entities = Flapjack::Diner.entities
459
- ```
572
+ [^](#contents_create_tags)
460
573
 
461
- <a name="entities_matching">&nbsp;</a>
462
- ### entities_matching
574
+ <a name="get_tags">&nbsp;</a>
575
+ #### tags
463
576
 
464
- Returns an array of entities matching a given regular expression
577
+ Return data for one, some or all tags.
465
578
 
466
579
  ```ruby
467
- entities = Flapjack::Diner.entities_matching(/^db-app-01/)
580
+ tag = Flapjack::Diner.tags(TAG_NAME)
581
+ some_tags = Flapjack::Diner.tags(TAG_NAME, TAG_NAME, ...)
582
+ first_page_of_tags = Flapjack::Diner.tags
468
583
  ```
469
584
 
470
- <a name="update_entities">&nbsp;</a>
471
- ### update_entities
585
+ [^](#contents_tags)
472
586
 
473
- Update data for one or more entities.
587
+ <a name="update_tags">&nbsp;</a>
588
+ #### update_tags
589
+
590
+ Update data for one or more tags.
474
591
 
475
592
  ```ruby
476
- # update values for one entity
477
- Flapjack::Diner.update_entities(ID, :key => value, ...)
593
+ # update values for one tag
594
+ Flapjack::Diner.update_tags(:id => TAG_NAME, KEY => VALUE, ...)
478
595
 
479
- # update values for multiple entities
480
- Flapjack::Diner.update_entities(ID1, ID2, ..., :key => value, ...)
596
+ # update values for multiple tags
597
+ Flapjack::Diner.update_tags({:id => TAG_NAME, KEY => VALUE, ...}, {:id => TAG_NAME, KEY => VALUE, ...})
481
598
  ```
482
599
 
483
- There are no valid update field keys yet.
484
-
485
- The linkage operations
486
-
487
- `:add_contact` and `:remove_contact`
488
- `:add_tag` and `:remove_tag`
600
+ Acceptable update field keys are
489
601
 
490
- take the id (for contact) or the name (for tag) of the relevant resource as the value.
602
+ `:checks`, `:contacts`, `:acceptors` and `:rejectors`
491
603
 
492
604
  Returns true if updating succeeded or false if updating failed.
493
605
 
606
+ [^](#contents_update_tags)
494
607
 
495
- <a name="create_scheduled_maintenances_entities">&nbsp;</a>
496
- ### create_scheduled_maintenances_entities
608
+ <a name="delete_tags">&nbsp;</a>
609
+ #### delete_tags
497
610
 
498
- Create one or more scheduled maintenance periods (`duration` seconds in length) on all checks for the provided entities.
611
+ Delete one or more tags.
499
612
 
500
613
  ```ruby
501
- Flapjack::Diner.create_scheduled_maintenances_entities(ENTITY_ID(S), [SCHEDULED_MAINTENANCE, ...])
502
- ```
614
+ # delete one tag
615
+ Flapjack::Diner.delete_tags(TAG_NAME)
503
616
 
504
- ```
505
- SCHEDULED_MAINTENANCE
506
- {
507
- :start_time => DATETIME,
508
- :duration => INTEGER,
509
- :summary => STRING
510
- }
617
+ # delete multiple tags
618
+ Flapjack::Diner.delete_tags(TAG_NAME, TAG_NAME, ...)
511
619
  ```
512
620
 
513
- Returns true if creation succeeded or false if creation failed.
514
-
515
- <a name="delete_scheduled_maintenances_entities">&nbsp;</a>
516
- ### delete_scheduled_maintenances_entities
621
+ Returns true if deletion succeeded or false if deletion failed.
517
622
 
518
- Delete scheduled maintenance periods starting at a specific time for checks across one or more entities.
623
+ [^](#contents_delete_tags)
519
624
 
520
- ```ruby
521
- Flapjack::Diner.delete_scheduled_maintenances_entities(ENTITY_ID(S), :start_time => DATETIME)
522
- ```
625
+ ---
523
626
 
524
- Returns true if deletion succeeded or false if deletion failed. Raises an exception if the `:start_time` parameter is not supplied.
627
+ <a name="section_maintenance_periods">&nbsp;</a>
628
+ ### Maintenance periods [^](#contents_section_maintenance_periods)
525
629
 
526
- <a name="create_unscheduled_maintenances_entities">&nbsp;</a>
527
- ### create_unscheduled_maintenances_entities
630
+ <a name="create_scheduled_maintenances">&nbsp;</a>
631
+ ### create_scheduled_maintenances
528
632
 
529
- Acknowledges any failing checks on the passed entities and sets up unscheduled maintenance (`duration` seconds long) on them.
633
+ Create one or more scheduled maintenance periods (`duration` seconds in length) on one or more checks.
530
634
 
531
635
  ```ruby
532
- Flapjack::Diner.create_unscheduled_maintenances_entities(ENTITY_ID(S), [SCHEDULED_MAINTENANCE, ...])
636
+ Flapjack::Diner.create_scheduled_maintenances(SCHEDULED_MAINTENANCE, ...)
533
637
  ```
534
638
 
535
- ```
536
- UNSCHEDULED_MAINTENANCE
639
+ ```ruby
640
+ SCHEDULED_MAINTENANCE
537
641
  {
538
- :duration => INTEGER,
539
- :summary => STRING
642
+ :id => UUID,
643
+ :start_time => DATETIME, # required
644
+ :end_time => DATETIME, # required
645
+ :summary => STRING,
646
+ :check => CHECK_ID, # one (and only one) of :check or :tag must be provided
647
+ :tag => TAG_NAME # :tag will create scheduled maintenance periods for all checks that this tag is associated with
540
648
  }
541
649
  ```
542
650
 
543
- Returns true if creation succeeded or false if creation failed.
651
+ Returns false if creation failed, or the created object(s) if it succeeded.
544
652
 
545
- <a name="update_unscheduled_maintenances_entities">&nbsp;</a>
546
- ### update_unscheduled_maintenances_entities
653
+ [^](#contents_create_scheduled_maintenances)
547
654
 
548
- Finalises currently existing unscheduled maintenance periods for all acknowledged checks in the provided entities. The periods end at the time provided in the `:end_time` parameter.
655
+ <a name="get_scheduled_maintenances">&nbsp;</a>
656
+ ### scheduled_maintenances
657
+
658
+ Return data for one, some or all scheduled maintenance periods.
549
659
 
550
660
  ```ruby
551
- Flapjack::Diner.update_unscheduled_maintenances_entities(ENTITY_ID(S), :end_time => DATETIME)
661
+ scheduled_maintenance = Flapjack::Diner.scheduled_maintenances(SCHEDULED_MAINTENANCE_ID)
662
+ some_scheduled_maintenances = Flapjack::Diner.scheduled_maintenances(SCHEDULED_MAINTENANCE_ID, SCHEDULED_MAINTENANCE_ID, ...)
663
+ first_page_of_scheduled_maintenances = Flapjack::Diner.scheduled_maintenances
552
664
  ```
553
665
 
554
- Returns true if the finalisation succeeded or false if deletion failed.
666
+ [^](#contents_scheduled_maintenances)
555
667
 
556
- <a name="create_test_notifications_entities">&nbsp;</a>
557
- ### create_test_notifications_entities
668
+ <a name="update_scheduled_maintenances">&nbsp;</a>
669
+ ### update_scheduled_maintenances
558
670
 
559
- Instructs Flapjack to issue test notifications on all checks for the passed entities. These notifications will be sent to contacts configured to receive notifications for those checks.
671
+ Update data for one or more scheduled maintenance periods.
560
672
 
561
673
  ```ruby
562
- Flapjack::Diner.create_test_notifications_entities(ENTITY_ID(S), [TEST_NOTIFICATION, ...])
563
- ```
674
+ # update values for one scheduled maintenance period
675
+ Flapjack::Diner.update_scheduled_maintenances(:id => SCHEDULED_MAINTENANCE_ID, KEY => VALUE, ...)
564
676
 
677
+ # update values for multiple scheduled maintenance periods
678
+ Flapjack::Diner.update_scheduled_maintenances({:id => SCHEDULED_MAINTENANCE_ID, KEY => VALUE, ...}, {:id => SCHEDULED_MAINTENANCE_ID, KEY => VALUE, ...})
565
679
  ```
566
- TEST_NOTIFICATION
567
- {
568
- :summary => STRING
569
- }
570
- ```
571
680
 
572
- Returns true if creation succeeded or false if creation failed.
681
+ Acceptable update field keys are
682
+
683
+ `:start_time`, `:end_time` and `:summary`
573
684
 
574
- ---
685
+ Returns true if updating succeeded or false if updating failed.
575
686
 
576
- <a name="create_checks">&nbsp;</a>
577
- ### create_checks
687
+ **FIXME** we may make it a configuration setting as to whether times in the past may be edited
578
688
 
579
- Create one or more checks.
689
+ [^](#contents_update_scheduled_maintenances)
690
+
691
+ <a name="delete_scheduled_maintenances">&nbsp;</a>
692
+ ### delete_scheduled_maintenances
693
+
694
+ Delete one or more scheduled maintenance periods.
580
695
 
581
696
  ```ruby
582
- Flapjack::Diner.create_checks([CHECK, ...])
697
+ Flapjack::Diner.delete_scheduled_maintenances(SCHEDULED_MAINTENANCE_ID)
698
+ Flapjack::Diner.delete_scheduled_maintenances(SCHEDULED_MAINTENANCE_ID, SCHEDULED_MAINTENANCE_ID, ...)
583
699
  ```
584
700
 
585
- ```
586
- CHECK
587
- {
588
- :entity_id => STRING,
589
- :name => STRING,
590
- :tags => [STRING, ...]
591
- }
592
- ```
701
+ Returns true if deletion succeeded or false if deletion failed.
593
702
 
594
- Returns an array of check ids if creation succeeded, or false if creation failed. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
703
+ **FIXME** we may make it a configuration setting as to whether scheduled maintenance periods that have already started (or finished) may be deleted
595
704
 
596
- <a name="checks">&nbsp;</a>
597
- ### checks
705
+ [^](#contents_delete_scheduled_maintenances)
598
706
 
599
- Return basic identity data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
707
+ <a name="get_unscheduled_maintenances">&nbsp;</a>
708
+ ### unscheduled_maintenances
709
+
710
+ Return data for one, some or all unscheduled maintenance periods.
600
711
 
601
712
  ```ruby
602
- check = Flapjack::Diner.checks(ID)
603
- some_checks = Flapjack::Diner.checks(ID1, ID2, ...)
604
- all_checks = Flapjack::Diner.checks
713
+ unscheduled_maintenance = Flapjack::Diner.unscheduled_maintenances(UNSCHEDULED_MAINTENANCE_ID)
714
+ some_unscheduled_maintenances = Flapjack::Diner.unscheduled_maintenances(UNSCHEDULED_MAINTENANCE_ID, UNSCHEDULED_MAINTENANCE_ID, ...)
715
+ first_page_of_unscheduled_maintenances = Flapjack::Diner.unscheduled_maintenances
605
716
  ```
606
717
 
607
- <a name="checks_matching">&nbsp;</a>
608
- ### checks_matching
718
+ [^](#contents_unscheduled_maintenances)
719
+
720
+ <a name="update_unscheduled_maintenances">&nbsp;</a>
721
+ ### update_unscheduled_maintenances
609
722
 
610
- Returns an array of checks matching a given regular expression
723
+ Update data for one or more unscheduled maintenance periods.
611
724
 
612
725
  ```ruby
613
- entities = Flapjack::Diner.checks_matching(/^PING/)
726
+ Flapjack::Diner.update_unscheduled_maintenances(:id => UNSCHEDULED_MAINTENANCE_ID, KEY => VALUE)
727
+
728
+ Flapjack::Diner.update_unscheduled_maintenances({:id => UNSCHEDULED_MAINTENANCE_ID, KEY => VALUE},
729
+ {:id => UNSCHEDULED_MAINTENANCE_ID, KEY => VALUE}, ...)
614
730
  ```
615
731
 
616
- <a name="update_checks">&nbsp;</a>
617
- ### update_checks
732
+ Acceptable update field keys are
618
733
 
619
- Update data for one or more checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
734
+ `:start_time`, `:end_time` and `:summary`
620
735
 
621
- ```ruby
622
- # update values for one checks
623
- Flapjack::Diner.update_checks(ID, :key => value, ...)
736
+ Returns true if updating succeeded or false if updating failed.
624
737
 
625
- # update values for multiple checks
626
- Flapjack::Diner.update_checks(ID1, ID2, ..., :key => value, ...)
627
- ```
738
+ **FIXME** we may make it a configuration setting as to whether times in the past may be edited
628
739
 
629
- Acceptable update field keys are
740
+ [^](#contents_update_unscheduled_maintenances)
630
741
 
631
- `:enabled`
742
+ <a name="delete_unscheduled_maintenances">&nbsp;</a>
743
+ ### delete_unscheduled_maintenances
632
744
 
633
- as well as the linkage operations
745
+ Delete one or more unscheduled maintenance periods.
634
746
 
635
- `:add_tag` and `:remove_tag`
747
+ ```ruby
748
+ Flapjack::Diner.delete_unscheduled_maintenances(UNSCHEDULED_MAINTENANCE_ID)
749
+ Flapjack::Diner.delete_unscheduled_maintenances(UNSCHEDULED_MAINTENANCE_ID, UNSCHEDULED_MAINTENANCE_ID, ...)
750
+ ```
636
751
 
637
- which take the name of the tag as the value.
752
+ Returns true if deletion succeeded or false if deletion failed.
638
753
 
639
- Returns true if updating succeeded or false if updating failed.
754
+ **FIXME** we may make it a configuration setting as to whether unscheduled maintenance periods may be deleted
755
+
756
+ [^](#contents_delete_unscheduled_maintenances)
640
757
 
641
758
  ---
642
759
 
643
- <a name="create_scheduled_maintenances_checks">&nbsp;</a>
644
- ### create_scheduled_maintenances_checks
760
+ <a name="section_events">&nbsp;</a>
761
+ ### Events [^](#contents_section_events)
762
+
763
+ <a name="create_acknowledgements">&nbsp;</a>
764
+ ### create_acknowledgements
645
765
 
646
- Create one or more scheduled maintenance periods (`duration` seconds in length) on one or more checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
766
+ Acknowledges any failing checks from those passed and sets up unscheduled maintenance (`duration` seconds long) on them.
647
767
 
648
768
  ```ruby
649
- Flapjack::Diner.create_scheduled_maintenances_checks(CHECK_ID(S), [SCHEDULED_MAINTENANCE, ...])
769
+ Flapjack::Diner.create_acknowledgements(ACKNOWLEDGEMENT, ...)
650
770
  ```
651
771
 
652
- ```
653
- SCHEDULED_MAINTENANCE
772
+ ```ruby
773
+ # ACKNOWLEDGEMENT
654
774
  {
655
- :start_time => DATETIME,
775
+ :summary => STRING,
656
776
  :duration => INTEGER,
657
- :summary => STRING
777
+ :check => CHECK_ID, # one (and only one) of :check or :tag must be provided
778
+ :tag => TAG_NAME # :tag will acknowledge all failing checks that this tag is associated with
658
779
  }
659
780
  ```
660
781
 
661
- Returns true if creation succeeded or false if creation failed.
782
+ Returns false if creation failed, or the created object(s) if it succeeded.
662
783
 
663
- <a name="delete_scheduled_maintenances_checks">&nbsp;</a>
664
- ### delete_scheduled_maintenances_checks
784
+ [^](#contents_create_acknowledgements)
665
785
 
666
- Delete scheduled maintenance periods starting at a specific time for one or more checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
786
+ <a name="create_test_notifications">&nbsp;</a>
787
+ ### create_test_notifications
667
788
 
668
- ```ruby
669
- Flapjack::Diner.delete_scheduled_maintenances_checks(CHECK_ID(S), :start_time => DATETIME)
670
- ```
671
-
672
- Returns true if deletion succeeded or false if deletion failed. Raises an exception if the `:start_time` parameter is not supplied.
673
-
674
- <a name="create_unscheduled_maintenances_checks">&nbsp;</a>
675
- ### create_unscheduled_maintenances_checks
676
-
677
- Acknowledges any failing checks from those passed and sets up unscheduled maintenance (`duration` seconds long) on them. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
789
+ Instructs Flapjack to issue test notifications on the passed checks. These notifications will be sent to contacts configured to receive notifications for those checks.
678
790
 
679
791
  ```ruby
680
- Flapjack::Diner.create_unscheduled_maintenances_checks(CHECK_ID(S), [SCHEDULED_MAINTENANCE, ...])
792
+ Flapjack::Diner.create_test_notifications(TEST_NOTIFICATION, ...)
681
793
  ```
682
794
 
683
- ```
684
- UNSCHEDULED_MAINTENANCE
795
+ ```ruby
796
+ # TEST_NOTIFICATION
685
797
  {
686
- :duration => INTEGER,
687
- :summary => STRING
798
+ :summary => STRING,
799
+ :check => CHECK_ID, # one (and only one) of :check or :tag must be provided
800
+ :tag => TAG_NAME # :tag will send test notifications for all checks that this tag is associated with
688
801
  }
689
802
  ```
690
803
 
691
- Returns true if creation succeeded or false if creation failed.
804
+ Returns false if creation failed, or the created object(s) if it succeeded.
692
805
 
693
- <a name="update_unscheduled_maintenances_checks">&nbsp;</a>
694
- ### update_unscheduled_maintenances_checks
806
+ [^](#contents_create_test_notifications)
695
807
 
696
- Finalises currently existing unscheduled maintenance periods for acknowledged checks. The periods end at the time provided in the `:end_time` parameter. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
808
+ ---
809
+
810
+ <a name="section_miscellaneous">&nbsp;</a>
811
+ ### Miscellaneous [^](#contents_section_miscellaneous)
812
+
813
+ <a name="get_states">&nbsp;</a>
814
+ ### states
815
+
816
+ Return data for one, some or all check states.
697
817
 
698
818
  ```ruby
699
- Flapjack::Diner.update_unscheduled_maintenances_checks(CHECK_ID(S), :end_time => DATETIME)
819
+ states = Flapjack::Diner.states(STATE_ID)
820
+ some_states = Flapjack::Diner.states(STATE_ID, STATE_ID, ...)
821
+ first_page_of_states = Flapjack::Diner.states
700
822
  ```
701
823
 
702
- Returns true if the finalisation succeeded or false if deletion failed.
824
+ [^](#contents_states)
703
825
 
704
- <a name="create_test_notifications_checks">&nbsp;</a>
705
- ### create_test_notifications_checks
826
+ <a name="get_metrics">&nbsp;</a>
827
+ ### metrics
706
828
 
707
- Instructs Flapjack to issue test notifications on the passed checks. These notifications will be sent to contacts configured to receive notifications for those checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
829
+ Return global metric data for the flapjack instance (i.e. all components backed by the shared data store).
708
830
 
709
831
  ```ruby
710
- Flapjack::Diner.create_test_notifications_checks(CHECK_ID(S), [TEST_NOTIFICATION, ...])
832
+ metrics = Flapjack::Diner.metrics
711
833
  ```
712
834
 
713
- ```
714
- TEST_NOTIFICATION
715
- {
716
- :summary => STRING
717
- }
835
+ [^](#contents_metrics)
836
+
837
+ <a name="get_statistics">&nbsp;</a>
838
+ ### statistics
839
+
840
+ Return data for one, some or all flapjack processor instances.
841
+
842
+ ```ruby
843
+ statistics = Flapjack::Diner.statistics(STATISTICS_ID)
844
+ some_statistics = Flapjack::Diner.statistics(STATISTICS_ID, STATISTICS_ID, ...)
845
+ first_page_of_statistics = Flapjack::Diner.statistics
718
846
  ```
719
847
 
720
- Returns true if creation succeeded or false if creation failed.
848
+ [^](#contents_statistics)
721
849
 
722
850
  ---
723
851
 
724
- <a name="status_report_entities">&nbsp;</a>
725
- ### status_report_entities
726
-
727
- Return a report on status data for checks in one, some or all entities.
852
+ <a name="common_options_get">&nbsp;</a>
853
+ ### Common options for all GET requests
854
+
855
+ | Option | Type | Description |
856
+ |--------------|-----------------------------|-------------|
857
+ | `:fields` | String or Array of Strings | Limit the fields of `:include`d records |
858
+ | `:filter` | Hash | Resources must match query terms |
859
+ | `:include` | String or Array of Strings | Full resources to return with the response |
860
+ | `:sort` | String or Array of Strings | How the resources should be sorted |
861
+ | `:page` | Integer, > 0 | Page number |
862
+ | `:per_page` | Integer, > 0 | Number of resources per page |
863
+
864
+
865
+ <a name="common_options_get_include">&nbsp;</a>
866
+ ### Associated data allowed for the include parameter
867
+
868
+ | Method | Association | Assoc. Type |
869
+ |-----------------------------|-----------------------------------|--------------------------------|
870
+ | `.checks` | 'alerting_media' | ['medium', ...] |
871
+ | `.checks` | 'contacts' | ['contact', ...] |
872
+ | `.checks` | 'current_scheduled_maintenances' | ['scheduled_maintenance', ...] |
873
+ | `.checks` | 'current_state' | 'state' |
874
+ | `.checks` | 'current_unscheduled_maintenance' | 'unscheduled_maintenance' |
875
+ | `.checks` | 'latest_notifications' | ['state', ...] |
876
+ | `.checks` | 'tags' | ['tag', ...] |
877
+ | `.contacts` | 'acceptors' | ['acceptor', ...] |
878
+ | `.contacts` | 'checks' | ['check', ...] |
879
+ | `.contacts` | 'media' | ['medium', ...] |
880
+ | `.contacts` | 'rejectors' | ['rejector', ...] |
881
+ | `.contacts` | 'tags' | ['tag', ...] |
882
+ | `.media` | 'acceptors' | ['acceptor', ...] |
883
+ | `.media` | 'alerting_checks' | ['check', ...] |
884
+ | `.media` | 'contact' | 'contact' |
885
+ | `.media` | 'rejectors' | ['rejector', ...] |
886
+ | `.acceptors` | 'contact' | 'contact' |
887
+ | `.acceptors` | 'media' | ['medium', ...] |
888
+ | `.acceptors` | 'tags' | ['tag', ...] |
889
+ | `.rejectors` | 'contact' | 'contact' |
890
+ | `.rejectors` | 'media' | ['medium', ...] |
891
+ | `.rejectors` | 'tags' | ['tag', ...] |
892
+ | `.scheduled_maintenances` | 'check' | 'check' |
893
+ | `.states` | 'check' | 'check' |
894
+ | `.tags` | 'acceptors' | ['acceptor', ...] |
895
+ | `.tags` | 'checks' | ['check', ...] |
896
+ | `.tags` | 'contacts' | ['contact', ...] |
897
+ | `.tags` | 'rejectors' | ['acceptor', ...] |
898
+ | `.unscheduled_maintenances` | 'check' | 'check' |
899
+
900
+ NB: these may be chained, as long as they follow the allowed paths above; e.g.
728
901
 
729
902
  ```ruby
730
- report = Flapjack::Diner.status_report_entities(ENTITY_ID)
731
- report_some = Flapjack::Diner.status_report_entities(ENTITY_ID1, ENTITY_ID2, ...)
732
- report_all = Flapjack::Diner.status_report_entities
903
+ Flapjack::Diner.contacts(CONTACT_ID, :include => 'media.alerting_checks')
733
904
  ```
734
905
 
735
- <a name="scheduled_maintenance_report_entities">&nbsp;</a>
736
- ### scheduled_maintenance_report_entities
906
+ The above will include both the contact's media *and* any alerting checks in extra data accessible via the `Flapjack::Diner.context` method; specifically, from the value held for`:included` key in the resulting Hash.
737
907
 
738
- Return a report on scheduled maintenance periods for checks in one, some or all entities.
908
+ ---
909
+
910
+ <a name="object_relationships_read">&nbsp;</a>
911
+ ### Retrieving object relationships
912
+
913
+ The following operations are supported: they will all return data in the format
739
914
 
740
915
  ```ruby
741
- report = Flapjack::Diner.scheduled_maintenance_report_entities(ENTITY_ID)
742
- report_some = Flapjack::Diner.scheduled_maintenance_report_entities(ENTITY_ID1, ENTITY_ID2, ...)
743
- report_all = Flapjack::Diner.scheduled_maintenance_report_entities
916
+ {:type => LINKED_TYPE, :id => UUID}
744
917
  ```
745
918
 
746
- <a name="unscheduled_maintenance_report_entities">&nbsp;</a>
747
- ### unscheduled_maintenance_report_entities
748
-
749
- Return a report on unscheduled maintenance periods for checks in one, some or all entities.
919
+ (for singular resources), or
750
920
 
751
921
  ```ruby
752
- report = Flapjack::Diner.unscheduled_maintenance_report_entities(ENTITY_ID)
753
- report_some = Flapjack::Diner.unscheduled_maintenance_report_entities(ENTITY_ID1, ENTITY_ID2, ...)
754
- report_all = Flapjack::Diner.unscheduled_maintenance_report_entities
922
+ [{:type => LINKED_TYPE, :id => UUID}, {:type => LINKED_TYPE, :id => UUID}, ...]
755
923
  ```
756
924
 
757
- <a name="downtime_report_entities">&nbsp;</a>
758
- ### downtime_report_entities
759
-
760
- Return a report on downtime data for checks in one, some or all entities.
925
+ for multiple resources.
761
926
 
762
- ```ruby
763
- report = Flapjack::Diner.downtime_report_entities(ENTITY_ID)
764
- report_some = Flapjack::Diner.downtime_report_entities(ENTITY_ID1, ENTITY_ID2, ...)
765
- report_all = Flapjack::Diner.downtime_report_entities
766
927
  ```
928
+ check_link_alerting_media(check_id, opts = {})
929
+ check_link_contacts(check_id, opts = {})
930
+ check_link_current_scheduled_maintenances(check_id, opts = {})
931
+ check_link_current_state(check_id, opts = {})
932
+ check_link_current_unscheduled_maintenance(check_id, opts = {})
933
+ check_link_latest_notifications(check_id, opts = {})
934
+ check_link_scheduled_maintenances(check_id, opts = {})
935
+ check_link_states(check_id, opts = {})
936
+ check_link_tags(check_id, opts = {})
937
+ check_link_unscheduled_maintenances(check_id, opts = {})
767
938
 
768
- <a name="outage_report_entities">&nbsp;</a>
769
- ### outage_report_entities
939
+ contact_link_acceptors(contact_id, opts = {})
940
+ contact_link_checks(contact_id, opts = {})
941
+ contact_link_media(contact_id, opts = {})
942
+ contact_link_rejectors(contact_id, opts = {})
943
+ contact_link_tags(contact_id, opts = {})
770
944
 
771
- Return a report on outage data for checks in one, some or all entities.
945
+ medium_link_acceptors(medium_id, opts = {})
946
+ medium_link_alerting_checks(medium_id, opts = {})
947
+ medium_link_contact(medium_id, opts = {})
948
+ medium_link_rejectors(medium_id, opts = {})
772
949
 
773
- ```ruby
774
- report = Flapjack::Diner.outage_report_entities(ENTITY_ID)
775
- report_some = Flapjack::Diner.outage_report_entities(ENTITY_ID1, ENTITY_ID2, ...)
776
- report_all = Flapjack::Diner.outage_report_entities
777
- ```
950
+ acceptor_link_contact(acceptor_id, opts = {})
951
+ acceptor_link_media(acceptor_id, opts = {})
952
+ acceptor_link_tags(acceptor_id, opts = {})
778
953
 
779
- <a name="status_report_checks">&nbsp;</a>
780
- ### status_report_checks
954
+ rejector_link_contact(rejector_id, opts = {})
955
+ rejector_link_media(rejector_id, opts = {})
956
+ rejector_link_tags(rejector_id, opts = {})
781
957
 
782
- Return a report on status data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
958
+ state_link_check(state_id, opts = {})
783
959
 
784
- ```ruby
785
- report = Flapjack::Diner.status_report_checks(CHECK_ID)
786
- report_some = Flapjack::Diner.status_report_checks(CHECK_ID1, CHECK_ID2, ...)
787
- report_all = Flapjack::Diner.status_report_checks
960
+ tag_link_acceptors(tag_name, opts = {})
961
+ tag_link_checks(tag_name, opts = {})
962
+ tag_link_contacts(tag_name, opts = {})
963
+ tag_link_rejectors(tag_name, opts = {})
964
+ tag_link_scheduled_maintenances(tag_name, opts = {})
965
+ tag_link_states(tag_name, opts = {})
966
+ tag_link_unscheduled_maintenances(tag_name, opts = {})
788
967
  ```
789
968
 
790
- <a name="scheduled_maintenance_report_checks">&nbsp;</a>
791
- ### scheduled_maintenance_report_checks
969
+ All returned results are paginated, and the [common options for GET requests](#common_options_get) apply here too.
792
970
 
793
- Return a report on scheduled maintenance periods for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
971
+ <a name="object_relationships_write">&nbsp;</a>
972
+ ### Manipulating object relationships
973
+
974
+ The following operations are supported; please note that some associations (e.g. associating an acceptor with a contact) must be made on object creation, via the secondary resource's create method, and cannot be altered later.
794
975
 
795
- ```ruby
796
- report = Flapjack::Diner.scheduled_maintenance_report_checks(CHECK_ID)
797
- report_some = Flapjack::Diner.scheduled_maintenance_report_checks(CHECK_ID1, CHECK_ID2, ...)
798
- report_all = Flapjack::Diner.scheduled_maintenance_report_checks
799
976
  ```
977
+ create_check_link_tags(check_id, *tags_names)
978
+ update_check_link_tags(check_id, *tags_names)
979
+ delete_check_link_tags(check_id, *tags_names)
800
980
 
801
- <a name="unscheduled_maintenance_report_checks">&nbsp;</a>
802
- ### unscheduled_maintenance_report_checks
981
+ create_contact_link_tags(contact_id, *tags_names)
982
+ update_contact_link_tags(contact_id, *tags_names)
983
+ delete_contact_link_tags(contact_id, *tags_names)
803
984
 
804
- Return a report on unscheduled maintenance periods for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
985
+ create_medium_link_acceptors(medium_id, *acceptors_ids)
986
+ update_medium_link_acceptors(medium_id, *acceptors_ids)
987
+ delete_medium_link_acceptors(medium_id, *acceptors_ids)
805
988
 
806
- ```ruby
807
- report = Flapjack::Diner.unscheduled_maintenance_report_checks(CHECK_ID)
808
- report_some = Flapjack::Diner.unscheduled_maintenance_report_checks(CHECK_ID1, CHECK_ID2, ...)
809
- report_all = Flapjack::Diner.unscheduled_maintenance_report_checks
810
- ```
989
+ create_medium_link_rejectors(medium_id, *rejectors_ids)
990
+ update_medium_link_rejectors(medium_id, *rejectors_ids)
991
+ delete_medium_link_rejectors(medium_id, *rejectors_ids)
811
992
 
812
- <a name="downtime_report_checks">&nbsp;</a>
813
- ### downtime_report_checks
993
+ create_acceptor_link_media(acceptor_id, *media_ids)
994
+ update_acceptor_link_media(acceptor_id, *media_ids)
995
+ delete_acceptor_link_media(acceptor_id, *media_ids)
814
996
 
815
- Return a report on downtime data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
997
+ create_acceptor_link_tags(acceptor_id, *tags_names)
998
+ update_acceptor_link_tags(acceptor_id, *tags_names)
999
+ delete_acceptor_link_tags(acceptor_id, *tags_names)
816
1000
 
817
- ```ruby
818
- report = Flapjack::Diner.downtime_report_checks(CHECK_ID)
819
- report_some = Flapjack::Diner.downtime_report_checks(CHECK_ID1, CHECK_ID2, ...)
820
- report_all = Flapjack::Diner.downtime_report_checks
821
- ```
1001
+ create_rejector_link_media(rejector_id, *media_ids)
1002
+ update_rejector_link_media(rejector_id, *media_ids)
1003
+ delete_rejector_link_media(rejector_id, *media_ids)
822
1004
 
823
- <a name="outage_report_checks">&nbsp;</a>
824
- ### outage_report_checks
1005
+ create_rejector_link_tags(rejector_id, *tags_names)
1006
+ update_rejector_link_tags(rejector_id, *tags_names)
1007
+ delete_rejector_link_tags(rejector_id, *tags_names)
825
1008
 
826
- Return a report on outage data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
1009
+ create_tag_link_checks(tag_name, *checks_ids)
1010
+ update_tag_link_checks(tag_name, *checks_ids)
1011
+ delete_tag_link_checks(tag_name, *checks_ids)
827
1012
 
828
- ```ruby
829
- report = Flapjack::Diner.outage_report_checks(CHECK_ID)
830
- report_some = Flapjack::Diner.outage_report_checks(CHECK_ID1, CHECK_ID2, ...)
831
- report_all = Flapjack::Diner.outage_report_checks
1013
+ create_tag_link_contacts(tag_name, *contacts_ids)
1014
+ update_tag_link_contacts(tag_name, *contacts_ids)
1015
+ delete_tag_link_contacts(tag_name, *contacts_ids)
1016
+
1017
+ create_tag_link_acceptors(tag_name, *acceptors_ids)
1018
+ update_tag_link_acceptors(tag_name, *acceptors_ids)
1019
+ delete_tag_link_acceptors(tag_name, *acceptors_ids)
1020
+
1021
+ create_tag_link_rejectors(tag_name, *rejectors_ids)
1022
+ update_tag_link_rejectors(tag_name, *rejectors_ids)
1023
+ delete_tag_link_rejectors(tag_name, *rejectors_ids)
832
1024
  ```
833
1025
 
1026
+ <a name="object_relationships_write_create">&nbsp;</a>
1027
+ #### `create_{resource}_link_{related}`
1028
+
1029
+ Creates new links between the `resource` represented by the first argument and the `related` resources represented by the rest of the arguments. At least one `related` resource identifier must be provided. If the `related` resource is already linked, it is skipped.
1030
+
1031
+ <a name="object_relationships_write_update">&nbsp;</a>
1032
+ #### `update_{resource}_link_{related}`
1033
+
1034
+ Replace all current links between the `resource` represented by the first argument with the `related` resources represented by the rest of the arguments. If there are no further arguments, removes all current links of that type for the `resource`, otherwise removes any not present in the passed `related` resources and adds any that are passed but not already present.
1035
+
1036
+ <a name="object_relationships_write_delete">&nbsp;</a>
1037
+ #### `delete_{resource}_link_{related}`
1038
+
1039
+ Remove the link between the `resource` represented by the first argument, and the `related` resources represented by the rest of the arguments. If there is no link for a related resource, deletion is skipped for that linkage.
1040
+
834
1041
  ---
835
1042
 
836
1043
  ## Contributing
@@ -839,4 +1046,4 @@ report_all = Flapjack::Diner.outage_report_checks
839
1046
  2. Create your feature branch (`git checkout -b my-new-feature`)
840
1047
  3. Commit your changes (`git commit -am 'Added some feature'`)
841
1048
  4. Push to the branch (`git push origin my-new-feature`)
842
- 5. Create new Pull Request
1049
+ 5. Create a new Pull Request