Skip to main content

greentic_deploy_spec/
retention.rs

1//! Auxiliary policy/health value types for [`Environment`](crate::Environment).
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Revocation policy for an Environment (`§5.1`). Detailed semantics
7/// (revocation registry, broadcast cadence) are owned by `greentic-cap`; this
8/// struct is intentionally a thin record carrying the binding-time settings.
9#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
10pub struct RevocationConfig {
11    /// Whether revocation enforcement is required for this env.
12    #[serde(default)]
13    pub required: bool,
14    /// Optional revocation list pointer (URI or env-relative path string).
15    #[serde(default, skip_serializing_if = "Option::is_none")]
16    pub list_ref: Option<String>,
17}
18
19/// Retention policy for revisions/audit (`§5.1`).
20#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
21pub struct RetentionPolicy {
22    /// How many ready/archived revisions to keep per deployment.
23    #[serde(default, skip_serializing_if = "Option::is_none")]
24    pub keep_revisions: Option<u32>,
25    /// How many days to retain audit events.
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub audit_retention_days: Option<u32>,
28}
29
30#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(rename_all = "lowercase")]
32pub enum HealthState {
33    #[default]
34    Unknown,
35    Green,
36    Yellow,
37    Red,
38}
39
40/// Coarse health snapshot for the Environment.
41#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
42pub struct HealthStatus {
43    #[serde(default)]
44    pub state: HealthState,
45    #[serde(default, skip_serializing_if = "Option::is_none")]
46    pub message: Option<String>,
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub last_checked_at: Option<DateTime<Utc>>,
49}