proxmox_api/generated/access/users/userid/
token.rs1pub mod tokenid;
2#[derive(Debug, Clone)]
3pub struct TokenClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> TokenClient<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, "/token"),
15 }
16 }
17}
18impl<T> TokenClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "Get user API tokens."]
23 #[doc = ""]
24 #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
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 GetOutputItems {
32 pub fn new(tokenid: TokenidStr) -> Self {
33 Self {
34 tokenid,
35 comment: ::std::default::Default::default(),
36 expire: ::std::default::Default::default(),
37 privsep: ::std::default::Default::default(),
38 additional_properties: ::std::default::Default::default(),
39 }
40 }
41}
42#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
43pub struct GetOutputItems {
44 #[serde(skip_serializing_if = "Option::is_none", default)]
45 pub comment: Option<String>,
46 #[serde(
47 serialize_with = "crate::types::serialize_unsigned_int_optional",
48 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
49 )]
50 #[serde(skip_serializing_if = "Option::is_none", default)]
51 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
52 #[doc = ""]
53 pub expire: Option<u64>,
54 #[serde(
55 serialize_with = "crate::types::serialize_bool_optional",
56 deserialize_with = "crate::types::deserialize_bool_optional"
57 )]
58 #[serde(skip_serializing_if = "Option::is_none", default)]
59 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
60 #[doc = ""]
61 pub privsep: Option<bool>,
62 #[doc = "User-specific token identifier."]
63 #[doc = ""]
64 pub tokenid: TokenidStr,
65 #[serde(
66 flatten,
67 default,
68 skip_serializing_if = "::std::collections::HashMap::is_empty"
69 )]
70 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
71}
72#[derive(Debug, Clone, PartialEq, PartialOrd)]
73pub struct TokenidStr {
74 value: String,
75}
76impl crate::types::bounded_string::BoundedString for TokenidStr {
77 const MIN_LENGTH: Option<usize> = None::<usize>;
78 const MAX_LENGTH: Option<usize> = None::<usize>;
79 const DEFAULT: Option<&'static str> = None::<&'static str>;
80 const PATTERN: Option<&'static str> = Some("(?^:[A-Za-z][A-Za-z0-9\\.\\-_]+)");
81 const TYPE_DESCRIPTION: &'static str =
82 "a string with pattern r\"(?^:[A-Za-z][A-Za-z0-9\\.\\-_]+)\" and no length constraints";
83 fn get_value(&self) -> &str {
84 &self.value
85 }
86 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
87 Self::validate(&value)?;
88 Ok(Self { value })
89 }
90}
91impl std::convert::TryFrom<String> for TokenidStr {
92 type Error = crate::types::bounded_string::BoundedStringError;
93 fn try_from(value: String) -> Result<Self, Self::Error> {
94 crate::types::bounded_string::BoundedString::new(value)
95 }
96}
97impl ::serde::Serialize for TokenidStr {
98 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
99 where
100 S: ::serde::Serializer,
101 {
102 crate::types::bounded_string::serialize_bounded_string(self, serializer)
103 }
104}
105impl<'de> ::serde::Deserialize<'de> for TokenidStr {
106 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
107 where
108 D: ::serde::Deserializer<'de>,
109 {
110 crate::types::bounded_string::deserialize_bounded_string(deserializer)
111 }
112}
113impl<T> TokenClient<T>
114where
115 T: crate::client::Client,
116{
117 pub fn tokenid(&self, tokenid: &str) -> tokenid::TokenidClient<T> {
118 tokenid::TokenidClient::<T>::new(self.client.clone(), &self.path, tokenid)
119 }
120}