Skip to main content

ory_client/apis/
frontend_api.rs

1/*
2 * Ory APIs
3 *
4 * # Introduction Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.  ## SDKs This document describes the APIs available in the Ory Network. The APIs are available as SDKs for the following languages:  | Language       | Download SDK                                                     | Documentation                                                                        | | -------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | Dart           | [pub.dev](https://pub.dev/packages/ory_client)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/dart/README.md)       | | .NET           | [nuget.org](https://www.nuget.org/packages/Ory.Client/)          | [README](https://github.com/ory/sdk/blob/master/clients/client/dotnet/README.md)     | | Elixir         | [hex.pm](https://hex.pm/packages/ory_client)                     | [README](https://github.com/ory/sdk/blob/master/clients/client/elixir/README.md)     | | Go             | [github.com](https://github.com/ory/client-go)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/go/README.md)         | | Java           | [maven.org](https://search.maven.org/artifact/sh.ory/ory-client) | [README](https://github.com/ory/sdk/blob/master/clients/client/java/README.md)       | | JavaScript     | [npmjs.com](https://www.npmjs.com/package/@ory/client)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript/README.md) | | JavaScript (With fetch) | [npmjs.com](https://www.npmjs.com/package/@ory/client-fetch)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript-fetch/README.md) |  | PHP            | [packagist.org](https://packagist.org/packages/ory/client)       | [README](https://github.com/ory/sdk/blob/master/clients/client/php/README.md)        | | Python         | [pypi.org](https://pypi.org/project/ory-client/)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/python/README.md)     | | Ruby           | [rubygems.org](https://rubygems.org/gems/ory-client)             | [README](https://github.com/ory/sdk/blob/master/clients/client/ruby/README.md)       | | Rust           | [crates.io](https://crates.io/crates/ory-client)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/rust/README.md)       | 
5 *
6 * The version of the OpenAPI document: v1.22.39
7 * Contact: support@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
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 [`delete_test_login_flow`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum DeleteTestLoginFlowError {
131    Status400(models::ErrorGeneric),
132    Status403(models::ErrorGeneric),
133    Status404(models::ErrorGeneric),
134    DefaultResponse(models::ErrorGeneric),
135    UnknownValue(serde_json::Value),
136}
137
138/// struct for typed errors of method [`disable_my_other_sessions`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum DisableMyOtherSessionsError {
142    Status400(models::ErrorGeneric),
143    Status401(models::ErrorGeneric),
144    DefaultResponse(models::ErrorGeneric),
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`disable_my_session`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum DisableMySessionError {
152    Status400(models::ErrorGeneric),
153    Status401(models::ErrorGeneric),
154    DefaultResponse(models::ErrorGeneric),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`exchange_session_token`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum ExchangeSessionTokenError {
162    Status403(models::ErrorGeneric),
163    Status404(models::ErrorGeneric),
164    Status410(models::ErrorGeneric),
165    Status422(models::ErrorGeneric),
166    DefaultResponse(models::ErrorGeneric),
167    UnknownValue(serde_json::Value),
168}
169
170/// struct for typed errors of method [`get_flow_error`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum GetFlowErrorError {
174    Status403(models::ErrorGeneric),
175    Status404(models::ErrorGeneric),
176    Status500(models::ErrorGeneric),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`get_login_flow`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum GetLoginFlowError {
184    Status403(models::ErrorGeneric),
185    Status404(models::ErrorGeneric),
186    Status410(models::ErrorGeneric),
187    DefaultResponse(models::ErrorGeneric),
188    UnknownValue(serde_json::Value),
189}
190
191/// struct for typed errors of method [`get_recovery_flow`]
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum GetRecoveryFlowError {
195    Status404(models::ErrorGeneric),
196    Status410(models::ErrorGeneric),
197    DefaultResponse(models::ErrorGeneric),
198    UnknownValue(serde_json::Value),
199}
200
201/// struct for typed errors of method [`get_registration_flow`]
202#[derive(Debug, Clone, Serialize, Deserialize)]
203#[serde(untagged)]
204pub enum GetRegistrationFlowError {
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_settings_flow`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum GetSettingsFlowError {
216    Status401(models::ErrorGeneric),
217    Status403(models::ErrorGeneric),
218    Status404(models::ErrorGeneric),
219    Status410(models::ErrorGeneric),
220    DefaultResponse(models::ErrorGeneric),
221    UnknownValue(serde_json::Value),
222}
223
224/// struct for typed errors of method [`get_verification_flow`]
225#[derive(Debug, Clone, Serialize, Deserialize)]
226#[serde(untagged)]
227pub enum GetVerificationFlowError {
228    Status403(models::ErrorGeneric),
229    Status404(models::ErrorGeneric),
230    DefaultResponse(models::ErrorGeneric),
231    UnknownValue(serde_json::Value),
232}
233
234/// struct for typed errors of method [`get_web_authn_java_script`]
235#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(untagged)]
237pub enum GetWebAuthnJavaScriptError {
238    UnknownValue(serde_json::Value),
239}
240
241/// struct for typed errors of method [`list_my_sessions`]
242#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum ListMySessionsError {
245    Status400(models::ErrorGeneric),
246    Status401(models::ErrorGeneric),
247    DefaultResponse(models::ErrorGeneric),
248    UnknownValue(serde_json::Value),
249}
250
251/// struct for typed errors of method [`perform_native_logout`]
252#[derive(Debug, Clone, Serialize, Deserialize)]
253#[serde(untagged)]
254pub enum PerformNativeLogoutError {
255    Status400(models::ErrorGeneric),
256    DefaultResponse(models::ErrorGeneric),
257    UnknownValue(serde_json::Value),
258}
259
260/// struct for typed errors of method [`to_session`]
261#[derive(Debug, Clone, Serialize, Deserialize)]
262#[serde(untagged)]
263pub enum ToSessionError {
264    Status401(models::ErrorGeneric),
265    Status403(models::ErrorGeneric),
266    DefaultResponse(models::ErrorGeneric),
267    UnknownValue(serde_json::Value),
268}
269
270/// struct for typed errors of method [`update_fedcm_flow`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum UpdateFedcmFlowError {
274    Status400(models::LoginFlow),
275    Status410(models::ErrorGeneric),
276    Status422(models::ErrorBrowserLocationChangeRequired),
277    DefaultResponse(models::ErrorGeneric),
278    UnknownValue(serde_json::Value),
279}
280
281/// struct for typed errors of method [`update_login_flow`]
282#[derive(Debug, Clone, Serialize, Deserialize)]
283#[serde(untagged)]
284pub enum UpdateLoginFlowError {
285    Status400(models::LoginFlow),
286    Status410(models::ErrorGeneric),
287    Status422(models::ErrorBrowserLocationChangeRequired),
288    DefaultResponse(models::ErrorGeneric),
289    UnknownValue(serde_json::Value),
290}
291
292/// struct for typed errors of method [`update_logout_flow`]
293#[derive(Debug, Clone, Serialize, Deserialize)]
294#[serde(untagged)]
295pub enum UpdateLogoutFlowError {
296    DefaultResponse(models::ErrorGeneric),
297    UnknownValue(serde_json::Value),
298}
299
300/// struct for typed errors of method [`update_recovery_flow`]
301#[derive(Debug, Clone, Serialize, Deserialize)]
302#[serde(untagged)]
303pub enum UpdateRecoveryFlowError {
304    Status400(models::RecoveryFlow),
305    Status410(models::ErrorGeneric),
306    Status422(models::ErrorBrowserLocationChangeRequired),
307    DefaultResponse(models::ErrorGeneric),
308    UnknownValue(serde_json::Value),
309}
310
311/// struct for typed errors of method [`update_registration_flow`]
312#[derive(Debug, Clone, Serialize, Deserialize)]
313#[serde(untagged)]
314pub enum UpdateRegistrationFlowError {
315    Status400(models::RegistrationFlow),
316    Status410(models::ErrorGeneric),
317    Status422(models::ErrorBrowserLocationChangeRequired),
318    DefaultResponse(models::ErrorGeneric),
319    UnknownValue(serde_json::Value),
320}
321
322/// struct for typed errors of method [`update_settings_flow`]
323#[derive(Debug, Clone, Serialize, Deserialize)]
324#[serde(untagged)]
325pub enum UpdateSettingsFlowError {
326    Status400(models::SettingsFlow),
327    Status401(models::ErrorGeneric),
328    Status403(models::ErrorGeneric),
329    Status410(models::ErrorGeneric),
330    Status422(models::ErrorBrowserLocationChangeRequired),
331    DefaultResponse(models::ErrorGeneric),
332    UnknownValue(serde_json::Value),
333}
334
335/// struct for typed errors of method [`update_verification_flow`]
336#[derive(Debug, Clone, Serialize, Deserialize)]
337#[serde(untagged)]
338pub enum UpdateVerificationFlowError {
339    Status400(models::VerificationFlow),
340    Status410(models::ErrorGeneric),
341    DefaultResponse(models::ErrorGeneric),
342    UnknownValue(serde_json::Value),
343}
344
345
346/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
347pub 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>, identity_schema: Option<&str>) -> Result<models::LoginFlow, Error<CreateBrowserLoginFlowError>> {
348    // add a prefix to parameters to efficiently prevent name collisions
349    let p_query_refresh = refresh;
350    let p_query_aal = aal;
351    let p_query_return_to = return_to;
352    let p_header_cookie = cookie;
353    let p_query_login_challenge = login_challenge;
354    let p_query_organization = organization;
355    let p_query_via = via;
356    let p_query_identity_schema = identity_schema;
357
358    let uri_str = format!("{}/self-service/login/browser", configuration.base_path);
359    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
360
361    if let Some(ref param_value) = p_query_refresh {
362        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
363    }
364    if let Some(ref param_value) = p_query_aal {
365        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
366    }
367    if let Some(ref param_value) = p_query_return_to {
368        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
369    }
370    if let Some(ref param_value) = p_query_login_challenge {
371        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
372    }
373    if let Some(ref param_value) = p_query_organization {
374        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
375    }
376    if let Some(ref param_value) = p_query_via {
377        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
378    }
379    if let Some(ref param_value) = p_query_identity_schema {
380        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
381    }
382    if let Some(ref user_agent) = configuration.user_agent {
383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384    }
385    if let Some(param_value) = p_header_cookie {
386        req_builder = req_builder.header("Cookie", param_value.to_string());
387    }
388
389    let req = req_builder.build()?;
390    let resp = configuration.client.execute(req).await?;
391
392    let status = resp.status();
393    let content_type = resp
394        .headers()
395        .get("content-type")
396        .and_then(|v| v.to_str().ok())
397        .unwrap_or("application/octet-stream");
398    let content_type = super::ContentType::from(content_type);
399
400    if !status.is_client_error() && !status.is_server_error() {
401        let content = resp.text().await?;
402        match content_type {
403            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
404            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
405            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
406        }
407    } else {
408        let content = resp.text().await?;
409        let entity: Option<CreateBrowserLoginFlowError> = serde_json::from_str(&content).ok();
410        Err(Error::ResponseError(ResponseContent { status, content, entity }))
411    }
412}
413
414/// 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.
415pub async fn create_browser_logout_flow(configuration: &configuration::Configuration, cookie: Option<&str>, return_to: Option<&str>) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
416    // add a prefix to parameters to efficiently prevent name collisions
417    let p_header_cookie = cookie;
418    let p_query_return_to = return_to;
419
420    let uri_str = format!("{}/self-service/logout/browser", configuration.base_path);
421    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
422
423    if let Some(ref param_value) = p_query_return_to {
424        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
425    }
426    if let Some(ref user_agent) = configuration.user_agent {
427        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
428    }
429    if let Some(param_value) = p_header_cookie {
430        req_builder = req_builder.header("cookie", param_value.to_string());
431    }
432
433    let req = req_builder.build()?;
434    let resp = configuration.client.execute(req).await?;
435
436    let status = resp.status();
437    let content_type = resp
438        .headers()
439        .get("content-type")
440        .and_then(|v| v.to_str().ok())
441        .unwrap_or("application/octet-stream");
442    let content_type = super::ContentType::from(content_type);
443
444    if !status.is_client_error() && !status.is_server_error() {
445        let content = resp.text().await?;
446        match content_type {
447            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LogoutFlow`"))),
449            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LogoutFlow`")))),
450        }
451    } else {
452        let content = resp.text().await?;
453        let entity: Option<CreateBrowserLogoutFlowError> = serde_json::from_str(&content).ok();
454        Err(Error::ResponseError(ResponseContent { status, content, entity }))
455    }
456}
457
458/// 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).
459pub async fn create_browser_recovery_flow(configuration: &configuration::Configuration, return_to: Option<&str>, skip_settings: Option<&str>) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
460    // add a prefix to parameters to efficiently prevent name collisions
461    let p_query_return_to = return_to;
462    let p_query_skip_settings = skip_settings;
463
464    let uri_str = format!("{}/self-service/recovery/browser", configuration.base_path);
465    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
466
467    if let Some(ref param_value) = p_query_return_to {
468        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
469    }
470    if let Some(ref param_value) = p_query_skip_settings {
471        req_builder = req_builder.query(&[("skip_settings", &param_value.to_string())]);
472    }
473    if let Some(ref user_agent) = configuration.user_agent {
474        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
475    }
476
477    let req = req_builder.build()?;
478    let resp = configuration.client.execute(req).await?;
479
480    let status = resp.status();
481    let content_type = resp
482        .headers()
483        .get("content-type")
484        .and_then(|v| v.to_str().ok())
485        .unwrap_or("application/octet-stream");
486    let content_type = super::ContentType::from(content_type);
487
488    if !status.is_client_error() && !status.is_server_error() {
489        let content = resp.text().await?;
490        match content_type {
491            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
492            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
493            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
494        }
495    } else {
496        let content = resp.text().await?;
497        let entity: Option<CreateBrowserRecoveryFlowError> = serde_json::from_str(&content).ok();
498        Err(Error::ResponseError(ResponseContent { status, content, entity }))
499    }
500}
501
502/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
503pub 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>, identity_schema: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateBrowserRegistrationFlowError>> {
504    // add a prefix to parameters to efficiently prevent name collisions
505    let p_query_return_to = return_to;
506    let p_query_login_challenge = login_challenge;
507    let p_query_after_verification_return_to = after_verification_return_to;
508    let p_query_organization = organization;
509    let p_query_identity_schema = identity_schema;
510
511    let uri_str = format!("{}/self-service/registration/browser", configuration.base_path);
512    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
513
514    if let Some(ref param_value) = p_query_return_to {
515        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
516    }
517    if let Some(ref param_value) = p_query_login_challenge {
518        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
519    }
520    if let Some(ref param_value) = p_query_after_verification_return_to {
521        req_builder = req_builder.query(&[("after_verification_return_to", &param_value.to_string())]);
522    }
523    if let Some(ref param_value) = p_query_organization {
524        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
525    }
526    if let Some(ref param_value) = p_query_identity_schema {
527        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
528    }
529    if let Some(ref user_agent) = configuration.user_agent {
530        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
531    }
532
533    let req = req_builder.build()?;
534    let resp = configuration.client.execute(req).await?;
535
536    let status = resp.status();
537    let content_type = resp
538        .headers()
539        .get("content-type")
540        .and_then(|v| v.to_str().ok())
541        .unwrap_or("application/octet-stream");
542    let content_type = super::ContentType::from(content_type);
543
544    if !status.is_client_error() && !status.is_server_error() {
545        let content = resp.text().await?;
546        match content_type {
547            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
548            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
549            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
550        }
551    } else {
552        let content = resp.text().await?;
553        let entity: Option<CreateBrowserRegistrationFlowError> = serde_json::from_str(&content).ok();
554        Err(Error::ResponseError(ResponseContent { status, content, entity }))
555    }
556}
557
558/// 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).
559pub async fn create_browser_settings_flow(configuration: &configuration::Configuration, return_to: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
560    // add a prefix to parameters to efficiently prevent name collisions
561    let p_query_return_to = return_to;
562    let p_header_cookie = cookie;
563
564    let uri_str = format!("{}/self-service/settings/browser", configuration.base_path);
565    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
566
567    if let Some(ref param_value) = p_query_return_to {
568        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
569    }
570    if let Some(ref user_agent) = configuration.user_agent {
571        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
572    }
573    if let Some(param_value) = p_header_cookie {
574        req_builder = req_builder.header("Cookie", param_value.to_string());
575    }
576
577    let req = req_builder.build()?;
578    let resp = configuration.client.execute(req).await?;
579
580    let status = resp.status();
581    let content_type = resp
582        .headers()
583        .get("content-type")
584        .and_then(|v| v.to_str().ok())
585        .unwrap_or("application/octet-stream");
586    let content_type = super::ContentType::from(content_type);
587
588    if !status.is_client_error() && !status.is_server_error() {
589        let content = resp.text().await?;
590        match content_type {
591            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
592            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
593            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
594        }
595    } else {
596        let content = resp.text().await?;
597        let entity: Option<CreateBrowserSettingsFlowError> = serde_json::from_str(&content).ok();
598        Err(Error::ResponseError(ResponseContent { status, content, entity }))
599    }
600}
601
602/// 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.com/docs/kratos/self-service/flows/verify-email-account-activation).
603pub async fn create_browser_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
604    // add a prefix to parameters to efficiently prevent name collisions
605    let p_query_return_to = return_to;
606
607    let uri_str = format!("{}/self-service/verification/browser", configuration.base_path);
608    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
609
610    if let Some(ref param_value) = p_query_return_to {
611        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
612    }
613    if let Some(ref user_agent) = configuration.user_agent {
614        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
615    }
616
617    let req = req_builder.build()?;
618    let resp = configuration.client.execute(req).await?;
619
620    let status = resp.status();
621    let content_type = resp
622        .headers()
623        .get("content-type")
624        .and_then(|v| v.to_str().ok())
625        .unwrap_or("application/octet-stream");
626    let content_type = super::ContentType::from(content_type);
627
628    if !status.is_client_error() && !status.is_server_error() {
629        let content = resp.text().await?;
630        match content_type {
631            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
632            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
633            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
634        }
635    } else {
636        let content = resp.text().await?;
637        let entity: Option<CreateBrowserVerificationFlowError> = serde_json::from_str(&content).ok();
638        Err(Error::ResponseError(ResponseContent { status, content, entity }))
639    }
640}
641
642/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
643pub async fn create_fedcm_flow(configuration: &configuration::Configuration, ) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
644
645    let uri_str = format!("{}/self-service/fed-cm/parameters", configuration.base_path);
646    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
647
648    if let Some(ref user_agent) = configuration.user_agent {
649        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
650    }
651
652    let req = req_builder.build()?;
653    let resp = configuration.client.execute(req).await?;
654
655    let status = resp.status();
656    let content_type = resp
657        .headers()
658        .get("content-type")
659        .and_then(|v| v.to_str().ok())
660        .unwrap_or("application/octet-stream");
661    let content_type = super::ContentType::from(content_type);
662
663    if !status.is_client_error() && !status.is_server_error() {
664        let content = resp.text().await?;
665        match content_type {
666            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
667            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateFedcmFlowResponse`"))),
668            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateFedcmFlowResponse`")))),
669        }
670    } else {
671        let content = resp.text().await?;
672        let entity: Option<CreateFedcmFlowError> = serde_json::from_str(&content).ok();
673        Err(Error::ResponseError(ResponseContent { status, content, entity }))
674    }
675}
676
677/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
678pub 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>, identity_schema: Option<&str>) -> Result<models::LoginFlow, Error<CreateNativeLoginFlowError>> {
679    // add a prefix to parameters to efficiently prevent name collisions
680    let p_query_refresh = refresh;
681    let p_query_aal = aal;
682    let p_header_x_session_token = x_session_token;
683    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
684    let p_query_return_to = return_to;
685    let p_query_organization = organization;
686    let p_query_via = via;
687    let p_query_identity_schema = identity_schema;
688
689    let uri_str = format!("{}/self-service/login/api", configuration.base_path);
690    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
691
692    if let Some(ref param_value) = p_query_refresh {
693        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
694    }
695    if let Some(ref param_value) = p_query_aal {
696        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
697    }
698    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
699        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
700    }
701    if let Some(ref param_value) = p_query_return_to {
702        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
703    }
704    if let Some(ref param_value) = p_query_organization {
705        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
706    }
707    if let Some(ref param_value) = p_query_via {
708        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
709    }
710    if let Some(ref param_value) = p_query_identity_schema {
711        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
712    }
713    if let Some(ref user_agent) = configuration.user_agent {
714        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
715    }
716    if let Some(param_value) = p_header_x_session_token {
717        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
718    }
719
720    let req = req_builder.build()?;
721    let resp = configuration.client.execute(req).await?;
722
723    let status = resp.status();
724    let content_type = resp
725        .headers()
726        .get("content-type")
727        .and_then(|v| v.to_str().ok())
728        .unwrap_or("application/octet-stream");
729    let content_type = super::ContentType::from(content_type);
730
731    if !status.is_client_error() && !status.is_server_error() {
732        let content = resp.text().await?;
733        match content_type {
734            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
735            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
736            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
737        }
738    } else {
739        let content = resp.text().await?;
740        let entity: Option<CreateNativeLoginFlowError> = serde_json::from_str(&content).ok();
741        Err(Error::ResponseError(ResponseContent { status, content, entity }))
742    }
743}
744
745/// 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).
746pub async fn create_native_recovery_flow(configuration: &configuration::Configuration, ) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
747
748    let uri_str = format!("{}/self-service/recovery/api", configuration.base_path);
749    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
750
751    if let Some(ref user_agent) = configuration.user_agent {
752        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
753    }
754
755    let req = req_builder.build()?;
756    let resp = configuration.client.execute(req).await?;
757
758    let status = resp.status();
759    let content_type = resp
760        .headers()
761        .get("content-type")
762        .and_then(|v| v.to_str().ok())
763        .unwrap_or("application/octet-stream");
764    let content_type = super::ContentType::from(content_type);
765
766    if !status.is_client_error() && !status.is_server_error() {
767        let content = resp.text().await?;
768        match content_type {
769            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
770            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
771            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
772        }
773    } else {
774        let content = resp.text().await?;
775        let entity: Option<CreateNativeRecoveryFlowError> = serde_json::from_str(&content).ok();
776        Err(Error::ResponseError(ResponseContent { status, content, entity }))
777    }
778}
779
780/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
781pub async fn create_native_registration_flow(configuration: &configuration::Configuration, return_session_token_exchange_code: Option<bool>, return_to: Option<&str>, organization: Option<&str>, identity_schema: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateNativeRegistrationFlowError>> {
782    // add a prefix to parameters to efficiently prevent name collisions
783    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
784    let p_query_return_to = return_to;
785    let p_query_organization = organization;
786    let p_query_identity_schema = identity_schema;
787
788    let uri_str = format!("{}/self-service/registration/api", configuration.base_path);
789    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
790
791    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
792        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
793    }
794    if let Some(ref param_value) = p_query_return_to {
795        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
796    }
797    if let Some(ref param_value) = p_query_organization {
798        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
799    }
800    if let Some(ref param_value) = p_query_identity_schema {
801        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
802    }
803    if let Some(ref user_agent) = configuration.user_agent {
804        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
805    }
806
807    let req = req_builder.build()?;
808    let resp = configuration.client.execute(req).await?;
809
810    let status = resp.status();
811    let content_type = resp
812        .headers()
813        .get("content-type")
814        .and_then(|v| v.to_str().ok())
815        .unwrap_or("application/octet-stream");
816    let content_type = super::ContentType::from(content_type);
817
818    if !status.is_client_error() && !status.is_server_error() {
819        let content = resp.text().await?;
820        match content_type {
821            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
822            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
823            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
824        }
825    } else {
826        let content = resp.text().await?;
827        let entity: Option<CreateNativeRegistrationFlowError> = serde_json::from_str(&content).ok();
828        Err(Error::ResponseError(ResponseContent { status, content, entity }))
829    }
830}
831
832/// 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).
833pub async fn create_native_settings_flow(configuration: &configuration::Configuration, x_session_token: Option<&str>) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
834    // add a prefix to parameters to efficiently prevent name collisions
835    let p_header_x_session_token = x_session_token;
836
837    let uri_str = format!("{}/self-service/settings/api", configuration.base_path);
838    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
839
840    if let Some(ref user_agent) = configuration.user_agent {
841        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
842    }
843    if let Some(param_value) = p_header_x_session_token {
844        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
845    }
846
847    let req = req_builder.build()?;
848    let resp = configuration.client.execute(req).await?;
849
850    let status = resp.status();
851    let content_type = resp
852        .headers()
853        .get("content-type")
854        .and_then(|v| v.to_str().ok())
855        .unwrap_or("application/octet-stream");
856    let content_type = super::ContentType::from(content_type);
857
858    if !status.is_client_error() && !status.is_server_error() {
859        let content = resp.text().await?;
860        match content_type {
861            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
862            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
863            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
864        }
865    } else {
866        let content = resp.text().await?;
867        let entity: Option<CreateNativeSettingsFlowError> = serde_json::from_str(&content).ok();
868        Err(Error::ResponseError(ResponseContent { status, content, entity }))
869    }
870}
871
872/// 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.com/docs/kratos/self-service/flows/verify-email-account-activation).
873pub async fn create_native_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
874    // add a prefix to parameters to efficiently prevent name collisions
875    let p_query_return_to = return_to;
876
877    let uri_str = format!("{}/self-service/verification/api", configuration.base_path);
878    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
879
880    if let Some(ref param_value) = p_query_return_to {
881        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
882    }
883    if let Some(ref user_agent) = configuration.user_agent {
884        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
885    }
886
887    let req = req_builder.build()?;
888    let resp = configuration.client.execute(req).await?;
889
890    let status = resp.status();
891    let content_type = resp
892        .headers()
893        .get("content-type")
894        .and_then(|v| v.to_str().ok())
895        .unwrap_or("application/octet-stream");
896    let content_type = super::ContentType::from(content_type);
897
898    if !status.is_client_error() && !status.is_server_error() {
899        let content = resp.text().await?;
900        match content_type {
901            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
902            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
903            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
904        }
905    } else {
906        let content = resp.text().await?;
907        let entity: Option<CreateNativeVerificationFlowError> = serde_json::from_str(&content).ok();
908        Err(Error::ResponseError(ResponseContent { status, content, entity }))
909    }
910}
911
912/// Deletes a dry-run OIDC test login flow. A flow whose debug payload has been captured requires the HMAC cookie set by the OIDC callback; a flow still in the initial choose-method state is deletable with just the flow ID (it carries no PII, and the admin may want to abandon it).
913pub async fn delete_test_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<(), Error<DeleteTestLoginFlowError>> {
914    // add a prefix to parameters to efficiently prevent name collisions
915    let p_query_id = id;
916    let p_header_cookie = cookie;
917
918    let uri_str = format!("{}/self-service/login/test", configuration.base_path);
919    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
920
921    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
922    if let Some(ref user_agent) = configuration.user_agent {
923        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
924    }
925    if let Some(param_value) = p_header_cookie {
926        req_builder = req_builder.header("Cookie", param_value.to_string());
927    }
928
929    let req = req_builder.build()?;
930    let resp = configuration.client.execute(req).await?;
931
932    let status = resp.status();
933
934    if !status.is_client_error() && !status.is_server_error() {
935        Ok(())
936    } else {
937        let content = resp.text().await?;
938        let entity: Option<DeleteTestLoginFlowError> = serde_json::from_str(&content).ok();
939        Err(Error::ResponseError(ResponseContent { status, content, entity }))
940    }
941}
942
943/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
944pub async fn disable_my_other_sessions(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
945    // add a prefix to parameters to efficiently prevent name collisions
946    let p_header_x_session_token = x_session_token;
947    let p_header_cookie = cookie;
948
949    let uri_str = format!("{}/sessions", configuration.base_path);
950    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
951
952    if let Some(ref user_agent) = configuration.user_agent {
953        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
954    }
955    if let Some(param_value) = p_header_x_session_token {
956        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
957    }
958    if let Some(param_value) = p_header_cookie {
959        req_builder = req_builder.header("Cookie", param_value.to_string());
960    }
961
962    let req = req_builder.build()?;
963    let resp = configuration.client.execute(req).await?;
964
965    let status = resp.status();
966    let content_type = resp
967        .headers()
968        .get("content-type")
969        .and_then(|v| v.to_str().ok())
970        .unwrap_or("application/octet-stream");
971    let content_type = super::ContentType::from(content_type);
972
973    if !status.is_client_error() && !status.is_server_error() {
974        let content = resp.text().await?;
975        match content_type {
976            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
977            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMySessionsCount`"))),
978            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteMySessionsCount`")))),
979        }
980    } else {
981        let content = resp.text().await?;
982        let entity: Option<DisableMyOtherSessionsError> = serde_json::from_str(&content).ok();
983        Err(Error::ResponseError(ResponseContent { status, content, entity }))
984    }
985}
986
987/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
988pub async fn disable_my_session(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<(), Error<DisableMySessionError>> {
989    // add a prefix to parameters to efficiently prevent name collisions
990    let p_path_id = id;
991    let p_header_x_session_token = x_session_token;
992    let p_header_cookie = cookie;
993
994    let uri_str = format!("{}/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
995    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
996
997    if let Some(ref user_agent) = configuration.user_agent {
998        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
999    }
1000    if let Some(param_value) = p_header_x_session_token {
1001        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1002    }
1003    if let Some(param_value) = p_header_cookie {
1004        req_builder = req_builder.header("Cookie", param_value.to_string());
1005    }
1006
1007    let req = req_builder.build()?;
1008    let resp = configuration.client.execute(req).await?;
1009
1010    let status = resp.status();
1011
1012    if !status.is_client_error() && !status.is_server_error() {
1013        Ok(())
1014    } else {
1015        let content = resp.text().await?;
1016        let entity: Option<DisableMySessionError> = serde_json::from_str(&content).ok();
1017        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1018    }
1019}
1020
1021pub async fn exchange_session_token(configuration: &configuration::Configuration, init_code: &str, return_to_code: &str) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
1022    // add a prefix to parameters to efficiently prevent name collisions
1023    let p_query_init_code = init_code;
1024    let p_query_return_to_code = return_to_code;
1025
1026    let uri_str = format!("{}/sessions/token-exchange", configuration.base_path);
1027    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1028
1029    req_builder = req_builder.query(&[("init_code", &p_query_init_code.to_string())]);
1030    req_builder = req_builder.query(&[("return_to_code", &p_query_return_to_code.to_string())]);
1031    if let Some(ref user_agent) = configuration.user_agent {
1032        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1033    }
1034
1035    let req = req_builder.build()?;
1036    let resp = configuration.client.execute(req).await?;
1037
1038    let status = resp.status();
1039    let content_type = resp
1040        .headers()
1041        .get("content-type")
1042        .and_then(|v| v.to_str().ok())
1043        .unwrap_or("application/octet-stream");
1044    let content_type = super::ContentType::from(content_type);
1045
1046    if !status.is_client_error() && !status.is_server_error() {
1047        let content = resp.text().await?;
1048        match content_type {
1049            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1050            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1051            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1052        }
1053    } else {
1054        let content = resp.text().await?;
1055        let entity: Option<ExchangeSessionTokenError> = serde_json::from_str(&content).ok();
1056        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1057    }
1058}
1059
1060/// 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.com/docs/kratos/self-service/flows/user-facing-errors).
1061pub async fn get_flow_error(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowError, Error<GetFlowErrorError>> {
1062    // add a prefix to parameters to efficiently prevent name collisions
1063    let p_query_id = id;
1064
1065    let uri_str = format!("{}/self-service/errors", configuration.base_path);
1066    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1067
1068    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1069    if let Some(ref user_agent) = configuration.user_agent {
1070        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1071    }
1072
1073    let req = req_builder.build()?;
1074    let resp = configuration.client.execute(req).await?;
1075
1076    let status = resp.status();
1077    let content_type = resp
1078        .headers()
1079        .get("content-type")
1080        .and_then(|v| v.to_str().ok())
1081        .unwrap_or("application/octet-stream");
1082    let content_type = super::ContentType::from(content_type);
1083
1084    if !status.is_client_error() && !status.is_server_error() {
1085        let content = resp.text().await?;
1086        match content_type {
1087            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1088            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowError`"))),
1089            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowError`")))),
1090        }
1091    } else {
1092        let content = resp.text().await?;
1093        let entity: Option<GetFlowErrorError> = serde_json::from_str(&content).ok();
1094        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1095    }
1096}
1097
1098/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1099pub async fn get_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
1100    // add a prefix to parameters to efficiently prevent name collisions
1101    let p_query_id = id;
1102    let p_header_cookie = cookie;
1103
1104    let uri_str = format!("{}/self-service/login/flows", configuration.base_path);
1105    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1106
1107    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1108    if let Some(ref user_agent) = configuration.user_agent {
1109        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1110    }
1111    if let Some(param_value) = p_header_cookie {
1112        req_builder = req_builder.header("Cookie", param_value.to_string());
1113    }
1114
1115    let req = req_builder.build()?;
1116    let resp = configuration.client.execute(req).await?;
1117
1118    let status = resp.status();
1119    let content_type = resp
1120        .headers()
1121        .get("content-type")
1122        .and_then(|v| v.to_str().ok())
1123        .unwrap_or("application/octet-stream");
1124    let content_type = super::ContentType::from(content_type);
1125
1126    if !status.is_client_error() && !status.is_server_error() {
1127        let content = resp.text().await?;
1128        match content_type {
1129            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1130            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
1131            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
1132        }
1133    } else {
1134        let content = resp.text().await?;
1135        let entity: Option<GetLoginFlowError> = serde_json::from_str(&content).ok();
1136        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1137    }
1138}
1139
1140/// 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).
1141pub async fn get_recovery_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
1142    // add a prefix to parameters to efficiently prevent name collisions
1143    let p_query_id = id;
1144    let p_header_cookie = cookie;
1145
1146    let uri_str = format!("{}/self-service/recovery/flows", configuration.base_path);
1147    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1148
1149    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1150    if let Some(ref user_agent) = configuration.user_agent {
1151        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1152    }
1153    if let Some(param_value) = p_header_cookie {
1154        req_builder = req_builder.header("Cookie", param_value.to_string());
1155    }
1156
1157    let req = req_builder.build()?;
1158    let resp = configuration.client.execute(req).await?;
1159
1160    let status = resp.status();
1161    let content_type = resp
1162        .headers()
1163        .get("content-type")
1164        .and_then(|v| v.to_str().ok())
1165        .unwrap_or("application/octet-stream");
1166    let content_type = super::ContentType::from(content_type);
1167
1168    if !status.is_client_error() && !status.is_server_error() {
1169        let content = resp.text().await?;
1170        match content_type {
1171            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1172            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1173            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
1174        }
1175    } else {
1176        let content = resp.text().await?;
1177        let entity: Option<GetRecoveryFlowError> = serde_json::from_str(&content).ok();
1178        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1179    }
1180}
1181
1182/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1183pub async fn get_registration_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
1184    // add a prefix to parameters to efficiently prevent name collisions
1185    let p_query_id = id;
1186    let p_header_cookie = cookie;
1187
1188    let uri_str = format!("{}/self-service/registration/flows", configuration.base_path);
1189    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1190
1191    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1192    if let Some(ref user_agent) = configuration.user_agent {
1193        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1194    }
1195    if let Some(param_value) = p_header_cookie {
1196        req_builder = req_builder.header("Cookie", param_value.to_string());
1197    }
1198
1199    let req = req_builder.build()?;
1200    let resp = configuration.client.execute(req).await?;
1201
1202    let status = resp.status();
1203    let content_type = resp
1204        .headers()
1205        .get("content-type")
1206        .and_then(|v| v.to_str().ok())
1207        .unwrap_or("application/octet-stream");
1208    let content_type = super::ContentType::from(content_type);
1209
1210    if !status.is_client_error() && !status.is_server_error() {
1211        let content = resp.text().await?;
1212        match content_type {
1213            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1214            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
1215            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
1216        }
1217    } else {
1218        let content = resp.text().await?;
1219        let entity: Option<GetRegistrationFlowError> = serde_json::from_str(&content).ok();
1220        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1221    }
1222}
1223
1224/// 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).
1225pub async fn get_settings_flow(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
1226    // add a prefix to parameters to efficiently prevent name collisions
1227    let p_query_id = id;
1228    let p_header_x_session_token = x_session_token;
1229    let p_header_cookie = cookie;
1230
1231    let uri_str = format!("{}/self-service/settings/flows", configuration.base_path);
1232    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1233
1234    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1235    if let Some(ref user_agent) = configuration.user_agent {
1236        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1237    }
1238    if let Some(param_value) = p_header_x_session_token {
1239        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1240    }
1241    if let Some(param_value) = p_header_cookie {
1242        req_builder = req_builder.header("Cookie", param_value.to_string());
1243    }
1244
1245    let req = req_builder.build()?;
1246    let resp = configuration.client.execute(req).await?;
1247
1248    let status = resp.status();
1249    let content_type = resp
1250        .headers()
1251        .get("content-type")
1252        .and_then(|v| v.to_str().ok())
1253        .unwrap_or("application/octet-stream");
1254    let content_type = super::ContentType::from(content_type);
1255
1256    if !status.is_client_error() && !status.is_server_error() {
1257        let content = resp.text().await?;
1258        match content_type {
1259            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1260            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1261            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
1262        }
1263    } else {
1264        let content = resp.text().await?;
1265        let entity: Option<GetSettingsFlowError> = serde_json::from_str(&content).ok();
1266        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1267    }
1268}
1269
1270/// 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.com/docs/kratos/self-service/flows/verify-email-account-activation).
1271pub async fn get_verification_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1272    // add a prefix to parameters to efficiently prevent name collisions
1273    let p_query_id = id;
1274    let p_header_cookie = cookie;
1275
1276    let uri_str = format!("{}/self-service/verification/flows", configuration.base_path);
1277    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1278
1279    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1280    if let Some(ref user_agent) = configuration.user_agent {
1281        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1282    }
1283    if let Some(param_value) = p_header_cookie {
1284        req_builder = req_builder.header("cookie", param_value.to_string());
1285    }
1286
1287    let req = req_builder.build()?;
1288    let resp = configuration.client.execute(req).await?;
1289
1290    let status = resp.status();
1291    let content_type = resp
1292        .headers()
1293        .get("content-type")
1294        .and_then(|v| v.to_str().ok())
1295        .unwrap_or("application/octet-stream");
1296    let content_type = super::ContentType::from(content_type);
1297
1298    if !status.is_client_error() && !status.is_server_error() {
1299        let content = resp.text().await?;
1300        match content_type {
1301            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1302            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1303            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
1304        }
1305    } else {
1306        let content = resp.text().await?;
1307        let entity: Option<GetVerificationFlowError> = serde_json::from_str(&content).ok();
1308        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1309    }
1310}
1311
1312/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1313pub async fn get_web_authn_java_script(configuration: &configuration::Configuration, ) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1314
1315    let uri_str = format!("{}/.well-known/ory/webauthn.js", configuration.base_path);
1316    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1317
1318    if let Some(ref user_agent) = configuration.user_agent {
1319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1320    }
1321
1322    let req = req_builder.build()?;
1323    let resp = configuration.client.execute(req).await?;
1324
1325    let status = resp.status();
1326    let content_type = resp
1327        .headers()
1328        .get("content-type")
1329        .and_then(|v| v.to_str().ok())
1330        .unwrap_or("application/octet-stream");
1331    let content_type = super::ContentType::from(content_type);
1332
1333    if !status.is_client_error() && !status.is_server_error() {
1334        let content = resp.text().await?;
1335        match content_type {
1336            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1337            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1338            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1339        }
1340    } else {
1341        let content = resp.text().await?;
1342        let entity: Option<GetWebAuthnJavaScriptError> = serde_json::from_str(&content).ok();
1343        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1344    }
1345}
1346
1347/// 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.
1348pub 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>> {
1349    // add a prefix to parameters to efficiently prevent name collisions
1350    let p_query_per_page = per_page;
1351    let p_query_page = page;
1352    let p_query_page_size = page_size;
1353    let p_query_page_token = page_token;
1354    let p_header_x_session_token = x_session_token;
1355    let p_header_cookie = cookie;
1356
1357    let uri_str = format!("{}/sessions", configuration.base_path);
1358    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1359
1360    if let Some(ref param_value) = p_query_per_page {
1361        req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
1362    }
1363    if let Some(ref param_value) = p_query_page {
1364        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1365    }
1366    if let Some(ref param_value) = p_query_page_size {
1367        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1368    }
1369    if let Some(ref param_value) = p_query_page_token {
1370        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
1371    }
1372    if let Some(ref user_agent) = configuration.user_agent {
1373        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1374    }
1375    if let Some(param_value) = p_header_x_session_token {
1376        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1377    }
1378    if let Some(param_value) = p_header_cookie {
1379        req_builder = req_builder.header("Cookie", param_value.to_string());
1380    }
1381
1382    let req = req_builder.build()?;
1383    let resp = configuration.client.execute(req).await?;
1384
1385    let status = resp.status();
1386    let content_type = resp
1387        .headers()
1388        .get("content-type")
1389        .and_then(|v| v.to_str().ok())
1390        .unwrap_or("application/octet-stream");
1391    let content_type = super::ContentType::from(content_type);
1392
1393    if !status.is_client_error() && !status.is_server_error() {
1394        let content = resp.text().await?;
1395        match content_type {
1396            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1397            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Session&gt;`"))),
1398            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Session&gt;`")))),
1399        }
1400    } else {
1401        let content = resp.text().await?;
1402        let entity: Option<ListMySessionsError> = serde_json::from_str(&content).ok();
1403        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1404    }
1405}
1406
1407/// 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.
1408pub async fn perform_native_logout(configuration: &configuration::Configuration, perform_native_logout_body: models::PerformNativeLogoutBody) -> Result<(), Error<PerformNativeLogoutError>> {
1409    // add a prefix to parameters to efficiently prevent name collisions
1410    let p_body_perform_native_logout_body = perform_native_logout_body;
1411
1412    let uri_str = format!("{}/self-service/logout/api", configuration.base_path);
1413    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1414
1415    if let Some(ref user_agent) = configuration.user_agent {
1416        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1417    }
1418    req_builder = req_builder.json(&p_body_perform_native_logout_body);
1419
1420    let req = req_builder.build()?;
1421    let resp = configuration.client.execute(req).await?;
1422
1423    let status = resp.status();
1424
1425    if !status.is_client_error() && !status.is_server_error() {
1426        Ok(())
1427    } else {
1428        let content = resp.text().await?;
1429        let entity: Option<PerformNativeLogoutError> = serde_json::from_str(&content).ok();
1430        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1431    }
1432}
1433
1434/// 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.
1435pub async fn to_session(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>, tokenize_as: Option<&str>) -> Result<models::Session, Error<ToSessionError>> {
1436    // add a prefix to parameters to efficiently prevent name collisions
1437    let p_header_x_session_token = x_session_token;
1438    let p_header_cookie = cookie;
1439    let p_query_tokenize_as = tokenize_as;
1440
1441    let uri_str = format!("{}/sessions/whoami", configuration.base_path);
1442    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1443
1444    if let Some(ref param_value) = p_query_tokenize_as {
1445        req_builder = req_builder.query(&[("tokenize_as", &param_value.to_string())]);
1446    }
1447    if let Some(ref user_agent) = configuration.user_agent {
1448        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1449    }
1450    if let Some(param_value) = p_header_x_session_token {
1451        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1452    }
1453    if let Some(param_value) = p_header_cookie {
1454        req_builder = req_builder.header("Cookie", param_value.to_string());
1455    }
1456
1457    let req = req_builder.build()?;
1458    let resp = configuration.client.execute(req).await?;
1459
1460    let status = resp.status();
1461    let content_type = resp
1462        .headers()
1463        .get("content-type")
1464        .and_then(|v| v.to_str().ok())
1465        .unwrap_or("application/octet-stream");
1466    let content_type = super::ContentType::from(content_type);
1467
1468    if !status.is_client_error() && !status.is_server_error() {
1469        let content = resp.text().await?;
1470        match content_type {
1471            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1472            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
1473            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Session`")))),
1474        }
1475    } else {
1476        let content = resp.text().await?;
1477        let entity: Option<ToSessionError> = serde_json::from_str(&content).ok();
1478        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1479    }
1480}
1481
1482/// 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`.
1483pub async fn update_fedcm_flow(configuration: &configuration::Configuration, update_fedcm_flow_body: models::UpdateFedcmFlowBody) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1484    // add a prefix to parameters to efficiently prevent name collisions
1485    let p_body_update_fedcm_flow_body = update_fedcm_flow_body;
1486
1487    let uri_str = format!("{}/self-service/fed-cm/token", configuration.base_path);
1488    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1489
1490    if let Some(ref user_agent) = configuration.user_agent {
1491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1492    }
1493    req_builder = req_builder.json(&p_body_update_fedcm_flow_body);
1494
1495    let req = req_builder.build()?;
1496    let resp = configuration.client.execute(req).await?;
1497
1498    let status = resp.status();
1499    let content_type = resp
1500        .headers()
1501        .get("content-type")
1502        .and_then(|v| v.to_str().ok())
1503        .unwrap_or("application/octet-stream");
1504    let content_type = super::ContentType::from(content_type);
1505
1506    if !status.is_client_error() && !status.is_server_error() {
1507        let content = resp.text().await?;
1508        match content_type {
1509            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1510            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1511            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1512        }
1513    } else {
1514        let content = resp.text().await?;
1515        let entity: Option<UpdateFedcmFlowError> = serde_json::from_str(&content).ok();
1516        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1517    }
1518}
1519
1520/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1521pub 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>> {
1522    // add a prefix to parameters to efficiently prevent name collisions
1523    let p_query_flow = flow;
1524    let p_body_update_login_flow_body = update_login_flow_body;
1525    let p_header_x_session_token = x_session_token;
1526    let p_header_cookie = cookie;
1527
1528    let uri_str = format!("{}/self-service/login", configuration.base_path);
1529    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1530
1531    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1532    if let Some(ref user_agent) = configuration.user_agent {
1533        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1534    }
1535    if let Some(param_value) = p_header_x_session_token {
1536        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1537    }
1538    if let Some(param_value) = p_header_cookie {
1539        req_builder = req_builder.header("Cookie", param_value.to_string());
1540    }
1541    req_builder = req_builder.json(&p_body_update_login_flow_body);
1542
1543    let req = req_builder.build()?;
1544    let resp = configuration.client.execute(req).await?;
1545
1546    let status = resp.status();
1547    let content_type = resp
1548        .headers()
1549        .get("content-type")
1550        .and_then(|v| v.to_str().ok())
1551        .unwrap_or("application/octet-stream");
1552    let content_type = super::ContentType::from(content_type);
1553
1554    if !status.is_client_error() && !status.is_server_error() {
1555        let content = resp.text().await?;
1556        match content_type {
1557            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1558            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1559            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1560        }
1561    } else {
1562        let content = resp.text().await?;
1563        let entity: Option<UpdateLoginFlowError> = serde_json::from_str(&content).ok();
1564        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1565    }
1566}
1567
1568/// 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.com/docs/next/kratos/self-service/flows/user-logout).
1569pub async fn update_logout_flow(configuration: &configuration::Configuration, token: Option<&str>, return_to: Option<&str>, cookie: Option<&str>) -> Result<(), Error<UpdateLogoutFlowError>> {
1570    // add a prefix to parameters to efficiently prevent name collisions
1571    let p_query_token = token;
1572    let p_query_return_to = return_to;
1573    let p_header_cookie = cookie;
1574
1575    let uri_str = format!("{}/self-service/logout", configuration.base_path);
1576    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1577
1578    if let Some(ref param_value) = p_query_token {
1579        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1580    }
1581    if let Some(ref param_value) = p_query_return_to {
1582        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
1583    }
1584    if let Some(ref user_agent) = configuration.user_agent {
1585        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1586    }
1587    if let Some(param_value) = p_header_cookie {
1588        req_builder = req_builder.header("Cookie", param_value.to_string());
1589    }
1590
1591    let req = req_builder.build()?;
1592    let resp = configuration.client.execute(req).await?;
1593
1594    let status = resp.status();
1595
1596    if !status.is_client_error() && !status.is_server_error() {
1597        Ok(())
1598    } else {
1599        let content = resp.text().await?;
1600        let entity: Option<UpdateLogoutFlowError> = serde_json::from_str(&content).ok();
1601        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1602    }
1603}
1604
1605/// 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).
1606pub 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>> {
1607    // add a prefix to parameters to efficiently prevent name collisions
1608    let p_query_flow = flow;
1609    let p_body_update_recovery_flow_body = update_recovery_flow_body;
1610    let p_query_token = token;
1611    let p_header_cookie = cookie;
1612
1613    let uri_str = format!("{}/self-service/recovery", configuration.base_path);
1614    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1615
1616    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1617    if let Some(ref param_value) = p_query_token {
1618        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1619    }
1620    if let Some(ref user_agent) = configuration.user_agent {
1621        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1622    }
1623    if let Some(param_value) = p_header_cookie {
1624        req_builder = req_builder.header("Cookie", param_value.to_string());
1625    }
1626    req_builder = req_builder.json(&p_body_update_recovery_flow_body);
1627
1628    let req = req_builder.build()?;
1629    let resp = configuration.client.execute(req).await?;
1630
1631    let status = resp.status();
1632    let content_type = resp
1633        .headers()
1634        .get("content-type")
1635        .and_then(|v| v.to_str().ok())
1636        .unwrap_or("application/octet-stream");
1637    let content_type = super::ContentType::from(content_type);
1638
1639    if !status.is_client_error() && !status.is_server_error() {
1640        let content = resp.text().await?;
1641        match content_type {
1642            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1643            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1644            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
1645        }
1646    } else {
1647        let content = resp.text().await?;
1648        let entity: Option<UpdateRecoveryFlowError> = serde_json::from_str(&content).ok();
1649        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1650    }
1651}
1652
1653/// 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.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1654pub async fn update_registration_flow(configuration: &configuration::Configuration, flow: &str, update_registration_flow_body: models::UpdateRegistrationFlowBody, cookie: Option<&str>) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
1655    // add a prefix to parameters to efficiently prevent name collisions
1656    let p_query_flow = flow;
1657    let p_body_update_registration_flow_body = update_registration_flow_body;
1658    let p_header_cookie = cookie;
1659
1660    let uri_str = format!("{}/self-service/registration", configuration.base_path);
1661    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1662
1663    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1664    if let Some(ref user_agent) = configuration.user_agent {
1665        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1666    }
1667    if let Some(param_value) = p_header_cookie {
1668        req_builder = req_builder.header("Cookie", param_value.to_string());
1669    }
1670    req_builder = req_builder.json(&p_body_update_registration_flow_body);
1671
1672    let req = req_builder.build()?;
1673    let resp = configuration.client.execute(req).await?;
1674
1675    let status = resp.status();
1676    let content_type = resp
1677        .headers()
1678        .get("content-type")
1679        .and_then(|v| v.to_str().ok())
1680        .unwrap_or("application/octet-stream");
1681    let content_type = super::ContentType::from(content_type);
1682
1683    if !status.is_client_error() && !status.is_server_error() {
1684        let content = resp.text().await?;
1685        match content_type {
1686            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1687            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeRegistration`"))),
1688            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeRegistration`")))),
1689        }
1690    } else {
1691        let content = resp.text().await?;
1692        let entity: Option<UpdateRegistrationFlowError> = serde_json::from_str(&content).ok();
1693        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1694    }
1695}
1696
1697/// 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).
1698pub 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>> {
1699    // add a prefix to parameters to efficiently prevent name collisions
1700    let p_query_flow = flow;
1701    let p_body_update_settings_flow_body = update_settings_flow_body;
1702    let p_header_x_session_token = x_session_token;
1703    let p_header_cookie = cookie;
1704
1705    let uri_str = format!("{}/self-service/settings", configuration.base_path);
1706    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1707
1708    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1709    if let Some(ref user_agent) = configuration.user_agent {
1710        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1711    }
1712    if let Some(param_value) = p_header_x_session_token {
1713        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1714    }
1715    if let Some(param_value) = p_header_cookie {
1716        req_builder = req_builder.header("Cookie", param_value.to_string());
1717    }
1718    req_builder = req_builder.json(&p_body_update_settings_flow_body);
1719
1720    let req = req_builder.build()?;
1721    let resp = configuration.client.execute(req).await?;
1722
1723    let status = resp.status();
1724    let content_type = resp
1725        .headers()
1726        .get("content-type")
1727        .and_then(|v| v.to_str().ok())
1728        .unwrap_or("application/octet-stream");
1729    let content_type = super::ContentType::from(content_type);
1730
1731    if !status.is_client_error() && !status.is_server_error() {
1732        let content = resp.text().await?;
1733        match content_type {
1734            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1735            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1736            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
1737        }
1738    } else {
1739        let content = resp.text().await?;
1740        let entity: Option<UpdateSettingsFlowError> = serde_json::from_str(&content).ok();
1741        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1742    }
1743}
1744
1745/// 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.com/docs/kratos/self-service/flows/verify-email-account-activation).
1746pub 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>> {
1747    // add a prefix to parameters to efficiently prevent name collisions
1748    let p_query_flow = flow;
1749    let p_body_update_verification_flow_body = update_verification_flow_body;
1750    let p_query_token = token;
1751    let p_header_cookie = cookie;
1752
1753    let uri_str = format!("{}/self-service/verification", configuration.base_path);
1754    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1755
1756    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1757    if let Some(ref param_value) = p_query_token {
1758        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1759    }
1760    if let Some(ref user_agent) = configuration.user_agent {
1761        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1762    }
1763    if let Some(param_value) = p_header_cookie {
1764        req_builder = req_builder.header("Cookie", param_value.to_string());
1765    }
1766    req_builder = req_builder.json(&p_body_update_verification_flow_body);
1767
1768    let req = req_builder.build()?;
1769    let resp = configuration.client.execute(req).await?;
1770
1771    let status = resp.status();
1772    let content_type = resp
1773        .headers()
1774        .get("content-type")
1775        .and_then(|v| v.to_str().ok())
1776        .unwrap_or("application/octet-stream");
1777    let content_type = super::ContentType::from(content_type);
1778
1779    if !status.is_client_error() && !status.is_server_error() {
1780        let content = resp.text().await?;
1781        match content_type {
1782            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1783            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1784            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
1785        }
1786    } else {
1787        let content = resp.text().await?;
1788        let entity: Option<UpdateVerificationFlowError> = serde_json::from_str(&content).ok();
1789        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1790    }
1791}
1792