Crate rusty_pager [] [src]

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),
   };
}

Modules

events

interfaces for the PagerDuty Events API v2