Skip to main content

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

1pub mod name;
2#[derive(Debug, Clone)]
3pub struct WebhookClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> WebhookClient<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, "/webhook"),
15        }
16    }
17}
18impl<T> WebhookClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "Returns a list of all webhook endpoints"]
23    #[doc = ""]
24    #[doc = "Permission check: 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> WebhookClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new webhook 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(method: Method, name: String, origin: Origin, url: String) -> Self {
45        Self {
46            method,
47            name,
48            origin,
49            url,
50            body: ::std::default::Default::default(),
51            comment: ::std::default::Default::default(),
52            disable: ::std::default::Default::default(),
53            header: ::std::default::Default::default(),
54            secret: ::std::default::Default::default(),
55            additional_properties: ::std::default::Default::default(),
56        }
57    }
58}
59#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
60pub struct GetOutputItems {
61    #[serde(skip_serializing_if = "Option::is_none", default)]
62    #[doc = "HTTP body, base64 encoded"]
63    #[doc = ""]
64    pub body: Option<String>,
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    #[doc = "Comment"]
67    #[doc = ""]
68    pub comment: Option<String>,
69    #[serde(
70        serialize_with = "crate::types::serialize_bool_optional",
71        deserialize_with = "crate::types::deserialize_bool_optional"
72    )]
73    #[serde(skip_serializing_if = "Option::is_none", default)]
74    #[doc = "Disable this target"]
75    #[doc = ""]
76    pub disable: Option<bool>,
77    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
78    #[doc = "HTTP headers to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
79    #[doc = ""]
80    pub header: Vec<String>,
81    #[doc = "HTTP method"]
82    #[doc = ""]
83    pub method: Method,
84    #[doc = "The name of the endpoint."]
85    #[doc = ""]
86    pub name: String,
87    #[doc = "Show if this entry was created by a user or was built-in"]
88    #[doc = ""]
89    pub origin: Origin,
90    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
91    #[doc = "Secrets to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
92    #[doc = ""]
93    pub secret: Vec<String>,
94    #[doc = "Server URL"]
95    #[doc = ""]
96    pub url: String,
97    #[serde(
98        flatten,
99        default,
100        skip_serializing_if = "::std::collections::HashMap::is_empty"
101    )]
102    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
103}
104impl PostParams {
105    pub fn new(method: Method, name: String, url: String) -> Self {
106        Self {
107            method,
108            name,
109            url,
110            body: ::std::default::Default::default(),
111            comment: ::std::default::Default::default(),
112            disable: ::std::default::Default::default(),
113            header: ::std::default::Default::default(),
114            secret: ::std::default::Default::default(),
115            additional_properties: ::std::default::Default::default(),
116        }
117    }
118}
119#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
120pub struct PostParams {
121    #[serde(skip_serializing_if = "Option::is_none", default)]
122    #[doc = "HTTP body, base64 encoded"]
123    #[doc = ""]
124    pub body: Option<String>,
125    #[serde(skip_serializing_if = "Option::is_none", default)]
126    #[doc = "Comment"]
127    #[doc = ""]
128    pub comment: Option<String>,
129    #[serde(
130        serialize_with = "crate::types::serialize_bool_optional",
131        deserialize_with = "crate::types::deserialize_bool_optional"
132    )]
133    #[serde(skip_serializing_if = "Option::is_none", default)]
134    #[doc = "Disable this target"]
135    #[doc = ""]
136    pub disable: Option<bool>,
137    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
138    #[doc = "HTTP headers to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
139    #[doc = ""]
140    pub header: Vec<String>,
141    #[doc = "HTTP method"]
142    #[doc = ""]
143    pub method: Method,
144    #[doc = "The name of the endpoint."]
145    #[doc = ""]
146    pub name: String,
147    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
148    #[doc = "Secrets to set. These have to be formatted as a property string in the format name=\\\\<name\\\\>,value=\\\\<base64 of value\\\\>"]
149    #[doc = ""]
150    pub secret: Vec<String>,
151    #[doc = "Server URL"]
152    #[doc = ""]
153    pub url: 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(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
162#[doc = "HTTP method"]
163#[doc = ""]
164pub enum Method {
165    #[serde(rename = "get")]
166    Get,
167    #[serde(rename = "post")]
168    Post,
169    #[serde(rename = "put")]
170    Put,
171}
172impl TryFrom<&str> for Method {
173    type Error = String;
174    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
175        match value {
176            "get" => Ok(Self::Get),
177            "post" => Ok(Self::Post),
178            "put" => Ok(Self::Put),
179            v => Err(format!("Unknown variant {v}")),
180        }
181    }
182}
183#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
184#[doc = "Show if this entry was created by a user or was built-in"]
185#[doc = ""]
186pub enum Origin {
187    #[serde(rename = "builtin")]
188    Builtin,
189    #[serde(rename = "modified-builtin")]
190    ModifiedBuiltin,
191    #[serde(rename = "user-created")]
192    UserCreated,
193}
194impl TryFrom<&str> for Origin {
195    type Error = String;
196    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
197        match value {
198            "builtin" => Ok(Self::Builtin),
199            "modified-builtin" => Ok(Self::ModifiedBuiltin),
200            "user-created" => Ok(Self::UserCreated),
201            v => Err(format!("Unknown variant {v}")),
202        }
203    }
204}
205impl<T> WebhookClient<T>
206where
207    T: crate::client::Client,
208{
209    pub fn name(&self, name: &str) -> name::NameClient<T> {
210        name::NameClient::<T>::new(self.client.clone(), &self.path, name)
211    }
212}