Skip to main content

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

1#[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 sendmail 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 sendmail 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 sendmail 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, &params).await
51    }
52}
53impl GetOutput {
54    pub fn new(name: String) -> Self {
55        Self {
56            name,
57            author: ::std::default::Default::default(),
58            comment: ::std::default::Default::default(),
59            digest: ::std::default::Default::default(),
60            disable: ::std::default::Default::default(),
61            from_address: ::std::default::Default::default(),
62            mailto: ::std::default::Default::default(),
63            mailto_user: ::std::default::Default::default(),
64            additional_properties: ::std::default::Default::default(),
65        }
66    }
67}
68#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
69pub struct GetOutput {
70    #[serde(skip_serializing_if = "Option::is_none", default)]
71    #[doc = "Author of the mail"]
72    #[doc = ""]
73    pub author: Option<String>,
74    #[serde(skip_serializing_if = "Option::is_none", default)]
75    #[doc = "Comment"]
76    #[doc = ""]
77    pub comment: Option<String>,
78    #[serde(skip_serializing_if = "Option::is_none", default)]
79    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
80    #[doc = ""]
81    pub digest: Option<DigestStr>,
82    #[serde(
83        serialize_with = "crate::types::serialize_bool_optional",
84        deserialize_with = "crate::types::deserialize_bool_optional"
85    )]
86    #[serde(skip_serializing_if = "Option::is_none", default)]
87    #[doc = "Disable this target"]
88    #[doc = ""]
89    pub disable: Option<bool>,
90    #[serde(rename = "from-address")]
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    #[doc = "`From` address for the mail"]
93    #[doc = ""]
94    pub from_address: Option<String>,
95    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
96    #[doc = "List of email recipients"]
97    #[doc = ""]
98    pub mailto: Vec<String>,
99    #[serde(rename = "mailto-user")]
100    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
101    #[doc = "List of users"]
102    #[doc = ""]
103    pub mailto_user: Vec<String>,
104    #[doc = "The name of the endpoint."]
105    #[doc = ""]
106    pub name: String,
107    #[serde(
108        flatten,
109        default,
110        skip_serializing_if = "::std::collections::HashMap::is_empty"
111    )]
112    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
113}
114#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
115pub struct PutParams {
116    #[serde(skip_serializing_if = "Option::is_none", default)]
117    #[doc = "Author of the mail"]
118    #[doc = ""]
119    pub author: Option<String>,
120    #[serde(skip_serializing_if = "Option::is_none", default)]
121    #[doc = "Comment"]
122    #[doc = ""]
123    pub comment: Option<String>,
124    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
125    #[doc = "A list of settings you want to delete."]
126    #[doc = ""]
127    pub delete: Vec<String>,
128    #[serde(skip_serializing_if = "Option::is_none", default)]
129    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
130    #[doc = ""]
131    pub digest: Option<DigestStr>,
132    #[serde(
133        serialize_with = "crate::types::serialize_bool_optional",
134        deserialize_with = "crate::types::deserialize_bool_optional"
135    )]
136    #[serde(skip_serializing_if = "Option::is_none", default)]
137    #[doc = "Disable this target"]
138    #[doc = ""]
139    pub disable: Option<bool>,
140    #[serde(rename = "from-address")]
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    #[doc = "`From` address for the mail"]
143    #[doc = ""]
144    pub from_address: Option<String>,
145    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
146    #[doc = "List of email recipients"]
147    #[doc = ""]
148    pub mailto: Vec<String>,
149    #[serde(rename = "mailto-user")]
150    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
151    #[doc = "List of users"]
152    #[doc = ""]
153    pub mailto_user: Vec<String>,
154    #[serde(
155        flatten,
156        default,
157        skip_serializing_if = "::std::collections::HashMap::is_empty"
158    )]
159    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
160}
161#[derive(Debug, Clone, PartialEq, PartialOrd)]
162pub struct DigestStr {
163    value: String,
164}
165impl crate::types::bounded_string::BoundedString for DigestStr {
166    const MIN_LENGTH: Option<usize> = None::<usize>;
167    const MAX_LENGTH: Option<usize> = Some(64usize);
168    const DEFAULT: Option<&'static str> = None::<&'static str>;
169    const PATTERN: Option<&'static str> = None::<&'static str>;
170    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
171    fn get_value(&self) -> &str {
172        &self.value
173    }
174    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
175        Self::validate(&value)?;
176        Ok(Self { value })
177    }
178}
179impl std::convert::TryFrom<String> for DigestStr {
180    type Error = crate::types::bounded_string::BoundedStringError;
181    fn try_from(value: String) -> Result<Self, Self::Error> {
182        crate::types::bounded_string::BoundedString::new(value)
183    }
184}
185impl ::serde::Serialize for DigestStr {
186    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
187    where
188        S: ::serde::Serializer,
189    {
190        crate::types::bounded_string::serialize_bounded_string(self, serializer)
191    }
192}
193impl<'de> ::serde::Deserialize<'de> for DigestStr {
194    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
195    where
196        D: ::serde::Deserializer<'de>,
197    {
198        crate::types::bounded_string::deserialize_bounded_string(deserializer)
199    }
200}