proxmox_api/generated/access/users/userid/token/
tokenid.rs1pub struct TokenidClient<T> {
2 client: T,
3 path: String,
4}
5impl<T> TokenidClient<T>
6where
7 T: crate::client::Client,
8{
9 pub fn new(client: T, parent_path: &str, tokenid: &str) -> Self {
10 Self {
11 client,
12 path: format!("{}/{}", parent_path, tokenid),
13 }
14 }
15}
16impl<T> TokenidClient<T>
17where
18 T: crate::client::Client,
19{
20 #[doc = "Remove API token for a specific user."]
21 pub fn delete(&self) -> Result<(), T::Error> {
22 let path = self.path.to_string();
23 self.client.delete(&path, &())
24 }
25}
26impl<T> TokenidClient<T>
27where
28 T: crate::client::Client,
29{
30 #[doc = "Get specific API token information."]
31 pub fn get(&self) -> Result<GetOutput, T::Error> {
32 let path = self.path.to_string();
33 self.client.get(&path, &())
34 }
35}
36impl<T> TokenidClient<T>
37where
38 T: crate::client::Client,
39{
40 #[doc = "Generate a new API token for a specific user. NOTE: returns API token value, which needs to be stored as it cannot be retrieved afterwards!"]
41 pub fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
42 let path = self.path.to_string();
43 self.client.post(&path, ¶ms)
44 }
45}
46impl<T> TokenidClient<T>
47where
48 T: crate::client::Client,
49{
50 #[doc = "Update API token for a specific user."]
51 pub fn put(&self, params: PutParams) -> Result<PutOutput, T::Error> {
52 let path = self.path.to_string();
53 self.client.put(&path, ¶ms)
54 }
55}
56#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
57pub struct GetOutput {
58 #[serde(skip_serializing_if = "Option::is_none", default)]
59 pub comment: Option<String>,
60 #[serde(skip_serializing_if = "Option::is_none", default)]
61 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
62 pub expire: Option<()>,
63 #[serde(
64 serialize_with = "crate::types::serialize_bool_optional",
65 deserialize_with = "crate::types::deserialize_bool_optional"
66 )]
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
69 pub privsep: Option<bool>,
70 #[serde(
71 flatten,
72 default,
73 skip_serializing_if = "::std::collections::HashMap::is_empty"
74 )]
75 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
76}
77#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
78pub struct InfoPostOutputInfo {
79 #[serde(skip_serializing_if = "Option::is_none", default)]
80 pub comment: Option<String>,
81 #[serde(skip_serializing_if = "Option::is_none", default)]
82 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
83 pub expire: Option<()>,
84 #[serde(
85 serialize_with = "crate::types::serialize_bool_optional",
86 deserialize_with = "crate::types::deserialize_bool_optional"
87 )]
88 #[serde(skip_serializing_if = "Option::is_none", default)]
89 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
90 pub privsep: Option<bool>,
91 #[serde(
92 flatten,
93 default,
94 skip_serializing_if = "::std::collections::HashMap::is_empty"
95 )]
96 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
97}
98impl PostOutput {
99 pub fn new(full_tokenid: String, info: InfoPostOutputInfo, value: String) -> Self {
100 Self {
101 full_tokenid,
102 info,
103 value,
104 }
105 }
106}
107#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
108pub struct PostOutput {
109 #[serde(rename = "full-tokenid")]
110 #[doc = "The full token id."]
111 pub full_tokenid: String,
112 pub info: InfoPostOutputInfo,
113 #[doc = "API token value used for authentication."]
114 pub value: String,
115}
116#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
117pub struct PostParams {
118 #[serde(skip_serializing_if = "Option::is_none", default)]
119 pub comment: Option<String>,
120 #[serde(skip_serializing_if = "Option::is_none", default)]
121 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
122 pub expire: Option<()>,
123 #[serde(
124 serialize_with = "crate::types::serialize_bool_optional",
125 deserialize_with = "crate::types::deserialize_bool_optional"
126 )]
127 #[serde(skip_serializing_if = "Option::is_none", default)]
128 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
129 pub privsep: Option<bool>,
130 #[serde(
131 flatten,
132 default,
133 skip_serializing_if = "::std::collections::HashMap::is_empty"
134 )]
135 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
136}
137#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
138pub struct PutOutput {
139 #[serde(skip_serializing_if = "Option::is_none", default)]
140 pub comment: Option<String>,
141 #[serde(skip_serializing_if = "Option::is_none", default)]
142 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
143 pub expire: Option<()>,
144 #[serde(
145 serialize_with = "crate::types::serialize_bool_optional",
146 deserialize_with = "crate::types::deserialize_bool_optional"
147 )]
148 #[serde(skip_serializing_if = "Option::is_none", default)]
149 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
150 pub privsep: Option<bool>,
151 #[serde(
152 flatten,
153 default,
154 skip_serializing_if = "::std::collections::HashMap::is_empty"
155 )]
156 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
157}
158#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
159pub struct PutParams {
160 #[serde(skip_serializing_if = "Option::is_none", default)]
161 pub comment: Option<String>,
162 #[serde(skip_serializing_if = "Option::is_none", default)]
163 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
164 pub expire: Option<()>,
165 #[serde(
166 serialize_with = "crate::types::serialize_bool_optional",
167 deserialize_with = "crate::types::deserialize_bool_optional"
168 )]
169 #[serde(skip_serializing_if = "Option::is_none", default)]
170 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
171 pub privsep: Option<bool>,
172 #[serde(
173 flatten,
174 default,
175 skip_serializing_if = "::std::collections::HashMap::is_empty"
176 )]
177 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
178}