#pager-duty #events #api #interface #api-bindings #integration #key

rusty-pager

为 PagerDuty API 提供非官方的 Rust 接口

2 个版本

使用旧 Rust 2015

0.1.1 2018年5月24日
0.1.0 2018年5月22日

#10 in #pager-duty

MIT 许可协议

9KB
157

rusty-pager

Rust 提供的非官方 PagerDuty SDK。


lib.rs:

rusty_pager 包提供用于 PagerDuty API 的 Rust SDK。

目前仅支持 Events v2 API。

使用示例

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

依赖项

~18–29MB
~518K SLoC