Skip to main content

proxmox_api/generated/cluster/notifications/endpoints/
sendmail.rs

1pub mod name;
2#[derive(Debug, Clone)]
3pub struct SendmailClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> SendmailClient<T>
8where
9    T: crate::client::Client,
10{
11    pub fn new(client: T, parent_path: &str) -> Self {
12        Self {
13            client,
14            path: format!("{}{}", parent_path, "/sendmail"),
15        }
16    }
17}
18impl<T> SendmailClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "Returns a list of all sendmail endpoints"]
23    #[doc = ""]
24    #[doc = "Permission check: or(perm(\"/mapping/notifications\", [\"Mapping.Modify\"]), perm(\"/mapping/notifications\", [\"Mapping.Audit\"]))"]
25    pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26        let path = self.path.to_string();
27        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28        Ok(optional_vec.unwrap_or_default())
29    }
30}
31impl<T> SendmailClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new sendmail endpoint"]
36    #[doc = ""]
37    #[doc = "Permission check: and(perm(\"/mapping/notifications\", [\"Mapping.Modify\"]), or(perm(\"/\", [\"Sys.Audit\", \"Sys.Modify\"]), perm(\"/\", [\"Sys.AccessNetwork\"])))"]
38    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39        let path = self.path.to_string();
40        self.client.post(&path, &params).await
41    }
42}
43impl GetOutputItems {
44    pub fn new(name: String, origin: Origin) -> Self {
45        Self {
46            name,
47            origin,
48            author: ::std::default::Default::default(),
49            comment: ::std::default::Default::default(),
50            disable: ::std::default::Default::default(),
51            from_address: ::std::default::Default::default(),
52            mailto: ::std::default::Default::default(),
53            mailto_user: ::std::default::Default::default(),
54            additional_properties: ::std::default::Default::default(),
55        }
56    }
57}
58#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
59pub struct GetOutputItems {
60    #[serde(skip_serializing_if = "Option::is_none", default)]
61    #[doc = "Author of the mail"]
62    #[doc = ""]
63    pub author: Option<String>,
64    #[serde(skip_serializing_if = "Option::is_none", default)]
65    #[doc = "Comment"]
66    #[doc = ""]
67    pub comment: Option<String>,
68    #[serde(
69        serialize_with = "crate::types::serialize_bool_optional",
70        deserialize_with = "crate::types::deserialize_bool_optional"
71    )]
72    #[serde(skip_serializing_if = "Option::is_none", default)]
73    #[doc = "Disable this target"]
74    #[doc = ""]
75    pub disable: Option<bool>,
76    #[serde(rename = "from-address")]
77    #[serde(skip_serializing_if = "Option::is_none", default)]
78    #[doc = "`From` address for the mail"]
79    #[doc = ""]
80    pub from_address: Option<String>,
81    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
82    #[doc = "List of email recipients"]
83    #[doc = ""]
84    pub mailto: Vec<String>,
85    #[serde(rename = "mailto-user")]
86    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
87    #[doc = "List of users"]
88    #[doc = ""]
89    pub mailto_user: Vec<String>,
90    #[doc = "The name of the endpoint."]
91    #[doc = ""]
92    pub name: String,
93    #[doc = "Show if this entry was created by a user or was built-in"]
94    #[doc = ""]
95    pub origin: Origin,
96    #[serde(
97        flatten,
98        default,
99        skip_serializing_if = "::std::collections::HashMap::is_empty"
100    )]
101    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
102}
103impl PostParams {
104    pub fn new(name: String) -> Self {
105        Self {
106            name,
107            author: ::std::default::Default::default(),
108            comment: ::std::default::Default::default(),
109            disable: ::std::default::Default::default(),
110            from_address: ::std::default::Default::default(),
111            mailto: ::std::default::Default::default(),
112            mailto_user: ::std::default::Default::default(),
113            additional_properties: ::std::default::Default::default(),
114        }
115    }
116}
117#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
118pub struct PostParams {
119    #[serde(skip_serializing_if = "Option::is_none", default)]
120    #[doc = "Author of the mail"]
121    #[doc = ""]
122    pub author: Option<String>,
123    #[serde(skip_serializing_if = "Option::is_none", default)]
124    #[doc = "Comment"]
125    #[doc = ""]
126    pub comment: Option<String>,
127    #[serde(
128        serialize_with = "crate::types::serialize_bool_optional",
129        deserialize_with = "crate::types::deserialize_bool_optional"
130    )]
131    #[serde(skip_serializing_if = "Option::is_none", default)]
132    #[doc = "Disable this target"]
133    #[doc = ""]
134    pub disable: Option<bool>,
135    #[serde(rename = "from-address")]
136    #[serde(skip_serializing_if = "Option::is_none", default)]
137    #[doc = "`From` address for the mail"]
138    #[doc = ""]
139    pub from_address: Option<String>,
140    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
141    #[doc = "List of email recipients"]
142    #[doc = ""]
143    pub mailto: Vec<String>,
144    #[serde(rename = "mailto-user")]
145    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
146    #[doc = "List of users"]
147    #[doc = ""]
148    pub mailto_user: Vec<String>,
149    #[doc = "The name of the endpoint."]
150    #[doc = ""]
151    pub name: String,
152    #[serde(
153        flatten,
154        default,
155        skip_serializing_if = "::std::collections::HashMap::is_empty"
156    )]
157    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
158}
159#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
160#[doc = "Show if this entry was created by a user or was built-in"]
161#[doc = ""]
162pub enum Origin {
163    #[serde(rename = "builtin")]
164    Builtin,
165    #[serde(rename = "modified-builtin")]
166    ModifiedBuiltin,
167    #[serde(rename = "user-created")]
168    UserCreated,
169}
170impl TryFrom<&str> for Origin {
171    type Error = String;
172    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
173        match value {
174            "builtin" => Ok(Self::Builtin),
175            "modified-builtin" => Ok(Self::ModifiedBuiltin),
176            "user-created" => Ok(Self::UserCreated),
177            v => Err(format!("Unknown variant {v}")),
178        }
179    }
180}
181impl<T> SendmailClient<T>
182where
183    T: crate::client::Client,
184{
185    pub fn name(&self, name: &str) -> name::NameClient<T> {
186        name::NameClient::<T>::new(self.client.clone(), &self.path, name)
187    }
188}