spacegate_config/service/fs/
delete.rs1use crate::service::Delete;
2use crate::{service::config_format::ConfigFormat, BoxError};
3
4use super::Fs;
5impl<F> Delete for Fs<F>
6where
7 F: ConfigFormat + Send + Sync,
8{
9 async fn delete_plugin(&self, id: &spacegate_model::PluginInstanceId) -> Result<(), BoxError> {
10 self.modify_cached(|config| {
11 config.plugins.remove(id);
12 Ok(())
13 })
14 .await
15 }
16
17 async fn delete_config_item_gateway(&self, gateway_name: &str) -> Result<(), BoxError> {
18 self.modify_cached(|config| {
19 config.gateways.remove(gateway_name);
20 Ok(())
21 })
22 .await
23 }
24
25 async fn delete_config_item_route(&self, gateway_name: &str, route_name: &str) -> Result<(), BoxError> {
26 self.modify_cached(|config| {
27 if let Some(gw) = config.gateways.get_mut(gateway_name) {
28 gw.routes.remove(route_name);
29 }
30 Ok(())
31 })
32 .await
33 }
34
35 async fn delete_config_item(&self, gateway_name: &str) -> Result<(), BoxError> {
36 self.modify_cached(|config| {
37 config.gateways.remove(gateway_name);
38 Ok(())
39 })
40 .await
41 }
42
43 async fn delete_config_item_all_routes(&self, gateway_name: &str) -> Result<(), BoxError> {
44 self.modify_cached(|config| {
45 if let Some(gw) = config.gateways.get_mut(gateway_name) {
46 gw.routes.clear()
47 }
48 Ok(())
49 })
50 .await
51 }
52}