coil_ops/recovery/
planning.rs1use crate::error::OpsModelError;
2use crate::identifiers::{RecoveryExecutionId, RecoveryWorkflowId};
3use crate::validation::require_non_empty;
4use coil_auth::Capability;
5use coil_jobs::{IdempotencyKey, JobInstant, JobSpec, PlannedJob};
6
7use super::{RecoveryStage, RecoveryWorkflowDefinition};
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct RecoveryPlanRequest {
11 pub execution_id: RecoveryExecutionId,
12 pub definition_id: RecoveryWorkflowId,
13 pub customer_app_id: String,
14 pub requested_by: String,
15 pub requested_at: JobInstant,
16 pub scheduled_for: Option<JobInstant>,
17 pub idempotency_key: Option<IdempotencyKey>,
18 pub operator_capabilities: Vec<Capability>,
19 pub local_only_sensitive_present: bool,
20 pub local_only_sensitive_acknowledged: bool,
21}
22
23impl RecoveryPlanRequest {
24 pub fn new(
25 execution_id: RecoveryExecutionId,
26 definition_id: RecoveryWorkflowId,
27 customer_app_id: impl Into<String>,
28 requested_by: impl Into<String>,
29 requested_at: JobInstant,
30 ) -> Result<Self, OpsModelError> {
31 Ok(Self {
32 execution_id,
33 definition_id,
34 customer_app_id: require_non_empty("recovery_customer_app_id", customer_app_id.into())?,
35 requested_by: require_non_empty("recovery_requested_by", requested_by.into())?,
36 requested_at,
37 scheduled_for: None,
38 idempotency_key: None,
39 operator_capabilities: Vec::new(),
40 local_only_sensitive_present: false,
41 local_only_sensitive_acknowledged: false,
42 })
43 }
44
45 pub fn scheduled_for(mut self, instant: JobInstant) -> Self {
46 self.scheduled_for = Some(instant);
47 self
48 }
49
50 pub fn with_idempotency_key(mut self, key: IdempotencyKey) -> Self {
51 self.idempotency_key = Some(key);
52 self
53 }
54
55 pub fn with_capability(mut self, capability: Capability) -> Self {
56 self.operator_capabilities.push(capability);
57 self
58 }
59
60 pub fn with_local_only_sensitive_data(mut self, acknowledged: bool) -> Self {
61 self.local_only_sensitive_present = true;
62 self.local_only_sensitive_acknowledged = acknowledged;
63 self
64 }
65}
66
67#[derive(Debug, Clone, PartialEq, Eq)]
68pub struct RecoveryPlan {
69 pub definition: RecoveryWorkflowDefinition,
70 pub job: JobSpec,
71 pub planned_job: PlannedJob,
72 pub customer_app_id: String,
73 pub stages: Vec<RecoveryStage>,
74 pub audit_message: String,
75 pub requires_host_local_restore: bool,
76}