1use super::responses::{
2 GenerateCredentialsResponse, GetStaticCredentialsResponse, ListConnectionsResponse,
3 ListRolesResponse, ListStaticRolesResponse, ReadConnectionResponse, ReadRoleResponse,
4 ReadStaticRoleResponse,
5};
6use rustify_derive::Endpoint;
7use std::fmt::Debug;
8
9#[derive(Builder, Debug, Default, Endpoint)]
17#[endpoint(
18 path = "{self.mount}/config/{self.name}",
19 method = "POST",
20 builder = "true"
21)]
22#[builder(setter(into, strip_option), default)]
23pub struct PostgreSQLConnectionRequest {
24 #[endpoint(skip)]
25 pub mount: String,
26 #[endpoint(skip)]
27 pub name: String,
28 pub connection_url: String,
29 pub plugin_name: String,
30 pub allowed_roles: Option<Vec<String>>, pub password_policy: Option<String>,
32 pub root_rotation_statements: Option<Vec<String>>,
33 pub verify_connection: Option<bool>,
34 pub max_connection_lifetime: Option<String>, pub max_idle_connections: Option<u64>,
36 pub max_open_connections: Option<u64>,
37 pub password: Option<String>,
38 pub username: Option<String>,
39 pub username_template: Option<String>,
40}
41
42#[derive(Builder, Debug, Default, Endpoint)]
50#[endpoint(
51 path = "{self.mount}/config/{self.name}",
52 response = "ReadConnectionResponse",
53 builder = "true"
54)]
55#[builder(setter(into, strip_option), default)]
56pub struct ReadConnectionRequest {
57 #[endpoint(skip)]
58 pub mount: String,
59 #[endpoint(skip)]
60 pub name: String,
61}
62
63#[derive(Builder, Debug, Default, Endpoint)]
71#[endpoint(
72 path = "{self.mount}/config",
73 method = "LIST",
74 response = "ListConnectionsResponse",
75 builder = "true"
76)]
77#[builder(setter(into, strip_option), default)]
78pub struct ListConnectionsRequest {
79 #[endpoint(skip)]
80 pub mount: String,
81}
82
83#[derive(Builder, Debug, Default, Endpoint)]
91#[endpoint(
92 path = "{self.mount}/config/{self.name}",
93 method = "DELETE",
94 builder = "true"
95)]
96#[builder(setter(into, strip_option), default)]
97pub struct DeleteConnectionRequest {
98 #[endpoint(skip)]
99 pub mount: String,
100 #[endpoint(skip)]
101 pub name: String,
102}
103
104#[derive(Builder, Debug, Default, Endpoint)]
113#[endpoint(
114 path = "{self.mount}/reset/{self.name}",
115 method = "POST",
116 builder = "true"
117)]
118#[builder(setter(into, strip_option), default)]
119pub struct ResetConnectionRequest {
120 #[endpoint(skip)]
121 pub mount: String,
122 #[endpoint(skip)]
123 pub name: String,
124}
125
126#[derive(Builder, Debug, Default, Endpoint)]
135#[endpoint(
136 path = "{self.mount}/rotate-root/{self.name}",
137 method = "POST",
138 builder = "true"
139)]
140#[builder(setter(into, strip_option), default)]
141pub struct RotateRootRequest {
142 #[endpoint(skip)]
143 pub mount: String,
144 #[endpoint(skip)]
145 pub name: String,
146}
147
148#[derive(Builder, Debug, Default, Endpoint)]
156#[endpoint(
157 path = "{self.mount}/roles/{self.name}",
158 method = "POST",
159 builder = "true"
160)]
161#[builder(setter(into, strip_option), default)]
162pub struct SetRoleRequest {
163 #[endpoint(skip)]
164 pub mount: String,
165 #[endpoint(skip)]
166 pub name: String,
167 pub creation_statements: Option<Vec<String>>,
168 pub db_name: String,
169 pub default_ttl: Option<String>,
170 pub max_ttl: Option<String>,
171 pub renew_statements: Option<Vec<String>>,
172 pub revocation_statements: Option<Vec<String>>,
173 pub rollback_statements: Option<Vec<String>>,
174}
175
176#[derive(Builder, Debug, Default, Endpoint)]
184#[endpoint(
185 path = "{self.mount}/roles/{self.name}",
186 response = "ReadRoleResponse",
187 builder = "true"
188)]
189#[builder(setter(into, strip_option), default)]
190pub struct ReadRoleRequest {
191 #[endpoint(skip)]
192 pub mount: String,
193 #[endpoint(skip)]
194 pub name: String,
195}
196
197#[derive(Builder, Debug, Default, Endpoint)]
205#[endpoint(
206 path = "{self.mount}/roles",
207 method = "LIST",
208 response = "ListRolesResponse",
209 builder = "true"
210)]
211#[builder(setter(into, strip_option), default)]
212pub struct ListRolesRequest {
213 #[endpoint(skip)]
214 pub mount: String,
215}
216
217#[derive(Builder, Debug, Default, Endpoint)]
225#[endpoint(
226 path = "{self.mount}/roles/{self.name}",
227 method = "DELETE",
228 builder = "true"
229)]
230#[builder(setter(into, strip_option), default)]
231pub struct DeleteRoleRequest {
232 #[endpoint(skip)]
233 pub mount: String,
234 #[endpoint(skip)]
235 pub name: String,
236}
237
238#[derive(Builder, Debug, Default, Endpoint)]
247#[endpoint(
248 path = "{self.mount}/creds/{self.name}",
249 response = "GenerateCredentialsResponse",
250 builder = "true"
251)]
252#[builder(setter(into, strip_option), default)]
253pub struct GenerateCredentialsRequest {
254 #[endpoint(skip)]
255 pub mount: String,
256 #[endpoint(skip)]
257 pub name: String,
258}
259
260#[derive(Builder, Debug, Default, Endpoint)]
268#[endpoint(
269 path = "{self.mount}/static-roles/{self.name}",
270 method = "POST",
271 builder = "true"
272)]
273#[builder(setter(into, strip_option), default)]
274pub struct SetStaticRoleRequest {
275 #[endpoint(skip)]
276 pub mount: String,
277 #[endpoint(skip)]
278 pub name: String,
279 pub db_name: String,
280 pub username: String,
281 pub rotation_period: String,
282 pub rotation_statements: Option<Vec<String>>,
283}
284
285#[derive(Builder, Debug, Default, Endpoint)]
293#[endpoint(
294 path = "{self.mount}/static-roles/{self.name}",
295 response = "ReadStaticRoleResponse",
296 builder = "true"
297)]
298#[builder(setter(into, strip_option), default)]
299pub struct ReadStaticRoleRequest {
300 #[endpoint(skip)]
301 pub mount: String,
302 #[endpoint(skip)]
303 pub name: String,
304}
305
306#[derive(Builder, Debug, Default, Endpoint)]
314#[endpoint(
315 path = "{self.mount}/static-roles",
316 method = "LIST",
317 response = "ListStaticRolesResponse",
318 builder = "true"
319)]
320#[builder(setter(into, strip_option), default)]
321pub struct ListStaticRolesRequest {
322 #[endpoint(skip)]
323 pub mount: String,
324}
325
326#[derive(Builder, Debug, Default, Endpoint)]
334#[endpoint(
335 path = "{self.mount}/static-roles/{self.name}",
336 method = "DELETE",
337 builder = "true"
338)]
339#[builder(setter(into, strip_option), default)]
340pub struct DeleteStaticRoleRequest {
341 #[endpoint(skip)]
342 pub mount: String,
343 #[endpoint(skip)]
344 pub name: String,
345}
346
347#[derive(Builder, Debug, Default, Endpoint)]
355#[endpoint(
356 path = "{self.mount}/static-creds/{self.name}",
357 response = "GetStaticCredentialsResponse",
358 builder = "true"
359)]
360#[builder(setter(into, strip_option), default)]
361pub struct GetStaticCredentialsRequest {
362 #[endpoint(skip)]
363 pub mount: String,
364 #[endpoint(skip)]
365 pub name: String,
366}
367
368#[derive(Builder, Debug, Default, Endpoint)]
377#[endpoint(
378 path = "{self.mount}/rotate-role/{self.name}",
379 method = "POST",
380 builder = "true"
381)]
382#[builder(setter(into, strip_option), default)]
383pub struct RotateStaticRoleRequest {
384 #[endpoint(skip)]
385 pub mount: String,
386 #[endpoint(skip)]
387 pub name: String,
388}