statusio 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/README.md +2 -15
- data/lib/statusio.rb +524 -573
- data/lib/statusio/rb/version.rb +1 -1
- data/statusio-rb.gemspec +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792ed4b80a0dc438bc682280f33190ddc2d2ec7a
|
4
|
+
data.tar.gz: 68a6292fd3798cfe36b74dc42a7e920b0d4860b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c7c727a9bc1732ee0a2fe58046d8a624596e027fbb0d1632ca97aa0d991797100c5fbfaab3ccdf0bfdb70a85ea5d9f32d913756e3590e297d6de297e071723
|
7
|
+
data.tar.gz: 4d6bc66d2af34f2553822a287f6fa7dfff463f9f5905c9ea3d5de1b96f15e0d805ec727a82dfc191c62d8a855c7d9810c0449f1c0bacb172a66159ad4e6f66da
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -25,27 +25,14 @@ Or install it yourself as:
|
|
25
25
|
## Usage
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
# Sign up an account and get your api_id
|
28
|
+
# Sign up for an account and get your api_id and api_key from the API tab
|
29
29
|
statusioclient = StatusioClient.new(api_key, api_id)
|
30
30
|
```
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
To work with maintenance methods
|
35
|
-
|
36
|
-
To work with subscriber methods
|
37
|
-
|
38
|
-
To work with metric methods
|
39
|
-
|
40
|
-
Please refer to Status.io API v2 for more details.
|
32
|
+
View the last release API documentation at: http://developers.status.io/
|
41
33
|
|
42
34
|
## Development
|
43
35
|
|
44
36
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
37
|
|
46
38
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
-
|
48
|
-
## Contributing
|
49
|
-
|
50
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/statusio-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
51
|
-
|
data/lib/statusio.rb
CHANGED
@@ -5,577 +5,528 @@ require 'uri'
|
|
5
5
|
require 'json'
|
6
6
|
|
7
7
|
class StatusioClient
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
def subscriber_add(statuspage_id, method, address, silent = 1, granular = '')
|
533
|
-
data = {}
|
534
|
-
data['statuspage_id'] = statuspage_id
|
535
|
-
data['method'] = method
|
536
|
-
data['address'] = address
|
537
|
-
data['silent'] = silent
|
538
|
-
data['granular'] = granular
|
539
|
-
|
540
|
-
response = RestClient.post(@url + 'subscriber/add', data, @headers)
|
541
|
-
if (response.code == 200)
|
542
|
-
return JSON.parse(response.body)
|
543
|
-
end
|
544
|
-
end
|
545
|
-
|
546
|
-
##
|
547
|
-
# Update existing subscriber
|
548
|
-
#
|
549
|
-
# @param statuspage_id(string) Status page ID
|
550
|
-
# @param subscriber_id(string) Subscriber ID
|
551
|
-
# @param address(string) Subscriber address (SMS number must include country code ie. +1)
|
552
|
-
# @param granular(string) List of component_container combos
|
553
|
-
# @return object
|
554
|
-
|
555
|
-
def subscriber_update(statuspage_id, subscriber_id, address, granular = '')
|
556
|
-
data = {}
|
557
|
-
data['statuspage_id'] = statuspage_id
|
558
|
-
data['subscriber_id'] = subscriber_id
|
559
|
-
data['address'] = address
|
560
|
-
data['granular'] = granular
|
561
|
-
|
562
|
-
response = RestClient.patch(@url + 'subscriber/update', data, @headers)
|
563
|
-
if (response.code == 200)
|
564
|
-
return JSON.parse(response.body)
|
565
|
-
end
|
566
|
-
end
|
567
|
-
|
568
|
-
##
|
569
|
-
# Delete subscriber
|
570
|
-
#
|
571
|
-
# @param statuspage_id(string) Status page ID
|
572
|
-
# @param subscriber_id(string) Subscriber ID
|
573
|
-
# @return object
|
574
|
-
|
575
|
-
def subscriber_remove(statuspage_id, subscriber_id)
|
576
|
-
response = RestClient.delete(@url + 'subscriber/remove/' + statuspage_id + '/' + subscriber_id, @headers)
|
577
|
-
if (response.code == 200)
|
578
|
-
return JSON.parse(response.body)
|
579
|
-
end
|
580
|
-
end
|
8
|
+
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
STATUS_OPERATIONAL = 100
|
12
|
+
STATUS_DEGRADED_PERFORMANCE = 300
|
13
|
+
STATUS_PARTIAL_SERVICE_DISRUPTION = 400
|
14
|
+
STATUS_SERVICE_DISRUPTION = 500
|
15
|
+
STATUS_SECURITY_EVENT = 600
|
16
|
+
|
17
|
+
STATE_INVESTIGATING = 100
|
18
|
+
STATE_IDENTIFIED = 200
|
19
|
+
STATE_MONITORING = 300
|
20
|
+
|
21
|
+
NOTIFY_EMAIL = 1
|
22
|
+
NOTIFY_SMS = 2
|
23
|
+
NOTIFY_WEBHOOK = 4
|
24
|
+
NOTIFY_SOCIAL = 8
|
25
|
+
NOTIFY_IRC = 16
|
26
|
+
NOTIFY_HIPCHAT = 32
|
27
|
+
NOTIFY_SLACK = 64
|
28
|
+
|
29
|
+
def initialize(api_key, api_id)
|
30
|
+
@api_key = api_key
|
31
|
+
@api_id = api_id
|
32
|
+
|
33
|
+
@url = 'https://api.status.io/v2/'
|
34
|
+
|
35
|
+
@headers = {
|
36
|
+
'x-api-id' => @api_id,
|
37
|
+
'x-api-key' => @api_key,
|
38
|
+
'Content-Type' => 'application/json',
|
39
|
+
'Accept' => 'application/json'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def get_notify(notifications)
|
46
|
+
notify = {
|
47
|
+
'notify_email' => '0',
|
48
|
+
'notify_sms' => '0',
|
49
|
+
'notify_webhook' => '0',
|
50
|
+
'social' => '0',
|
51
|
+
'irc' => '0',
|
52
|
+
'hipchat' => '0',
|
53
|
+
'slack' => '0'
|
54
|
+
}
|
55
|
+
|
56
|
+
if notifications & NOTIFY_EMAIL == NOTIFY_EMAIL
|
57
|
+
notify['notify_email'] = '1'
|
58
|
+
end
|
59
|
+
|
60
|
+
if notifications & NOTIFY_SMS == NOTIFY_SMS
|
61
|
+
notify['notify_sms'] = '1'
|
62
|
+
end
|
63
|
+
|
64
|
+
if notifications & NOTIFY_WEBHOOK == NOTIFY_WEBHOOK
|
65
|
+
notify['notify_webhook'] = '1'
|
66
|
+
end
|
67
|
+
|
68
|
+
if notifications & NOTIFY_SOCIAL == NOTIFY_SOCIAL
|
69
|
+
notify['social'] = '1'
|
70
|
+
end
|
71
|
+
|
72
|
+
if notifications & NOTIFY_IRC == NOTIFY_IRC
|
73
|
+
notify['irc'] = '1'
|
74
|
+
end
|
75
|
+
|
76
|
+
if notifications & NOTIFY_HIPCHAT == NOTIFY_HIPCHAT
|
77
|
+
notify['hipchat'] = '1'
|
78
|
+
end
|
79
|
+
|
80
|
+
if notifications & NOTIFY_SLACK == NOTIFY_SLACK
|
81
|
+
notify['slack'] = '1'
|
82
|
+
end
|
83
|
+
|
84
|
+
return notify
|
85
|
+
end
|
86
|
+
|
87
|
+
def request(params)
|
88
|
+
response = RestClient::Request.execute(params.merge(:headers => @headers))
|
89
|
+
body = JSON.parse(response.body)
|
90
|
+
|
91
|
+
if body['status'] && body['status']['error'] == 'yes'
|
92
|
+
raise StatusioClient::Error, body['status']['message']
|
93
|
+
elsif response.code == 200
|
94
|
+
return body
|
95
|
+
else
|
96
|
+
raise Net::HTTPError, response.inspect
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
public
|
101
|
+
|
102
|
+
##
|
103
|
+
# List all components.
|
104
|
+
#
|
105
|
+
# @param statuspage_id(string) Status page ID
|
106
|
+
# @return object
|
107
|
+
|
108
|
+
def component_list(statuspage_id)
|
109
|
+
request :method => :get,
|
110
|
+
:url => @url + 'component/list/' + statuspage_id
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Update the status of a component on the fly without creating an incident or maintenance.
|
115
|
+
#
|
116
|
+
# @param statuspage_id(string) string Status page ID
|
117
|
+
# @param components(array) ID of each affected component
|
118
|
+
# @param containers(array) ID of each affected container
|
119
|
+
# @param details(string) A brief message describing this update
|
120
|
+
# @param current_status(int) Any numeric status code.
|
121
|
+
# @return object
|
122
|
+
|
123
|
+
def component_status_update(statuspage_id, components, containers, details, current_status)
|
124
|
+
request :method => :post,
|
125
|
+
:url => @url + 'component/status/update',
|
126
|
+
:payload => {
|
127
|
+
'statuspage_id' => statuspage_id,
|
128
|
+
'components' => components,
|
129
|
+
'containers' => containers,
|
130
|
+
'details' => details,
|
131
|
+
'current_status' => current_status
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
# INCIDENT
|
136
|
+
|
137
|
+
##
|
138
|
+
# List all active and resolved incidents.
|
139
|
+
#
|
140
|
+
# @param statuspage_id(string) Status page ID
|
141
|
+
# @return object
|
142
|
+
|
143
|
+
def incident_list(statuspage_id)
|
144
|
+
request :method => :get,
|
145
|
+
:url => @url + 'incident/list/' + statuspage_id
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
##
|
150
|
+
# Display incident message.
|
151
|
+
#
|
152
|
+
# @param statuspage_id(string) Status page ID
|
153
|
+
# @param message_id(string) Message ID
|
154
|
+
# @return object
|
155
|
+
|
156
|
+
def incident_message(statuspage_id, message_id)
|
157
|
+
request :method => :get,
|
158
|
+
:url => @url + 'incident/message/' + statuspage_id + '/' + message_id
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Create a new incident.
|
163
|
+
#
|
164
|
+
# @param statuspage_id(string) Status page ID
|
165
|
+
# @param incident_name(string) A descriptive title for the incident
|
166
|
+
# @param incident_details(string) Message describing this incident
|
167
|
+
# @param components(array) ID of each affected component
|
168
|
+
# @param containers(array) ID of each affected container
|
169
|
+
# @param current_status(int) The status of the components and containers affected by this incident (StatusioClient::STATUS_#).
|
170
|
+
# @param current_state(int) The state of this incident (StatusioClient::STATE_#).
|
171
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
172
|
+
# @param all_infrastructure_affected(int) Affect all components and containers (default = 0)
|
173
|
+
# @return object
|
174
|
+
|
175
|
+
def incident_create(statuspage_id, incident_name, incident_details, components, containers, current_status, current_state, notifications = 0, all_infrastructure_affected = 0)
|
176
|
+
data = get_notify(notifications)
|
177
|
+
data['statuspage_id'] = statuspage_id
|
178
|
+
data['incident_name'] = incident_name
|
179
|
+
data['incident_details'] = incident_details
|
180
|
+
data['components'] = components
|
181
|
+
data['containers'] = containers
|
182
|
+
data['current_status'] = current_status
|
183
|
+
data['current_state'] = current_state
|
184
|
+
data['all_infrastructure_affected'] = all_infrastructure_affected
|
185
|
+
|
186
|
+
request :method => :post,
|
187
|
+
:url => @url + 'incident/create',
|
188
|
+
:payload => data
|
189
|
+
end
|
190
|
+
|
191
|
+
##
|
192
|
+
# Update an existing incident
|
193
|
+
#
|
194
|
+
# @param statuspage_id(string) Status page ID
|
195
|
+
# @param incident_id(string) Incident ID
|
196
|
+
# @param incident_details(string) Message describing this incident
|
197
|
+
# @param current_status(int) The status of the components and containers affected by this incident (StatusioClient::STATUS_#).
|
198
|
+
# @param current_state(int) The state of this incident (StatusioClient::STATE_#).
|
199
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
200
|
+
# @return object
|
201
|
+
|
202
|
+
def incident_update(statuspage_id, incident_id, incident_details, current_status, current_state, notifications = 0)
|
203
|
+
data = get_notify(notifications)
|
204
|
+
data['statuspage_id'] = statuspage_id
|
205
|
+
data['incident_id'] = incident_id
|
206
|
+
data['incident_details'] = incident_details
|
207
|
+
data['current_status'] = current_status
|
208
|
+
data['current_state'] = current_state
|
209
|
+
|
210
|
+
request :method => :post,
|
211
|
+
:url => @url + 'incident/update',
|
212
|
+
:payload => data
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# Resolve an existing incident. The incident will be shown in the history instead of on the main page.
|
217
|
+
#
|
218
|
+
# @param statuspage_id(string) Status page ID
|
219
|
+
# @param incident_id(string) Incident ID
|
220
|
+
# @param incident_details(string) Message describing this incident
|
221
|
+
# @param current_status(int) The status of the components and containers affected by this incident (StatusioClient::STATUS_#).
|
222
|
+
# @param current_state(int) The state of this incident (StatusioClient::STATE_#).
|
223
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
224
|
+
# @return object
|
225
|
+
|
226
|
+
def incident_resolve(statuspage_id, incident_id, incident_details, current_status, current_state, notifications = 0)
|
227
|
+
data = get_notify(notifications)
|
228
|
+
data['statuspage_id'] = statuspage_id
|
229
|
+
data['incident_id'] = incident_id
|
230
|
+
data['incident_details'] = incident_details
|
231
|
+
data['current_status'] = current_status
|
232
|
+
data['current_state'] =current_state
|
233
|
+
|
234
|
+
request :method => :post,
|
235
|
+
:url => @url + 'incident/resolve',
|
236
|
+
:payload => data
|
237
|
+
end
|
238
|
+
|
239
|
+
##
|
240
|
+
# Delete an existing incident. The incident will be deleted forever and cannot be recovered.
|
241
|
+
#
|
242
|
+
# @param statuspage_id(string) Status page ID
|
243
|
+
# @param incident_id(string) Incident ID
|
244
|
+
# @return object
|
245
|
+
|
246
|
+
def incident_delete(statuspage_id, incident_id)
|
247
|
+
data = {}
|
248
|
+
data['statuspage_id'] = statuspage_id
|
249
|
+
data['incident_id'] = incident_id
|
250
|
+
|
251
|
+
request :method => :post,
|
252
|
+
:url => @url + 'incident/delete',
|
253
|
+
:payload => data
|
254
|
+
end
|
255
|
+
|
256
|
+
# MAINTENANCE
|
257
|
+
|
258
|
+
##
|
259
|
+
# List all active, resolved and upcoming maintenances
|
260
|
+
#
|
261
|
+
# @param statuspage_id(string) Status page ID
|
262
|
+
# @return object
|
263
|
+
#/
|
264
|
+
|
265
|
+
def maintenance_list(statuspage_id)
|
266
|
+
request :method => :get,
|
267
|
+
:url => @url + 'maintenance/list/' + statuspage_id
|
268
|
+
end
|
269
|
+
|
270
|
+
##
|
271
|
+
# Display maintenance message
|
272
|
+
#
|
273
|
+
# @param statuspage_id(string) Status page ID
|
274
|
+
# @param message_id(string) Message ID
|
275
|
+
# @return object
|
276
|
+
|
277
|
+
def maintenance_message(statuspage_id, message_id)
|
278
|
+
request :method => :get,
|
279
|
+
:url => @url + 'maintenance/message/' + statuspage_id + '/' + message_id
|
280
|
+
end
|
281
|
+
|
282
|
+
##
|
283
|
+
# Schedule a new maintenance
|
284
|
+
#
|
285
|
+
# @param statuspage_id(string) Status page ID
|
286
|
+
# @param maintenance_name(string) A descriptive title for this maintenance
|
287
|
+
# @param maintenance_details(string) Message describing this maintenance
|
288
|
+
# @param components(array) ID of each affected component
|
289
|
+
# @param containers(array) ID of each affected container
|
290
|
+
# @param date_planned_start(string) Date maintenance is expected to start
|
291
|
+
# @param time_planned_start(string) Time maintenance is expected to start
|
292
|
+
# @param date_planned_end(string) Date maintenance is expected to end
|
293
|
+
# @param time_planned_end(string) Time maintenance is expected to end
|
294
|
+
# @param automation(int) Automatically start and end the maintenance (default = 0)
|
295
|
+
# @param all_infrastructure_affected(int) Affect all components and containers (default = 0)
|
296
|
+
# @param maintenance_notify_now(int) Notify subscribers now (1 = Send notification)
|
297
|
+
# @param maintenance_notify_1_hr(int) Notify subscribers 1 hour before scheduled maintenance start time (1 = Send notification)
|
298
|
+
# @param maintenance_notify_24_hr(int) Notify subscribers 24 hours before scheduled maintenance start time (1 = Send notification)
|
299
|
+
# @param maintenance_notify_72_hr(int) Notify subscribers 72 hours before scheduled maintenance start time (1 = Send notification)
|
300
|
+
# @return object
|
301
|
+
|
302
|
+
def maintenance_schedule(statuspage_id, maintenance_name, maintenance_details, components, containers,
|
303
|
+
date_planned_start, time_planned_start, date_planned_end, time_planned_end,
|
304
|
+
automation = 0, all_infrastructure_affected = 0,
|
305
|
+
maintenance_notify_now = 0, maintenance_notify_1_hr = 0,
|
306
|
+
maintenance_notify_24_hr = 0, maintenance_notify_72_hr = 0)
|
307
|
+
data = {}
|
308
|
+
data['statuspage_id'] = statuspage_id
|
309
|
+
data['maintenance_name'] = maintenance_name
|
310
|
+
data['maintenance_details'] = maintenance_details
|
311
|
+
data['components'] = components
|
312
|
+
data['containers'] = containers
|
313
|
+
data['all_infrastructure_affected'] = all_infrastructure_affected
|
314
|
+
data['date_planned_start'] = date_planned_start
|
315
|
+
data['time_planned_start'] = time_planned_start
|
316
|
+
data['date_planned_end'] = date_planned_end
|
317
|
+
data['time_planned_end'] = time_planned_end
|
318
|
+
data['automation'] = automation
|
319
|
+
data['maintenance_notify_now'] = maintenance_notify_now
|
320
|
+
data['maintenance_notify_1_hr'] = maintenance_notify_1_hr
|
321
|
+
data['maintenance_notify_24_hr'] = maintenance_notify_24_hr
|
322
|
+
data['maintenance_notify_72_hr'] = maintenance_notify_72_hr
|
323
|
+
|
324
|
+
request :method => :post,
|
325
|
+
:url => @url + 'maintenance/schedule',
|
326
|
+
:payload => data
|
327
|
+
end
|
328
|
+
|
329
|
+
##
|
330
|
+
# Begin a scheduled maintenance now
|
331
|
+
#
|
332
|
+
# @param statuspage_id(string) Status page ID
|
333
|
+
# @param maintenance_id(string) Maintenance ID
|
334
|
+
# @param maintenance_details(string) Message describing this maintenance update
|
335
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
336
|
+
# @return object
|
337
|
+
|
338
|
+
def maintenance_start(statuspage_id, maintenance_id, maintenance_details, notifications = 0)
|
339
|
+
data = get_notify(notifications)
|
340
|
+
data['statuspage_id'] = statuspage_id
|
341
|
+
data['maintenance_id'] = maintenance_id
|
342
|
+
data['maintenance_details'] = maintenance_details
|
343
|
+
|
344
|
+
request :method => :post,
|
345
|
+
:url => @url + 'maintenance/start',
|
346
|
+
:payload => data
|
347
|
+
end
|
348
|
+
|
349
|
+
##
|
350
|
+
# Update an active maintenance
|
351
|
+
#
|
352
|
+
# @param statuspage_id(string) Status page ID
|
353
|
+
# @param maintenance_id(string) Maintenance ID
|
354
|
+
# @param maintenance_details(string) Message describing this maintenance
|
355
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
356
|
+
# @return object
|
357
|
+
|
358
|
+
def maintenance_update(statuspage_id, maintenance_id, maintenance_details, notifications = 0)
|
359
|
+
data = get_notify(notifications)
|
360
|
+
data['statuspage_id'] = statuspage_id
|
361
|
+
data['maintenance_id'] = maintenance_id
|
362
|
+
data['maintenance_details'] = maintenance_details
|
363
|
+
|
364
|
+
request :method => :post,
|
365
|
+
:url => @url + 'maintenance/update',
|
366
|
+
:payload => data
|
367
|
+
end
|
368
|
+
|
369
|
+
##
|
370
|
+
# Close an active maintenance. The maintenance will be moved to the history.
|
371
|
+
#
|
372
|
+
# @param statuspage_id(string) Status page ID
|
373
|
+
# @param maintenance_id(string) Maintenance ID
|
374
|
+
# @param maintenance_details(string) Message describing this maintenance
|
375
|
+
# @param notifications(int) Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).
|
376
|
+
# @return object
|
377
|
+
|
378
|
+
def maintenance_finish(statuspage_id, maintenance_id, maintenance_details, notifications = 0)
|
379
|
+
data = get_notify(notifications)
|
380
|
+
data['statuspage_id'] = statuspage_id
|
381
|
+
data['maintenance_id'] = maintenance_id
|
382
|
+
data['maintenance_details'] = maintenance_details
|
383
|
+
|
384
|
+
request :method => :post,
|
385
|
+
:url => @url + 'maintenance/finish',
|
386
|
+
:payload => data
|
387
|
+
end
|
388
|
+
|
389
|
+
##
|
390
|
+
# Delete an existing maintenance. The maintenance will be deleted forever and cannot be recovered.
|
391
|
+
#
|
392
|
+
# @param statuspage_id(string) Status page ID
|
393
|
+
# @param maintenance_id(string) Maintenance ID
|
394
|
+
# @return object
|
395
|
+
#/
|
396
|
+
def maintenance_delete(statuspage_id, maintenance_id)
|
397
|
+
data = {}
|
398
|
+
data['statuspage_id'] = statuspage_id
|
399
|
+
data['maintenance_id'] = maintenance_id
|
400
|
+
|
401
|
+
request :method => :post,
|
402
|
+
:url => @url + 'maintenance/delete',
|
403
|
+
:payload => data
|
404
|
+
end
|
405
|
+
|
406
|
+
# METRIC
|
407
|
+
|
408
|
+
##
|
409
|
+
# Update custom metric data
|
410
|
+
#
|
411
|
+
# @param statuspage_id(string) Status page ID
|
412
|
+
# @param metric_id(string) Metric ID
|
413
|
+
# @param day_avg(float) Average value for past 24 hours
|
414
|
+
# @param day_start(int) UNIX timestamp for start of metric timeframe
|
415
|
+
# @param day_dates(array) An array of timestamps for the past 24 hours (2014-03-28T05:43:00+00:00)
|
416
|
+
# @param day_values(array) An array of values matching the timestamps (Must be 24 values)
|
417
|
+
# @param week_avg(float) Average value for past 7 days
|
418
|
+
# @param week_start(int) UNIX timestamp for start of metric timeframe
|
419
|
+
# @param week_dates(array) An array of timestamps for the past 7 days (2014-03-28T05:43:00+00:00)
|
420
|
+
# @param week_values(array) An array of values matching the timestamps (Must be 7 values)
|
421
|
+
# @param month_avg(float) Average value for past 30 days
|
422
|
+
# @param month_start(int) UNIX timestamp for start of metric timeframe
|
423
|
+
# @param month_dates(array) An array of timestamps for the past 30 days (2014-03-28T05:43:00+00:00)
|
424
|
+
# @param month_values(array) An array of values matching the timestamps (Must be 30 values)
|
425
|
+
# @return object
|
426
|
+
|
427
|
+
def metric_update(statuspage_id, metric_id, day_avg, day_start, day_dates, day_values,
|
428
|
+
week_avg, week_start, week_dates, week_values,
|
429
|
+
month_avg, month_start, month_dates, month_values)
|
430
|
+
data = {}
|
431
|
+
data['statuspage_id'] = statuspage_id
|
432
|
+
data['metric_id'] = metric_id
|
433
|
+
data['day_avg'] = day_avg
|
434
|
+
data['day_start'] = day_start
|
435
|
+
data['day_dates'] = day_dates
|
436
|
+
data['day_values'] = day_values
|
437
|
+
data['week_avg'] = week_avg
|
438
|
+
data['week_start'] = week_start
|
439
|
+
data['week_dates'] = week_dates
|
440
|
+
data['week_values'] =week_values
|
441
|
+
data['month_avg'] = month_avg
|
442
|
+
data['month_start'] = month_start
|
443
|
+
data['month_dates'] = month_dates
|
444
|
+
data['month_values'] = month_values
|
445
|
+
|
446
|
+
request :method => :post,
|
447
|
+
:url => @url + 'metric/update',
|
448
|
+
:payload => data
|
449
|
+
end
|
450
|
+
|
451
|
+
# STATUS
|
452
|
+
|
453
|
+
##
|
454
|
+
# Show the summary status for all components and containers
|
455
|
+
#
|
456
|
+
# @param statuspage_id(string) Status page ID
|
457
|
+
# @return object
|
458
|
+
|
459
|
+
def status_summary(statuspage_id)
|
460
|
+
request :method => :get,
|
461
|
+
:url => @url + 'status/summary/' + statuspage_id
|
462
|
+
end
|
463
|
+
|
464
|
+
# SUBSCRIBER
|
465
|
+
|
466
|
+
##
|
467
|
+
# List all subscribers
|
468
|
+
#
|
469
|
+
# @param statuspage_id(string) Status page ID
|
470
|
+
# @return object
|
471
|
+
|
472
|
+
def subscriber_list(statuspage_id)
|
473
|
+
request :method => :get,
|
474
|
+
:url => @url + 'subscriber/list/' + statuspage_id
|
475
|
+
end
|
476
|
+
|
477
|
+
##
|
478
|
+
# Add a new subscriber
|
479
|
+
#
|
480
|
+
# @param statuspage_id(string) Status page ID
|
481
|
+
# @param method(string) Communication method of subscriber. Valid methods are `email`, `sms` or `webhook`
|
482
|
+
# @param address(string) Subscriber address (SMS number must include country code ie. +1)
|
483
|
+
# @param silent(int) Supress the welcome message (1 = Do not send notification)
|
484
|
+
# @param granular(string) List of component_container combos
|
485
|
+
# @return object
|
486
|
+
|
487
|
+
def subscriber_add(statuspage_id, method, address, silent = 1, granular = '')
|
488
|
+
data = {}
|
489
|
+
data['statuspage_id'] = statuspage_id
|
490
|
+
data['method'] = method
|
491
|
+
data['address'] = address
|
492
|
+
data['silent'] = silent
|
493
|
+
data['granular'] = granular
|
494
|
+
|
495
|
+
request :method => :post,
|
496
|
+
:url => @url + 'subscriber/add',
|
497
|
+
:payload => data
|
498
|
+
end
|
499
|
+
|
500
|
+
##
|
501
|
+
# Update existing subscriber
|
502
|
+
#
|
503
|
+
# @param statuspage_id(string) Status page ID
|
504
|
+
# @param subscriber_id(string) Subscriber ID
|
505
|
+
# @param address(string) Subscriber address (SMS number must include country code ie. +1)
|
506
|
+
# @param granular(string) List of component_container combos
|
507
|
+
# @return object
|
508
|
+
|
509
|
+
def subscriber_update(statuspage_id, subscriber_id, address, granular = '')
|
510
|
+
data = {}
|
511
|
+
data['statuspage_id'] = statuspage_id
|
512
|
+
data['subscriber_id'] = subscriber_id
|
513
|
+
data['address'] = address
|
514
|
+
data['granular'] = granular
|
515
|
+
|
516
|
+
request :method => :patch,
|
517
|
+
:url => @url + 'subscriber/update',
|
518
|
+
:payload => data
|
519
|
+
end
|
520
|
+
|
521
|
+
##
|
522
|
+
# Delete subscriber
|
523
|
+
#
|
524
|
+
# @param statuspage_id(string) Status page ID
|
525
|
+
# @param subscriber_id(string) Subscriber ID
|
526
|
+
# @return object
|
527
|
+
|
528
|
+
def subscriber_remove(statuspage_id, subscriber_id)
|
529
|
+
request :method => :delete,
|
530
|
+
:url => @url + 'subscriber/remove/' + statuspage_id + '/' + subscriber_id
|
531
|
+
end
|
581
532
|
end
|
data/lib/statusio/rb/version.rb
CHANGED
data/statusio-rb.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statusio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Status.io
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Ruby library wrapper for Status.io - A Complete Status Platform - Status
|
14
28
|
pages, incident tracking, subscriber notifications and more
|
15
29
|
email:
|
@@ -48,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
62
|
version: '0'
|
49
63
|
requirements: []
|
50
64
|
rubyforge_project:
|
51
|
-
rubygems_version: 2.0.14
|
65
|
+
rubygems_version: 2.0.14.1
|
52
66
|
signing_key:
|
53
67
|
specification_version: 4
|
54
68
|
summary: Ruby library wrapper for Status.io
|