proxmox_api/generated/cluster/notifications/endpoints/smtp/
name.rs1#[derive(Debug, Clone)]
2pub struct NameClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> NameClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str, name: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}/{}", parent_path, name),
14 }
15 }
16}
17impl<T> NameClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Remove smtp endpoint"]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/mapping/notifications\", [\"Mapping.Modify\"])"]
24 pub async fn delete(&self) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.delete(&path, &()).await
27 }
28}
29impl<T> NameClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Return a specific smtp endpoint"]
34 #[doc = ""]
35 #[doc = "Permission check: or(perm(\"/mapping/notifications\", [\"Mapping.Modify\"]), perm(\"/mapping/notifications\", [\"Mapping.Audit\"]))"]
36 pub async fn get(&self) -> Result<GetOutput, T::Error> {
37 let path = self.path.to_string();
38 self.client.get(&path, &()).await
39 }
40}
41impl<T> NameClient<T>
42where
43 T: crate::client::Client,
44{
45 #[doc = "Update existing smtp endpoint"]
46 #[doc = ""]
47 #[doc = "Permission check: and(perm(\"/mapping/notifications\", [\"Mapping.Modify\"]), or(perm(\"/\", [\"Sys.Audit\", \"Sys.Modify\"]), perm(\"/\", [\"Sys.AccessNetwork\"])))"]
48 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49 let path = self.path.to_string();
50 self.client.put(&path, ¶ms).await
51 }
52}
53impl GetOutput {
54 pub fn new(from_address: String, name: String, server: String) -> Self {
55 Self {
56 from_address,
57 name,
58 server,
59 author: ::std::default::Default::default(),
60 comment: ::std::default::Default::default(),
61 digest: ::std::default::Default::default(),
62 disable: ::std::default::Default::default(),
63 mailto: ::std::default::Default::default(),
64 mailto_user: ::std::default::Default::default(),
65 mode: ::std::default::Default::default(),
66 port: ::std::default::Default::default(),
67 username: ::std::default::Default::default(),
68 additional_properties: ::std::default::Default::default(),
69 }
70 }
71}
72#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
73pub struct GetOutput {
74 #[serde(skip_serializing_if = "Option::is_none", default)]
75 #[doc = "Author of the mail. Defaults to 'Proxmox VE'."]
76 #[doc = ""]
77 pub author: Option<String>,
78 #[serde(skip_serializing_if = "Option::is_none", default)]
79 #[doc = "Comment"]
80 #[doc = ""]
81 pub comment: Option<String>,
82 #[serde(skip_serializing_if = "Option::is_none", default)]
83 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
84 #[doc = ""]
85 pub digest: Option<DigestStr>,
86 #[serde(
87 serialize_with = "crate::types::serialize_bool_optional",
88 deserialize_with = "crate::types::deserialize_bool_optional"
89 )]
90 #[serde(skip_serializing_if = "Option::is_none", default)]
91 #[doc = "Disable this target"]
92 #[doc = ""]
93 pub disable: Option<bool>,
94 #[serde(rename = "from-address")]
95 #[doc = "`From` address for the mail"]
96 #[doc = ""]
97 pub from_address: String,
98 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
99 #[doc = "List of email recipients"]
100 #[doc = ""]
101 pub mailto: Vec<String>,
102 #[serde(rename = "mailto-user")]
103 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
104 #[doc = "List of users"]
105 #[doc = ""]
106 pub mailto_user: Vec<String>,
107 #[serde(skip_serializing_if = "Option::is_none", default)]
108 #[doc = "Determine which encryption method shall be used for the connection."]
109 #[doc = ""]
110 pub mode: Option<Mode>,
111 #[doc = "The name of the endpoint."]
112 #[doc = ""]
113 pub name: String,
114 #[serde(
115 serialize_with = "crate::types::serialize_int_optional",
116 deserialize_with = "crate::types::deserialize_int_optional"
117 )]
118 #[serde(skip_serializing_if = "Option::is_none", default)]
119 #[doc = "The port to be used. Defaults to 465 for TLS based connections, 587 for STARTTLS based connections and port 25 for insecure plain-text connections."]
120 #[doc = ""]
121 pub port: Option<i64>,
122 #[doc = "The address of the SMTP server."]
123 #[doc = ""]
124 pub server: String,
125 #[serde(skip_serializing_if = "Option::is_none", default)]
126 #[doc = "Username for SMTP authentication"]
127 #[doc = ""]
128 pub username: Option<String>,
129 #[serde(
130 flatten,
131 default,
132 skip_serializing_if = "::std::collections::HashMap::is_empty"
133 )]
134 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
135}
136#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
137pub struct PutParams {
138 #[serde(skip_serializing_if = "Option::is_none", default)]
139 #[doc = "Author of the mail. Defaults to 'Proxmox VE'."]
140 #[doc = ""]
141 pub author: Option<String>,
142 #[serde(skip_serializing_if = "Option::is_none", default)]
143 #[doc = "Comment"]
144 #[doc = ""]
145 pub comment: Option<String>,
146 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
147 #[doc = "A list of settings you want to delete."]
148 #[doc = ""]
149 pub delete: Vec<String>,
150 #[serde(skip_serializing_if = "Option::is_none", default)]
151 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
152 #[doc = ""]
153 pub digest: Option<DigestStr>,
154 #[serde(
155 serialize_with = "crate::types::serialize_bool_optional",
156 deserialize_with = "crate::types::deserialize_bool_optional"
157 )]
158 #[serde(skip_serializing_if = "Option::is_none", default)]
159 #[doc = "Disable this target"]
160 #[doc = ""]
161 pub disable: Option<bool>,
162 #[serde(rename = "from-address")]
163 #[serde(skip_serializing_if = "Option::is_none", default)]
164 #[doc = "`From` address for the mail"]
165 #[doc = ""]
166 pub from_address: Option<String>,
167 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
168 #[doc = "List of email recipients"]
169 #[doc = ""]
170 pub mailto: Vec<String>,
171 #[serde(rename = "mailto-user")]
172 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
173 #[doc = "List of users"]
174 #[doc = ""]
175 pub mailto_user: Vec<String>,
176 #[serde(skip_serializing_if = "Option::is_none", default)]
177 #[doc = "Determine which encryption method shall be used for the connection."]
178 #[doc = ""]
179 pub mode: Option<Mode>,
180 #[serde(skip_serializing_if = "Option::is_none", default)]
181 #[doc = "Password for SMTP authentication"]
182 #[doc = ""]
183 pub password: Option<String>,
184 #[serde(
185 serialize_with = "crate::types::serialize_int_optional",
186 deserialize_with = "crate::types::deserialize_int_optional"
187 )]
188 #[serde(skip_serializing_if = "Option::is_none", default)]
189 #[doc = "The port to be used. Defaults to 465 for TLS based connections, 587 for STARTTLS based connections and port 25 for insecure plain-text connections."]
190 #[doc = ""]
191 pub port: Option<i64>,
192 #[serde(skip_serializing_if = "Option::is_none", default)]
193 #[doc = "The address of the SMTP server."]
194 #[doc = ""]
195 pub server: Option<String>,
196 #[serde(skip_serializing_if = "Option::is_none", default)]
197 #[doc = "Username for SMTP authentication"]
198 #[doc = ""]
199 pub username: Option<String>,
200 #[serde(
201 flatten,
202 default,
203 skip_serializing_if = "::std::collections::HashMap::is_empty"
204 )]
205 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
206}
207#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
208#[doc = "Determine which encryption method shall be used for the connection."]
209#[doc = ""]
210pub enum Mode {
211 #[serde(rename = "insecure")]
212 Insecure,
213 #[serde(rename = "starttls")]
214 Starttls,
215 #[serde(rename = "tls")]
216 #[default]
217 Tls,
218}
219impl TryFrom<&str> for Mode {
220 type Error = String;
221 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
222 match value {
223 "insecure" => Ok(Self::Insecure),
224 "starttls" => Ok(Self::Starttls),
225 "tls" => Ok(Self::Tls),
226 v => Err(format!("Unknown variant {v}")),
227 }
228 }
229}
230#[derive(Debug, Clone, PartialEq, PartialOrd)]
231pub struct DigestStr {
232 value: String,
233}
234impl crate::types::bounded_string::BoundedString for DigestStr {
235 const MIN_LENGTH: Option<usize> = None::<usize>;
236 const MAX_LENGTH: Option<usize> = Some(64usize);
237 const DEFAULT: Option<&'static str> = None::<&'static str>;
238 const PATTERN: Option<&'static str> = None::<&'static str>;
239 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
240 fn get_value(&self) -> &str {
241 &self.value
242 }
243 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
244 Self::validate(&value)?;
245 Ok(Self { value })
246 }
247}
248impl std::convert::TryFrom<String> for DigestStr {
249 type Error = crate::types::bounded_string::BoundedStringError;
250 fn try_from(value: String) -> Result<Self, Self::Error> {
251 crate::types::bounded_string::BoundedString::new(value)
252 }
253}
254impl ::serde::Serialize for DigestStr {
255 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
256 where
257 S: ::serde::Serializer,
258 {
259 crate::types::bounded_string::serialize_bounded_string(self, serializer)
260 }
261}
262impl<'de> ::serde::Deserialize<'de> for DigestStr {
263 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
264 where
265 D: ::serde::Deserializer<'de>,
266 {
267 crate::types::bounded_string::deserialize_bounded_string(deserializer)
268 }
269}