vaultrs/api/auth/userpass/
requests.rs

1use super::responses::{ListUsersResponse, ReadUserResponse};
2use rustify_derive::Endpoint;
3
4/// ## Create/Update User
5/// Create a new user or update an existing user.
6///
7/// * Path: /auth/{self.mount}/users/{self.username}
8/// * Method: POST
9/// * Response: N/A
10/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#create-update-user>
11#[derive(Builder, Debug, Default, Endpoint)]
12#[endpoint(
13    path = "/auth/{self.mount}/users/{self.username}",
14    method = "POST",
15    builder = "true"
16)]
17#[builder(setter(into, strip_option), default)]
18pub struct CreateUserRequest {
19    #[endpoint(skip)]
20    pub mount: String,
21    #[endpoint(skip)]
22    pub username: String,
23    pub password: String,
24    pub token_bound_cidrs: Option<Vec<String>>,
25    pub token_explicit_max_ttl: Option<String>,
26    pub token_no_default_policy: Option<bool>,
27    pub token_num_uses: Option<u64>,
28    pub token_ttl: Option<String>,
29    pub token_max_ttl: Option<String>,
30    pub token_period: Option<String>,
31    pub token_policies: Option<Vec<String>>,
32    pub token_type: Option<String>,
33}
34
35/// ## Read User
36/// Reads the properties of an existing username.
37///
38/// * Path: /auth/{self.mount}/users/{self.username}
39/// * Method: GET
40/// * Response: [ReadUserResponse]
41/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#read-user>
42#[derive(Builder, Debug, Default, Endpoint)]
43#[endpoint(
44    path = "/auth/{self.mount}/users/{self.username}",
45    response = "ReadUserResponse",
46    builder = "true"
47)]
48#[builder(setter(into, strip_option), default)]
49pub struct ReadUserRequest {
50    #[endpoint(skip)]
51    pub mount: String,
52    #[endpoint(skip)]
53    pub username: String,
54}
55
56/// ## Delete User
57/// This endpoint deletes the user from the method.
58///
59/// * Path: /auth/{self.mount}/users/{self.username}
60/// * Method: DELETE
61/// * Response: N/A
62/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#delete-user>
63#[derive(Builder, Debug, Default, Endpoint)]
64#[endpoint(
65    path = "/auth/{self.mount}/users/{self.username}",
66    method = "DELETE",
67    builder = "true"
68)]
69#[builder(setter(into, strip_option), default)]
70pub struct DeleteUserRequest {
71    #[endpoint(skip)]
72    pub mount: String,
73    #[endpoint(skip)]
74    pub username: String,
75}
76
77/// ## Update Password on User
78/// Update password for an existing user.
79///
80/// * Path: /auth/{self.mount}/users/{self.username}/password
81/// * Method: POST
82/// * Response: N/A
83/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#update-password-on-user>
84#[derive(Builder, Debug, Default, Endpoint)]
85#[endpoint(
86    path = "/auth/{self.mount}/users/{self.username}/password",
87    method = "POST",
88    builder = "true"
89)]
90#[builder(setter(into, strip_option), default)]
91pub struct UpdatePasswordRequest {
92    #[endpoint(skip)]
93    pub mount: String,
94    #[endpoint(skip)]
95    pub username: String,
96    pub password: String,
97}
98
99/// ## Update Policies on User
100/// Update policies for an existing user.
101///
102/// * Path: /auth/{self.mount}/users/{self.username}/policies
103/// * Method: POST
104/// * Response: N/A
105/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#update-policies-on-user>
106#[derive(Builder, Debug, Default, Endpoint)]
107#[endpoint(
108    path = "/auth/{self.mount}/users/{self.username}/policies",
109    method = "POST",
110    builder = "true"
111)]
112#[builder(setter(into, strip_option), default)]
113pub struct UpdatePoliciesRequest {
114    #[endpoint(skip)]
115    pub mount: String,
116    #[endpoint(skip)]
117    pub username: String,
118    pub policies: String,
119}
120
121/// ## List Users
122/// List available userpass users.
123///
124/// * Path: /auth/{self.mount}/users
125/// * Method: LIST
126/// * Response: [ListUsersResponse]
127/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#list-users>
128#[derive(Builder, Debug, Default, Endpoint)]
129#[endpoint(
130    path = "/auth/{self.mount}/users",
131    method = "LIST",
132    response = "ListUsersResponse",
133    builder = "true"
134)]
135#[builder(setter(into, strip_option), default)]
136pub struct ListUsersRequest {
137    #[endpoint(skip)]
138    pub mount: String,
139}
140
141/// ## Login
142/// Login with the username and password.
143///
144/// * Path: /auth/{self.mount}/login/{self.username}
145/// * Method: POST
146/// * Response: N/A
147/// * Reference: <https://developer.hashicorp.com/vault/api-docs/auth/userpass#login>
148#[derive(Builder, Debug, Default, Endpoint)]
149#[endpoint(
150    path = "/auth/{self.mount}/login/{self.username}",
151    method = "POST",
152    builder = "true"
153)]
154#[builder(setter(into, strip_option), default)]
155pub struct LoginRequest {
156    #[endpoint(skip)]
157    pub mount: String,
158    #[endpoint(skip)]
159    pub username: String,
160    pub password: String,
161}