sdkms/generated/
session_generated.rs

1/* Copyright (c) Fortanix, Inc.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7use super::*;
8use serde::{Deserialize, Serialize};
9
10/// A challenge used for multi-factor authentication.
11#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
12pub struct MfaChallengeResponse {
13    pub u2f_challenge: String,
14    pub u2f_keys: Vec<U2fRegisteredKey>,
15}
16
17/// Description of a registered U2F device.
18#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
19#[serde(rename_all = "camelCase")]
20pub struct U2fRegisteredKey {
21    pub key_handle: String,
22    pub version: String,
23}
24
25/// Request to select an account.
26#[derive(Debug, Serialize, Deserialize, Clone)]
27pub struct SelectAccountRequest {
28    pub acct_id: Uuid,
29}
30
31/// Response to select account request.
32#[derive(Debug, Serialize, Deserialize, Clone)]
33pub struct SelectAccountResponse {
34    #[serde(default)]
35    pub cookie: Option<String>,
36}
37
38/// Request to start configuring U2F.
39#[derive(Debug, Default, Serialize, Deserialize, Clone)]
40pub struct Config2faAuthRequest {
41    pub password: String,
42}
43
44#[derive(Debug, Default, Serialize, Deserialize, Clone)]
45pub struct Config2faAuthResponse {}
46
47/// Request to authenticate using U2F recovery code.
48#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
49pub struct RecoveryCodeAuthRequest {
50    pub recovery_code: String,
51}
52
53pub struct OperationRefresh;
54#[allow(unused)]
55impl Operation for OperationRefresh {
56    type PathParams = ();
57    type QueryParams = ();
58    type Body = ();
59    type Output = ();
60
61    fn method() -> Method {
62        Method::POST
63    }
64    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
65        format!("/sys/v1/session/refresh")
66    }
67    fn to_body(body: &Self::Body) -> Option<serde_json::Value> {
68        None
69    }
70}
71
72impl SdkmsClient {
73    pub fn refresh(&self) -> Result<()> {
74        self.execute::<OperationRefresh>(&(), (), None)
75    }
76}
77
78pub struct OperationSelectAccount;
79#[allow(unused)]
80impl Operation for OperationSelectAccount {
81    type PathParams = ();
82    type QueryParams = ();
83    type Body = SelectAccountRequest;
84    type Output = SelectAccountResponse;
85
86    fn method() -> Method {
87        Method::POST
88    }
89    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
90        format!("/sys/v1/session/select_account")
91    }
92}
93
94impl SdkmsClient {
95    pub fn select_account(&self, req: &SelectAccountRequest) -> Result<SelectAccountResponse> {
96        self.execute::<OperationSelectAccount>(req, (), None)
97    }
98}
99
100pub struct OperationU2fAuth;
101#[allow(unused)]
102impl Operation for OperationU2fAuth {
103    type PathParams = ();
104    type QueryParams = ();
105    type Body = U2fAuthRequest;
106    type Output = ();
107
108    fn method() -> Method {
109        Method::POST
110    }
111    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
112        format!("/sys/v1/session/auth/2fa/u2f")
113    }
114}
115
116impl SdkmsClient {
117    pub fn u2f_auth(&self, req: &U2fAuthRequest) -> Result<()> {
118        self.execute::<OperationU2fAuth>(req, (), None)
119    }
120}
121
122pub struct OperationRecoveryCodeAuth;
123#[allow(unused)]
124impl Operation for OperationRecoveryCodeAuth {
125    type PathParams = ();
126    type QueryParams = ();
127    type Body = RecoveryCodeAuthRequest;
128    type Output = ();
129
130    fn method() -> Method {
131        Method::POST
132    }
133    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
134        format!("/sys/v1/session/auth/2fa/recovery_code")
135    }
136}
137
138impl SdkmsClient {
139    pub fn recovery_code_auth(&self, req: &RecoveryCodeAuthRequest) -> Result<()> {
140        self.execute::<OperationRecoveryCodeAuth>(req, (), None)
141    }
142}
143
144pub struct OperationConfig2faAuth;
145#[allow(unused)]
146impl Operation for OperationConfig2faAuth {
147    type PathParams = ();
148    type QueryParams = ();
149    type Body = Config2faAuthRequest;
150    type Output = Config2faAuthResponse;
151
152    fn method() -> Method {
153        Method::POST
154    }
155    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
156        format!("/sys/v1/session/config_2fa/auth")
157    }
158}
159
160impl SdkmsClient {
161    pub fn config_2fa_auth(&self, req: &Config2faAuthRequest) -> Result<Config2faAuthResponse> {
162        self.execute::<OperationConfig2faAuth>(req, (), None)
163    }
164}
165
166pub struct OperationConfig2faTerminate;
167#[allow(unused)]
168impl Operation for OperationConfig2faTerminate {
169    type PathParams = ();
170    type QueryParams = ();
171    type Body = ();
172    type Output = ();
173
174    fn method() -> Method {
175        Method::POST
176    }
177    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
178        format!("/sys/v1/session/config_2fa/terminate")
179    }
180    fn to_body(body: &Self::Body) -> Option<serde_json::Value> {
181        None
182    }
183}
184
185impl SdkmsClient {
186    pub fn config_2fa_terminate(&self) -> Result<()> {
187        self.execute::<OperationConfig2faTerminate>(&(), (), None)
188    }
189}
190
191pub struct OperationU2fNewChallenge;
192#[allow(unused)]
193impl Operation for OperationU2fNewChallenge {
194    type PathParams = ();
195    type QueryParams = ();
196    type Body = ();
197    type Output = MfaChallengeResponse;
198
199    fn method() -> Method {
200        Method::POST
201    }
202    fn path(p: <Self::PathParams as TupleRef>::Ref, q: Option<&Self::QueryParams>) -> String {
203        format!("/sys/v1/session/config_2fa/new_challenge")
204    }
205    fn to_body(body: &Self::Body) -> Option<serde_json::Value> {
206        None
207    }
208}
209
210impl SdkmsClient {
211    pub fn u2f_new_challenge(&self) -> Result<MfaChallengeResponse> {
212        self.execute::<OperationU2fNewChallenge>(&(), (), None)
213    }
214}