Skip to main content

proxmox_api/generated/access/openid/
login.rs

1#[derive(Debug, Clone)]
2pub struct LoginClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> LoginClient<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, "/login"),
14        }
15    }
16}
17impl<T> LoginClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Verify OpenID authorization code and create a ticket."]
22    #[doc = ""]
23    #[doc = "Accessible without authentication."]
24    pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.post(&path, &params).await
27    }
28}
29#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
30pub struct CapPostOutputCap {
31    #[serde(
32        flatten,
33        default,
34        skip_serializing_if = "::std::collections::HashMap::is_empty"
35    )]
36    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
37}
38impl PostOutput {
39    pub fn new(
40        csrfpreventiontoken: String,
41        cap: CapPostOutputCap,
42        ticket: String,
43        username: String,
44    ) -> Self {
45        Self {
46            csrfpreventiontoken,
47            cap,
48            ticket,
49            username,
50            clustername: ::std::default::Default::default(),
51            additional_properties: ::std::default::Default::default(),
52        }
53    }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
56pub struct PostOutput {
57    #[serde(rename = "CSRFPreventionToken")]
58    pub csrfpreventiontoken: String,
59    pub cap: CapPostOutputCap,
60    #[serde(skip_serializing_if = "Option::is_none", default)]
61    pub clustername: Option<String>,
62    pub ticket: String,
63    pub username: String,
64    #[serde(
65        flatten,
66        default,
67        skip_serializing_if = "::std::collections::HashMap::is_empty"
68    )]
69    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
70}
71impl PostParams {
72    pub fn new(code: CodeStr, redirect_url: RedirectUrlStr, state: StateStr) -> Self {
73        Self {
74            code,
75            redirect_url,
76            state,
77            additional_properties: ::std::default::Default::default(),
78        }
79    }
80}
81#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
82pub struct PostParams {
83    #[doc = "OpenId authorization code."]
84    #[doc = ""]
85    pub code: CodeStr,
86    #[serde(rename = "redirect-url")]
87    #[doc = "Redirection Url. The client should set this to the used server url (location.origin)."]
88    #[doc = ""]
89    pub redirect_url: RedirectUrlStr,
90    #[doc = "OpenId state."]
91    #[doc = ""]
92    pub state: StateStr,
93    #[serde(
94        flatten,
95        default,
96        skip_serializing_if = "::std::collections::HashMap::is_empty"
97    )]
98    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
99}
100#[derive(Debug, Clone, PartialEq, PartialOrd)]
101pub struct CodeStr {
102    value: String,
103}
104impl crate::types::bounded_string::BoundedString for CodeStr {
105    const MIN_LENGTH: Option<usize> = None::<usize>;
106    const MAX_LENGTH: Option<usize> = Some(4096usize);
107    const DEFAULT: Option<&'static str> = None::<&'static str>;
108    const PATTERN: Option<&'static str> = None::<&'static str>;
109    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
110    fn get_value(&self) -> &str {
111        &self.value
112    }
113    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
114        Self::validate(&value)?;
115        Ok(Self { value })
116    }
117}
118impl std::convert::TryFrom<String> for CodeStr {
119    type Error = crate::types::bounded_string::BoundedStringError;
120    fn try_from(value: String) -> Result<Self, Self::Error> {
121        crate::types::bounded_string::BoundedString::new(value)
122    }
123}
124impl ::serde::Serialize for CodeStr {
125    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
126    where
127        S: ::serde::Serializer,
128    {
129        crate::types::bounded_string::serialize_bounded_string(self, serializer)
130    }
131}
132impl<'de> ::serde::Deserialize<'de> for CodeStr {
133    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
134    where
135        D: ::serde::Deserializer<'de>,
136    {
137        crate::types::bounded_string::deserialize_bounded_string(deserializer)
138    }
139}
140#[derive(Debug, Clone, PartialEq, PartialOrd)]
141pub struct RedirectUrlStr {
142    value: String,
143}
144impl crate::types::bounded_string::BoundedString for RedirectUrlStr {
145    const MIN_LENGTH: Option<usize> = None::<usize>;
146    const MAX_LENGTH: Option<usize> = Some(255usize);
147    const DEFAULT: Option<&'static str> = None::<&'static str>;
148    const PATTERN: Option<&'static str> = None::<&'static str>;
149    const TYPE_DESCRIPTION: &'static str = "a string with length at most 255";
150    fn get_value(&self) -> &str {
151        &self.value
152    }
153    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
154        Self::validate(&value)?;
155        Ok(Self { value })
156    }
157}
158impl std::convert::TryFrom<String> for RedirectUrlStr {
159    type Error = crate::types::bounded_string::BoundedStringError;
160    fn try_from(value: String) -> Result<Self, Self::Error> {
161        crate::types::bounded_string::BoundedString::new(value)
162    }
163}
164impl ::serde::Serialize for RedirectUrlStr {
165    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
166    where
167        S: ::serde::Serializer,
168    {
169        crate::types::bounded_string::serialize_bounded_string(self, serializer)
170    }
171}
172impl<'de> ::serde::Deserialize<'de> for RedirectUrlStr {
173    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
174    where
175        D: ::serde::Deserializer<'de>,
176    {
177        crate::types::bounded_string::deserialize_bounded_string(deserializer)
178    }
179}
180#[derive(Debug, Clone, PartialEq, PartialOrd)]
181pub struct StateStr {
182    value: String,
183}
184impl crate::types::bounded_string::BoundedString for StateStr {
185    const MIN_LENGTH: Option<usize> = None::<usize>;
186    const MAX_LENGTH: Option<usize> = Some(1024usize);
187    const DEFAULT: Option<&'static str> = None::<&'static str>;
188    const PATTERN: Option<&'static str> = None::<&'static str>;
189    const TYPE_DESCRIPTION: &'static str = "a string with length at most 1024";
190    fn get_value(&self) -> &str {
191        &self.value
192    }
193    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
194        Self::validate(&value)?;
195        Ok(Self { value })
196    }
197}
198impl std::convert::TryFrom<String> for StateStr {
199    type Error = crate::types::bounded_string::BoundedStringError;
200    fn try_from(value: String) -> Result<Self, Self::Error> {
201        crate::types::bounded_string::BoundedString::new(value)
202    }
203}
204impl ::serde::Serialize for StateStr {
205    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
206    where
207        S: ::serde::Serializer,
208    {
209        crate::types::bounded_string::serialize_bounded_string(self, serializer)
210    }
211}
212impl<'de> ::serde::Deserialize<'de> for StateStr {
213    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
214    where
215        D: ::serde::Deserializer<'de>,
216    {
217        crate::types::bounded_string::deserialize_bounded_string(deserializer)
218    }
219}