#pager-duty #api-bindings

rusty-pager

unoffical rust interface for the pagerduty api

2 releases

Uses old Rust 2015

0.1.1 May 24, 2018
0.1.0 May 22, 2018

#10 in #pager-duty

MIT license

9KB
157 lines

rusty-pager

An unofficial Rust SDK for PagerDuty.


lib.rs:

The rusty_pager crate provides a Rust SDK for the PagerDuty APIs.

Currently only the Events v2 API is supported.

Usage Example

use rusty_pager::events::{EventManager, EventSeverity};

fn main() {
   // your pagerduty integration key
   let integration_key = String::from("your-integration-key");
   // create a new event manager
   let event_mgr = EventManager::new(integration_key);

   // starting out without an event id (until we trigger one...)
   let mut event_id: Option<String> = None;

   // trigger a new event
   event_id = match event_mgr.trigger(
       &event_id,            // this is currently None, so a new event will be triggered
       "some message",
       "my-monitoring-agent",
       EventSeverity::Critical,
   ) {
       Ok(event_id) => Some(event_id),
       Err(err) => panic!("failed to trigger pagerduty event! {:?}", err),
   };

   // re-trigger an existing event
   match event_mgr.trigger(
       &event_id,            // since we set this to the last event_id, it'll retrigger
       "some message",
       "my-monitoring-agent",
       EventSeverity::Critical,
   ) {
       Ok(_) => {},
       Err(err) => panic!("failed to re-trigger pagerduty event! {:?}", err),
   };

   // resolve an existing event
   match event_mgr.resolve(event_id.as_ref().unwrap()) {
       Ok(()) => {},
       Err(err) => panic!("failed to resolve pagerduty event! {:?}", err),
   };
}

Dependencies

~18–29MB
~503K SLoC