Skip to main content

canic_host/deployment_truth/model/lifecycle/plan/
mod.rs

1use super::super::CanisterControlClassV1;
2use super::authority::{LifecycleAuthorityV1, LifecycleModeV1};
3use super::handoff::ExternalLifecyclePendingActionV1;
4use super::proposal::ExternalUpgradeProposalV1;
5use serde::{Deserialize, Serialize};
6
7///
8/// ExternalLifecyclePlanV1
9///
10#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
11pub struct ExternalLifecyclePlanV1 {
12    pub schema_version: u32,
13    pub lifecycle_plan_id: String,
14    pub lifecycle_plan_digest: String,
15    pub lifecycle_authority_report_id: String,
16    pub deployment_plan_id: String,
17    pub deployment_plan_digest: String,
18    pub inventory_id: String,
19    pub lifecycle_authority_rows: Vec<LifecycleAuthorityV1>,
20    pub directly_executable_role_upgrades: Vec<ExternalLifecycleRoleUpgradeV1>,
21    pub proposed_external_role_upgrades: Vec<ExternalLifecycleRoleUpgradeV1>,
22    pub blocked_role_upgrades: Vec<ExternalLifecycleRoleUpgradeV1>,
23    pub dependency_blockers: Vec<String>,
24    pub protected_call_implications: Vec<String>,
25    pub residual_exposure: Vec<String>,
26    pub status: ExternalLifecyclePlanStatusV1,
27}
28
29///
30/// ExternalLifecycleRoleUpgradeV1
31///
32#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
33pub struct ExternalLifecycleRoleUpgradeV1 {
34    pub subject: String,
35    pub canister_id: Option<String>,
36    pub role: Option<String>,
37    pub control_class: CanisterControlClassV1,
38    pub lifecycle_mode: LifecycleModeV1,
39    pub required_external_action: Option<String>,
40    pub blockers: Vec<String>,
41    pub warnings: Vec<String>,
42}
43
44///
45/// ExternalLifecyclePlanStatusV1
46///
47#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
48pub enum ExternalLifecyclePlanStatusV1 {
49    Ready,
50    PendingExternalAction,
51    Blocked,
52}
53
54impl ExternalLifecyclePlanStatusV1 {
55    #[must_use]
56    pub const fn label(self) -> &'static str {
57        match self {
58            Self::Ready => "ready",
59            Self::PendingExternalAction => "pending_external_action",
60            Self::Blocked => "blocked",
61        }
62    }
63}
64
65///
66/// ExternalUpgradeProposalReportV1
67///
68#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
69pub struct ExternalUpgradeProposalReportV1 {
70    pub schema_version: u32,
71    pub report_id: String,
72    pub report_digest: String,
73    pub lifecycle_plan_id: String,
74    pub lifecycle_plan_digest: String,
75    pub deployment_plan_id: String,
76    pub deployment_plan_digest: String,
77    pub inventory_id: String,
78    pub proposals: Vec<ExternalUpgradeProposalV1>,
79    pub blocked_subjects: Vec<String>,
80}
81
82///
83/// ExternalLifecyclePendingReportV1
84///
85#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
86pub struct ExternalLifecyclePendingReportV1 {
87    pub schema_version: u32,
88    pub report_id: String,
89    pub report_digest: String,
90    pub lifecycle_plan_id: String,
91    pub lifecycle_plan_digest: String,
92    pub proposal_report_id: String,
93    pub proposal_report_digest: String,
94    pub deployment_plan_id: String,
95    pub deployment_plan_digest: String,
96    pub inventory_id: String,
97    pub direct_upgrade_count: usize,
98    pub pending_external_count: usize,
99    pub blocked_count: usize,
100    pub pending_external_actions: Vec<ExternalLifecyclePendingActionV1>,
101    pub blocked_subjects: Vec<String>,
102    pub residual_exposure: Vec<String>,
103    pub status: ExternalLifecyclePlanStatusV1,
104}
105
106///
107/// ExternalLifecycleCheckV1
108///
109#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
110pub struct ExternalLifecycleCheckV1 {
111    pub schema_version: u32,
112    pub check_id: String,
113    pub check_digest: String,
114    pub lifecycle_plan_id: String,
115    pub lifecycle_plan_digest: String,
116    pub proposal_report_id: String,
117    pub proposal_report_digest: String,
118    pub pending_report_id: String,
119    pub pending_report_digest: String,
120    pub deployment_plan_id: String,
121    pub deployment_plan_digest: String,
122    pub inventory_id: String,
123    pub status: ExternalLifecyclePlanStatusV1,
124    pub direct_upgrade_count: usize,
125    pub pending_external_count: usize,
126    pub blocked_count: usize,
127    pub residual_exposure_count: usize,
128    pub summary: String,
129    pub next_actions: Vec<String>,
130}
131
132#[cfg(test)]
133mod tests {
134    use super::*;
135
136    #[test]
137    fn external_lifecycle_plan_status_owns_text_labels() {
138        assert_eq!(ExternalLifecyclePlanStatusV1::Ready.label(), "ready");
139        assert_eq!(
140            ExternalLifecyclePlanStatusV1::PendingExternalAction.label(),
141            "pending_external_action"
142        );
143        assert_eq!(ExternalLifecyclePlanStatusV1::Blocked.label(), "blocked");
144    }
145}