manta_server/backend_dispatcher/delete_configurations.rs
1//! [`DeleteConfigurationsAndDataRelatedTrait`] impl for
2//! [`StaticBackendDispatcher`].
3//!
4//! Implements the "delete CFS configurations and everything that
5//! references them" cascade — CFS sessions, IMS images, BOS templates,
6//! and the configurations themselves. Used by the `delete configs`
7//! CLI path and the corresponding HTTP handler. Ochami uses the
8//! trait default and returns [`Error::Message`] for both methods.
9
10use super::*;
11
12impl DeleteConfigurationsAndDataRelatedTrait for StaticBackendDispatcher {
13 /// Dry-run inventory: enumerate every artifact that would be
14 /// touched by a matching [`delete`](Self::delete) call without
15 /// actually deleting anything. Returns
16 /// `(sessions, image_refs, configuration_names,
17 /// session_template_names, template_refs, configurations)` where
18 /// the `(String, String, String)` triples carry id/name/derived-id
19 /// triples ready to be shown to the operator before they confirm.
20 async fn get_data_to_delete(
21 &self,
22 token: &str,
23 group_name_available_vec: &[String],
24 configuration_name_pattern_opt: Option<&str>,
25 since_opt: Option<NaiveDateTime>,
26 until_opt: Option<NaiveDateTime>,
27 ) -> Result<
28 (
29 Vec<CfsSessionGetResponse>,
30 Vec<(String, String, String)>,
31 Vec<String>,
32 Vec<String>,
33 Vec<(String, String, String)>,
34 Vec<CfsConfigurationResponse>,
35 ),
36 Error,
37 > {
38 dispatch!(
39 self,
40 get_data_to_delete,
41 token,
42 group_name_available_vec,
43 configuration_name_pattern_opt,
44 since_opt,
45 until_opt
46 )
47 }
48
49 /// Execute the cascade: delete BOS templates, CFS sessions, IMS
50 /// images, and finally the CFS configurations themselves, in that
51 /// order so foreign-key-like references are gone before the
52 /// configurations they point at. Each input slice is the exact set
53 /// of names/ids to delete — typically the output of
54 /// [`get_data_to_delete`](Self::get_data_to_delete).
55 async fn delete(
56 &self,
57 token: &str,
58 cfs_configuration_name_vec: &[String],
59 image_id_vec: &[String],
60 cfs_session_name_vec: &[String],
61 bos_sessiontemplate_name_vec: &[String],
62 ) -> Result<(), Error> {
63 dispatch!(
64 self,
65 delete,
66 token,
67 cfs_configuration_name_vec,
68 image_id_vec,
69 cfs_session_name_vec,
70 bos_sessiontemplate_name_vec
71 )
72 }
73}