casdoor_sdk/apis/
mfaapi_api.rs1
2
3use reqwest;
4
5use crate::{apis::ResponseContent, models};
6use super::{Error, configuration};
7
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11#[serde(untagged)]
12pub enum ApiControllerDeleteMfaError {
13 UnknownValue(serde_json::Value),
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ApiControllerMfaSetupEnableError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum ApiControllerMfaSetupInitiateError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum ApiControllerMfaSetupVerifyError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum ApiControllerSetPreferredMfaError {
41 UnknownValue(serde_json::Value),
42}
43
44
45pub async fn delete_mfa(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerDeleteMfaError>> {
47 let local_var_configuration = configuration;
48
49 let local_var_client = &local_var_configuration.client;
53
54 let local_var_uri_str = format!("{}/api/delete-mfa/", local_var_configuration.base_path);
55 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
56
57 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
58 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
59 }
60
61 let local_var_req = local_var_req_builder.build()?;
62 let local_var_resp = local_var_client.execute(local_var_req).await?;
63
64 let local_var_status = local_var_resp.status();
65 let local_var_content = local_var_resp.text().await?;
66
67 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
68 serde_json::from_str(&local_var_content).map_err(Error::from)
69 } else {
70 let local_var_entity: Option<ApiControllerDeleteMfaError> = serde_json::from_str(&local_var_content).ok();
71 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
72 Err(Error::ResponseError(local_var_error))
73 }
74}
75
76pub async fn mfa_setup_enable(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerMfaSetupEnableError>> {
78 let local_var_configuration = configuration;
79
80 let local_var_client = &local_var_configuration.client;
84
85 let local_var_uri_str = format!("{}/api/mfa/setup/enable", local_var_configuration.base_path);
86 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
87
88 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
89 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
90 }
91
92 let local_var_req = local_var_req_builder.build()?;
93 let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95 let local_var_status = local_var_resp.status();
96 let local_var_content = local_var_resp.text().await?;
97
98 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99 serde_json::from_str(&local_var_content).map_err(Error::from)
100 } else {
101 let local_var_entity: Option<ApiControllerMfaSetupEnableError> = serde_json::from_str(&local_var_content).ok();
102 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
103 Err(Error::ResponseError(local_var_error))
104 }
105}
106
107pub async fn mfa_setup_initiate(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerMfaSetupInitiateError>> {
109 let local_var_configuration = configuration;
110
111 let local_var_client = &local_var_configuration.client;
115
116 let local_var_uri_str = format!("{}/api/mfa/setup/initiate", local_var_configuration.base_path);
117 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
118
119 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
120 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
121 }
122
123 let local_var_req = local_var_req_builder.build()?;
124 let local_var_resp = local_var_client.execute(local_var_req).await?;
125
126 let local_var_status = local_var_resp.status();
127 let local_var_content = local_var_resp.text().await?;
128
129 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130 serde_json::from_str(&local_var_content).map_err(Error::from)
131 } else {
132 let local_var_entity: Option<ApiControllerMfaSetupInitiateError> = serde_json::from_str(&local_var_content).ok();
133 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
134 Err(Error::ResponseError(local_var_error))
135 }
136}
137
138pub async fn mfa_setup_verify(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerMfaSetupVerifyError>> {
140 let local_var_configuration = configuration;
141
142 let local_var_client = &local_var_configuration.client;
146
147 let local_var_uri_str = format!("{}/api/mfa/setup/verify", local_var_configuration.base_path);
148 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
149
150 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
151 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
152 }
153
154 let local_var_req = local_var_req_builder.build()?;
155 let local_var_resp = local_var_client.execute(local_var_req).await?;
156
157 let local_var_status = local_var_resp.status();
158 let local_var_content = local_var_resp.text().await?;
159
160 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
161 serde_json::from_str(&local_var_content).map_err(Error::from)
162 } else {
163 let local_var_entity: Option<ApiControllerMfaSetupVerifyError> = serde_json::from_str(&local_var_content).ok();
164 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
165 Err(Error::ResponseError(local_var_error))
166 }
167}
168
169pub async fn set_preferred_mfa(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerSetPreferredMfaError>> {
171 let local_var_configuration = configuration;
172
173 let local_var_client = &local_var_configuration.client;
177
178 let local_var_uri_str = format!("{}/api/set-preferred-mfa", local_var_configuration.base_path);
179 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
180
181 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
182 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
183 }
184
185 let local_var_req = local_var_req_builder.build()?;
186 let local_var_resp = local_var_client.execute(local_var_req).await?;
187
188 let local_var_status = local_var_resp.status();
189 let local_var_content = local_var_resp.text().await?;
190
191 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
192 serde_json::from_str(&local_var_content).map_err(Error::from)
193 } else {
194 let local_var_entity: Option<ApiControllerSetPreferredMfaError> = serde_json::from_str(&local_var_content).ok();
195 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
196 Err(Error::ResponseError(local_var_error))
197 }
198}
199