Skip to main content

proxmox_api/generated/cluster/notifications/endpoints/webhook/
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 webhook 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 webhook 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 webhook 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(method: Method, name: String, url: String) -> Self {
55        Self {
56            method,
57            name,
58            url,
59            body: ::std::default::Default::default(),
60            comment: ::std::default::Default::default(),
61            digest: ::std::default::Default::default(),
62            disable: ::std::default::Default::default(),
63            header: ::std::default::Default::default(),
64            secret: ::std::default::Default::default(),
65            additional_properties: ::std::default::Default::default(),
66        }
67    }
68}
69#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
70pub struct GetOutput {
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    #[doc = "HTTP body, base64 encoded"]
73    #[doc = ""]
74    pub body: Option<String>,
75    #[serde(skip_serializing_if = "Option::is_none", default)]
76    #[doc = "Comment"]
77    #[doc = ""]
78    pub comment: Option<String>,
79    #[serde(skip_serializing_if = "Option::is_none", default)]
80    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
81    #[doc = ""]
82    pub digest: Option<DigestStr>,
83    #[serde(
84        serialize_with = "crate::types::serialize_bool_optional",
85        deserialize_with = "crate::types::deserialize_bool_optional"
86    )]
87    #[serde(skip_serializing_if = "Option::is_none", default)]
88    #[doc = "Disable this target"]
89    #[doc = ""]
90    pub disable: Option<bool>,
91    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
92    #[doc = "HTTP headers to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
93    #[doc = ""]
94    pub header: Vec<String>,
95    #[doc = "HTTP method"]
96    #[doc = ""]
97    pub method: Method,
98    #[doc = "The name of the endpoint."]
99    #[doc = ""]
100    pub name: String,
101    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
102    #[doc = "Secrets to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
103    #[doc = ""]
104    pub secret: Vec<String>,
105    #[doc = "Server URL"]
106    #[doc = ""]
107    pub url: String,
108    #[serde(
109        flatten,
110        default,
111        skip_serializing_if = "::std::collections::HashMap::is_empty"
112    )]
113    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
114}
115#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
116pub struct PutParams {
117    #[serde(skip_serializing_if = "Option::is_none", default)]
118    #[doc = "HTTP body, base64 encoded"]
119    #[doc = ""]
120    pub body: Option<String>,
121    #[serde(skip_serializing_if = "Option::is_none", default)]
122    #[doc = "Comment"]
123    #[doc = ""]
124    pub comment: Option<String>,
125    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
126    #[doc = "A list of settings you want to delete."]
127    #[doc = ""]
128    pub delete: Vec<String>,
129    #[serde(skip_serializing_if = "Option::is_none", default)]
130    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
131    #[doc = ""]
132    pub digest: Option<DigestStr>,
133    #[serde(
134        serialize_with = "crate::types::serialize_bool_optional",
135        deserialize_with = "crate::types::deserialize_bool_optional"
136    )]
137    #[serde(skip_serializing_if = "Option::is_none", default)]
138    #[doc = "Disable this target"]
139    #[doc = ""]
140    pub disable: Option<bool>,
141    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
142    #[doc = "HTTP headers to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
143    #[doc = ""]
144    pub header: Vec<String>,
145    #[serde(skip_serializing_if = "Option::is_none", default)]
146    #[doc = "HTTP method"]
147    #[doc = ""]
148    pub method: Option<Method>,
149    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
150    #[doc = "Secrets to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
151    #[doc = ""]
152    pub secret: Vec<String>,
153    #[serde(skip_serializing_if = "Option::is_none", default)]
154    #[doc = "Server URL"]
155    #[doc = ""]
156    pub url: Option<String>,
157    #[serde(
158        flatten,
159        default,
160        skip_serializing_if = "::std::collections::HashMap::is_empty"
161    )]
162    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
163}
164#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
165#[doc = "HTTP method"]
166#[doc = ""]
167pub enum Method {
168    #[serde(rename = "get")]
169    Get,
170    #[serde(rename = "post")]
171    Post,
172    #[serde(rename = "put")]
173    Put,
174}
175impl TryFrom<&str> for Method {
176    type Error = String;
177    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
178        match value {
179            "get" => Ok(Self::Get),
180            "post" => Ok(Self::Post),
181            "put" => Ok(Self::Put),
182            v => Err(format!("Unknown variant {v}")),
183        }
184    }
185}
186#[derive(Debug, Clone, PartialEq, PartialOrd)]
187pub struct DigestStr {
188    value: String,
189}
190impl crate::types::bounded_string::BoundedString for DigestStr {
191    const MIN_LENGTH: Option<usize> = None::<usize>;
192    const MAX_LENGTH: Option<usize> = Some(64usize);
193    const DEFAULT: Option<&'static str> = None::<&'static str>;
194    const PATTERN: Option<&'static str> = None::<&'static str>;
195    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
196    fn get_value(&self) -> &str {
197        &self.value
198    }
199    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
200        Self::validate(&value)?;
201        Ok(Self { value })
202    }
203}
204impl std::convert::TryFrom<String> for DigestStr {
205    type Error = crate::types::bounded_string::BoundedStringError;
206    fn try_from(value: String) -> Result<Self, Self::Error> {
207        crate::types::bounded_string::BoundedString::new(value)
208    }
209}
210impl ::serde::Serialize for DigestStr {
211    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
212    where
213        S: ::serde::Serializer,
214    {
215        crate::types::bounded_string::serialize_bounded_string(self, serializer)
216    }
217}
218impl<'de> ::serde::Deserialize<'de> for DigestStr {
219    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
220    where
221        D: ::serde::Deserializer<'de>,
222    {
223        crate::types::bounded_string::deserialize_bounded_string(deserializer)
224    }
225}