Skip to main content

proxmox_api/generated/access/
password.rs

1#[derive(Debug, Clone)]
2pub struct PasswordClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> PasswordClient<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, "/password"),
14        }
15    }
16}
17impl<T> PasswordClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Change user password."]
22    #[doc = ""]
23    #[doc = "Permission check: or(userid-param(\"self\"), and(userid-param(\"Realm.AllocateUser\"), userid-group([\"User.Modify\"])))"]
24    #[doc = "Each user is allowed to change their own password. A user can change the password of another user if they have 'Realm.AllocateUser' (on the realm of user \\<userid\\>) and 'User.Modify' permission on /access/groups/\\<group\\> on a group where user \\<userid\\> is member of. For the PAM realm, a password change does not take  effect cluster-wide, but only applies to the local node."]
25    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
26        let path = self.path.to_string();
27        self.client.put(&path, &params).await
28    }
29}
30impl PutParams {
31    pub fn new(password: PasswordStr, userid: UseridStr) -> Self {
32        Self {
33            password,
34            userid,
35            confirmation_password: ::std::default::Default::default(),
36            additional_properties: ::std::default::Default::default(),
37        }
38    }
39}
40#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
41pub struct PutParams {
42    #[serde(rename = "confirmation-password")]
43    #[serde(skip_serializing_if = "Option::is_none", default)]
44    #[doc = "The current password of the user performing the change."]
45    #[doc = ""]
46    pub confirmation_password: Option<ConfirmationPasswordStr>,
47    #[doc = "The new password."]
48    #[doc = ""]
49    pub password: PasswordStr,
50    #[doc = "Full User ID, in the `name@realm` format."]
51    #[doc = ""]
52    pub userid: UseridStr,
53    #[serde(
54        flatten,
55        default,
56        skip_serializing_if = "::std::collections::HashMap::is_empty"
57    )]
58    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
59}
60#[derive(Debug, Clone, PartialEq, PartialOrd)]
61pub struct ConfirmationPasswordStr {
62    value: String,
63}
64impl crate::types::bounded_string::BoundedString for ConfirmationPasswordStr {
65    const MIN_LENGTH: Option<usize> = Some(5usize);
66    const MAX_LENGTH: Option<usize> = Some(64usize);
67    const DEFAULT: Option<&'static str> = None::<&'static str>;
68    const PATTERN: Option<&'static str> = None::<&'static str>;
69    const TYPE_DESCRIPTION: &'static str = "a string with length between 5 and 64";
70    fn get_value(&self) -> &str {
71        &self.value
72    }
73    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
74        Self::validate(&value)?;
75        Ok(Self { value })
76    }
77}
78impl std::convert::TryFrom<String> for ConfirmationPasswordStr {
79    type Error = crate::types::bounded_string::BoundedStringError;
80    fn try_from(value: String) -> Result<Self, Self::Error> {
81        crate::types::bounded_string::BoundedString::new(value)
82    }
83}
84impl ::serde::Serialize for ConfirmationPasswordStr {
85    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
86    where
87        S: ::serde::Serializer,
88    {
89        crate::types::bounded_string::serialize_bounded_string(self, serializer)
90    }
91}
92impl<'de> ::serde::Deserialize<'de> for ConfirmationPasswordStr {
93    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
94    where
95        D: ::serde::Deserializer<'de>,
96    {
97        crate::types::bounded_string::deserialize_bounded_string(deserializer)
98    }
99}
100#[derive(Debug, Clone, PartialEq, PartialOrd)]
101pub struct PasswordStr {
102    value: String,
103}
104impl crate::types::bounded_string::BoundedString for PasswordStr {
105    const MIN_LENGTH: Option<usize> = Some(8usize);
106    const MAX_LENGTH: Option<usize> = Some(64usize);
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 between 8 and 64";
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 PasswordStr {
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 PasswordStr {
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 PasswordStr {
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 UseridStr {
142    value: String,
143}
144impl crate::types::bounded_string::BoundedString for UseridStr {
145    const MIN_LENGTH: Option<usize> = None::<usize>;
146    const MAX_LENGTH: Option<usize> = Some(64usize);
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 64";
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 UseridStr {
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 UseridStr {
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 UseridStr {
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}