Skip to main content

soma_gateway/
registry.rs

1#[derive(Debug, Clone, PartialEq, Eq)]
2pub struct GatewayServiceMeta {
3    pub id: String,
4    pub display_name: String,
5    pub actions: Vec<GatewayServiceAction>,
6    pub env: Vec<GatewayEnvVar>,
7}
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct GatewayServiceAction {
11    pub name: String,
12    pub admin_required: bool,
13    pub destructive: bool,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct GatewayEnvVar {
18    pub name: String,
19    pub required: bool,
20    pub secret: bool,
21}
22
23impl GatewayServiceMeta {
24    #[must_use]
25    pub fn new(id: impl Into<String>, display_name: impl Into<String>) -> Self {
26        Self {
27            id: id.into(),
28            display_name: display_name.into(),
29            actions: Vec::new(),
30            env: Vec::new(),
31        }
32    }
33
34    #[must_use]
35    pub fn with_action(mut self, action: GatewayServiceAction) -> Self {
36        self.actions.push(action);
37        self
38    }
39
40    #[must_use]
41    pub fn with_env(mut self, env: GatewayEnvVar) -> Self {
42        self.env.push(env);
43        self
44    }
45}
46
47#[cfg(test)]
48#[path = "registry_tests.rs"]
49mod tests;