elasticctl-api 0.9.4

Typed detection-rule model and endpoint wrappers for Elastic Security.
Documentation
//! Bounded shared reads for cross-vertical reports.
use elasticctl_core::{Error, ErrorKind, Result};
mod alert_activity;
pub mod alert_context;
pub mod coverage;
mod exception_coverage;
pub mod readiness;
pub mod rule_health;
mod rule_snapshot;
pub use alert_activity::*;
pub use alert_context::*;
pub use coverage::*;
pub use exception_coverage::*;
pub use rule_health::*;
pub use rule_snapshot::*;
pub const MAX_EXCEPTION_LISTS: usize = 5;
pub const MAX_RELATED_CASES: usize = 5;
pub const RECENT_ALERTS: usize = 5;
pub const MAX_PATTERNS: usize = 16;
pub const MAX_PACKAGES: usize = 8;
pub const MESSAGE_BYTES: usize = 2_048;
#[derive(Debug)]
pub enum Part<T> {
    Ok(T),
    Unavailable(Error),
    Skipped(SkipReason),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SkipReason {
    NotApplicable,
    DependencyUnavailable,
    NotConfigured,
}
pub fn is_fatal(kind: ErrorKind) -> bool {
    matches!(
        kind,
        ErrorKind::Auth | ErrorKind::Connection | ErrorKind::Timeout
    )
}
pub fn degrade<T>(result: Result<T>) -> Result<Part<T>> {
    match result {
        Ok(v) => Ok(Part::Ok(v)),
        Err(e) if is_fatal(e.kind) => Err(e),
        Err(e) => Ok(Part::Unavailable(e)),
    }
}
pub fn is_path_segment(value: &str) -> bool {
    !matches!(value, "" | "." | "..")
}
/// Refuse an id read from a response or a local file before it becomes one
/// URL path segment. URL parsing removes `.` and `..` segments, so either
/// would move the request to a parent route.
pub fn require_path_segment(value: &str) -> Result<&str> {
    if is_path_segment(value) {
        Ok(value)
    } else {
        Err(Error::new(
            ErrorKind::Http,
            "id is not a single URL path segment",
        ))
    }
}