proxmox_api/generated/access/
ticket.rs1#[derive(Debug, Clone)]
2pub struct TicketClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> TicketClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/ticket"),
14 }
15 }
16}
17impl<T> TicketClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Dummy. Useful for formatters which want to provide a login page."]
22 #[doc = ""]
23 #[doc = "Accessible without authentication."]
24 pub async fn get(&self) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, &()).await
27 }
28}
29impl<T> TicketClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Create or verify authentication ticket."]
34 #[doc = ""]
35 #[doc = "Accessible without authentication."]
36 pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
37 let path = self.path.to_string();
38 self.client.post(&path, ¶ms).await
39 }
40}
41impl PostOutput {
42 pub fn new(username: String) -> Self {
43 Self {
44 username,
45 csrfpreventiontoken: ::std::default::Default::default(),
46 clustername: ::std::default::Default::default(),
47 ticket: ::std::default::Default::default(),
48 additional_properties: ::std::default::Default::default(),
49 }
50 }
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
53pub struct PostOutput {
54 #[serde(rename = "CSRFPreventionToken")]
55 #[serde(skip_serializing_if = "Option::is_none", default)]
56 pub csrfpreventiontoken: Option<String>,
57 #[serde(skip_serializing_if = "Option::is_none", default)]
58 pub clustername: Option<String>,
59 #[serde(skip_serializing_if = "Option::is_none", default)]
60 pub ticket: Option<String>,
61 pub username: String,
62 #[serde(
63 flatten,
64 default,
65 skip_serializing_if = "::std::collections::HashMap::is_empty"
66 )]
67 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
68}
69impl PostParams {
70 pub fn new(password: String, username: UsernameStr) -> Self {
71 Self {
72 password,
73 username,
74 new_format: ::std::default::Default::default(),
75 otp: ::std::default::Default::default(),
76 path: ::std::default::Default::default(),
77 privs: ::std::default::Default::default(),
78 realm: ::std::default::Default::default(),
79 tfa_challenge: ::std::default::Default::default(),
80 additional_properties: ::std::default::Default::default(),
81 }
82 }
83}
84#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
85pub struct PostParams {
86 #[serde(rename = "new-format")]
87 #[serde(
88 serialize_with = "crate::types::serialize_bool_optional",
89 deserialize_with = "crate::types::deserialize_bool_optional"
90 )]
91 #[serde(skip_serializing_if = "Option::is_none", default)]
92 #[doc = "This parameter is now ignored and assumed to be 1."]
93 #[doc = ""]
94 pub new_format: Option<bool>,
95 #[serde(skip_serializing_if = "Option::is_none", default)]
96 #[doc = "One-time password for Two-factor authentication."]
97 #[doc = ""]
98 pub otp: Option<String>,
99 #[doc = "The secret password. This can also be a valid ticket."]
100 #[doc = ""]
101 pub password: String,
102 #[serde(skip_serializing_if = "Option::is_none", default)]
103 #[doc = "Verify ticket, and check if user have access 'privs' on 'path'"]
104 #[doc = ""]
105 pub path: Option<PathStr>,
106 #[serde(skip_serializing_if = "Option::is_none", default)]
107 #[doc = "Verify ticket, and check if user have access 'privs' on 'path'"]
108 #[doc = ""]
109 pub privs: Option<PrivsStr>,
110 #[serde(skip_serializing_if = "Option::is_none", default)]
111 #[doc = "You can optionally pass the realm using this parameter. Normally the realm is simply added to the username \\\\<username\\\\>@\\\\<realm\\\\>."]
112 #[doc = ""]
113 pub realm: Option<RealmStr>,
114 #[serde(rename = "tfa-challenge")]
115 #[serde(skip_serializing_if = "Option::is_none", default)]
116 #[doc = "The signed TFA challenge string the user wants to respond to."]
117 #[doc = ""]
118 pub tfa_challenge: Option<String>,
119 #[doc = "User name"]
120 #[doc = ""]
121 pub username: UsernameStr,
122 #[serde(
123 flatten,
124 default,
125 skip_serializing_if = "::std::collections::HashMap::is_empty"
126 )]
127 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
128}
129#[derive(Debug, Clone, PartialEq, PartialOrd)]
130pub struct PathStr {
131 value: String,
132}
133impl crate::types::bounded_string::BoundedString for PathStr {
134 const MIN_LENGTH: Option<usize> = None::<usize>;
135 const MAX_LENGTH: Option<usize> = Some(64usize);
136 const DEFAULT: Option<&'static str> = None::<&'static str>;
137 const PATTERN: Option<&'static str> = None::<&'static str>;
138 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
139 fn get_value(&self) -> &str {
140 &self.value
141 }
142 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
143 Self::validate(&value)?;
144 Ok(Self { value })
145 }
146}
147impl std::convert::TryFrom<String> for PathStr {
148 type Error = crate::types::bounded_string::BoundedStringError;
149 fn try_from(value: String) -> Result<Self, Self::Error> {
150 crate::types::bounded_string::BoundedString::new(value)
151 }
152}
153impl ::serde::Serialize for PathStr {
154 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
155 where
156 S: ::serde::Serializer,
157 {
158 crate::types::bounded_string::serialize_bounded_string(self, serializer)
159 }
160}
161impl<'de> ::serde::Deserialize<'de> for PathStr {
162 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
163 where
164 D: ::serde::Deserializer<'de>,
165 {
166 crate::types::bounded_string::deserialize_bounded_string(deserializer)
167 }
168}
169#[derive(Debug, Clone, PartialEq, PartialOrd)]
170pub struct PrivsStr {
171 value: String,
172}
173impl crate::types::bounded_string::BoundedString for PrivsStr {
174 const MIN_LENGTH: Option<usize> = None::<usize>;
175 const MAX_LENGTH: Option<usize> = Some(64usize);
176 const DEFAULT: Option<&'static str> = None::<&'static str>;
177 const PATTERN: Option<&'static str> = None::<&'static str>;
178 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
179 fn get_value(&self) -> &str {
180 &self.value
181 }
182 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
183 Self::validate(&value)?;
184 Ok(Self { value })
185 }
186}
187impl std::convert::TryFrom<String> for PrivsStr {
188 type Error = crate::types::bounded_string::BoundedStringError;
189 fn try_from(value: String) -> Result<Self, Self::Error> {
190 crate::types::bounded_string::BoundedString::new(value)
191 }
192}
193impl ::serde::Serialize for PrivsStr {
194 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
195 where
196 S: ::serde::Serializer,
197 {
198 crate::types::bounded_string::serialize_bounded_string(self, serializer)
199 }
200}
201impl<'de> ::serde::Deserialize<'de> for PrivsStr {
202 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
203 where
204 D: ::serde::Deserializer<'de>,
205 {
206 crate::types::bounded_string::deserialize_bounded_string(deserializer)
207 }
208}
209#[derive(Debug, Clone, PartialEq, PartialOrd)]
210pub struct RealmStr {
211 value: String,
212}
213impl crate::types::bounded_string::BoundedString for RealmStr {
214 const MIN_LENGTH: Option<usize> = None::<usize>;
215 const MAX_LENGTH: Option<usize> = Some(32usize);
216 const DEFAULT: Option<&'static str> = None::<&'static str>;
217 const PATTERN: Option<&'static str> = None::<&'static str>;
218 const TYPE_DESCRIPTION: &'static str = "a string with length at most 32";
219 fn get_value(&self) -> &str {
220 &self.value
221 }
222 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
223 Self::validate(&value)?;
224 Ok(Self { value })
225 }
226}
227impl std::convert::TryFrom<String> for RealmStr {
228 type Error = crate::types::bounded_string::BoundedStringError;
229 fn try_from(value: String) -> Result<Self, Self::Error> {
230 crate::types::bounded_string::BoundedString::new(value)
231 }
232}
233impl ::serde::Serialize for RealmStr {
234 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
235 where
236 S: ::serde::Serializer,
237 {
238 crate::types::bounded_string::serialize_bounded_string(self, serializer)
239 }
240}
241impl<'de> ::serde::Deserialize<'de> for RealmStr {
242 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
243 where
244 D: ::serde::Deserializer<'de>,
245 {
246 crate::types::bounded_string::deserialize_bounded_string(deserializer)
247 }
248}
249#[derive(Debug, Clone, PartialEq, PartialOrd)]
250pub struct UsernameStr {
251 value: String,
252}
253impl crate::types::bounded_string::BoundedString for UsernameStr {
254 const MIN_LENGTH: Option<usize> = None::<usize>;
255 const MAX_LENGTH: Option<usize> = Some(64usize);
256 const DEFAULT: Option<&'static str> = None::<&'static str>;
257 const PATTERN: Option<&'static str> = None::<&'static str>;
258 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
259 fn get_value(&self) -> &str {
260 &self.value
261 }
262 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
263 Self::validate(&value)?;
264 Ok(Self { value })
265 }
266}
267impl std::convert::TryFrom<String> for UsernameStr {
268 type Error = crate::types::bounded_string::BoundedStringError;
269 fn try_from(value: String) -> Result<Self, Self::Error> {
270 crate::types::bounded_string::BoundedString::new(value)
271 }
272}
273impl ::serde::Serialize for UsernameStr {
274 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
275 where
276 S: ::serde::Serializer,
277 {
278 crate::types::bounded_string::serialize_bounded_string(self, serializer)
279 }
280}
281impl<'de> ::serde::Deserialize<'de> for UsernameStr {
282 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
283 where
284 D: ::serde::Deserializer<'de>,
285 {
286 crate::types::bounded_string::deserialize_bounded_string(deserializer)
287 }
288}