Class: StatusioClient
- Inherits:
-
Object
- Object
- StatusioClient
- 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
-
#component_list(statuspage_id) ⇒ Object
List all components.
-
#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.
-
#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.
-
#incident_delete(statuspage_id, incident_id) ⇒ Object
Delete an existing incident.
-
#incident_list(statuspage_id) ⇒ Object
List all active and resolved incidents.
-
#incident_list_by_id(statuspage_id) ⇒ Object
List all active and resolved incidents by ID.
-
#incident_message(statuspage_id, message_id) ⇒ Object
Display incident message.
-
#incident_resolve(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0) ⇒ Object
Resolve an existing incident.
-
#incident_single(statuspage_id, incident_id) ⇒ Object
Get single incident.
-
#incident_update(statuspage_id, incident_id, incident_details, current_status, current_state, message_subject, notifications = 0) ⇒ Object
Update an existing incident.
-
#initialize(api_key, api_id) ⇒ StatusioClient
constructor
A new instance of StatusioClient.
-
#maintenance_delete(statuspage_id, maintenance_id) ⇒ Object
Delete an existing maintenance.
-
#maintenance_finish(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object
Close an active maintenance.
-
#maintenance_list(statuspage_id) ⇒ Object
List all active, resolved and upcoming maintenances.
-
#maintenance_list_by_id(statuspage_id) ⇒ Object
List all active, resolved and upcoming maintenances by ID.
-
#maintenance_message(statuspage_id, message_id) ⇒ Object
Display maintenance message.
-
#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.
-
#maintenance_single(statuspage_id, maintenance_id) ⇒ Object
Get single maintenance.
-
#maintenance_start(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object
Begin a scheduled maintenance now.
-
#maintenance_update(statuspage_id, maintenance_id, maintenance_details, message_subject, notifications = 0) ⇒ Object
Update an active maintenance.
-
#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.
-
#status_summary(statuspage_id) ⇒ Object
Show the summary status for all components and containers.
-
#subscriber_add(statuspage_id, method, address, silent = '1', granular = '') ⇒ Object
Add a new subscriber.
-
#subscriber_list(statuspage_id) ⇒ Object
List all subscribers.
-
#subscriber_remove(statuspage_id, subscriber_id) ⇒ Object
Delete subscriber.
-
#subscriber_update(statuspage_id, subscriber_id, address, granular = '') ⇒ Object
Update existing subscriber.
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.
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.
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.
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, , 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'] = 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.
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.
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.
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.
166 167 168 169 |
# File 'lib/statusio.rb', line 166 def (statuspage_id, ) request :method => :get, :url => @url + 'incident/message/' + statuspage_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.
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, , 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'] = request :method => :post, :url => @url + 'incident/resolve', :payload => data end |
#incident_single(statuspage_id, incident_id) ⇒ Object
Get single incident.
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
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, , 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'] = 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.
/
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.
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, , notifications = 0) data = get_notify(notifications) data['statuspage_id'] = statuspage_id data['maintenance_id'] = maintenance_id data['maintenance_details'] = maintenance_details data['message_subject'] = request :method => :post, :url => @url + 'maintenance/finish', :payload => data end |
#maintenance_list(statuspage_id) ⇒ Object
List all active, resolved and upcoming maintenances
/
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
/
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
315 316 317 318 |
# File 'lib/statusio.rb', line 315 def (statuspage_id, ) request :method => :get, :url => @url + 'maintenance/message/' + statuspage_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
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, , 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'] = 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
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
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, , notifications = 0) data = get_notify(notifications) data['statuspage_id'] = statuspage_id data['maintenance_id'] = maintenance_id data['maintenance_details'] = maintenance_details data['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
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, , notifications = 0) data = get_notify(notifications) data['statuspage_id'] = statuspage_id data['maintenance_id'] = maintenance_id data['maintenance_details'] = maintenance_details data['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
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
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
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
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
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
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 |