1use std::collections::HashMap;
2
3use super::responses::{
4 GenerateSSHCredsResponse, ListRolesByIPResponse, ListRolesResponse,
5 ListZeroAddressRolesResponse, ReadPublicKeyResponse, ReadRoleResponse, SignSSHKeyResponse,
6 SubmitCAInfoResponse, VerifySSHOTPResponse,
7};
8use rustify_derive::Endpoint;
9
10#[derive(Builder, Debug, Default, Endpoint)]
18#[endpoint(
19 path = "{self.mount}/keys/{self.name}",
20 method = "POST",
21 builder = "true"
22)]
23#[builder(setter(into, strip_option), default)]
24pub struct SetKeyRequest {
25 #[endpoint(skip)]
26 pub mount: String,
27 #[endpoint(skip)]
28 pub name: String,
29 pub key: String,
30}
31
32#[derive(Builder, Debug, Default, Endpoint)]
40#[endpoint(
41 path = "{self.mount}/keys/{self.name}",
42 method = "DELETE",
43 builder = "true"
44)]
45#[builder(setter(into, strip_option), default)]
46pub struct DeleteKeyRequest {
47 #[endpoint(skip)]
48 pub mount: String,
49 #[endpoint(skip)]
50 pub name: String,
51}
52
53#[derive(Builder, Debug, Default, Endpoint)]
61#[endpoint(
62 path = "{self.mount}/roles/{self.name}",
63 method = "POST",
64 builder = "true"
65)]
66#[builder(setter(into, strip_option), default)]
67pub struct SetRoleRequest {
68 #[endpoint(skip)]
69 pub mount: String,
70 pub name: String,
71 pub key_type: String,
72 pub algorithm_signer: Option<String>,
73 pub allow_bare_domains: Option<bool>,
74 pub allow_host_certificates: Option<bool>,
75 pub allow_subdomains: Option<bool>,
76 pub allow_user_certificates: Option<bool>,
77 pub allow_user_key_ids: Option<bool>,
78 pub allowed_user_key_lengths: Option<HashMap<String, u64>>,
79 pub allowed_critical_options: Option<HashMap<String, String>>,
80 pub allowed_domains: Option<String>,
81 pub allowed_extensions: Option<String>,
82 pub allowed_users: Option<String>,
83 pub allowed_users_template: Option<bool>,
84 pub admin_user: Option<String>,
85 pub cidr_list: Option<String>,
86 pub efault_critical_options: Option<HashMap<String, String>>,
87 pub default_user: Option<String>,
88 pub exclude_cidr_list: Option<String>,
89 pub install_script: Option<String>,
90 pub key: Option<String>,
91 pub key_bits: Option<u64>,
92 pub key_id_format: Option<String>,
93 pub key_option_specs: Option<String>,
94 pub max_ttl: Option<String>,
95 pub port: Option<u64>,
96 pub ttl: Option<String>,
97}
98
99#[derive(Builder, Debug, Default, Endpoint)]
107#[endpoint(
108 path = "{self.mount}/roles/{self.name}",
109 response = "ReadRoleResponse",
110 builder = "true"
111)]
112#[builder(setter(into, strip_option), default)]
113pub struct ReadRoleRequest {
114 #[endpoint(skip)]
115 pub mount: String,
116 #[endpoint(skip)]
117 pub name: String,
118}
119
120#[derive(Builder, Debug, Default, Endpoint)]
128#[endpoint(
129 path = "{self.mount}/roles",
130 method = "LIST",
131 response = "ListRolesResponse",
132 builder = "true"
133)]
134#[builder(setter(into, strip_option), default)]
135pub struct ListRolesRequest {
136 #[endpoint(skip)]
137 pub mount: String,
138}
139
140#[derive(Builder, Debug, Default, Endpoint)]
148#[endpoint(
149 path = "{self.mount}/roles/{self.name}",
150 method = "DELETE",
151 builder = "true"
152)]
153#[builder(setter(into, strip_option), default)]
154pub struct DeleteRoleRequest {
155 #[endpoint(skip)]
156 pub mount: String,
157 #[endpoint(skip)]
158 pub name: String,
159}
160
161#[derive(Builder, Debug, Default, Endpoint)]
169#[endpoint(
170 path = "{self.mount}/config/zeroaddress",
171 response = "ListZeroAddressRolesResponse",
172 builder = "true"
173)]
174#[builder(setter(into, strip_option), default)]
175pub struct ListZeroAddressRolesRequest {
176 #[endpoint(skip)]
177 pub mount: String,
178}
179
180#[derive(Builder, Debug, Default, Endpoint)]
188#[endpoint(
189 path = "{self.mount}/config/zeroaddress",
190 method = "POST",
191 builder = "true"
192)]
193#[builder(setter(into, strip_option), default)]
194pub struct ConfigureZeroAddressRolesRequest {
195 #[endpoint(skip)]
196 pub mount: String,
197 pub roles: Vec<String>,
198}
199
200#[derive(Builder, Debug, Default, Endpoint)]
208#[endpoint(
209 path = "{self.mount}/roles/zeroaddress",
210 method = "DELETE",
211 builder = "true"
212)]
213#[builder(setter(into, strip_option), default)]
214pub struct DeleteZeroAddressRolesRequest {
215 #[endpoint(skip)]
216 pub mount: String,
217}
218
219#[derive(Builder, Debug, Default, Endpoint)]
228#[endpoint(
229 path = "{self.mount}/creds/{self.name}",
230 method = "POST",
231 response = "GenerateSSHCredsResponse",
232 builder = "true"
233)]
234#[builder(setter(into, strip_option), default)]
235pub struct GenerateSSHCredsRequest {
236 #[endpoint(skip)]
237 pub mount: String,
238 #[endpoint(skip)]
239 pub name: String,
240 pub ip: String,
241 pub username: Option<String>,
242}
243
244#[derive(Builder, Debug, Default, Endpoint)]
252#[endpoint(
253 path = "{self.mount}/lookup",
254 method = "POST",
255 response = "ListRolesByIPResponse",
256 builder = "true"
257)]
258#[builder(setter(into, strip_option), default)]
259pub struct ListRolesByIPRequest {
260 #[endpoint(skip)]
261 pub mount: String,
262 pub ip: String,
263}
264
265#[derive(Builder, Debug, Default, Endpoint)]
273#[endpoint(
274 path = "{self.mount}/verify",
275 method = "POST",
276 response = "VerifySSHOTPResponse",
277 builder = "true"
278)]
279#[builder(setter(into, strip_option), default)]
280pub struct VerifySSHOTPRequest {
281 #[endpoint(skip)]
282 pub mount: String,
283 pub otp: String,
284}
285
286#[derive(Builder, Debug, Default, Endpoint)]
295#[endpoint(
296 path = "{self.mount}/config/ca",
297 method = "POST",
298 response = "SubmitCAInfoResponse",
299 builder = "true"
300)]
301#[builder(setter(into, strip_option), default)]
302pub struct SubmitCAInfoRequest {
303 #[endpoint(skip)]
304 pub mount: String,
305 pub generate_signing_key: Option<bool>,
306 pub private_key: Option<String>,
307 pub public_key: Option<String>,
308}
309
310#[derive(Builder, Debug, Default, Endpoint)]
318#[endpoint(path = "{self.mount}/config/ca", method = "DELETE", builder = "true")]
319#[builder(setter(into, strip_option), default)]
320pub struct DeleteCAInfoRequest {
321 #[endpoint(skip)]
322 pub mount: String,
323}
324
325#[derive(Builder, Debug, Default, Endpoint)]
333#[endpoint(
334 path = "{self.mount}/config/ca",
335 response = "ReadPublicKeyResponse",
336 builder = "true"
337)]
338#[builder(setter(into, strip_option), default)]
339pub struct ReadPublicKeyRequest {
340 #[endpoint(skip)]
341 pub mount: String,
342}
343
344#[derive(Builder, Debug, Default, Endpoint)]
353#[endpoint(
354 path = "{self.mount}/sign/{self.name}",
355 method = "POST",
356 response = "SignSSHKeyResponse",
357 builder = "true"
358)]
359#[builder(setter(into, strip_option), default)]
360pub struct SignSSHKeyRequest {
361 #[endpoint(skip)]
362 pub mount: String,
363 #[endpoint(skip)]
364 pub name: String,
365 pub cert_type: Option<String>,
366 pub critical_options: Option<HashMap<String, String>>,
367 pub extensions: Option<HashMap<String, String>>,
368 pub key_id: Option<String>,
369 pub public_key: String,
370 pub ttl: Option<String>,
371 pub valid_principals: Option<String>,
372}