Skip to main content

proxmox_api/generated/nodes/node/ceph/
cmd_safety.rs

1#[derive(Debug, Clone)]
2pub struct CmdSafetyClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> CmdSafetyClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/cmd-safety"),
14        }
15    }
16}
17impl<T> CmdSafetyClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Heuristical check if it is safe to perform an action."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
24    pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &params).await
27    }
28}
29impl GetOutput {
30    pub fn new(safe: bool) -> Self {
31        Self {
32            safe,
33            status: ::std::default::Default::default(),
34            additional_properties: ::std::default::Default::default(),
35        }
36    }
37}
38#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
39pub struct GetOutput {
40    #[serde(
41        serialize_with = "crate::types::serialize_bool",
42        deserialize_with = "crate::types::deserialize_bool"
43    )]
44    #[doc = "If it is safe to run the command."]
45    #[doc = ""]
46    pub safe: bool,
47    #[serde(skip_serializing_if = "Option::is_none", default)]
48    #[doc = "Status message given by Ceph."]
49    #[doc = ""]
50    pub status: Option<String>,
51    #[serde(
52        flatten,
53        default,
54        skip_serializing_if = "::std::collections::HashMap::is_empty"
55    )]
56    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
57}
58impl GetParams {
59    pub fn new(action: Action, id: String, service: Service) -> Self {
60        Self {
61            action,
62            id,
63            service,
64            additional_properties: ::std::default::Default::default(),
65        }
66    }
67}
68#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
69pub struct GetParams {
70    #[doc = "Action to check"]
71    #[doc = ""]
72    pub action: Action,
73    #[doc = "ID of the service"]
74    #[doc = ""]
75    pub id: String,
76    #[doc = "Service type"]
77    #[doc = ""]
78    pub service: Service,
79    #[serde(
80        flatten,
81        default,
82        skip_serializing_if = "::std::collections::HashMap::is_empty"
83    )]
84    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
85}
86#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
87#[doc = "Action to check"]
88#[doc = ""]
89pub enum Action {
90    #[serde(rename = "destroy")]
91    Destroy,
92    #[serde(rename = "stop")]
93    Stop,
94}
95impl TryFrom<&str> for Action {
96    type Error = String;
97    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
98        match value {
99            "destroy" => Ok(Self::Destroy),
100            "stop" => Ok(Self::Stop),
101            v => Err(format!("Unknown variant {v}")),
102        }
103    }
104}
105#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
106#[doc = "Service type"]
107#[doc = ""]
108pub enum Service {
109    #[serde(rename = "mds")]
110    Mds,
111    #[serde(rename = "mon")]
112    Mon,
113    #[serde(rename = "osd")]
114    Osd,
115}
116impl TryFrom<&str> for Service {
117    type Error = String;
118    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
119        match value {
120            "mds" => Ok(Self::Mds),
121            "mon" => Ok(Self::Mon),
122            "osd" => Ok(Self::Osd),
123            v => Err(format!("Unknown variant {v}")),
124        }
125    }
126}