1use super::responses::{
2 ListAccessorResponse, ListTokenRolesResponse, LookupTokenResponse, ReadTokenRoleResponse,
3};
4use rustify_derive::Endpoint;
5use serde::Serialize;
6use std::{collections::HashMap, fmt::Debug};
7
8#[derive(Builder, Debug, Default, Endpoint)]
17#[endpoint(
18 path = "/auth/token/accessors",
19 method = "LIST",
20 response = "ListAccessorResponse",
21 builder = "true"
22)]
23#[builder(setter(into, strip_option), default)]
24pub struct ListAccessorRequest {}
25
26#[derive(Builder, Debug, Default, Endpoint, Serialize)]
34#[endpoint(path = "/auth/token/create", method = "POST", builder = "true")]
35#[builder(setter(into, strip_option), default)]
36pub struct CreateTokenRequest {
37 pub display_name: Option<String>,
38 pub entity_alias: Option<String>,
39 pub explicit_max_ttl: Option<String>,
40 pub id: Option<String>,
41 pub lease: Option<String>,
42 pub meta: Option<HashMap<String, String>>,
43 pub no_default_policy: Option<bool>,
44 pub no_parent: Option<bool>,
45 pub num_uses: Option<u64>,
46 pub policies: Option<Vec<String>>,
47 pub period: Option<String>,
48 pub renewable: Option<bool>,
49 pub ttl: Option<String>,
50 #[serde(rename = "type")]
51 pub token_type: Option<String>,
52}
53
54#[derive(Builder, Debug, Default, Endpoint, Serialize)]
62#[endpoint(path = "/auth/token/create-orphan", method = "POST", builder = "true")]
63#[builder(setter(into, strip_option), default)]
64pub struct CreateOrphanTokenRequest {
65 pub display_name: Option<String>,
66 pub entity_alias: Option<String>,
67 pub explicit_max_ttl: Option<String>,
68 pub id: Option<String>,
69 pub lease: Option<String>,
70 pub meta: Option<HashMap<String, String>>,
71 pub no_default_policy: Option<bool>,
72 pub no_parent: Option<bool>,
73 pub num_uses: Option<u64>,
74 pub policies: Option<Vec<String>>,
75 pub period: Option<String>,
76 pub renewable: Option<bool>,
77 pub ttl: Option<String>,
78 #[serde(rename = "type")]
79 pub token_type: Option<String>,
80}
81
82#[derive(Builder, Debug, Default, Endpoint, Serialize)]
90#[endpoint(
91 path = "/auth/token/create/{self.role_name}",
92 method = "POST",
93 builder = "true"
94)]
95#[builder(setter(into, strip_option), default)]
96pub struct CreateRoleTokenRequest {
97 #[endpoint(skip)]
98 pub role_name: String,
99 pub display_name: Option<String>,
100 pub entity_alias: Option<String>,
101 pub explicit_max_ttl: Option<String>,
102 pub id: Option<String>,
103 pub lease: Option<String>,
104 pub meta: Option<HashMap<String, String>>,
105 pub no_default_policy: Option<bool>,
106 pub no_parent: Option<bool>,
107 pub num_uses: Option<u64>,
108 pub policies: Option<Vec<String>>,
109 pub period: Option<String>,
110 pub renewable: Option<bool>,
111 pub ttl: Option<String>,
112 #[serde(rename = "type")]
113 pub token_type: Option<String>,
114}
115
116#[derive(Builder, Debug, Default, Endpoint)]
124#[endpoint(
125 path = "/auth/token/lookup",
126 method = "POST",
127 response = "LookupTokenResponse",
128 builder = "true"
129)]
130#[builder(setter(into, strip_option), default)]
131pub struct LookupTokenRequest {
132 pub token: String,
133}
134
135#[derive(Builder, Debug, Default, Endpoint)]
143#[endpoint(
144 path = "/auth/token/lookup-self",
145 response = "LookupTokenResponse",
146 builder = "true"
147)]
148#[builder(setter(into, strip_option), default)]
149pub struct LookupTokenSelfRequest {}
150
151#[derive(Builder, Debug, Default, Endpoint)]
159#[endpoint(
160 path = "/auth/token/lookup-accessor",
161 method = "POST",
162 response = "LookupTokenResponse",
163 builder = "true"
164)]
165#[builder(setter(into, strip_option), default)]
166pub struct LookupTokenAccessorRequest {
167 pub accessor: String,
168}
169
170#[derive(Builder, Debug, Default, Endpoint)]
178#[endpoint(path = "/auth/token/renew", method = "POST", builder = "true")]
179#[builder(setter(into, strip_option), default)]
180pub struct RenewTokenRequest {
181 pub token: String,
182 pub increment: Option<String>,
183}
184
185#[derive(Builder, Debug, Default, Endpoint)]
193#[endpoint(path = " /auth/token/renew-self", method = "POST", builder = "true")]
194#[builder(setter(into, strip_option), default)]
195pub struct RenewTokenSelfRequest {
196 pub increment: Option<String>,
197}
198
199#[derive(Builder, Debug, Default, Endpoint)]
207#[endpoint(path = "/auth/token/renew-accessor", method = "POST", builder = "true")]
208#[builder(setter(into, strip_option), default)]
209pub struct RenewTokenAccessorRequest {
210 pub accessor: String,
211 pub increment: Option<String>,
212}
213
214#[derive(Builder, Debug, Default, Endpoint)]
222#[endpoint(path = "/auth/token/revoke", method = "POST", builder = "true")]
223#[builder(setter(into, strip_option), default)]
224pub struct RevokeTokenRequest {
225 pub token: String,
226}
227
228#[derive(Builder, Debug, Default, Endpoint)]
236#[endpoint(path = " /auth/token/revoke-self", method = "POST", builder = "true")]
237#[builder(setter(into, strip_option), default)]
238pub struct RevokeTokenSelfRequest {}
239
240#[derive(Builder, Debug, Default, Endpoint)]
248#[endpoint(
249 path = "/auth/token/revoke-accessor",
250 method = "POST",
251 builder = "true"
252)]
253#[builder(setter(into, strip_option), default)]
254pub struct RevokeTokenAccessorRequest {
255 pub accessor: String,
256}
257
258#[derive(Builder, Debug, Default, Endpoint)]
266#[endpoint(path = "/auth/token/revoke-orphan", method = "POST", builder = "true")]
267#[builder(setter(into, strip_option), default)]
268pub struct RevokeTokenOrphanRequest {
269 pub token: String,
270}
271
272#[derive(Builder, Debug, Default, Endpoint)]
280#[endpoint(
281 path = "/auth/token/roles/{self.role_name}",
282 response = "ReadTokenRoleResponse",
283 builder = "true"
284)]
285#[builder(setter(into, strip_option), default)]
286pub struct ReadTokenRoleRequest {
287 #[endpoint(skip)]
288 pub role_name: String,
289}
290
291#[derive(Builder, Debug, Default, Endpoint)]
299#[endpoint(
300 path = "/auth/token/roles",
301 method = "LIST",
302 response = "ListTokenRolesResponse",
303 builder = "true"
304)]
305#[builder(setter(into, strip_option), default)]
306pub struct ListTokenRolesRequest {}
307
308#[derive(Builder, Debug, Default, Endpoint)]
316#[endpoint(
317 path = "/auth/token/roles/{self.role_name}",
318 method = "POST",
319 builder = "true"
320)]
321#[builder(setter(into, strip_option), default)]
322pub struct SetTokenRoleRequest {
323 #[endpoint(skip)]
324 pub role_name: String,
325 pub allowed_entity_aliases: Option<Vec<String>>,
326 pub allowed_policies: Option<Vec<String>>,
327 pub disallowed_policies: Option<Vec<String>>,
328 pub orphan: Option<bool>,
329 pub path_suffix: Option<String>,
330 pub renewable: Option<bool>,
331 pub token_bound_cidrs: Option<Vec<String>>,
332 pub token_explicit_max_ttl: Option<String>,
333 pub token_no_default_policy: Option<bool>,
334 pub token_num_uses: Option<u64>,
335 pub token_period: Option<String>,
336 pub token_type: Option<String>,
337}
338
339#[derive(Builder, Debug, Default, Endpoint)]
347#[endpoint(
348 path = "/auth/token/roles/{self.role_name}",
349 method = "DELETE",
350 builder = "true"
351)]
352#[builder(setter(into, strip_option), default)]
353pub struct DeleteTokenRoleRequest {
354 #[endpoint(skip)]
355 pub role_name: String,
356}
357
358#[derive(Builder, Debug, Default, Endpoint)]
367#[endpoint(path = "/auth/token/tidy", method = "POST", builder = "true")]
368#[builder(setter(into, strip_option), default)]
369pub struct TidyRequest {}