Class: StatusioClient

Inherits:
Object
  • Object
show all
Defined in:
lib/statusio.rb,
lib/statusio/rb/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

STATUS_OPERATIONAL =
100
STATUS_DEGRADED_PERFORMANCE =
300
STATUS_PARTIAL_SERVICE_DISRUPTION =
400
STATUS_SERVICE_DISRUPTION =
500
STATUS_SECURITY_EVENT =
600
STATE_INVESTIGATING =
100
STATE_IDENTIFIED =
200
STATE_MONITORING =
300
NOTIFY_EMAIL =
1
NOTIFY_SMS =
2
NOTIFY_WEBHOOK =
4
NOTIFY_SOCIAL =
8
NOTIFY_IRC =
16
NOTIFY_HIPCHAT =
32
NOTIFY_SLACK =
64
VERSION =
'0.2.8'

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_id) ⇒ StatusioClient

Returns a new instance of StatusioClient.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/statusio.rb', line 29

def initialize(api_key, api_id)
  @api_key = api_key
  @api_id = api_id

  @url = 'https://api.status.io/v2/'

  @headers = {
    'x-api-id' => @api_id,
    'x-api-key' => @api_key,
    'Content-Type' => 'application/json',
    'Accept' => 'application/json'
  }
end

Instance Method Details

#component_list(statuspage_id) ⇒ Object

List all components.

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



108
109
110
111
# File 'lib/statusio.rb', line 108

def component_list(statuspage_id)
  request :method  => :get,
          :url     => @url + 'component/list/' + statuspage_id
end

#component_status_update(statuspage_id, component, container, details, current_status) ⇒ Object

Update the status of a component on the fly without creating an incident or maintenance.

Parameters:

  • statuspage_id (string)

    string Status page ID

  • component (string)

    ID of affected component

  • container (string)

    ID of affected container

  • details (string)

    A brief message describing this update

  • current_status (int)

    Any numeric status code.

Returns:

  • object



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/statusio.rb', line 123

def component_status_update(statuspage_id, component, container, details, current_status)
  request :method  => :post,
          :url     => @url + 'component/status/update',
          :payload => {
            'statuspage_id'  => statuspage_id,
            'component'     => component,
            'container'     => container,
            'details'        => details,
            'current_status' => current_status
          }
end

#incident_create(statuspage_id, incident_name, incident_details, infrastructure_affected, current_status, current_state, message_subject, notifications = 0, all_infrastructure_affected = "0") ⇒ Object

Create a new incident.

Parameters:

  • statuspage_id (string)

    Status page ID

  • incident_name (string)

    A descriptive title for the incident

  • incident_details (string)

    Message describing this incident

  • infrastructure_affected (array)

    ID of each affected component and container combo

  • current_status (int)

    The status of the components and containers affected by this incident (StatusioClient::STATUS_#).

  • current_state (int)

    The state of this incident (StatusioClient::STATE_#).

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

  • all_infrastructure_affected (string) (defaults to: "0")

    Affect all components and containers (default = 0)

Returns:

  • object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/statusio.rb', line 197

def incident_create(statuspage_id, incident_name, incident_details, infrastructure_affected, current_status, current_state, message_subject, notifications = 0, all_infrastructure_affected = "0")
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['incident_name'] = incident_name
  data['incident_details'] = incident_details
  data['infrastructure_affected'] = infrastructure_affected
  data['current_status'] = current_status
  data['current_state'] = current_state
  data['message_subject'] = message_subject
  data['all_infrastructure_affected'] = all_infrastructure_affected

  request :method  => :post,
  	      :url     => @url + 'incident/create',
  	      :payload => data
end

#incident_delete(statuspage_id, incident_id) ⇒ Object

Delete an existing incident. The incident will be deleted forever and cannot be recovered.

Parameters:

  • statuspage_id (string)

    Status page ID

  • incident_id (string)

    Incident ID

Returns:

  • object



272
273
274
275
276
277
278
279
280
# File 'lib/statusio.rb', line 272

def incident_delete(statuspage_id, incident_id)
  data = {}
  data['statuspage_id'] = statuspage_id
  data['incident_id'] = incident_id

  request :method  => :post,
          :url     => @url + 'incident/delete',
          :payload => data
end

#incident_list(statuspage_id) ⇒ Object

List all active and resolved incidents.

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



143
144
145
146
# File 'lib/statusio.rb', line 143

def incident_list(statuspage_id)
  request :method  => :get,
          :url     => @url + 'incident/list/' + statuspage_id
end

#incident_list_by_id(statuspage_id) ⇒ Object

List all active and resolved incidents by ID.

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



154
155
156
157
# File 'lib/statusio.rb', line 154

def incident_list_by_id(statuspage_id)
  request :method  => :get,
          :url     => @url + 'incidents/' + statuspage_id
end

#incident_message(statuspage_id, message_id) ⇒ Object

Display incident message.

Parameters:

  • statuspage_id (string)

    Status page ID

  • message_id (string)

    Message ID

Returns:

  • object



166
167
168
169
# File 'lib/statusio.rb', line 166

def incident_message(statuspage_id, message_id)
  request :method  => :get,
          :url     => @url + 'incident/message/' + statuspage_id + '/' + message_id
end

#incident_resolve(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0) ⇒ Object

Resolve an existing incident. The incident will be shown in the history instead of on the main page.

Parameters:

  • statuspage_id (string)

    Status page ID

  • incident_id (string)

    Incident ID

  • incident_details (string)

    Message describing this incident

  • current_status (int)

    The status of the components and containers affected by this incident (StatusioClient::STATUS_#).

  • current_state (int)

    The state of this incident (StatusioClient::STATE_#).

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

Returns:

  • object



251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/statusio.rb', line 251

def incident_resolve(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0)
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['incident_id'] = incident_id
  data['incident_details'] = incident_details
  data['current_status'] = current_status
  data['current_state'] =current_state
  data['message_subject'] = message_subject

  request :method  => :post,
          :url     => @url + 'incident/resolve',
          :payload => data
end

#incident_single(statuspage_id, incident_id) ⇒ Object

Get single incident.

Parameters:

  • statuspage_id (string)

    Status page ID

  • incident_id (string)

    Incident ID

Returns:

  • object



178
179
180
181
# File 'lib/statusio.rb', line 178

def incident_single(statuspage_id, incident_id)
  request :method  => :get,
          :url     => @url + 'incident/' + statuspage_id + '/' + incident_id
end

#incident_update(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0) ⇒ Object

Update an existing incident

Parameters:

  • statuspage_id (string)

    Status page ID

  • incident_id (string)

    Incident ID

  • incident_details (string)

    Message describing this incident

  • current_status (int)

    The status of the components and containers affected by this incident (StatusioClient::STATUS_#).

  • current_state (int)

    The state of this incident (StatusioClient::STATE_#).

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

Returns:

  • object



225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/statusio.rb', line 225

def incident_update(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0)
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['incident_id'] = incident_id
  data['incident_details'] = incident_details
  data['current_status'] = current_status
  data['current_state'] = current_state
  data['message_subject'] = message_subject

  request :method  => :post,
          :url     => @url + 'incident/update',
          :payload => data
end

#maintenance_delete(statuspage_id, maintenance_id) ⇒ Object

Delete an existing maintenance. The maintenance will be deleted forever and cannot be recovered.

/

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_id (string)

    Maintenance ID

Returns:

  • object



452
453
454
455
456
457
458
459
460
# File 'lib/statusio.rb', line 452

def maintenance_delete(statuspage_id, maintenance_id)
  data = {}
  data['statuspage_id'] = statuspage_id
  data['maintenance_id'] = maintenance_id

  request :method  => :post,
          :url     => @url + 'maintenance/delete',
          :payload => data
end

#maintenance_finish(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object

Close an active maintenance. The maintenance will be moved to the history.

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_id (string)

    Maintenance ID

  • maintenance_details (string)

    Message describing this maintenance

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

Returns:

  • object



433
434
435
436
437
438
439
440
441
442
443
# File 'lib/statusio.rb', line 433

def maintenance_finish(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0)
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['maintenance_id'] = maintenance_id
  data['maintenance_details'] = maintenance_details
  data['message_subject'] = message_subject

  request :method  => :post,
          :url     => @url + 'maintenance/finish',
          :payload => data
end

#maintenance_list(statuspage_id) ⇒ Object

List all active, resolved and upcoming maintenances

/

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



291
292
293
294
# File 'lib/statusio.rb', line 291

def maintenance_list(statuspage_id)
  request :method => :get,
          :url    => @url + 'maintenance/list/' + statuspage_id
end

#maintenance_list_by_id(statuspage_id) ⇒ Object

List all active, resolved and upcoming maintenances by ID

/

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



303
304
305
306
# File 'lib/statusio.rb', line 303

def maintenance_list_by_id(statuspage_id)
  request :method => :get,
          :url    => @url + 'maintenances/' + statuspage_id
end

#maintenance_message(statuspage_id, message_id) ⇒ Object

Display maintenance message

Parameters:

  • statuspage_id (string)

    Status page ID

  • message_id (string)

    Message ID

Returns:

  • object



315
316
317
318
# File 'lib/statusio.rb', line 315

def maintenance_message(statuspage_id, message_id)
  request :method  => :get,
          :url     => @url + 'maintenance/message/' + statuspage_id + '/' + message_id
end

#maintenance_schedule(statuspage_id, maintenance_name, maintenance_details, infrastructure_affected, date_planned_start, time_planned_start, date_planned_end, time_planned_end, message_subject, automation = "0", all_infrastructure_affected = "0", maintenance_notify_now = "0", maintenance_notify_1_hr = "0", maintenance_notify_24_hr = "0", maintenance_notify_72_hr = "0") ⇒ Object

Schedule a new maintenance

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_name (string)

    A descriptive title for this maintenance

  • maintenance_details (string)

    Message describing this maintenance

  • infrastructure_affected (array)

    ID of each affected component and container combo

  • date_planned_start (string)

    Date maintenance is expected to start

  • time_planned_start (string)

    Time maintenance is expected to start

  • date_planned_end (string)

    Date maintenance is expected to end

  • time_planned_end (string)

    Time maintenance is expected to end

  • message_subject (string)

    Message subject for email notifications

  • automation (string) (defaults to: "0")

    Automatically start and end the maintenance (default = 0)

  • all_infrastructure_affected (string) (defaults to: "0")

    Affect all components and containers (default = 0)

  • maintenance_notify_now (string) (defaults to: "0")

    Notify subscribers now (1 = Send notification)

  • maintenance_notify_1_hr (string) (defaults to: "0")

    Notify subscribers 1 hour before scheduled maintenance start time (1 = Send notification)

  • maintenance_notify_24_hr (string) (defaults to: "0")

    Notify subscribers 24 hours before scheduled maintenance start time (1 = Send notification)

  • maintenance_notify_72_hr (string) (defaults to: "0")

    Notify subscribers 72 hours before scheduled maintenance start time (1 = Send notification)

Returns:

  • object



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
# File 'lib/statusio.rb', line 352

def maintenance_schedule(statuspage_id, maintenance_name, maintenance_details, infrastructure_affected,
                         date_planned_start, time_planned_start, date_planned_end, time_planned_end,
                         message_subject, automation = "0", all_infrastructure_affected = "0",
                         maintenance_notify_now = "0", maintenance_notify_1_hr = "0",
                         maintenance_notify_24_hr = "0", maintenance_notify_72_hr = "0")
  data = {}
  data['statuspage_id'] = statuspage_id
  data['maintenance_name'] = maintenance_name
  data['maintenance_details'] = maintenance_details
  data['infrastructure_affected'] = infrastructure_affected
  data['all_infrastructure_affected'] = all_infrastructure_affected
  data['date_planned_start'] = date_planned_start
  data['time_planned_start'] = time_planned_start
  data['date_planned_end'] = date_planned_end
  data['time_planned_end'] = time_planned_end
  data['message_subject'] = message_subject
  data['automation'] = automation
  data['maintenance_notify_now'] = maintenance_notify_now
  data['maintenance_notify_1_hr'] = maintenance_notify_1_hr
  data['maintenance_notify_24_hr'] = maintenance_notify_24_hr
  data['maintenance_notify_72_hr'] = maintenance_notify_72_hr

  request :method  => :post,
          :url     => @url + 'maintenance/schedule',
          :payload => data
end

#maintenance_single(statuspage_id, maintenance_id) ⇒ Object

Get single maintenance

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_id (string)

    Maintenance ID

Returns:

  • object



327
328
329
330
# File 'lib/statusio.rb', line 327

def maintenance_single(statuspage_id, maintenance_id)
  request :method  => :get,
          :url     => @url + 'maintenance/' + statuspage_id + '/' + maintenance_id
end

#maintenance_start(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object

Begin a scheduled maintenance now

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_id (string)

    Maintenance ID

  • maintenance_details (string)

    Message describing this maintenance update

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

Returns:

  • object



389
390
391
392
393
394
395
396
397
398
399
# File 'lib/statusio.rb', line 389

def maintenance_start(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0)
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['maintenance_id'] = maintenance_id
  data['maintenance_details'] = maintenance_details
  data['message_subject'] = message_subject

  request :method  => :post,
          :url     => @url + 'maintenance/start',
          :payload => data
end

#maintenance_update(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object

Update an active maintenance

Parameters:

  • statuspage_id (string)

    Status page ID

  • maintenance_id (string)

    Maintenance ID

  • maintenance_details (string)

    Message describing this maintenance

  • message_subject (string)

    Message subject for email notifications

  • notifications (int) (defaults to: 0)

    Bitmasked notifications (StatusioClient::NOTIFY_#). To use multiple just add them up (ie StatusioClient::NOTIFY_SMS + StatusioClient::NOTIFY_SLACK).

Returns:

  • object



411
412
413
414
415
416
417
418
419
420
421
# File 'lib/statusio.rb', line 411

def maintenance_update(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0)
  data = get_notify(notifications)
  data['statuspage_id'] = statuspage_id
  data['maintenance_id'] = maintenance_id
  data['maintenance_details'] = maintenance_details
  data['message_subject'] = message_subject

  request :method  => :post,
          :url     => @url + 'maintenance/update',
          :payload => data
end

#metric_update(statuspage_id, metric_id, day_avg, day_start, day_dates, day_values, week_avg, week_start, week_dates, week_values, month_avg, month_start, month_dates, month_values) ⇒ Object

Update custom metric data

Parameters:

  • statuspage_id (string)

    Status page ID

  • metric_id (string)

    Metric ID

  • day_avg (float)

    Average value for past 24 hours

  • day_start (int)

    UNIX timestamp for start of metric timeframe

  • day_dates (array)

    An array of timestamps for the past 24 hours (2014-03-28T05:43:00+00:00)

  • day_values (array)

    An array of values matching the timestamps (Must be 24 values)

  • week_avg (float)

    Average value for past 7 days

  • week_start (int)

    UNIX timestamp for start of metric timeframe

  • week_dates (array)

    An array of timestamps for the past 7 days (2014-03-28T05:43:00+00:00)

  • week_values (array)

    An array of values matching the timestamps (Must be 7 values)

  • month_avg (float)

    Average value for past 30 days

  • month_start (int)

    UNIX timestamp for start of metric timeframe

  • month_dates (array)

    An array of timestamps for the past 30 days (2014-03-28T05:43:00+00:00)

  • month_values (array)

    An array of values matching the timestamps (Must be 30 values)

Returns:

  • object



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/statusio.rb', line 483

def metric_update(statuspage_id, metric_id, day_avg, day_start, day_dates, day_values,
                  week_avg, week_start, week_dates, week_values,
                  month_avg, month_start, month_dates, month_values)
  data = {}
  data['statuspage_id'] = statuspage_id
  data['metric_id'] = metric_id
  data['day_avg'] = day_avg
  data['day_start'] = day_start
  data['day_dates'] = day_dates
  data['day_values'] = day_values
  data['week_avg'] = week_avg
  data['week_start'] = week_start
  data['week_dates'] = week_dates
  data['week_values'] =week_values
  data['month_avg'] = month_avg
  data['month_start'] = month_start
  data['month_dates'] = month_dates
  data['month_values'] = month_values

  request :method  => :post,
          :url     => @url + 'metric/update',
          :payload => data
end

#status_summary(statuspage_id) ⇒ Object

Show the summary status for all components and containers

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



515
516
517
518
# File 'lib/statusio.rb', line 515

def status_summary(statuspage_id)
    request :method => :get,
            :url    => @url + 'status/summary/' + statuspage_id
end

#subscriber_add(statuspage_id, method, address, silent = '1', granular = '') ⇒ Object

Add a new subscriber

Parameters:

  • statuspage_id (string)

    Status page ID

  • method (string)

    Communication method of subscriber. Valid methods are ‘email`, `sms` or `webhook`

  • address (string)

    Subscriber address (SMS number must include country code ie. +1)

  • silent (string) (defaults to: '1')

    Suppress the welcome message (1 = Do not send notification)

  • granular (string) (defaults to: '')

    List of component_container combos

Returns:

  • object



543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/statusio.rb', line 543

def subscriber_add(statuspage_id, method, address, silent = '1', granular = '')
  data = {}
  data['statuspage_id'] = statuspage_id
  data['method'] = method
  data['address'] = address
  data['silent'] = silent
  data['granular'] = granular

  request :method  => :post,
          :url     => @url + 'subscriber/add',
          :payload => data
end

#subscriber_list(statuspage_id) ⇒ Object

List all subscribers

Parameters:

  • statuspage_id (string)

    Status page ID

Returns:

  • object



528
529
530
531
# File 'lib/statusio.rb', line 528

def subscriber_list(statuspage_id)
  request :method => :get,
          :url => @url + 'subscriber/list/' + statuspage_id
end

#subscriber_remove(statuspage_id, subscriber_id) ⇒ Object

Delete subscriber

Parameters:

  • statuspage_id (string)

    Status page ID

  • subscriber_id (string)

    Subscriber ID

Returns:

  • object



584
585
586
587
# File 'lib/statusio.rb', line 584

def subscriber_remove(statuspage_id, subscriber_id)
	request :method  => :delete,
          :url     => @url + 'subscriber/remove/' + statuspage_id + '/' + subscriber_id
end

#subscriber_update(statuspage_id, subscriber_id, address, granular = '') ⇒ Object

Update existing subscriber

Parameters:

  • statuspage_id (string)

    Status page ID

  • subscriber_id (string)

    Subscriber ID

  • address (string)

    Subscriber address (SMS number must include country code ie. +1)

  • granular (string) (defaults to: '')

    List of component_container combos

Returns:

  • object



565
566
567
568
569
570
571
572
573
574
575
# File 'lib/statusio.rb', line 565

def subscriber_update(statuspage_id, subscriber_id, address, granular = '')
  data = {}
  data['statuspage_id'] = statuspage_id
  data['subscriber_id'] = subscriber_id
  data['address'] = address
  data['granular'] = granular

  request :method  => :patch,
          :url     => @url + 'subscriber/update',
          :payload => data
end