proxmox_api/generated/cluster/notifications/endpoints/
gotify.rs1pub mod name;
2#[derive(Debug, Clone)]
3pub struct GotifyClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> GotifyClient<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, "/gotify"),
15 }
16 }
17}
18impl<T> GotifyClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "Returns a list of all gotify 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> GotifyClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create a new gotify 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, ¶ms).await
41 }
42}
43impl GetOutputItems {
44 pub fn new(name: String, origin: Origin, server: String) -> Self {
45 Self {
46 name,
47 origin,
48 server,
49 comment: ::std::default::Default::default(),
50 disable: ::std::default::Default::default(),
51 additional_properties: ::std::default::Default::default(),
52 }
53 }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
56pub struct GetOutputItems {
57 #[serde(skip_serializing_if = "Option::is_none", default)]
58 #[doc = "Comment"]
59 #[doc = ""]
60 pub comment: Option<String>,
61 #[serde(
62 serialize_with = "crate::types::serialize_bool_optional",
63 deserialize_with = "crate::types::deserialize_bool_optional"
64 )]
65 #[serde(skip_serializing_if = "Option::is_none", default)]
66 #[doc = "Disable this target"]
67 #[doc = ""]
68 pub disable: Option<bool>,
69 #[doc = "The name of the endpoint."]
70 #[doc = ""]
71 pub name: String,
72 #[doc = "Show if this entry was created by a user or was built-in"]
73 #[doc = ""]
74 pub origin: Origin,
75 #[doc = "Server URL"]
76 #[doc = ""]
77 pub server: String,
78 #[serde(
79 flatten,
80 default,
81 skip_serializing_if = "::std::collections::HashMap::is_empty"
82 )]
83 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
84}
85impl PostParams {
86 pub fn new(name: String, server: String, token: String) -> Self {
87 Self {
88 name,
89 server,
90 token,
91 comment: ::std::default::Default::default(),
92 disable: ::std::default::Default::default(),
93 additional_properties: ::std::default::Default::default(),
94 }
95 }
96}
97#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
98pub struct PostParams {
99 #[serde(skip_serializing_if = "Option::is_none", default)]
100 #[doc = "Comment"]
101 #[doc = ""]
102 pub comment: Option<String>,
103 #[serde(
104 serialize_with = "crate::types::serialize_bool_optional",
105 deserialize_with = "crate::types::deserialize_bool_optional"
106 )]
107 #[serde(skip_serializing_if = "Option::is_none", default)]
108 #[doc = "Disable this target"]
109 #[doc = ""]
110 pub disable: Option<bool>,
111 #[doc = "The name of the endpoint."]
112 #[doc = ""]
113 pub name: String,
114 #[doc = "Server URL"]
115 #[doc = ""]
116 pub server: String,
117 #[doc = "Secret token"]
118 #[doc = ""]
119 pub token: String,
120 #[serde(
121 flatten,
122 default,
123 skip_serializing_if = "::std::collections::HashMap::is_empty"
124 )]
125 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
126}
127#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
128#[doc = "Show if this entry was created by a user or was built-in"]
129#[doc = ""]
130pub enum Origin {
131 #[serde(rename = "builtin")]
132 Builtin,
133 #[serde(rename = "modified-builtin")]
134 ModifiedBuiltin,
135 #[serde(rename = "user-created")]
136 UserCreated,
137}
138impl TryFrom<&str> for Origin {
139 type Error = String;
140 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
141 match value {
142 "builtin" => Ok(Self::Builtin),
143 "modified-builtin" => Ok(Self::ModifiedBuiltin),
144 "user-created" => Ok(Self::UserCreated),
145 v => Err(format!("Unknown variant {v}")),
146 }
147 }
148}
149impl<T> GotifyClient<T>
150where
151 T: crate::client::Client,
152{
153 pub fn name(&self, name: &str) -> name::NameClient<T> {
154 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
155 }
156}