ory_kratos_client/apis/
frontend_api.rs

1/*
2 * Ory Identities API
3 *
4 * This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more. 
5 *
6 * The version of the OpenAPI document: v1.3.8
7 * Contact: office@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_browser_login_flow`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateBrowserLoginFlowError {
22    Status400(models::ErrorGeneric),
23    DefaultResponse(models::ErrorGeneric),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`create_browser_logout_flow`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum CreateBrowserLogoutFlowError {
31    Status400(models::ErrorGeneric),
32    Status401(models::ErrorGeneric),
33    Status500(models::ErrorGeneric),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`create_browser_recovery_flow`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum CreateBrowserRecoveryFlowError {
41    Status400(models::ErrorGeneric),
42    DefaultResponse(models::ErrorGeneric),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`create_browser_registration_flow`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum CreateBrowserRegistrationFlowError {
50    DefaultResponse(models::ErrorGeneric),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`create_browser_settings_flow`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum CreateBrowserSettingsFlowError {
58    Status400(models::ErrorGeneric),
59    Status401(models::ErrorGeneric),
60    Status403(models::ErrorGeneric),
61    DefaultResponse(models::ErrorGeneric),
62    UnknownValue(serde_json::Value),
63}
64
65/// struct for typed errors of method [`create_browser_verification_flow`]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum CreateBrowserVerificationFlowError {
69    DefaultResponse(models::ErrorGeneric),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`create_fedcm_flow`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum CreateFedcmFlowError {
77    Status400(models::ErrorGeneric),
78    DefaultResponse(models::ErrorGeneric),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`create_native_login_flow`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum CreateNativeLoginFlowError {
86    Status400(models::ErrorGeneric),
87    DefaultResponse(models::ErrorGeneric),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`create_native_recovery_flow`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum CreateNativeRecoveryFlowError {
95    Status400(models::ErrorGeneric),
96    DefaultResponse(models::ErrorGeneric),
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`create_native_registration_flow`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum CreateNativeRegistrationFlowError {
104    Status400(models::ErrorGeneric),
105    DefaultResponse(models::ErrorGeneric),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`create_native_settings_flow`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum CreateNativeSettingsFlowError {
113    Status400(models::ErrorGeneric),
114    DefaultResponse(models::ErrorGeneric),
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`create_native_verification_flow`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum CreateNativeVerificationFlowError {
122    Status400(models::ErrorGeneric),
123    DefaultResponse(models::ErrorGeneric),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method [`disable_my_other_sessions`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum DisableMyOtherSessionsError {
131    Status400(models::ErrorGeneric),
132    Status401(models::ErrorGeneric),
133    DefaultResponse(models::ErrorGeneric),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`disable_my_session`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum DisableMySessionError {
141    Status400(models::ErrorGeneric),
142    Status401(models::ErrorGeneric),
143    DefaultResponse(models::ErrorGeneric),
144    UnknownValue(serde_json::Value),
145}
146
147/// struct for typed errors of method [`exchange_session_token`]
148#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum ExchangeSessionTokenError {
151    Status403(models::ErrorGeneric),
152    Status404(models::ErrorGeneric),
153    Status410(models::ErrorGeneric),
154    DefaultResponse(models::ErrorGeneric),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`get_flow_error`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum GetFlowErrorError {
162    Status403(models::ErrorGeneric),
163    Status404(models::ErrorGeneric),
164    Status500(models::ErrorGeneric),
165    UnknownValue(serde_json::Value),
166}
167
168/// struct for typed errors of method [`get_login_flow`]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum GetLoginFlowError {
172    Status403(models::ErrorGeneric),
173    Status404(models::ErrorGeneric),
174    Status410(models::ErrorGeneric),
175    DefaultResponse(models::ErrorGeneric),
176    UnknownValue(serde_json::Value),
177}
178
179/// struct for typed errors of method [`get_recovery_flow`]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum GetRecoveryFlowError {
183    Status404(models::ErrorGeneric),
184    Status410(models::ErrorGeneric),
185    DefaultResponse(models::ErrorGeneric),
186    UnknownValue(serde_json::Value),
187}
188
189/// struct for typed errors of method [`get_registration_flow`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum GetRegistrationFlowError {
193    Status403(models::ErrorGeneric),
194    Status404(models::ErrorGeneric),
195    Status410(models::ErrorGeneric),
196    DefaultResponse(models::ErrorGeneric),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`get_settings_flow`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetSettingsFlowError {
204    Status401(models::ErrorGeneric),
205    Status403(models::ErrorGeneric),
206    Status404(models::ErrorGeneric),
207    Status410(models::ErrorGeneric),
208    DefaultResponse(models::ErrorGeneric),
209    UnknownValue(serde_json::Value),
210}
211
212/// struct for typed errors of method [`get_verification_flow`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum GetVerificationFlowError {
216    Status403(models::ErrorGeneric),
217    Status404(models::ErrorGeneric),
218    DefaultResponse(models::ErrorGeneric),
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`get_web_authn_java_script`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum GetWebAuthnJavaScriptError {
226    UnknownValue(serde_json::Value),
227}
228
229/// struct for typed errors of method [`list_my_sessions`]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum ListMySessionsError {
233    Status400(models::ErrorGeneric),
234    Status401(models::ErrorGeneric),
235    DefaultResponse(models::ErrorGeneric),
236    UnknownValue(serde_json::Value),
237}
238
239/// struct for typed errors of method [`perform_native_logout`]
240#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum PerformNativeLogoutError {
243    Status400(models::ErrorGeneric),
244    DefaultResponse(models::ErrorGeneric),
245    UnknownValue(serde_json::Value),
246}
247
248/// struct for typed errors of method [`to_session`]
249#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum ToSessionError {
252    Status401(models::ErrorGeneric),
253    Status403(models::ErrorGeneric),
254    DefaultResponse(models::ErrorGeneric),
255    UnknownValue(serde_json::Value),
256}
257
258/// struct for typed errors of method [`update_fedcm_flow`]
259#[derive(Debug, Clone, Serialize, Deserialize)]
260#[serde(untagged)]
261pub enum UpdateFedcmFlowError {
262    Status400(models::LoginFlow),
263    Status410(models::ErrorGeneric),
264    Status422(models::ErrorBrowserLocationChangeRequired),
265    DefaultResponse(models::ErrorGeneric),
266    UnknownValue(serde_json::Value),
267}
268
269/// struct for typed errors of method [`update_login_flow`]
270#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum UpdateLoginFlowError {
273    Status400(models::LoginFlow),
274    Status410(models::ErrorGeneric),
275    Status422(models::ErrorBrowserLocationChangeRequired),
276    DefaultResponse(models::ErrorGeneric),
277    UnknownValue(serde_json::Value),
278}
279
280/// struct for typed errors of method [`update_logout_flow`]
281#[derive(Debug, Clone, Serialize, Deserialize)]
282#[serde(untagged)]
283pub enum UpdateLogoutFlowError {
284    DefaultResponse(models::ErrorGeneric),
285    UnknownValue(serde_json::Value),
286}
287
288/// struct for typed errors of method [`update_recovery_flow`]
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum UpdateRecoveryFlowError {
292    Status400(models::RecoveryFlow),
293    Status410(models::ErrorGeneric),
294    Status422(models::ErrorBrowserLocationChangeRequired),
295    DefaultResponse(models::ErrorGeneric),
296    UnknownValue(serde_json::Value),
297}
298
299/// struct for typed errors of method [`update_registration_flow`]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301#[serde(untagged)]
302pub enum UpdateRegistrationFlowError {
303    Status400(models::RegistrationFlow),
304    Status410(models::ErrorGeneric),
305    Status422(models::ErrorBrowserLocationChangeRequired),
306    DefaultResponse(models::ErrorGeneric),
307    UnknownValue(serde_json::Value),
308}
309
310/// struct for typed errors of method [`update_settings_flow`]
311#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum UpdateSettingsFlowError {
314    Status400(models::SettingsFlow),
315    Status401(models::ErrorGeneric),
316    Status403(models::ErrorGeneric),
317    Status410(models::ErrorGeneric),
318    Status422(models::ErrorBrowserLocationChangeRequired),
319    DefaultResponse(models::ErrorGeneric),
320    UnknownValue(serde_json::Value),
321}
322
323/// struct for typed errors of method [`update_verification_flow`]
324#[derive(Debug, Clone, Serialize, Deserialize)]
325#[serde(untagged)]
326pub enum UpdateVerificationFlowError {
327    Status400(models::VerificationFlow),
328    Status410(models::ErrorGeneric),
329    DefaultResponse(models::ErrorGeneric),
330    UnknownValue(serde_json::Value),
331}
332
333
334/// This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
335pub async fn create_browser_login_flow(configuration: &configuration::Configuration, refresh: Option<bool>, aal: Option<&str>, return_to: Option<&str>, cookie: Option<&str>, login_challenge: Option<&str>, organization: Option<&str>, via: Option<&str>) -> Result<models::LoginFlow, Error<CreateBrowserLoginFlowError>> {
336    let local_var_configuration = configuration;
337
338    let local_var_client = &local_var_configuration.client;
339
340    let local_var_uri_str = format!("{}/self-service/login/browser", local_var_configuration.base_path);
341    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
342
343    if let Some(ref local_var_str) = refresh {
344        local_var_req_builder = local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
345    }
346    if let Some(ref local_var_str) = aal {
347        local_var_req_builder = local_var_req_builder.query(&[("aal", &local_var_str.to_string())]);
348    }
349    if let Some(ref local_var_str) = return_to {
350        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
351    }
352    if let Some(ref local_var_str) = login_challenge {
353        local_var_req_builder = local_var_req_builder.query(&[("login_challenge", &local_var_str.to_string())]);
354    }
355    if let Some(ref local_var_str) = organization {
356        local_var_req_builder = local_var_req_builder.query(&[("organization", &local_var_str.to_string())]);
357    }
358    if let Some(ref local_var_str) = via {
359        local_var_req_builder = local_var_req_builder.query(&[("via", &local_var_str.to_string())]);
360    }
361    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
362        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
363    }
364    if let Some(local_var_param_value) = cookie {
365        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
366    }
367
368    let local_var_req = local_var_req_builder.build()?;
369    let local_var_resp = local_var_client.execute(local_var_req).await?;
370
371    let local_var_status = local_var_resp.status();
372    let local_var_content = local_var_resp.text().await?;
373
374    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
375        serde_json::from_str(&local_var_content).map_err(Error::from)
376    } else {
377        let local_var_entity: Option<CreateBrowserLoginFlowError> = serde_json::from_str(&local_var_content).ok();
378        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
379        Err(Error::ResponseError(local_var_error))
380    }
381}
382
383/// This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error.  When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.
384pub async fn create_browser_logout_flow(configuration: &configuration::Configuration, cookie: Option<&str>, return_to: Option<&str>) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
385    let local_var_configuration = configuration;
386
387    let local_var_client = &local_var_configuration.client;
388
389    let local_var_uri_str = format!("{}/self-service/logout/browser", local_var_configuration.base_path);
390    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
391
392    if let Some(ref local_var_str) = return_to {
393        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
394    }
395    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
396        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
397    }
398    if let Some(local_var_param_value) = cookie {
399        local_var_req_builder = local_var_req_builder.header("cookie", local_var_param_value.to_string());
400    }
401
402    let local_var_req = local_var_req_builder.build()?;
403    let local_var_resp = local_var_client.execute(local_var_req).await?;
404
405    let local_var_status = local_var_resp.status();
406    let local_var_content = local_var_resp.text().await?;
407
408    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
409        serde_json::from_str(&local_var_content).map_err(Error::from)
410    } else {
411        let local_var_entity: Option<CreateBrowserLogoutFlowError> = serde_json::from_str(&local_var_content).ok();
412        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
413        Err(Error::ResponseError(local_var_error))
414    }
415}
416
417/// This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists, the browser is returned to the configured return URL.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects or a 400 bad request error if the user is already authenticated.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
418pub async fn create_browser_recovery_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
419    let local_var_configuration = configuration;
420
421    let local_var_client = &local_var_configuration.client;
422
423    let local_var_uri_str = format!("{}/self-service/recovery/browser", local_var_configuration.base_path);
424    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
425
426    if let Some(ref local_var_str) = return_to {
427        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
428    }
429    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
430        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
431    }
432
433    let local_var_req = local_var_req_builder.build()?;
434    let local_var_resp = local_var_client.execute(local_var_req).await?;
435
436    let local_var_status = local_var_resp.status();
437    let local_var_content = local_var_resp.text().await?;
438
439    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
440        serde_json::from_str(&local_var_content).map_err(Error::from)
441    } else {
442        let local_var_entity: Option<CreateBrowserRecoveryFlowError> = serde_json::from_str(&local_var_content).ok();
443        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
444        Err(Error::ResponseError(local_var_error))
445    }
446}
447
448/// This endpoint initializes a browser-based user registration flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.registration.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url`.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  If this endpoint is called via an AJAX request, the response contains the registration flow without a redirect.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
449pub async fn create_browser_registration_flow(configuration: &configuration::Configuration, return_to: Option<&str>, login_challenge: Option<&str>, after_verification_return_to: Option<&str>, organization: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateBrowserRegistrationFlowError>> {
450    let local_var_configuration = configuration;
451
452    let local_var_client = &local_var_configuration.client;
453
454    let local_var_uri_str = format!("{}/self-service/registration/browser", local_var_configuration.base_path);
455    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
456
457    if let Some(ref local_var_str) = return_to {
458        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
459    }
460    if let Some(ref local_var_str) = login_challenge {
461        local_var_req_builder = local_var_req_builder.query(&[("login_challenge", &local_var_str.to_string())]);
462    }
463    if let Some(ref local_var_str) = after_verification_return_to {
464        local_var_req_builder = local_var_req_builder.query(&[("after_verification_return_to", &local_var_str.to_string())]);
465    }
466    if let Some(ref local_var_str) = organization {
467        local_var_req_builder = local_var_req_builder.query(&[("organization", &local_var_str.to_string())]);
468    }
469    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
470        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
471    }
472
473    let local_var_req = local_var_req_builder.build()?;
474    let local_var_resp = local_var_client.execute(local_var_req).await?;
475
476    let local_var_status = local_var_resp.status();
477    let local_var_content = local_var_resp.text().await?;
478
479    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
480        serde_json::from_str(&local_var_content).map_err(Error::from)
481    } else {
482        let local_var_entity: Option<CreateBrowserRegistrationFlowError> = serde_json::from_str(&local_var_content).ok();
483        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
484        Err(Error::ResponseError(local_var_error))
485    }
486}
487
488/// This endpoint initializes a browser-based user settings flow. Once initialized, the browser will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid Ory Kratos Session Cookie is included in the request, a login flow will be initialized.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid user session was set, the browser will be redirected to the login endpoint.  If this endpoint is called via an AJAX request, the response contains the settings flow without any redirects or a 401 forbidden error if no valid session was set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
489pub async fn create_browser_settings_flow(configuration: &configuration::Configuration, return_to: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
490    let local_var_configuration = configuration;
491
492    let local_var_client = &local_var_configuration.client;
493
494    let local_var_uri_str = format!("{}/self-service/settings/browser", local_var_configuration.base_path);
495    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
496
497    if let Some(ref local_var_str) = return_to {
498        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
499    }
500    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
501        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
502    }
503    if let Some(local_var_param_value) = cookie {
504        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
505    }
506
507    let local_var_req = local_var_req_builder.build()?;
508    let local_var_resp = local_var_client.execute(local_var_req).await?;
509
510    let local_var_status = local_var_resp.status();
511    let local_var_content = local_var_resp.text().await?;
512
513    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
514        serde_json::from_str(&local_var_content).map_err(Error::from)
515    } else {
516        let local_var_entity: Option<CreateBrowserSettingsFlowError> = serde_json::from_str(&local_var_content).ok();
517        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
518        Err(Error::ResponseError(local_var_error))
519    }
520}
521
522/// This endpoint initializes a browser-based account verification flow. Once initialized, the browser will be redirected to `selfservice.flows.verification.ui_url` with the flow ID set as the query parameter `?flow=`.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...).  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
523pub async fn create_browser_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
524    let local_var_configuration = configuration;
525
526    let local_var_client = &local_var_configuration.client;
527
528    let local_var_uri_str = format!("{}/self-service/verification/browser", local_var_configuration.base_path);
529    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
530
531    if let Some(ref local_var_str) = return_to {
532        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
533    }
534    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
535        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
536    }
537
538    let local_var_req = local_var_req_builder.build()?;
539    let local_var_resp = local_var_client.execute(local_var_req).await?;
540
541    let local_var_status = local_var_resp.status();
542    let local_var_content = local_var_resp.text().await?;
543
544    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
545        serde_json::from_str(&local_var_content).map_err(Error::from)
546    } else {
547        let local_var_entity: Option<CreateBrowserVerificationFlowError> = serde_json::from_str(&local_var_content).ok();
548        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
549        Err(Error::ResponseError(local_var_error))
550    }
551}
552
553/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
554pub async fn create_fedcm_flow(configuration: &configuration::Configuration, ) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
555    let local_var_configuration = configuration;
556
557    let local_var_client = &local_var_configuration.client;
558
559    let local_var_uri_str = format!("{}/self-service/fed-cm/parameters", local_var_configuration.base_path);
560    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
561
562    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
563        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
564    }
565
566    let local_var_req = local_var_req_builder.build()?;
567    let local_var_resp = local_var_client.execute(local_var_req).await?;
568
569    let local_var_status = local_var_resp.status();
570    let local_var_content = local_var_resp.text().await?;
571
572    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
573        serde_json::from_str(&local_var_content).map_err(Error::from)
574    } else {
575        let local_var_entity: Option<CreateFedcmFlowError> = serde_json::from_str(&local_var_content).ok();
576        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
577        Err(Error::ResponseError(local_var_error))
578    }
579}
580
581/// This endpoint initiates a login flow for native apps that do not use a browser, such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing login flow call `/self-service/login/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks, including CSRF login attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
582pub async fn create_native_login_flow(configuration: &configuration::Configuration, refresh: Option<bool>, aal: Option<&str>, x_session_token: Option<&str>, return_session_token_exchange_code: Option<bool>, return_to: Option<&str>, organization: Option<&str>, via: Option<&str>) -> Result<models::LoginFlow, Error<CreateNativeLoginFlowError>> {
583    let local_var_configuration = configuration;
584
585    let local_var_client = &local_var_configuration.client;
586
587    let local_var_uri_str = format!("{}/self-service/login/api", local_var_configuration.base_path);
588    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
589
590    if let Some(ref local_var_str) = refresh {
591        local_var_req_builder = local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
592    }
593    if let Some(ref local_var_str) = aal {
594        local_var_req_builder = local_var_req_builder.query(&[("aal", &local_var_str.to_string())]);
595    }
596    if let Some(ref local_var_str) = return_session_token_exchange_code {
597        local_var_req_builder = local_var_req_builder.query(&[("return_session_token_exchange_code", &local_var_str.to_string())]);
598    }
599    if let Some(ref local_var_str) = return_to {
600        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
601    }
602    if let Some(ref local_var_str) = organization {
603        local_var_req_builder = local_var_req_builder.query(&[("organization", &local_var_str.to_string())]);
604    }
605    if let Some(ref local_var_str) = via {
606        local_var_req_builder = local_var_req_builder.query(&[("via", &local_var_str.to_string())]);
607    }
608    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
609        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
610    }
611    if let Some(local_var_param_value) = x_session_token {
612        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
613    }
614
615    let local_var_req = local_var_req_builder.build()?;
616    let local_var_resp = local_var_client.execute(local_var_req).await?;
617
618    let local_var_status = local_var_resp.status();
619    let local_var_content = local_var_resp.text().await?;
620
621    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
622        serde_json::from_str(&local_var_content).map_err(Error::from)
623    } else {
624        let local_var_entity: Option<CreateNativeLoginFlowError> = serde_json::from_str(&local_var_content).ok();
625        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
626        Err(Error::ResponseError(local_var_error))
627    }
628}
629
630/// This endpoint initiates a recovery flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error.  On an existing recovery flow, use the `getRecoveryFlow` API endpoint.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
631pub async fn create_native_recovery_flow(configuration: &configuration::Configuration, ) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
632    let local_var_configuration = configuration;
633
634    let local_var_client = &local_var_configuration.client;
635
636    let local_var_uri_str = format!("{}/self-service/recovery/api", local_var_configuration.base_path);
637    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
638
639    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
640        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
641    }
642
643    let local_var_req = local_var_req_builder.build()?;
644    let local_var_resp = local_var_client.execute(local_var_req).await?;
645
646    let local_var_status = local_var_resp.status();
647    let local_var_content = local_var_resp.text().await?;
648
649    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
650        serde_json::from_str(&local_var_content).map_err(Error::from)
651    } else {
652        let local_var_entity: Option<CreateNativeRecoveryFlowError> = serde_json::from_str(&local_var_content).ok();
653        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
654        Err(Error::ResponseError(local_var_error))
655    }
656}
657
658/// This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing registration flow call `/self-service/registration/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
659pub async fn create_native_registration_flow(configuration: &configuration::Configuration, return_session_token_exchange_code: Option<bool>, return_to: Option<&str>, organization: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateNativeRegistrationFlowError>> {
660    let local_var_configuration = configuration;
661
662    let local_var_client = &local_var_configuration.client;
663
664    let local_var_uri_str = format!("{}/self-service/registration/api", local_var_configuration.base_path);
665    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
666
667    if let Some(ref local_var_str) = return_session_token_exchange_code {
668        local_var_req_builder = local_var_req_builder.query(&[("return_session_token_exchange_code", &local_var_str.to_string())]);
669    }
670    if let Some(ref local_var_str) = return_to {
671        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
672    }
673    if let Some(ref local_var_str) = organization {
674        local_var_req_builder = local_var_req_builder.query(&[("organization", &local_var_str.to_string())]);
675    }
676    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
677        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
678    }
679
680    let local_var_req = local_var_req_builder.build()?;
681    let local_var_resp = local_var_client.execute(local_var_req).await?;
682
683    let local_var_status = local_var_resp.status();
684    let local_var_content = local_var_resp.text().await?;
685
686    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
687        serde_json::from_str(&local_var_content).map_err(Error::from)
688    } else {
689        let local_var_entity: Option<CreateNativeRegistrationFlowError> = serde_json::from_str(&local_var_content).ok();
690        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
691        Err(Error::ResponseError(local_var_error))
692    }
693}
694
695/// This endpoint initiates a settings flow for API clients such as mobile devices, smart TVs, and so on. You must provide a valid Ory Kratos Session Token for this endpoint to respond with HTTP 200 OK.  To fetch an existing settings flow call `/self-service/settings/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
696pub async fn create_native_settings_flow(configuration: &configuration::Configuration, x_session_token: Option<&str>) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
697    let local_var_configuration = configuration;
698
699    let local_var_client = &local_var_configuration.client;
700
701    let local_var_uri_str = format!("{}/self-service/settings/api", local_var_configuration.base_path);
702    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
703
704    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
705        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
706    }
707    if let Some(local_var_param_value) = x_session_token {
708        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
709    }
710
711    let local_var_req = local_var_req_builder.build()?;
712    let local_var_resp = local_var_client.execute(local_var_req).await?;
713
714    let local_var_status = local_var_resp.status();
715    let local_var_content = local_var_resp.text().await?;
716
717    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
718        serde_json::from_str(&local_var_content).map_err(Error::from)
719    } else {
720        let local_var_entity: Option<CreateNativeSettingsFlowError> = serde_json::from_str(&local_var_content).ok();
721        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
722        Err(Error::ResponseError(local_var_error))
723    }
724}
725
726/// This endpoint initiates a verification flow for API clients such as mobile devices, smart TVs, and so on.  To fetch an existing verification flow call `/self-service/verification/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
727pub async fn create_native_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
728    let local_var_configuration = configuration;
729
730    let local_var_client = &local_var_configuration.client;
731
732    let local_var_uri_str = format!("{}/self-service/verification/api", local_var_configuration.base_path);
733    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
734
735    if let Some(ref local_var_str) = return_to {
736        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
737    }
738    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
739        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
740    }
741
742    let local_var_req = local_var_req_builder.build()?;
743    let local_var_resp = local_var_client.execute(local_var_req).await?;
744
745    let local_var_status = local_var_resp.status();
746    let local_var_content = local_var_resp.text().await?;
747
748    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
749        serde_json::from_str(&local_var_content).map_err(Error::from)
750    } else {
751        let local_var_entity: Option<CreateNativeVerificationFlowError> = serde_json::from_str(&local_var_content).ok();
752        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
753        Err(Error::ResponseError(local_var_error))
754    }
755}
756
757/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
758pub async fn disable_my_other_sessions(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
759    let local_var_configuration = configuration;
760
761    let local_var_client = &local_var_configuration.client;
762
763    let local_var_uri_str = format!("{}/sessions", local_var_configuration.base_path);
764    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
765
766    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
767        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
768    }
769    if let Some(local_var_param_value) = x_session_token {
770        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
771    }
772    if let Some(local_var_param_value) = cookie {
773        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
774    }
775
776    let local_var_req = local_var_req_builder.build()?;
777    let local_var_resp = local_var_client.execute(local_var_req).await?;
778
779    let local_var_status = local_var_resp.status();
780    let local_var_content = local_var_resp.text().await?;
781
782    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
783        serde_json::from_str(&local_var_content).map_err(Error::from)
784    } else {
785        let local_var_entity: Option<DisableMyOtherSessionsError> = serde_json::from_str(&local_var_content).ok();
786        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
787        Err(Error::ResponseError(local_var_error))
788    }
789}
790
791/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
792pub async fn disable_my_session(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<(), Error<DisableMySessionError>> {
793    let local_var_configuration = configuration;
794
795    let local_var_client = &local_var_configuration.client;
796
797    let local_var_uri_str = format!("{}/sessions/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
798    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
799
800    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
801        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
802    }
803    if let Some(local_var_param_value) = x_session_token {
804        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
805    }
806    if let Some(local_var_param_value) = cookie {
807        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
808    }
809
810    let local_var_req = local_var_req_builder.build()?;
811    let local_var_resp = local_var_client.execute(local_var_req).await?;
812
813    let local_var_status = local_var_resp.status();
814    let local_var_content = local_var_resp.text().await?;
815
816    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
817        Ok(())
818    } else {
819        let local_var_entity: Option<DisableMySessionError> = serde_json::from_str(&local_var_content).ok();
820        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
821        Err(Error::ResponseError(local_var_error))
822    }
823}
824
825pub async fn exchange_session_token(configuration: &configuration::Configuration, init_code: &str, return_to_code: &str) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
826    let local_var_configuration = configuration;
827
828    let local_var_client = &local_var_configuration.client;
829
830    let local_var_uri_str = format!("{}/sessions/token-exchange", local_var_configuration.base_path);
831    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
832
833    local_var_req_builder = local_var_req_builder.query(&[("init_code", &init_code.to_string())]);
834    local_var_req_builder = local_var_req_builder.query(&[("return_to_code", &return_to_code.to_string())]);
835    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
836        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
837    }
838
839    let local_var_req = local_var_req_builder.build()?;
840    let local_var_resp = local_var_client.execute(local_var_req).await?;
841
842    let local_var_status = local_var_resp.status();
843    let local_var_content = local_var_resp.text().await?;
844
845    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
846        serde_json::from_str(&local_var_content).map_err(Error::from)
847    } else {
848        let local_var_entity: Option<ExchangeSessionTokenError> = serde_json::from_str(&local_var_content).ok();
849        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
850        Err(Error::ResponseError(local_var_error))
851    }
852}
853
854/// This endpoint returns the error associated with a user-facing self service errors.  This endpoint supports stub values to help you implement the error UI:  `?id=stub:500` - returns a stub 500 (Internal Server Error) error.  More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors).
855pub async fn get_flow_error(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowError, Error<GetFlowErrorError>> {
856    let local_var_configuration = configuration;
857
858    let local_var_client = &local_var_configuration.client;
859
860    let local_var_uri_str = format!("{}/self-service/errors", local_var_configuration.base_path);
861    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
862
863    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
864    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
865        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
866    }
867
868    let local_var_req = local_var_req_builder.build()?;
869    let local_var_resp = local_var_client.execute(local_var_req).await?;
870
871    let local_var_status = local_var_resp.status();
872    let local_var_content = local_var_resp.text().await?;
873
874    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
875        serde_json::from_str(&local_var_content).map_err(Error::from)
876    } else {
877        let local_var_entity: Option<GetFlowErrorError> = serde_json::from_str(&local_var_content).ok();
878        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
879        Err(Error::ResponseError(local_var_error))
880    }
881}
882
883/// This endpoint returns a login flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/login', async function (req, res) { const flow = await client.getLoginFlow(req.header('cookie'), req.query['flow'])  res.render('login', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
884pub async fn get_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
885    let local_var_configuration = configuration;
886
887    let local_var_client = &local_var_configuration.client;
888
889    let local_var_uri_str = format!("{}/self-service/login/flows", local_var_configuration.base_path);
890    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
891
892    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
893    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
894        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
895    }
896    if let Some(local_var_param_value) = cookie {
897        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
898    }
899
900    let local_var_req = local_var_req_builder.build()?;
901    let local_var_resp = local_var_client.execute(local_var_req).await?;
902
903    let local_var_status = local_var_resp.status();
904    let local_var_content = local_var_resp.text().await?;
905
906    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
907        serde_json::from_str(&local_var_content).map_err(Error::from)
908    } else {
909        let local_var_entity: Option<GetLoginFlowError> = serde_json::from_str(&local_var_content).ok();
910        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
911        Err(Error::ResponseError(local_var_error))
912    }
913}
914
915/// This endpoint returns a recovery flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getRecoveryFlow(req.header('Cookie'), req.query['flow'])  res.render('recovery', flow) }) ```  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
916pub async fn get_recovery_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
917    let local_var_configuration = configuration;
918
919    let local_var_client = &local_var_configuration.client;
920
921    let local_var_uri_str = format!("{}/self-service/recovery/flows", local_var_configuration.base_path);
922    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
923
924    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
925    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
926        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
927    }
928    if let Some(local_var_param_value) = cookie {
929        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
930    }
931
932    let local_var_req = local_var_req_builder.build()?;
933    let local_var_resp = local_var_client.execute(local_var_req).await?;
934
935    let local_var_status = local_var_resp.status();
936    let local_var_content = local_var_resp.text().await?;
937
938    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
939        serde_json::from_str(&local_var_content).map_err(Error::from)
940    } else {
941        let local_var_entity: Option<GetRecoveryFlowError> = serde_json::from_str(&local_var_content).ok();
942        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
943        Err(Error::ResponseError(local_var_error))
944    }
945}
946
947/// This endpoint returns a registration flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/registration', async function (req, res) { const flow = await client.getRegistrationFlow(req.header('cookie'), req.query['flow'])  res.render('registration', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
948pub async fn get_registration_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
949    let local_var_configuration = configuration;
950
951    let local_var_client = &local_var_configuration.client;
952
953    let local_var_uri_str = format!("{}/self-service/registration/flows", local_var_configuration.base_path);
954    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
955
956    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
957    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
958        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
959    }
960    if let Some(local_var_param_value) = cookie {
961        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
962    }
963
964    let local_var_req = local_var_req_builder.build()?;
965    let local_var_resp = local_var_client.execute(local_var_req).await?;
966
967    let local_var_status = local_var_resp.status();
968    let local_var_content = local_var_resp.text().await?;
969
970    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
971        serde_json::from_str(&local_var_content).map_err(Error::from)
972    } else {
973        let local_var_entity: Option<GetRegistrationFlowError> = serde_json::from_str(&local_var_content).ok();
974        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
975        Err(Error::ResponseError(local_var_error))
976    }
977}
978
979/// When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie or the Ory Kratos Session Token are set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  You can access this endpoint without credentials when using Ory Kratos' Admin API.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
980pub async fn get_settings_flow(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
981    let local_var_configuration = configuration;
982
983    let local_var_client = &local_var_configuration.client;
984
985    let local_var_uri_str = format!("{}/self-service/settings/flows", local_var_configuration.base_path);
986    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
987
988    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
989    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
990        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
991    }
992    if let Some(local_var_param_value) = x_session_token {
993        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
994    }
995    if let Some(local_var_param_value) = cookie {
996        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
997    }
998
999    let local_var_req = local_var_req_builder.build()?;
1000    let local_var_resp = local_var_client.execute(local_var_req).await?;
1001
1002    let local_var_status = local_var_resp.status();
1003    let local_var_content = local_var_resp.text().await?;
1004
1005    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1006        serde_json::from_str(&local_var_content).map_err(Error::from)
1007    } else {
1008        let local_var_entity: Option<GetSettingsFlowError> = serde_json::from_str(&local_var_content).ok();
1009        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1010        Err(Error::ResponseError(local_var_error))
1011    }
1012}
1013
1014/// This endpoint returns a verification flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getVerificationFlow(req.header('cookie'), req.query['flow'])  res.render('verification', flow) }) ```  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1015pub async fn get_verification_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1016    let local_var_configuration = configuration;
1017
1018    let local_var_client = &local_var_configuration.client;
1019
1020    let local_var_uri_str = format!("{}/self-service/verification/flows", local_var_configuration.base_path);
1021    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1022
1023    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
1024    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1025        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1026    }
1027    if let Some(local_var_param_value) = cookie {
1028        local_var_req_builder = local_var_req_builder.header("cookie", local_var_param_value.to_string());
1029    }
1030
1031    let local_var_req = local_var_req_builder.build()?;
1032    let local_var_resp = local_var_client.execute(local_var_req).await?;
1033
1034    let local_var_status = local_var_resp.status();
1035    let local_var_content = local_var_resp.text().await?;
1036
1037    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1038        serde_json::from_str(&local_var_content).map_err(Error::from)
1039    } else {
1040        let local_var_entity: Option<GetVerificationFlowError> = serde_json::from_str(&local_var_content).ok();
1041        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1042        Err(Error::ResponseError(local_var_error))
1043    }
1044}
1045
1046/// This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration.  If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file:  ```html <script src=\"https://public-kratos.example.org/.well-known/ory/webauthn.js\" type=\"script\" async /> ```  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1047pub async fn get_web_authn_java_script(configuration: &configuration::Configuration, ) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1048    let local_var_configuration = configuration;
1049
1050    let local_var_client = &local_var_configuration.client;
1051
1052    let local_var_uri_str = format!("{}/.well-known/ory/webauthn.js", local_var_configuration.base_path);
1053    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1054
1055    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1056        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1057    }
1058
1059    let local_var_req = local_var_req_builder.build()?;
1060    let local_var_resp = local_var_client.execute(local_var_req).await?;
1061
1062    let local_var_status = local_var_resp.status();
1063    let local_var_content = local_var_resp.text().await?;
1064
1065    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1066        serde_json::from_str(&local_var_content).map_err(Error::from)
1067    } else {
1068        let local_var_entity: Option<GetWebAuthnJavaScriptError> = serde_json::from_str(&local_var_content).ok();
1069        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1070        Err(Error::ResponseError(local_var_error))
1071    }
1072}
1073
1074/// This endpoints returns all other active sessions that belong to the logged-in user. The current session can be retrieved by calling the `/sessions/whoami` endpoint.
1075pub async fn list_my_sessions(configuration: &configuration::Configuration, per_page: Option<i64>, page: Option<i64>, page_size: Option<i64>, page_token: Option<&str>, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<Vec<models::Session>, Error<ListMySessionsError>> {
1076    let local_var_configuration = configuration;
1077
1078    let local_var_client = &local_var_configuration.client;
1079
1080    let local_var_uri_str = format!("{}/sessions", local_var_configuration.base_path);
1081    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1082
1083    if let Some(ref local_var_str) = per_page {
1084        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1085    }
1086    if let Some(ref local_var_str) = page {
1087        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1088    }
1089    if let Some(ref local_var_str) = page_size {
1090        local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
1091    }
1092    if let Some(ref local_var_str) = page_token {
1093        local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
1094    }
1095    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1096        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1097    }
1098    if let Some(local_var_param_value) = x_session_token {
1099        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
1100    }
1101    if let Some(local_var_param_value) = cookie {
1102        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1103    }
1104
1105    let local_var_req = local_var_req_builder.build()?;
1106    let local_var_resp = local_var_client.execute(local_var_req).await?;
1107
1108    let local_var_status = local_var_resp.status();
1109    let local_var_content = local_var_resp.text().await?;
1110
1111    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1112        serde_json::from_str(&local_var_content).map_err(Error::from)
1113    } else {
1114        let local_var_entity: Option<ListMySessionsError> = serde_json::from_str(&local_var_content).ok();
1115        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1116        Err(Error::ResponseError(local_var_error))
1117    }
1118}
1119
1120/// Use this endpoint to log out an identity using an Ory Session Token. If the Ory Session Token was successfully revoked, the server returns a 204 No Content response. A 204 No Content response is also sent when the Ory Session Token has been revoked already before.  If the Ory Session Token is malformed or does not exist a 403 Forbidden response will be returned.  This endpoint does not remove any HTTP Cookies - use the Browser-Based Self-Service Logout Flow instead.
1121pub async fn perform_native_logout(configuration: &configuration::Configuration, perform_native_logout_body: models::PerformNativeLogoutBody) -> Result<(), Error<PerformNativeLogoutError>> {
1122    let local_var_configuration = configuration;
1123
1124    let local_var_client = &local_var_configuration.client;
1125
1126    let local_var_uri_str = format!("{}/self-service/logout/api", local_var_configuration.base_path);
1127    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1128
1129    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1130        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1131    }
1132    local_var_req_builder = local_var_req_builder.json(&perform_native_logout_body);
1133
1134    let local_var_req = local_var_req_builder.build()?;
1135    let local_var_resp = local_var_client.execute(local_var_req).await?;
1136
1137    let local_var_status = local_var_resp.status();
1138    let local_var_content = local_var_resp.text().await?;
1139
1140    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1141        Ok(())
1142    } else {
1143        let local_var_entity: Option<PerformNativeLogoutError> = serde_json::from_str(&local_var_content).ok();
1144        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1145        Err(Error::ResponseError(local_var_error))
1146    }
1147}
1148
1149/// Uses the HTTP Headers in the GET request to determine (e.g. by using checking the cookies) who is authenticated. Returns a session object in the body or 401 if the credentials are invalid or no credentials were sent. When the request it successful it adds the user ID to the 'X-Kratos-Authenticated-Identity-Id' header in the response.  If you call this endpoint from a server-side application, you must forward the HTTP Cookie Header to this endpoint:  ```js pseudo-code example router.get('/protected-endpoint', async function (req, res) { const session = await client.toSession(undefined, req.header('cookie'))  console.log(session) }) ```  When calling this endpoint from a non-browser application (e.g. mobile app) you must include the session token:  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\")  console.log(session) ```  When using a token template, the token is included in the `tokenized` field of the session.  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\", { tokenize_as: \"example-jwt-template\" })  console.log(session.tokenized) // The JWT ```  Depending on your configuration this endpoint might return a 403 status code if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  This endpoint is useful for:  AJAX calls. Remember to send credentials and set up CORS correctly! Reverse proxies and API Gateways Server-side calls - use the `X-Session-Token` header!  This endpoint authenticates users by checking:  if the `Cookie` HTTP header was set containing an Ory Kratos Session Cookie; if the `Authorization: bearer <ory-session-token>` HTTP header was set with a valid Ory Kratos Session Token; if the `X-Session-Token` HTTP header was set with a valid Ory Kratos Session Token.  If none of these headers are set or the cookie or token are invalid, the endpoint returns a HTTP 401 status code.  As explained above, this request may fail due to several reasons. The `error.id` can be one of:  `session_inactive`: No active session was found in the request (e.g. no Ory Session Cookie / Ory Session Token). `session_aal2_required`: An active session was found but it does not fulfil the Authenticator Assurance Level, implying that the session must (e.g.) authenticate the second factor.
1150pub async fn to_session(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>, tokenize_as: Option<&str>) -> Result<models::Session, Error<ToSessionError>> {
1151    let local_var_configuration = configuration;
1152
1153    let local_var_client = &local_var_configuration.client;
1154
1155    let local_var_uri_str = format!("{}/sessions/whoami", local_var_configuration.base_path);
1156    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1157
1158    if let Some(ref local_var_str) = tokenize_as {
1159        local_var_req_builder = local_var_req_builder.query(&[("tokenize_as", &local_var_str.to_string())]);
1160    }
1161    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1162        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1163    }
1164    if let Some(local_var_param_value) = x_session_token {
1165        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
1166    }
1167    if let Some(local_var_param_value) = cookie {
1168        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1169    }
1170
1171    let local_var_req = local_var_req_builder.build()?;
1172    let local_var_resp = local_var_client.execute(local_var_req).await?;
1173
1174    let local_var_status = local_var_resp.status();
1175    let local_var_content = local_var_resp.text().await?;
1176
1177    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1178        serde_json::from_str(&local_var_content).map_err(Error::from)
1179    } else {
1180        let local_var_entity: Option<ToSessionError> = serde_json::from_str(&local_var_content).ok();
1181        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1182        Err(Error::ResponseError(local_var_error))
1183    }
1184}
1185
1186/// Use this endpoint to submit a token from a FedCM provider through `navigator.credentials.get` and log the user in. The parameters from `navigator.credentials.get` must have come from `GET self-service/fed-cm/parameters`.
1187pub async fn update_fedcm_flow(configuration: &configuration::Configuration, update_fedcm_flow_body: models::UpdateFedcmFlowBody) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1188    let local_var_configuration = configuration;
1189
1190    let local_var_client = &local_var_configuration.client;
1191
1192    let local_var_uri_str = format!("{}/self-service/fed-cm/token", local_var_configuration.base_path);
1193    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1194
1195    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1196        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1197    }
1198    local_var_req_builder = local_var_req_builder.json(&update_fedcm_flow_body);
1199
1200    let local_var_req = local_var_req_builder.build()?;
1201    let local_var_resp = local_var_client.execute(local_var_req).await?;
1202
1203    let local_var_status = local_var_resp.status();
1204    let local_var_content = local_var_resp.text().await?;
1205
1206    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1207        serde_json::from_str(&local_var_content).map_err(Error::from)
1208    } else {
1209        let local_var_entity: Option<UpdateFedcmFlowError> = serde_json::from_str(&local_var_content).ok();
1210        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1211        Err(Error::ResponseError(local_var_error))
1212    }
1213}
1214
1215/// Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and responds with HTTP 200 and a application/json body with the session token on success; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after login URL or the `return_to` value if it was set and if the login succeeded; a HTTP 303 redirect to the login UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1216pub async fn update_login_flow(configuration: &configuration::Configuration, flow: &str, update_login_flow_body: models::UpdateLoginFlowBody, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SuccessfulNativeLogin, Error<UpdateLoginFlowError>> {
1217    let local_var_configuration = configuration;
1218
1219    let local_var_client = &local_var_configuration.client;
1220
1221    let local_var_uri_str = format!("{}/self-service/login", local_var_configuration.base_path);
1222    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1223
1224    local_var_req_builder = local_var_req_builder.query(&[("flow", &flow.to_string())]);
1225    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1226        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1227    }
1228    if let Some(local_var_param_value) = x_session_token {
1229        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
1230    }
1231    if let Some(local_var_param_value) = cookie {
1232        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1233    }
1234    local_var_req_builder = local_var_req_builder.json(&update_login_flow_body);
1235
1236    let local_var_req = local_var_req_builder.build()?;
1237    let local_var_resp = local_var_client.execute(local_var_req).await?;
1238
1239    let local_var_status = local_var_resp.status();
1240    let local_var_content = local_var_resp.text().await?;
1241
1242    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1243        serde_json::from_str(&local_var_content).map_err(Error::from)
1244    } else {
1245        let local_var_entity: Option<UpdateLoginFlowError> = serde_json::from_str(&local_var_content).ok();
1246        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1247        Err(Error::ResponseError(local_var_error))
1248    }
1249}
1250
1251/// This endpoint logs out an identity in a self-service manner.  If the `Accept` HTTP header is not set to `application/json`, the browser will be redirected (HTTP 303 See Other) to the `return_to` parameter of the initial request or fall back to `urls.default_return_to`.  If the `Accept` HTTP header is set to `application/json`, a 204 No Content response will be sent on successful logout instead.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  More information can be found at [Ory Kratos User Logout Documentation](https://www.ory.sh/docs/next/kratos/self-service/flows/user-logout).
1252pub async fn update_logout_flow(configuration: &configuration::Configuration, token: Option<&str>, return_to: Option<&str>, cookie: Option<&str>) -> Result<(), Error<UpdateLogoutFlowError>> {
1253    let local_var_configuration = configuration;
1254
1255    let local_var_client = &local_var_configuration.client;
1256
1257    let local_var_uri_str = format!("{}/self-service/logout", local_var_configuration.base_path);
1258    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1259
1260    if let Some(ref local_var_str) = token {
1261        local_var_req_builder = local_var_req_builder.query(&[("token", &local_var_str.to_string())]);
1262    }
1263    if let Some(ref local_var_str) = return_to {
1264        local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
1265    }
1266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1267        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1268    }
1269    if let Some(local_var_param_value) = cookie {
1270        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1271    }
1272
1273    let local_var_req = local_var_req_builder.build()?;
1274    let local_var_resp = local_var_client.execute(local_var_req).await?;
1275
1276    let local_var_status = local_var_resp.status();
1277    let local_var_content = local_var_resp.text().await?;
1278
1279    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1280        Ok(())
1281    } else {
1282        let local_var_entity: Option<UpdateLogoutFlowError> = serde_json::from_str(&local_var_content).ok();
1283        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1284        Err(Error::ResponseError(local_var_error))
1285    }
1286}
1287
1288/// Use this endpoint to update a recovery flow. This endpoint behaves differently for API and browser flows and has several states:  `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid. and a HTTP 303 See Other redirect with a fresh recovery flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Recovery UI URL with the Recovery Flow ID appended. `sent_email` is the success state after `choose_method` for the `link` method and allows the user to request another recovery email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a recovery link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Recover UI URL with a new Recovery Flow ID which contains an error message that the recovery link was invalid.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
1289pub async fn update_recovery_flow(configuration: &configuration::Configuration, flow: &str, update_recovery_flow_body: models::UpdateRecoveryFlowBody, token: Option<&str>, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<UpdateRecoveryFlowError>> {
1290    let local_var_configuration = configuration;
1291
1292    let local_var_client = &local_var_configuration.client;
1293
1294    let local_var_uri_str = format!("{}/self-service/recovery", local_var_configuration.base_path);
1295    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1296
1297    local_var_req_builder = local_var_req_builder.query(&[("flow", &flow.to_string())]);
1298    if let Some(ref local_var_str) = token {
1299        local_var_req_builder = local_var_req_builder.query(&[("token", &local_var_str.to_string())]);
1300    }
1301    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1302        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1303    }
1304    if let Some(local_var_param_value) = cookie {
1305        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1306    }
1307    local_var_req_builder = local_var_req_builder.json(&update_recovery_flow_body);
1308
1309    let local_var_req = local_var_req_builder.build()?;
1310    let local_var_resp = local_var_client.execute(local_var_req).await?;
1311
1312    let local_var_status = local_var_resp.status();
1313    let local_var_content = local_var_resp.text().await?;
1314
1315    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1316        serde_json::from_str(&local_var_content).map_err(Error::from)
1317    } else {
1318        let local_var_entity: Option<UpdateRecoveryFlowError> = serde_json::from_str(&local_var_content).ok();
1319        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1320        Err(Error::ResponseError(local_var_error))
1321    }
1322}
1323
1324/// Use this endpoint to complete a registration flow by sending an identity's traits and password. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and respond with HTTP 200 and a application/json body with the created identity success - if the session hook is configured the `session` and `session_token` will also be included; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after registration URL or the `return_to` value if it was set and if the registration succeeded; a HTTP 303 redirect to the registration UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1325pub async fn update_registration_flow(configuration: &configuration::Configuration, flow: &str, update_registration_flow_body: models::UpdateRegistrationFlowBody, cookie: Option<&str>) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
1326    let local_var_configuration = configuration;
1327
1328    let local_var_client = &local_var_configuration.client;
1329
1330    let local_var_uri_str = format!("{}/self-service/registration", local_var_configuration.base_path);
1331    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1332
1333    local_var_req_builder = local_var_req_builder.query(&[("flow", &flow.to_string())]);
1334    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1335        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1336    }
1337    if let Some(local_var_param_value) = cookie {
1338        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1339    }
1340    local_var_req_builder = local_var_req_builder.json(&update_registration_flow_body);
1341
1342    let local_var_req = local_var_req_builder.build()?;
1343    let local_var_resp = local_var_client.execute(local_var_req).await?;
1344
1345    let local_var_status = local_var_resp.status();
1346    let local_var_content = local_var_resp.text().await?;
1347
1348    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1349        serde_json::from_str(&local_var_content).map_err(Error::from)
1350    } else {
1351        let local_var_entity: Option<UpdateRegistrationFlowError> = serde_json::from_str(&local_var_content).ok();
1352        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1353        Err(Error::ResponseError(local_var_error))
1354    }
1355}
1356
1357/// Use this endpoint to complete a settings flow by sending an identity's updated password. This endpoint behaves differently for API and browser flows.  API-initiated flows expect `application/json` to be sent in the body and respond with HTTP 200 and an application/json body with the session token on success; HTTP 303 redirect to a fresh settings flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors. HTTP 401 when the endpoint is called without a valid session token. HTTP 403 when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low. Implies that the user needs to re-authenticate.  Browser flows without HTTP Header `Accept` or with `Accept: text/_*` respond with a HTTP 303 redirect to the post/after settings URL or the `return_to` value if it was set and if the flow succeeded; a HTTP 303 redirect to the Settings UI URL with the flow ID containing the validation errors otherwise. a HTTP 303 redirect to the login endpoint when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low.  Browser flows with HTTP Header `Accept: application/json` respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 401 when the endpoint is called without a valid session cookie. HTTP 403 when the page is accessed without a session cookie or the session's AAL is too low. HTTP 400 on form validation errors.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called with a `Accept: application/json` HTTP header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_refresh_required`: The identity requested to change something that needs a privileged session. Redirect the identity to the login init endpoint with query parameters `?refresh=true&return_to=<the-current-browser-url>`, or initiate a refresh login flow otherwise. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
1358pub async fn update_settings_flow(configuration: &configuration::Configuration, flow: &str, update_settings_flow_body: models::UpdateSettingsFlowBody, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<UpdateSettingsFlowError>> {
1359    let local_var_configuration = configuration;
1360
1361    let local_var_client = &local_var_configuration.client;
1362
1363    let local_var_uri_str = format!("{}/self-service/settings", local_var_configuration.base_path);
1364    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1365
1366    local_var_req_builder = local_var_req_builder.query(&[("flow", &flow.to_string())]);
1367    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1368        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1369    }
1370    if let Some(local_var_param_value) = x_session_token {
1371        local_var_req_builder = local_var_req_builder.header("X-Session-Token", local_var_param_value.to_string());
1372    }
1373    if let Some(local_var_param_value) = cookie {
1374        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1375    }
1376    local_var_req_builder = local_var_req_builder.json(&update_settings_flow_body);
1377
1378    let local_var_req = local_var_req_builder.build()?;
1379    let local_var_resp = local_var_client.execute(local_var_req).await?;
1380
1381    let local_var_status = local_var_resp.status();
1382    let local_var_content = local_var_resp.text().await?;
1383
1384    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1385        serde_json::from_str(&local_var_content).map_err(Error::from)
1386    } else {
1387        let local_var_entity: Option<UpdateSettingsFlowError> = serde_json::from_str(&local_var_content).ok();
1388        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1389        Err(Error::ResponseError(local_var_error))
1390    }
1391}
1392
1393/// Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states:  `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 303 See Other redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Verification UI URL with the Verification Flow ID appended. `sent_email` is the success state after `choose_method` when using the `link` method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a verification link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an error message that the verification link was invalid.  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1394pub async fn update_verification_flow(configuration: &configuration::Configuration, flow: &str, update_verification_flow_body: models::UpdateVerificationFlowBody, token: Option<&str>, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<UpdateVerificationFlowError>> {
1395    let local_var_configuration = configuration;
1396
1397    let local_var_client = &local_var_configuration.client;
1398
1399    let local_var_uri_str = format!("{}/self-service/verification", local_var_configuration.base_path);
1400    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1401
1402    local_var_req_builder = local_var_req_builder.query(&[("flow", &flow.to_string())]);
1403    if let Some(ref local_var_str) = token {
1404        local_var_req_builder = local_var_req_builder.query(&[("token", &local_var_str.to_string())]);
1405    }
1406    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1407        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1408    }
1409    if let Some(local_var_param_value) = cookie {
1410        local_var_req_builder = local_var_req_builder.header("Cookie", local_var_param_value.to_string());
1411    }
1412    local_var_req_builder = local_var_req_builder.json(&update_verification_flow_body);
1413
1414    let local_var_req = local_var_req_builder.build()?;
1415    let local_var_resp = local_var_client.execute(local_var_req).await?;
1416
1417    let local_var_status = local_var_resp.status();
1418    let local_var_content = local_var_resp.text().await?;
1419
1420    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1421        serde_json::from_str(&local_var_content).map_err(Error::from)
1422    } else {
1423        let local_var_entity: Option<UpdateVerificationFlowError> = serde_json::from_str(&local_var_content).ok();
1424        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1425        Err(Error::ResponseError(local_var_error))
1426    }
1427}
1428