vaultrs/api/token/
requests.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
use super::responses::{
    ListAccessorResponse, ListTokenRolesResponse, LookupTokenResponse, ReadTokenRoleResponse,
};
use rustify_derive::Endpoint;
use serde::Serialize;
use std::{collections::HashMap, fmt::Debug};

/// ## List Accessors
/// This endpoint lists token accessors.
///
/// * Path: /auth/token/accessors
/// * Method: LIST
/// * Response: [ListAccessorResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#list-accessors>

#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/accessors",
    method = "LIST",
    response = "ListAccessorResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListAccessorRequest {}

/// ## Create Token
/// Creates a new token.
///
/// * Path: /auth/token/create
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#create-token>
#[derive(Builder, Debug, Default, Endpoint, Serialize)]
#[endpoint(path = "/auth/token/create", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct CreateTokenRequest {
    pub display_name: Option<String>,
    pub entity_alias: Option<String>,
    pub explicit_max_ttl: Option<String>,
    pub id: Option<String>,
    pub lease: Option<String>,
    pub meta: Option<HashMap<String, String>>,
    pub no_default_policy: Option<bool>,
    pub no_parent: Option<bool>,
    pub num_uses: Option<u64>,
    pub policies: Option<Vec<String>>,
    pub period: Option<String>,
    pub renewable: Option<bool>,
    pub ttl: Option<String>,
    #[serde(rename = "type")]
    pub token_type: Option<String>,
}

/// ## Create Orphan Token
/// Creates a new orphan token.
///
/// * Path: /auth/token/create-orphan
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#create-token>
#[derive(Builder, Debug, Default, Endpoint, Serialize)]
#[endpoint(path = "/auth/token/create-orphan", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct CreateOrphanTokenRequest {
    pub display_name: Option<String>,
    pub entity_alias: Option<String>,
    pub explicit_max_ttl: Option<String>,
    pub id: Option<String>,
    pub lease: Option<String>,
    pub meta: Option<HashMap<String, String>>,
    pub no_default_policy: Option<bool>,
    pub no_parent: Option<bool>,
    pub num_uses: Option<u64>,
    pub policies: Option<Vec<String>>,
    pub period: Option<String>,
    pub renewable: Option<bool>,
    pub ttl: Option<String>,
    #[serde(rename = "type")]
    pub token_type: Option<String>,
}

/// ## Create Role Token
/// Creates a new role token.
///
/// * Path: /auth/token/create/{self.role_name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#create-token>
#[derive(Builder, Debug, Default, Endpoint, Serialize)]
#[endpoint(
    path = "/auth/token/create/{self.role_name}",
    method = "POST",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct CreateRoleTokenRequest {
    #[endpoint(skip)]
    pub role_name: String,
    pub display_name: Option<String>,
    pub entity_alias: Option<String>,
    pub explicit_max_ttl: Option<String>,
    pub id: Option<String>,
    pub lease: Option<String>,
    pub meta: Option<HashMap<String, String>>,
    pub no_default_policy: Option<bool>,
    pub no_parent: Option<bool>,
    pub num_uses: Option<u64>,
    pub policies: Option<Vec<String>>,
    pub period: Option<String>,
    pub renewable: Option<bool>,
    pub ttl: Option<String>,
    #[serde(rename = "type")]
    pub token_type: Option<String>,
}

/// ## Lookup a Token
/// Returns information about the client token.
///
/// * Path: /auth/token/lookup
/// * Method: POST
/// * Response: [LookupTokenResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#lookup-a-token>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/lookup",
    method = "POST",
    response = "LookupTokenResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct LookupTokenRequest {
    pub token: String,
}

/// ## Lookup a Token (Self)
/// Returns information about the current client token.
///
/// * Path: /auth/token/lookup-self
/// * Method: GET
/// * Response: [LookupTokenResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#lookup-a-token-self>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/lookup-self",
    response = "LookupTokenResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct LookupTokenSelfRequest {}

/// ## Lookup a Token (Accessor)
/// Returns information about the client token from the accessor.
///
/// * Path: /auth/token/lookup-accessor
/// * Method: POST
/// * Response: [LookupTokenResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#lookup-a-token-accessor>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/lookup-accessor",
    method = "POST",
    response = "LookupTokenResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct LookupTokenAccessorRequest {
    pub accessor: String,
}

/// ## Renew a Token
/// Renews a lease associated with a token.
///
/// * Path: /auth/token/renew
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#renew-a-token>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "/auth/token/renew", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RenewTokenRequest {
    pub token: String,
    pub increment: Option<String>,
}

/// ## Renew a Token (Self)
/// Renews a lease associated with the calling token.
///
/// * Path: /auth/token/renew-self
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#renew-a-token-self>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "	/auth/token/renew-self", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RenewTokenSelfRequest {
    pub increment: Option<String>,
}

/// ## Renew a Token (Accessor)
/// Renews a lease associated with a token using its accessor.
///
/// * Path: /auth/token/renew-accessor
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#renew-a-token-self>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "/auth/token/renew-accessor", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RenewTokenAccessorRequest {
    pub accessor: String,
    pub increment: Option<String>,
}

/// ## Revoke a Token
/// Revokes a token and all child tokens
///
/// * Path: /auth/token/revoke
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#revoke-a-token>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "/auth/token/revoke", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RevokeTokenRequest {
    pub token: String,
}

/// ## Revoke a Token (Self)
/// Revokes the token used to call it and all child tokens.
///
/// * Path: /auth/token/revoke-self
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#revoke-a-token-self>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "	/auth/token/revoke-self", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RevokeTokenSelfRequest {}

/// ## Revoke a Token Accessor
/// Revoke the token associated with the accessor and all the child tokens.
///
/// * Path: /auth/token/revoke-accessor
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#revoke-a-token-accessor>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/revoke-accessor",
    method = "POST",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct RevokeTokenAccessorRequest {
    pub accessor: String,
}

/// ## Revoke Token and Orphan Children
/// Revokes a token but not its child tokens.
///
/// * Path: /auth/token/revoke-orphan
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#revoke-token-and-orphan-children>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "/auth/token/revoke-orphan", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct RevokeTokenOrphanRequest {
    pub token: String,
}

/// ## Read Token Role
/// Fetches the named role configuration.
///
/// * Path: /auth/token/roles/{self.role_name}
/// * Method: GET
/// * Response: [ReadTokenRoleResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#read-token-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/roles/{self.role_name}",
    response = "ReadTokenRoleResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadTokenRoleRequest {
    #[endpoint(skip)]
    pub role_name: String,
}

/// ## List Token Roles
/// List available token roles.
///
/// * Path: /auth/token/roles
/// * Method: GET
/// * Response: [ListTokenRolesResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#list-token-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/roles",
    method = "LIST",
    response = "ListTokenRolesResponse",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListTokenRolesRequest {}

/// ## Create/Update Token Role
/// List available token roles.
///
/// * Path: /auth/token/roles/:role_name
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#create-update-token-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/roles/{self.role_name}",
    method = "POST",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetTokenRoleRequest {
    #[endpoint(skip)]
    pub role_name: String,
    pub allowed_entity_aliases: Option<Vec<String>>,
    pub allowed_policies: Option<Vec<String>>,
    pub disallowed_policies: Option<Vec<String>>,
    pub orphan: Option<bool>,
    pub path_suffix: Option<String>,
    pub renewable: Option<bool>,
    pub token_bound_cidrs: Option<Vec<String>>,
    pub token_explicit_max_ttl: Option<String>,
    pub token_no_default_policy: Option<bool>,
    pub token_num_uses: Option<u64>,
    pub token_period: Option<String>,
    pub token_type: Option<String>,
}

/// ## Delete Token Role
/// This endpoint deletes the named token role.
///
/// * Path: /auth/token/roles/{self.role_name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#delete-token-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
    path = "/auth/token/roles/{self.role_name}",
    method = "DELETE",
    builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteTokenRoleRequest {
    #[endpoint(skip)]
    pub role_name: String,
}

/// ## Tidy Tokens
/// Performs some maintenance tasks to clean up invalid entries that may remain
// in the token store.
///
/// * Path: /auth/token/tidy
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/token#tidy-tokens>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "/auth/token/tidy", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct TidyRequest {}