Skip to main content

oppex_sdk/
lib.rs

1//! Post incidents to the Oppex incident API.
2//!
3//! ```text
4//! POST https://api.oppex.ai/api/v1/incident/post
5//! ```
6//!
7//! Create one [`IncidentClient`] per application, share it across threads, and
8//! let it drop (or call [`IncidentClient::close`]) during shutdown.
9//!
10//! ```no_run
11//! use oppex_sdk::{IncidentClient, IncidentRequest, Severity};
12//!
13//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
14//! let client = IncidentClient::builder()
15//!     .api_key("api-key")
16//!     .service_key("service-key")
17//!     .build()?;
18//!
19//! let request = IncidentRequest::builder()
20//!     .title("Checkout latency breached the SLO")
21//!     .source("checkout-api")
22//!     .severity(Severity::High)
23//!     .build()?;
24//!
25//! let response = client.post(&request)?;
26//! println!("created {:?}", response.incident_id());
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! The service key is optional. A client built with only an API key posts with
32//! [`IncidentClient::post_with_service_routing`], which omits `serviceKey` from
33//! the payload so the API resolves the target service itself.
34
35mod client;
36mod error;
37mod internal;
38mod request;
39mod response;
40mod severity;
41
42/// The SDK version, as `MAJOR.MINOR.PATCH`. Read from the crate's own manifest,
43/// so it cannot drift from the published version.
44pub const VERSION: &str = env!("CARGO_PKG_VERSION");
45
46pub use client::{IncidentClient, IncidentClientBuilder};
47pub use error::{IncidentError, NO_STATUS_CODE};
48pub use internal::transport::DEFAULT_ENDPOINT;
49pub use request::{IncidentRequest, IncidentRequestBuilder};
50pub use response::IncidentResponse;
51pub use severity::Severity;