vaultrs/api/auth/approle/
requests.rs

1use super::responses::{
2    CreateCustomSecretIDResponse, GenerateNewSecretIDResponse, ListRolesResponse,
3    ListSecretIDResponse, ReadAppRoleResponse, ReadRoleIDResponse, ReadSecretIDResponse,
4};
5use rustify_derive::Endpoint;
6
7/// ## Login with Approle
8/// Issues a Vault token based on the presented credentials.
9///
10/// * Path: /auth/approle/login
11/// * Method: POST
12/// * Response: N/A
13/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#login-with-approle>
14#[derive(Builder, Debug, Endpoint)]
15#[endpoint(path = "/auth/{self.mount}/login", method = "POST", builder = "true")]
16#[builder(setter(into))]
17pub struct LoginWithApproleRequest {
18    #[endpoint(skip)]
19    pub mount: String,
20    pub role_id: String,
21    pub secret_id: String,
22}
23
24/// ## List Roles
25/// This endpoint returns a list the existing AppRoles in the method.
26///
27/// * Path: /auth/{self.mount}/role
28/// * Method: LIST
29/// * Response: [ListRolesResponse]
30/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#list-roles>
31#[derive(Builder, Debug, Default, Endpoint)]
32#[endpoint(
33    path = "/auth/{self.mount}/role",
34    method = "LIST",
35    response = "ListRolesResponse",
36    builder = "true"
37)]
38#[builder(setter(into, strip_option), default)]
39pub struct ListRolesRequest {
40    #[endpoint(skip)]
41    pub mount: String,
42}
43
44/// ## Create/Update AppRole
45/// Creates a new AppRole or updates an existing AppRole.
46///
47/// * Path: /auth/{self.mount}/role/{self.role_name}
48/// * Method: POST
49/// * Response: N/A
50/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#create-update-approle>
51#[derive(Builder, Debug, Default, Endpoint)]
52#[endpoint(
53    path = "/auth/{self.mount}/role/{self.role_name}",
54    method = "POST",
55    builder = "true"
56)]
57#[builder(setter(into, strip_option), default)]
58pub struct SetAppRoleRequest {
59    #[endpoint(skip)]
60    pub mount: String,
61    #[endpoint(skip)]
62    pub role_name: String,
63    pub bind_secret_id: Option<bool>,
64    pub secret_id_bound_cidrs: Option<Vec<String>>,
65    pub secret_id_num_uses: Option<u64>,
66    pub secret_id_ttl: Option<String>,
67    pub enable_local_secret_ids: Option<bool>,
68    pub token_ttl: Option<String>,
69    pub token_max_ttl: Option<String>,
70    pub token_policies: Option<Vec<String>>,
71    pub token_bound_cidrs: Option<Vec<String>>,
72    pub token_explicit_max_ttl: Option<String>,
73    pub token_no_default_policy: Option<bool>,
74    pub token_num_uses: Option<u64>,
75    pub token_period: Option<String>,
76    pub token_type: Option<String>,
77}
78
79/// ## Read AppRole
80/// Reads the properties of an existing AppRole.
81///
82/// * Path: /auth/{self.mount}/role/{self.role_name}
83/// * Method: GET
84/// * Response: [ReadAppRoleResponse]
85/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#read-approle>
86#[derive(Builder, Debug, Default, Endpoint)]
87#[endpoint(
88    path = "/auth/{self.mount}/role/{self.role_name}",
89    response = "ReadAppRoleResponse",
90    builder = "true"
91)]
92#[builder(setter(into, strip_option), default)]
93pub struct ReadAppRoleRequest {
94    #[endpoint(skip)]
95    pub mount: String,
96    #[endpoint(skip)]
97    pub role_name: String,
98}
99
100/// ## Delete AppRole
101/// Deletes an existing AppRole.
102///
103/// * Path: /auth/{self.mount}/role/{self.role_name}
104/// * Method: DELETE
105/// * Response: N/A
106/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#delete-approle>
107#[derive(Builder, Debug, Default, Endpoint)]
108#[endpoint(
109    path = "/auth/{self.mount}/role/{self.role_name}",
110    method = "DELETE",
111    builder = "true"
112)]
113#[builder(setter(into, strip_option), default)]
114pub struct DeleteAppRoleRequest {
115    #[endpoint(skip)]
116    pub mount: String,
117    #[endpoint(skip)]
118    pub role_name: String,
119}
120
121/// ## Read AppRole RoleID
122/// Reads the RoleID of an existing AppRole.
123///
124/// * Path: /auth/{self.mount}/role/{self.role_name}/role-id
125/// * Method: GET
126/// * Response: [ReadRoleIDResponse]
127/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#read-approle-role-id>
128#[derive(Builder, Debug, Default, Endpoint)]
129#[endpoint(
130    path = "/auth/{self.mount}/role/{self.role_name}/role-id",
131    response = "ReadRoleIDResponse",
132    builder = "true"
133)]
134#[builder(setter(into, strip_option), default)]
135pub struct ReadRoleIDRequest {
136    #[endpoint(skip)]
137    pub mount: String,
138    #[endpoint(skip)]
139    pub role_name: String,
140}
141
142/// ## Update AppRole Role ID
143/// Reads the RoleID of an existing AppRole.
144///
145/// * Path: /auth/{self.mount}/role/{self.role_name}/role-id
146/// * Method: POST
147/// * Response: N/A
148/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#update-approle-role-id>
149#[derive(Builder, Debug, Default, Endpoint)]
150#[endpoint(
151    path = "/auth/{self.mount}/role/{self.role_name}/role-id",
152    method = "POST",
153    builder = "true"
154)]
155#[builder(setter(into, strip_option), default)]
156pub struct UpdateRoleIDRequest {
157    #[endpoint(skip)]
158    pub mount: String,
159    #[endpoint(skip)]
160    pub role_name: String,
161    pub role_id: String,
162}
163
164/// ## Generate New Secret ID
165/// Generates and issues a new SecretID on an existing AppRole.
166///
167/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id
168/// * Method: POST
169/// * Response: [GenerateNewSecretIDResponse]
170/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#generate-new-secret-id>
171#[derive(Builder, Debug, Default, Endpoint)]
172#[endpoint(
173    path = "/auth/{self.mount}/role/{self.role_name}/secret-id",
174    method = "POST",
175    response = "GenerateNewSecretIDResponse",
176    builder = "true"
177)]
178#[builder(setter(into, strip_option), default)]
179pub struct GenerateNewSecretIDRequest {
180    #[endpoint(skip)]
181    pub mount: String,
182    #[endpoint(skip)]
183    pub role_name: String,
184    pub metadata: Option<String>,
185    pub cidr_list: Option<Vec<String>>,
186    pub token_bound_cidrs: Option<Vec<String>>,
187}
188
189/// ## List Secret ID Accessors
190/// Lists the accessors of all the SecretIDs issued against the AppRole.
191///
192/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id
193/// * Method: LIST
194/// * Response: [ListSecretIDResponse]
195/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#list-secret-id-accessors>
196#[derive(Builder, Debug, Default, Endpoint)]
197#[endpoint(
198    path = "/auth/{self.mount}/role/{self.role_name}/secret-id",
199    method = "LIST",
200    response = "ListSecretIDResponse",
201    builder = "true"
202)]
203#[builder(setter(into, strip_option), default)]
204pub struct ListSecretIDRequest {
205    #[endpoint(skip)]
206    pub mount: String,
207    #[endpoint(skip)]
208    pub role_name: String,
209}
210
211/// ## Read AppRole Secret ID
212/// Reads out the properties of a SecretID.
213///
214/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id/lookup
215/// * Method: POST
216/// * Response: [ReadSecretIDResponse]
217/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#read-approle-secret-id>
218#[derive(Builder, Debug, Default, Endpoint)]
219#[endpoint(
220    path = "/auth/{self.mount}/role/{self.role_name}/secret-id/lookup",
221    method = "POST",
222    response = "ReadSecretIDResponse",
223    builder = "true"
224)]
225#[builder(setter(into, strip_option), default)]
226pub struct ReadSecretIDRequest {
227    #[endpoint(skip)]
228    pub mount: String,
229    #[endpoint(skip)]
230    pub role_name: String,
231    pub secret_id: String,
232}
233
234/// ## Destroy AppRole Secret ID
235/// Destroy an AppRole secret ID.
236///
237/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id/destroy
238/// * Method: POST
239/// * Response: N/A
240/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#destroy-approle-secret-id>
241#[derive(Builder, Debug, Default, Endpoint)]
242#[endpoint(
243    path = "/auth/{self.mount}/role/{self.role_name}/secret-id/destroy",
244    method = "POST",
245    builder = "true"
246)]
247#[builder(setter(into, strip_option), default)]
248pub struct DeleteSecretIDRequest {
249    #[endpoint(skip)]
250    pub mount: String,
251    #[endpoint(skip)]
252    pub role_name: String,
253    pub secret_id: String,
254}
255
256/// ## Read AppRole Secret ID Accessor
257/// Reads out the properties of a SecretID.
258///
259/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id-accessor/lookup
260/// * Method: POST
261/// * Response: [ReadSecretIDResponse]
262/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#read-approle-secret-id-accessor>
263#[derive(Builder, Debug, Default, Endpoint)]
264#[endpoint(
265    path = "/auth/{self.mount}/role/{self.role_name}/secret-id-accessor/lookup",
266    method = "POST",
267    response = "ReadSecretIDResponse",
268    builder = "true"
269)]
270#[builder(setter(into, strip_option), default)]
271pub struct ReadSecretIDAccessorRequest {
272    #[endpoint(skip)]
273    pub mount: String,
274    #[endpoint(skip)]
275    pub role_name: String,
276    pub secret_id_accessor: String,
277}
278
279/// ## Destroy AppRole Secret ID Accessor
280/// Destroy an AppRole secret ID by its accessor.
281///
282/// * Path: /auth/{self.mount}/role/{self.role_name}/secret-id-accessor/destroy
283/// * Method: POST
284/// * Response: N/A
285/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#destroy-approle-secret-id-accessor>
286#[derive(Builder, Debug, Default, Endpoint)]
287#[endpoint(
288    path = "/auth/{self.mount}/role/{self.role_name}/secret-id-accessor/destroy",
289    method = "POST",
290    builder = "true"
291)]
292#[builder(setter(into, strip_option), default)]
293pub struct DeleteSecretIDAccessorRequest {
294    #[endpoint(skip)]
295    pub mount: String,
296    #[endpoint(skip)]
297    pub role_name: String,
298    pub secret_id_accessor: String,
299}
300
301/// ## Create Custom AppRole Secret ID
302/// Assigns a "custom" SecretID against an existing AppRole.
303///
304/// * Path: /auth/{self.mount}/role/{self.role_name}/custom-secret-id
305/// * Method: POST
306/// * Response: [CreateCustomSecretIDResponse]
307/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#create-custom-approle-secret-id>
308#[derive(Builder, Debug, Default, Endpoint)]
309#[endpoint(
310    path = "/auth/{self.mount}/role/{self.role_name}/custom-secret-id",
311    method = "POST",
312    response = "CreateCustomSecretIDResponse",
313    builder = "true"
314)]
315#[builder(setter(into, strip_option), default)]
316pub struct CreateCustomSecretIDRequest {
317    #[endpoint(skip)]
318    pub mount: String,
319    #[endpoint(skip)]
320    pub role_name: String,
321    pub secret_id: String,
322    pub metadata: Option<String>,
323    pub cidr_list: Option<Vec<String>>,
324    pub token_bound_cidrs: Option<Vec<String>>,
325}
326
327/// ## Tidy Tokens
328/// Performs some maintenance tasks to clean up invalid entries that may remain
329/// in the token store.
330///
331/// * Path: /auth/{self.mount}/tidy/secret-id
332/// * Method: POST
333/// * Response: N/A
334/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/approle#tidy-tokens>
335#[derive(Builder, Debug, Default, Endpoint)]
336#[endpoint(
337    path = "/auth/{self.mount}/tidy/secret-id",
338    method = "POST",
339    builder = "true"
340)]
341#[builder(setter(into, strip_option), default)]
342pub struct TidyRequest {
343    #[endpoint(skip)]
344    pub mount: String,
345}