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.6
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 [`disable_my_other_sessions`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum DisableMyOtherSessionsError {
131    Status400(models::ErrorGeneric),
132    Status401(models::ErrorGeneric),
133    DefaultResponse(models::ErrorGeneric),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`disable_my_session`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum DisableMySessionError {
141    Status400(models::ErrorGeneric),
142    Status401(models::ErrorGeneric),
143    DefaultResponse(models::ErrorGeneric),
144    UnknownValue(serde_json::Value),
145}
146
147/// struct for typed errors of method [`exchange_session_token`]
148#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum ExchangeSessionTokenError {
151    Status403(models::ErrorGeneric),
152    Status404(models::ErrorGeneric),
153    Status410(models::ErrorGeneric),
154    DefaultResponse(models::ErrorGeneric),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`get_flow_error`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum GetFlowErrorError {
162    Status403(models::ErrorGeneric),
163    Status404(models::ErrorGeneric),
164    Status500(models::ErrorGeneric),
165    UnknownValue(serde_json::Value),
166}
167
168/// struct for typed errors of method [`get_login_flow`]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum GetLoginFlowError {
172    Status403(models::ErrorGeneric),
173    Status404(models::ErrorGeneric),
174    Status410(models::ErrorGeneric),
175    DefaultResponse(models::ErrorGeneric),
176    UnknownValue(serde_json::Value),
177}
178
179/// struct for typed errors of method [`get_recovery_flow`]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum GetRecoveryFlowError {
183    Status404(models::ErrorGeneric),
184    Status410(models::ErrorGeneric),
185    DefaultResponse(models::ErrorGeneric),
186    UnknownValue(serde_json::Value),
187}
188
189/// struct for typed errors of method [`get_registration_flow`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum GetRegistrationFlowError {
193    Status403(models::ErrorGeneric),
194    Status404(models::ErrorGeneric),
195    Status410(models::ErrorGeneric),
196    DefaultResponse(models::ErrorGeneric),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`get_settings_flow`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetSettingsFlowError {
204    Status401(models::ErrorGeneric),
205    Status403(models::ErrorGeneric),
206    Status404(models::ErrorGeneric),
207    Status410(models::ErrorGeneric),
208    DefaultResponse(models::ErrorGeneric),
209    UnknownValue(serde_json::Value),
210}
211
212/// struct for typed errors of method [`get_verification_flow`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum GetVerificationFlowError {
216    Status403(models::ErrorGeneric),
217    Status404(models::ErrorGeneric),
218    DefaultResponse(models::ErrorGeneric),
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`get_web_authn_java_script`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum GetWebAuthnJavaScriptError {
226    UnknownValue(serde_json::Value),
227}
228
229/// struct for typed errors of method [`list_my_sessions`]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum ListMySessionsError {
233    Status400(models::ErrorGeneric),
234    Status401(models::ErrorGeneric),
235    DefaultResponse(models::ErrorGeneric),
236    UnknownValue(serde_json::Value),
237}
238
239/// struct for typed errors of method [`perform_native_logout`]
240#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum PerformNativeLogoutError {
243    Status400(models::ErrorGeneric),
244    DefaultResponse(models::ErrorGeneric),
245    UnknownValue(serde_json::Value),
246}
247
248/// struct for typed errors of method [`to_session`]
249#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum ToSessionError {
252    Status401(models::ErrorGeneric),
253    Status403(models::ErrorGeneric),
254    DefaultResponse(models::ErrorGeneric),
255    UnknownValue(serde_json::Value),
256}
257
258/// struct for typed errors of method [`update_fedcm_flow`]
259#[derive(Debug, Clone, Serialize, Deserialize)]
260#[serde(untagged)]
261pub enum UpdateFedcmFlowError {
262    Status400(models::LoginFlow),
263    Status410(models::ErrorGeneric),
264    Status422(models::ErrorBrowserLocationChangeRequired),
265    DefaultResponse(models::ErrorGeneric),
266    UnknownValue(serde_json::Value),
267}
268
269/// struct for typed errors of method [`update_login_flow`]
270#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum UpdateLoginFlowError {
273    Status400(models::LoginFlow),
274    Status410(models::ErrorGeneric),
275    Status422(models::ErrorBrowserLocationChangeRequired),
276    DefaultResponse(models::ErrorGeneric),
277    UnknownValue(serde_json::Value),
278}
279
280/// struct for typed errors of method [`update_logout_flow`]
281#[derive(Debug, Clone, Serialize, Deserialize)]
282#[serde(untagged)]
283pub enum UpdateLogoutFlowError {
284    DefaultResponse(models::ErrorGeneric),
285    UnknownValue(serde_json::Value),
286}
287
288/// struct for typed errors of method [`update_recovery_flow`]
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum UpdateRecoveryFlowError {
292    Status400(models::RecoveryFlow),
293    Status410(models::ErrorGeneric),
294    Status422(models::ErrorBrowserLocationChangeRequired),
295    DefaultResponse(models::ErrorGeneric),
296    UnknownValue(serde_json::Value),
297}
298
299/// struct for typed errors of method [`update_registration_flow`]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301#[serde(untagged)]
302pub enum UpdateRegistrationFlowError {
303    Status400(models::RegistrationFlow),
304    Status410(models::ErrorGeneric),
305    Status422(models::ErrorBrowserLocationChangeRequired),
306    DefaultResponse(models::ErrorGeneric),
307    UnknownValue(serde_json::Value),
308}
309
310/// struct for typed errors of method [`update_settings_flow`]
311#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum UpdateSettingsFlowError {
314    Status400(models::SettingsFlow),
315    Status401(models::ErrorGeneric),
316    Status403(models::ErrorGeneric),
317    Status410(models::ErrorGeneric),
318    Status422(models::ErrorBrowserLocationChangeRequired),
319    DefaultResponse(models::ErrorGeneric),
320    UnknownValue(serde_json::Value),
321}
322
323/// struct for typed errors of method [`update_verification_flow`]
324#[derive(Debug, Clone, Serialize, Deserialize)]
325#[serde(untagged)]
326pub enum UpdateVerificationFlowError {
327    Status400(models::VerificationFlow),
328    Status410(models::ErrorGeneric),
329    DefaultResponse(models::ErrorGeneric),
330    UnknownValue(serde_json::Value),
331}
332
333
334/// This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
335pub async fn create_browser_login_flow(configuration: &configuration::Configuration, refresh: Option<bool>, aal: Option<&str>, return_to: Option<&str>, cookie: Option<&str>, login_challenge: Option<&str>, organization: Option<&str>, via: Option<&str>, identity_schema: Option<&str>) -> Result<models::LoginFlow, Error<CreateBrowserLoginFlowError>> {
336    // add a prefix to parameters to efficiently prevent name collisions
337    let p_refresh = refresh;
338    let p_aal = aal;
339    let p_return_to = return_to;
340    let p_cookie = cookie;
341    let p_login_challenge = login_challenge;
342    let p_organization = organization;
343    let p_via = via;
344    let p_identity_schema = identity_schema;
345
346    let uri_str = format!("{}/self-service/login/browser", configuration.base_path);
347    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
348
349    if let Some(ref param_value) = p_refresh {
350        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
351    }
352    if let Some(ref param_value) = p_aal {
353        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
354    }
355    if let Some(ref param_value) = p_return_to {
356        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
357    }
358    if let Some(ref param_value) = p_login_challenge {
359        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
360    }
361    if let Some(ref param_value) = p_organization {
362        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
363    }
364    if let Some(ref param_value) = p_via {
365        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
366    }
367    if let Some(ref param_value) = p_identity_schema {
368        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
369    }
370    if let Some(ref user_agent) = configuration.user_agent {
371        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
372    }
373    if let Some(param_value) = p_cookie {
374        req_builder = req_builder.header("Cookie", param_value.to_string());
375    }
376
377    let req = req_builder.build()?;
378    let resp = configuration.client.execute(req).await?;
379
380    let status = resp.status();
381    let content_type = resp
382        .headers()
383        .get("content-type")
384        .and_then(|v| v.to_str().ok())
385        .unwrap_or("application/octet-stream");
386    let content_type = super::ContentType::from(content_type);
387
388    if !status.is_client_error() && !status.is_server_error() {
389        let content = resp.text().await?;
390        match content_type {
391            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
392            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
393            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`")))),
394        }
395    } else {
396        let content = resp.text().await?;
397        let entity: Option<CreateBrowserLoginFlowError> = serde_json::from_str(&content).ok();
398        Err(Error::ResponseError(ResponseContent { status, content, entity }))
399    }
400}
401
402/// 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.
403pub async fn create_browser_logout_flow(configuration: &configuration::Configuration, cookie: Option<&str>, return_to: Option<&str>) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
404    // add a prefix to parameters to efficiently prevent name collisions
405    let p_cookie = cookie;
406    let p_return_to = return_to;
407
408    let uri_str = format!("{}/self-service/logout/browser", configuration.base_path);
409    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
410
411    if let Some(ref param_value) = p_return_to {
412        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
413    }
414    if let Some(ref user_agent) = configuration.user_agent {
415        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416    }
417    if let Some(param_value) = p_cookie {
418        req_builder = req_builder.header("cookie", param_value.to_string());
419    }
420
421    let req = req_builder.build()?;
422    let resp = configuration.client.execute(req).await?;
423
424    let status = resp.status();
425    let content_type = resp
426        .headers()
427        .get("content-type")
428        .and_then(|v| v.to_str().ok())
429        .unwrap_or("application/octet-stream");
430    let content_type = super::ContentType::from(content_type);
431
432    if !status.is_client_error() && !status.is_server_error() {
433        let content = resp.text().await?;
434        match content_type {
435            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
436            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LogoutFlow`"))),
437            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`")))),
438        }
439    } else {
440        let content = resp.text().await?;
441        let entity: Option<CreateBrowserLogoutFlowError> = serde_json::from_str(&content).ok();
442        Err(Error::ResponseError(ResponseContent { status, content, entity }))
443    }
444}
445
446/// 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).
447pub async fn create_browser_recovery_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
448    // add a prefix to parameters to efficiently prevent name collisions
449    let p_return_to = return_to;
450
451    let uri_str = format!("{}/self-service/recovery/browser", configuration.base_path);
452    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
453
454    if let Some(ref param_value) = p_return_to {
455        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
456    }
457    if let Some(ref user_agent) = configuration.user_agent {
458        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
459    }
460
461    let req = req_builder.build()?;
462    let resp = configuration.client.execute(req).await?;
463
464    let status = resp.status();
465    let content_type = resp
466        .headers()
467        .get("content-type")
468        .and_then(|v| v.to_str().ok())
469        .unwrap_or("application/octet-stream");
470    let content_type = super::ContentType::from(content_type);
471
472    if !status.is_client_error() && !status.is_server_error() {
473        let content = resp.text().await?;
474        match content_type {
475            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
476            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
477            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`")))),
478        }
479    } else {
480        let content = resp.text().await?;
481        let entity: Option<CreateBrowserRecoveryFlowError> = serde_json::from_str(&content).ok();
482        Err(Error::ResponseError(ResponseContent { status, content, entity }))
483    }
484}
485
486/// This endpoint initializes a browser-based user registration flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.registration.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url`.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  If this endpoint is called via an AJAX request, the response contains the registration flow without a redirect.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
487pub 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>> {
488    // add a prefix to parameters to efficiently prevent name collisions
489    let p_return_to = return_to;
490    let p_login_challenge = login_challenge;
491    let p_after_verification_return_to = after_verification_return_to;
492    let p_organization = organization;
493    let p_identity_schema = identity_schema;
494
495    let uri_str = format!("{}/self-service/registration/browser", configuration.base_path);
496    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
497
498    if let Some(ref param_value) = p_return_to {
499        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
500    }
501    if let Some(ref param_value) = p_login_challenge {
502        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
503    }
504    if let Some(ref param_value) = p_after_verification_return_to {
505        req_builder = req_builder.query(&[("after_verification_return_to", &param_value.to_string())]);
506    }
507    if let Some(ref param_value) = p_organization {
508        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
509    }
510    if let Some(ref param_value) = p_identity_schema {
511        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
512    }
513    if let Some(ref user_agent) = configuration.user_agent {
514        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
515    }
516
517    let req = req_builder.build()?;
518    let resp = configuration.client.execute(req).await?;
519
520    let status = resp.status();
521    let content_type = resp
522        .headers()
523        .get("content-type")
524        .and_then(|v| v.to_str().ok())
525        .unwrap_or("application/octet-stream");
526    let content_type = super::ContentType::from(content_type);
527
528    if !status.is_client_error() && !status.is_server_error() {
529        let content = resp.text().await?;
530        match content_type {
531            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
532            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
533            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`")))),
534        }
535    } else {
536        let content = resp.text().await?;
537        let entity: Option<CreateBrowserRegistrationFlowError> = serde_json::from_str(&content).ok();
538        Err(Error::ResponseError(ResponseContent { status, content, entity }))
539    }
540}
541
542/// 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).
543pub async fn create_browser_settings_flow(configuration: &configuration::Configuration, return_to: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
544    // add a prefix to parameters to efficiently prevent name collisions
545    let p_return_to = return_to;
546    let p_cookie = cookie;
547
548    let uri_str = format!("{}/self-service/settings/browser", configuration.base_path);
549    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
550
551    if let Some(ref param_value) = p_return_to {
552        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
553    }
554    if let Some(ref user_agent) = configuration.user_agent {
555        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
556    }
557    if let Some(param_value) = p_cookie {
558        req_builder = req_builder.header("Cookie", param_value.to_string());
559    }
560
561    let req = req_builder.build()?;
562    let resp = configuration.client.execute(req).await?;
563
564    let status = resp.status();
565    let content_type = resp
566        .headers()
567        .get("content-type")
568        .and_then(|v| v.to_str().ok())
569        .unwrap_or("application/octet-stream");
570    let content_type = super::ContentType::from(content_type);
571
572    if !status.is_client_error() && !status.is_server_error() {
573        let content = resp.text().await?;
574        match content_type {
575            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
576            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
577            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`")))),
578        }
579    } else {
580        let content = resp.text().await?;
581        let entity: Option<CreateBrowserSettingsFlowError> = serde_json::from_str(&content).ok();
582        Err(Error::ResponseError(ResponseContent { status, content, entity }))
583    }
584}
585
586/// This endpoint initializes a browser-based account verification flow. Once initialized, the browser will be redirected to `selfservice.flows.verification.ui_url` with the flow ID set as the query parameter `?flow=`.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...).  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
587pub async fn create_browser_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
588    // add a prefix to parameters to efficiently prevent name collisions
589    let p_return_to = return_to;
590
591    let uri_str = format!("{}/self-service/verification/browser", configuration.base_path);
592    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
593
594    if let Some(ref param_value) = p_return_to {
595        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
596    }
597    if let Some(ref user_agent) = configuration.user_agent {
598        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
599    }
600
601    let req = req_builder.build()?;
602    let resp = configuration.client.execute(req).await?;
603
604    let status = resp.status();
605    let content_type = resp
606        .headers()
607        .get("content-type")
608        .and_then(|v| v.to_str().ok())
609        .unwrap_or("application/octet-stream");
610    let content_type = super::ContentType::from(content_type);
611
612    if !status.is_client_error() && !status.is_server_error() {
613        let content = resp.text().await?;
614        match content_type {
615            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
616            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
617            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`")))),
618        }
619    } else {
620        let content = resp.text().await?;
621        let entity: Option<CreateBrowserVerificationFlowError> = serde_json::from_str(&content).ok();
622        Err(Error::ResponseError(ResponseContent { status, content, entity }))
623    }
624}
625
626/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
627pub async fn create_fedcm_flow(configuration: &configuration::Configuration, ) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
628
629    let uri_str = format!("{}/self-service/fed-cm/parameters", configuration.base_path);
630    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
631
632    if let Some(ref user_agent) = configuration.user_agent {
633        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
634    }
635
636    let req = req_builder.build()?;
637    let resp = configuration.client.execute(req).await?;
638
639    let status = resp.status();
640    let content_type = resp
641        .headers()
642        .get("content-type")
643        .and_then(|v| v.to_str().ok())
644        .unwrap_or("application/octet-stream");
645    let content_type = super::ContentType::from(content_type);
646
647    if !status.is_client_error() && !status.is_server_error() {
648        let content = resp.text().await?;
649        match content_type {
650            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
651            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateFedcmFlowResponse`"))),
652            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`")))),
653        }
654    } else {
655        let content = resp.text().await?;
656        let entity: Option<CreateFedcmFlowError> = serde_json::from_str(&content).ok();
657        Err(Error::ResponseError(ResponseContent { status, content, entity }))
658    }
659}
660
661/// This endpoint initiates a login flow for native apps that do not use a browser, such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing login flow call `/self-service/login/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks, including CSRF login attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
662pub 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>> {
663    // add a prefix to parameters to efficiently prevent name collisions
664    let p_refresh = refresh;
665    let p_aal = aal;
666    let p_x_session_token = x_session_token;
667    let p_return_session_token_exchange_code = return_session_token_exchange_code;
668    let p_return_to = return_to;
669    let p_organization = organization;
670    let p_via = via;
671    let p_identity_schema = identity_schema;
672
673    let uri_str = format!("{}/self-service/login/api", configuration.base_path);
674    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
675
676    if let Some(ref param_value) = p_refresh {
677        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
678    }
679    if let Some(ref param_value) = p_aal {
680        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
681    }
682    if let Some(ref param_value) = p_return_session_token_exchange_code {
683        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
684    }
685    if let Some(ref param_value) = p_return_to {
686        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
687    }
688    if let Some(ref param_value) = p_organization {
689        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
690    }
691    if let Some(ref param_value) = p_via {
692        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
693    }
694    if let Some(ref param_value) = p_identity_schema {
695        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
696    }
697    if let Some(ref user_agent) = configuration.user_agent {
698        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
699    }
700    if let Some(param_value) = p_x_session_token {
701        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
702    }
703
704    let req = req_builder.build()?;
705    let resp = configuration.client.execute(req).await?;
706
707    let status = resp.status();
708    let content_type = resp
709        .headers()
710        .get("content-type")
711        .and_then(|v| v.to_str().ok())
712        .unwrap_or("application/octet-stream");
713    let content_type = super::ContentType::from(content_type);
714
715    if !status.is_client_error() && !status.is_server_error() {
716        let content = resp.text().await?;
717        match content_type {
718            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
719            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
720            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`")))),
721        }
722    } else {
723        let content = resp.text().await?;
724        let entity: Option<CreateNativeLoginFlowError> = serde_json::from_str(&content).ok();
725        Err(Error::ResponseError(ResponseContent { status, content, entity }))
726    }
727}
728
729/// 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).
730pub async fn create_native_recovery_flow(configuration: &configuration::Configuration, ) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
731
732    let uri_str = format!("{}/self-service/recovery/api", configuration.base_path);
733    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
734
735    if let Some(ref user_agent) = configuration.user_agent {
736        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
737    }
738
739    let req = req_builder.build()?;
740    let resp = configuration.client.execute(req).await?;
741
742    let status = resp.status();
743    let content_type = resp
744        .headers()
745        .get("content-type")
746        .and_then(|v| v.to_str().ok())
747        .unwrap_or("application/octet-stream");
748    let content_type = super::ContentType::from(content_type);
749
750    if !status.is_client_error() && !status.is_server_error() {
751        let content = resp.text().await?;
752        match content_type {
753            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
754            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
755            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`")))),
756        }
757    } else {
758        let content = resp.text().await?;
759        let entity: Option<CreateNativeRecoveryFlowError> = serde_json::from_str(&content).ok();
760        Err(Error::ResponseError(ResponseContent { status, content, entity }))
761    }
762}
763
764/// This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing registration flow call `/self-service/registration/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
765pub 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>> {
766    // add a prefix to parameters to efficiently prevent name collisions
767    let p_return_session_token_exchange_code = return_session_token_exchange_code;
768    let p_return_to = return_to;
769    let p_organization = organization;
770    let p_identity_schema = identity_schema;
771
772    let uri_str = format!("{}/self-service/registration/api", configuration.base_path);
773    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
774
775    if let Some(ref param_value) = p_return_session_token_exchange_code {
776        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
777    }
778    if let Some(ref param_value) = p_return_to {
779        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
780    }
781    if let Some(ref param_value) = p_organization {
782        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
783    }
784    if let Some(ref param_value) = p_identity_schema {
785        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
786    }
787    if let Some(ref user_agent) = configuration.user_agent {
788        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
789    }
790
791    let req = req_builder.build()?;
792    let resp = configuration.client.execute(req).await?;
793
794    let status = resp.status();
795    let content_type = resp
796        .headers()
797        .get("content-type")
798        .and_then(|v| v.to_str().ok())
799        .unwrap_or("application/octet-stream");
800    let content_type = super::ContentType::from(content_type);
801
802    if !status.is_client_error() && !status.is_server_error() {
803        let content = resp.text().await?;
804        match content_type {
805            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
806            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
807            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`")))),
808        }
809    } else {
810        let content = resp.text().await?;
811        let entity: Option<CreateNativeRegistrationFlowError> = serde_json::from_str(&content).ok();
812        Err(Error::ResponseError(ResponseContent { status, content, entity }))
813    }
814}
815
816/// 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).
817pub async fn create_native_settings_flow(configuration: &configuration::Configuration, x_session_token: Option<&str>) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
818    // add a prefix to parameters to efficiently prevent name collisions
819    let p_x_session_token = x_session_token;
820
821    let uri_str = format!("{}/self-service/settings/api", configuration.base_path);
822    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
823
824    if let Some(ref user_agent) = configuration.user_agent {
825        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
826    }
827    if let Some(param_value) = p_x_session_token {
828        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
829    }
830
831    let req = req_builder.build()?;
832    let resp = configuration.client.execute(req).await?;
833
834    let status = resp.status();
835    let content_type = resp
836        .headers()
837        .get("content-type")
838        .and_then(|v| v.to_str().ok())
839        .unwrap_or("application/octet-stream");
840    let content_type = super::ContentType::from(content_type);
841
842    if !status.is_client_error() && !status.is_server_error() {
843        let content = resp.text().await?;
844        match content_type {
845            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
846            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
847            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`")))),
848        }
849    } else {
850        let content = resp.text().await?;
851        let entity: Option<CreateNativeSettingsFlowError> = serde_json::from_str(&content).ok();
852        Err(Error::ResponseError(ResponseContent { status, content, entity }))
853    }
854}
855
856/// This endpoint initiates a verification flow for API clients such as mobile devices, smart TVs, and so on.  To fetch an existing verification flow call `/self-service/verification/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
857pub async fn create_native_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
858    // add a prefix to parameters to efficiently prevent name collisions
859    let p_return_to = return_to;
860
861    let uri_str = format!("{}/self-service/verification/api", configuration.base_path);
862    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
863
864    if let Some(ref param_value) = p_return_to {
865        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
866    }
867    if let Some(ref user_agent) = configuration.user_agent {
868        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
869    }
870
871    let req = req_builder.build()?;
872    let resp = configuration.client.execute(req).await?;
873
874    let status = resp.status();
875    let content_type = resp
876        .headers()
877        .get("content-type")
878        .and_then(|v| v.to_str().ok())
879        .unwrap_or("application/octet-stream");
880    let content_type = super::ContentType::from(content_type);
881
882    if !status.is_client_error() && !status.is_server_error() {
883        let content = resp.text().await?;
884        match content_type {
885            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
886            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
887            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`")))),
888        }
889    } else {
890        let content = resp.text().await?;
891        let entity: Option<CreateNativeVerificationFlowError> = serde_json::from_str(&content).ok();
892        Err(Error::ResponseError(ResponseContent { status, content, entity }))
893    }
894}
895
896/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
897pub async fn disable_my_other_sessions(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
898    // add a prefix to parameters to efficiently prevent name collisions
899    let p_x_session_token = x_session_token;
900    let p_cookie = cookie;
901
902    let uri_str = format!("{}/sessions", configuration.base_path);
903    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
904
905    if let Some(ref user_agent) = configuration.user_agent {
906        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
907    }
908    if let Some(param_value) = p_x_session_token {
909        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
910    }
911    if let Some(param_value) = p_cookie {
912        req_builder = req_builder.header("Cookie", param_value.to_string());
913    }
914
915    let req = req_builder.build()?;
916    let resp = configuration.client.execute(req).await?;
917
918    let status = resp.status();
919    let content_type = resp
920        .headers()
921        .get("content-type")
922        .and_then(|v| v.to_str().ok())
923        .unwrap_or("application/octet-stream");
924    let content_type = super::ContentType::from(content_type);
925
926    if !status.is_client_error() && !status.is_server_error() {
927        let content = resp.text().await?;
928        match content_type {
929            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
930            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMySessionsCount`"))),
931            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`")))),
932        }
933    } else {
934        let content = resp.text().await?;
935        let entity: Option<DisableMyOtherSessionsError> = serde_json::from_str(&content).ok();
936        Err(Error::ResponseError(ResponseContent { status, content, entity }))
937    }
938}
939
940/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
941pub async fn disable_my_session(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<(), Error<DisableMySessionError>> {
942    // add a prefix to parameters to efficiently prevent name collisions
943    let p_id = id;
944    let p_x_session_token = x_session_token;
945    let p_cookie = cookie;
946
947    let uri_str = format!("{}/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
948    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
949
950    if let Some(ref user_agent) = configuration.user_agent {
951        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
952    }
953    if let Some(param_value) = p_x_session_token {
954        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
955    }
956    if let Some(param_value) = p_cookie {
957        req_builder = req_builder.header("Cookie", param_value.to_string());
958    }
959
960    let req = req_builder.build()?;
961    let resp = configuration.client.execute(req).await?;
962
963    let status = resp.status();
964
965    if !status.is_client_error() && !status.is_server_error() {
966        Ok(())
967    } else {
968        let content = resp.text().await?;
969        let entity: Option<DisableMySessionError> = serde_json::from_str(&content).ok();
970        Err(Error::ResponseError(ResponseContent { status, content, entity }))
971    }
972}
973
974pub async fn exchange_session_token(configuration: &configuration::Configuration, init_code: &str, return_to_code: &str) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
975    // add a prefix to parameters to efficiently prevent name collisions
976    let p_init_code = init_code;
977    let p_return_to_code = return_to_code;
978
979    let uri_str = format!("{}/sessions/token-exchange", configuration.base_path);
980    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
981
982    req_builder = req_builder.query(&[("init_code", &p_init_code.to_string())]);
983    req_builder = req_builder.query(&[("return_to_code", &p_return_to_code.to_string())]);
984    if let Some(ref user_agent) = configuration.user_agent {
985        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
986    }
987
988    let req = req_builder.build()?;
989    let resp = configuration.client.execute(req).await?;
990
991    let status = resp.status();
992    let content_type = resp
993        .headers()
994        .get("content-type")
995        .and_then(|v| v.to_str().ok())
996        .unwrap_or("application/octet-stream");
997    let content_type = super::ContentType::from(content_type);
998
999    if !status.is_client_error() && !status.is_server_error() {
1000        let content = resp.text().await?;
1001        match content_type {
1002            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1003            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1004            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`")))),
1005        }
1006    } else {
1007        let content = resp.text().await?;
1008        let entity: Option<ExchangeSessionTokenError> = serde_json::from_str(&content).ok();
1009        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1010    }
1011}
1012
1013/// This endpoint returns the error associated with a user-facing self service errors.  This endpoint supports stub values to help you implement the error UI:  `?id=stub:500` - returns a stub 500 (Internal Server Error) error.  More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors).
1014pub async fn get_flow_error(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowError, Error<GetFlowErrorError>> {
1015    // add a prefix to parameters to efficiently prevent name collisions
1016    let p_id = id;
1017
1018    let uri_str = format!("{}/self-service/errors", configuration.base_path);
1019    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1020
1021    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1022    if let Some(ref user_agent) = configuration.user_agent {
1023        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1024    }
1025
1026    let req = req_builder.build()?;
1027    let resp = configuration.client.execute(req).await?;
1028
1029    let status = resp.status();
1030    let content_type = resp
1031        .headers()
1032        .get("content-type")
1033        .and_then(|v| v.to_str().ok())
1034        .unwrap_or("application/octet-stream");
1035    let content_type = super::ContentType::from(content_type);
1036
1037    if !status.is_client_error() && !status.is_server_error() {
1038        let content = resp.text().await?;
1039        match content_type {
1040            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1041            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowError`"))),
1042            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`")))),
1043        }
1044    } else {
1045        let content = resp.text().await?;
1046        let entity: Option<GetFlowErrorError> = serde_json::from_str(&content).ok();
1047        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1048    }
1049}
1050
1051/// This endpoint returns a login flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/login', async function (req, res) { const flow = await client.getLoginFlow(req.header('cookie'), req.query['flow'])  res.render('login', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1052pub async fn get_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
1053    // add a prefix to parameters to efficiently prevent name collisions
1054    let p_id = id;
1055    let p_cookie = cookie;
1056
1057    let uri_str = format!("{}/self-service/login/flows", configuration.base_path);
1058    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1059
1060    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1061    if let Some(ref user_agent) = configuration.user_agent {
1062        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1063    }
1064    if let Some(param_value) = p_cookie {
1065        req_builder = req_builder.header("Cookie", param_value.to_string());
1066    }
1067
1068    let req = req_builder.build()?;
1069    let resp = configuration.client.execute(req).await?;
1070
1071    let status = resp.status();
1072    let content_type = resp
1073        .headers()
1074        .get("content-type")
1075        .and_then(|v| v.to_str().ok())
1076        .unwrap_or("application/octet-stream");
1077    let content_type = super::ContentType::from(content_type);
1078
1079    if !status.is_client_error() && !status.is_server_error() {
1080        let content = resp.text().await?;
1081        match content_type {
1082            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1083            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
1084            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`")))),
1085        }
1086    } else {
1087        let content = resp.text().await?;
1088        let entity: Option<GetLoginFlowError> = serde_json::from_str(&content).ok();
1089        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1090    }
1091}
1092
1093/// 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).
1094pub async fn get_recovery_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
1095    // add a prefix to parameters to efficiently prevent name collisions
1096    let p_id = id;
1097    let p_cookie = cookie;
1098
1099    let uri_str = format!("{}/self-service/recovery/flows", configuration.base_path);
1100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1101
1102    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1103    if let Some(ref user_agent) = configuration.user_agent {
1104        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1105    }
1106    if let Some(param_value) = p_cookie {
1107        req_builder = req_builder.header("Cookie", param_value.to_string());
1108    }
1109
1110    let req = req_builder.build()?;
1111    let resp = configuration.client.execute(req).await?;
1112
1113    let status = resp.status();
1114    let content_type = resp
1115        .headers()
1116        .get("content-type")
1117        .and_then(|v| v.to_str().ok())
1118        .unwrap_or("application/octet-stream");
1119    let content_type = super::ContentType::from(content_type);
1120
1121    if !status.is_client_error() && !status.is_server_error() {
1122        let content = resp.text().await?;
1123        match content_type {
1124            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1125            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1126            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`")))),
1127        }
1128    } else {
1129        let content = resp.text().await?;
1130        let entity: Option<GetRecoveryFlowError> = serde_json::from_str(&content).ok();
1131        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1132    }
1133}
1134
1135/// This endpoint returns a registration flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/registration', async function (req, res) { const flow = await client.getRegistrationFlow(req.header('cookie'), req.query['flow'])  res.render('registration', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1136pub async fn get_registration_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
1137    // add a prefix to parameters to efficiently prevent name collisions
1138    let p_id = id;
1139    let p_cookie = cookie;
1140
1141    let uri_str = format!("{}/self-service/registration/flows", configuration.base_path);
1142    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1143
1144    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1145    if let Some(ref user_agent) = configuration.user_agent {
1146        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1147    }
1148    if let Some(param_value) = p_cookie {
1149        req_builder = req_builder.header("Cookie", param_value.to_string());
1150    }
1151
1152    let req = req_builder.build()?;
1153    let resp = configuration.client.execute(req).await?;
1154
1155    let status = resp.status();
1156    let content_type = resp
1157        .headers()
1158        .get("content-type")
1159        .and_then(|v| v.to_str().ok())
1160        .unwrap_or("application/octet-stream");
1161    let content_type = super::ContentType::from(content_type);
1162
1163    if !status.is_client_error() && !status.is_server_error() {
1164        let content = resp.text().await?;
1165        match content_type {
1166            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1167            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
1168            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`")))),
1169        }
1170    } else {
1171        let content = resp.text().await?;
1172        let entity: Option<GetRegistrationFlowError> = serde_json::from_str(&content).ok();
1173        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1174    }
1175}
1176
1177/// 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).
1178pub async fn get_settings_flow(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
1179    // add a prefix to parameters to efficiently prevent name collisions
1180    let p_id = id;
1181    let p_x_session_token = x_session_token;
1182    let p_cookie = cookie;
1183
1184    let uri_str = format!("{}/self-service/settings/flows", configuration.base_path);
1185    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1186
1187    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1188    if let Some(ref user_agent) = configuration.user_agent {
1189        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1190    }
1191    if let Some(param_value) = p_x_session_token {
1192        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1193    }
1194    if let Some(param_value) = p_cookie {
1195        req_builder = req_builder.header("Cookie", param_value.to_string());
1196    }
1197
1198    let req = req_builder.build()?;
1199    let resp = configuration.client.execute(req).await?;
1200
1201    let status = resp.status();
1202    let content_type = resp
1203        .headers()
1204        .get("content-type")
1205        .and_then(|v| v.to_str().ok())
1206        .unwrap_or("application/octet-stream");
1207    let content_type = super::ContentType::from(content_type);
1208
1209    if !status.is_client_error() && !status.is_server_error() {
1210        let content = resp.text().await?;
1211        match content_type {
1212            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1213            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1214            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`")))),
1215        }
1216    } else {
1217        let content = resp.text().await?;
1218        let entity: Option<GetSettingsFlowError> = serde_json::from_str(&content).ok();
1219        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1220    }
1221}
1222
1223/// This endpoint returns a verification flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getVerificationFlow(req.header('cookie'), req.query['flow'])  res.render('verification', flow) }) ```  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1224pub async fn get_verification_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1225    // add a prefix to parameters to efficiently prevent name collisions
1226    let p_id = id;
1227    let p_cookie = cookie;
1228
1229    let uri_str = format!("{}/self-service/verification/flows", configuration.base_path);
1230    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1231
1232    req_builder = req_builder.query(&[("id", &p_id.to_string())]);
1233    if let Some(ref user_agent) = configuration.user_agent {
1234        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1235    }
1236    if let Some(param_value) = p_cookie {
1237        req_builder = req_builder.header("cookie", param_value.to_string());
1238    }
1239
1240    let req = req_builder.build()?;
1241    let resp = configuration.client.execute(req).await?;
1242
1243    let status = resp.status();
1244    let content_type = resp
1245        .headers()
1246        .get("content-type")
1247        .and_then(|v| v.to_str().ok())
1248        .unwrap_or("application/octet-stream");
1249    let content_type = super::ContentType::from(content_type);
1250
1251    if !status.is_client_error() && !status.is_server_error() {
1252        let content = resp.text().await?;
1253        match content_type {
1254            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1255            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1256            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`")))),
1257        }
1258    } else {
1259        let content = resp.text().await?;
1260        let entity: Option<GetVerificationFlowError> = serde_json::from_str(&content).ok();
1261        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1262    }
1263}
1264
1265/// This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration.  If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file:  ```html <script src=\"https://public-kratos.example.org/.well-known/ory/webauthn.js\" type=\"script\" async /> ```  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1266pub async fn get_web_authn_java_script(configuration: &configuration::Configuration, ) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1267
1268    let uri_str = format!("{}/.well-known/ory/webauthn.js", configuration.base_path);
1269    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1270
1271    if let Some(ref user_agent) = configuration.user_agent {
1272        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1273    }
1274
1275    let req = req_builder.build()?;
1276    let resp = configuration.client.execute(req).await?;
1277
1278    let status = resp.status();
1279    let content_type = resp
1280        .headers()
1281        .get("content-type")
1282        .and_then(|v| v.to_str().ok())
1283        .unwrap_or("application/octet-stream");
1284    let content_type = super::ContentType::from(content_type);
1285
1286    if !status.is_client_error() && !status.is_server_error() {
1287        let content = resp.text().await?;
1288        match content_type {
1289            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1290            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1291            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`")))),
1292        }
1293    } else {
1294        let content = resp.text().await?;
1295        let entity: Option<GetWebAuthnJavaScriptError> = serde_json::from_str(&content).ok();
1296        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1297    }
1298}
1299
1300/// 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.
1301pub 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>> {
1302    // add a prefix to parameters to efficiently prevent name collisions
1303    let p_per_page = per_page;
1304    let p_page = page;
1305    let p_page_size = page_size;
1306    let p_page_token = page_token;
1307    let p_x_session_token = x_session_token;
1308    let p_cookie = cookie;
1309
1310    let uri_str = format!("{}/sessions", configuration.base_path);
1311    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1312
1313    if let Some(ref param_value) = p_per_page {
1314        req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
1315    }
1316    if let Some(ref param_value) = p_page {
1317        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1318    }
1319    if let Some(ref param_value) = p_page_size {
1320        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1321    }
1322    if let Some(ref param_value) = p_page_token {
1323        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
1324    }
1325    if let Some(ref user_agent) = configuration.user_agent {
1326        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1327    }
1328    if let Some(param_value) = p_x_session_token {
1329        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1330    }
1331    if let Some(param_value) = p_cookie {
1332        req_builder = req_builder.header("Cookie", param_value.to_string());
1333    }
1334
1335    let req = req_builder.build()?;
1336    let resp = configuration.client.execute(req).await?;
1337
1338    let status = resp.status();
1339    let content_type = resp
1340        .headers()
1341        .get("content-type")
1342        .and_then(|v| v.to_str().ok())
1343        .unwrap_or("application/octet-stream");
1344    let content_type = super::ContentType::from(content_type);
1345
1346    if !status.is_client_error() && !status.is_server_error() {
1347        let content = resp.text().await?;
1348        match content_type {
1349            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1350            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;`"))),
1351            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;`")))),
1352        }
1353    } else {
1354        let content = resp.text().await?;
1355        let entity: Option<ListMySessionsError> = serde_json::from_str(&content).ok();
1356        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1357    }
1358}
1359
1360/// 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.
1361pub async fn perform_native_logout(configuration: &configuration::Configuration, perform_native_logout_body: models::PerformNativeLogoutBody) -> Result<(), Error<PerformNativeLogoutError>> {
1362    // add a prefix to parameters to efficiently prevent name collisions
1363    let p_perform_native_logout_body = perform_native_logout_body;
1364
1365    let uri_str = format!("{}/self-service/logout/api", configuration.base_path);
1366    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1367
1368    if let Some(ref user_agent) = configuration.user_agent {
1369        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1370    }
1371    req_builder = req_builder.json(&p_perform_native_logout_body);
1372
1373    let req = req_builder.build()?;
1374    let resp = configuration.client.execute(req).await?;
1375
1376    let status = resp.status();
1377
1378    if !status.is_client_error() && !status.is_server_error() {
1379        Ok(())
1380    } else {
1381        let content = resp.text().await?;
1382        let entity: Option<PerformNativeLogoutError> = serde_json::from_str(&content).ok();
1383        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1384    }
1385}
1386
1387/// 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.
1388pub async fn to_session(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>, tokenize_as: Option<&str>) -> Result<models::Session, Error<ToSessionError>> {
1389    // add a prefix to parameters to efficiently prevent name collisions
1390    let p_x_session_token = x_session_token;
1391    let p_cookie = cookie;
1392    let p_tokenize_as = tokenize_as;
1393
1394    let uri_str = format!("{}/sessions/whoami", configuration.base_path);
1395    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1396
1397    if let Some(ref param_value) = p_tokenize_as {
1398        req_builder = req_builder.query(&[("tokenize_as", &param_value.to_string())]);
1399    }
1400    if let Some(ref user_agent) = configuration.user_agent {
1401        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1402    }
1403    if let Some(param_value) = p_x_session_token {
1404        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1405    }
1406    if let Some(param_value) = p_cookie {
1407        req_builder = req_builder.header("Cookie", param_value.to_string());
1408    }
1409
1410    let req = req_builder.build()?;
1411    let resp = configuration.client.execute(req).await?;
1412
1413    let status = resp.status();
1414    let content_type = resp
1415        .headers()
1416        .get("content-type")
1417        .and_then(|v| v.to_str().ok())
1418        .unwrap_or("application/octet-stream");
1419    let content_type = super::ContentType::from(content_type);
1420
1421    if !status.is_client_error() && !status.is_server_error() {
1422        let content = resp.text().await?;
1423        match content_type {
1424            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1425            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
1426            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`")))),
1427        }
1428    } else {
1429        let content = resp.text().await?;
1430        let entity: Option<ToSessionError> = serde_json::from_str(&content).ok();
1431        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1432    }
1433}
1434
1435/// 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`.
1436pub async fn update_fedcm_flow(configuration: &configuration::Configuration, update_fedcm_flow_body: models::UpdateFedcmFlowBody) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1437    // add a prefix to parameters to efficiently prevent name collisions
1438    let p_update_fedcm_flow_body = update_fedcm_flow_body;
1439
1440    let uri_str = format!("{}/self-service/fed-cm/token", configuration.base_path);
1441    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1442
1443    if let Some(ref user_agent) = configuration.user_agent {
1444        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1445    }
1446    req_builder = req_builder.json(&p_update_fedcm_flow_body);
1447
1448    let req = req_builder.build()?;
1449    let resp = configuration.client.execute(req).await?;
1450
1451    let status = resp.status();
1452    let content_type = resp
1453        .headers()
1454        .get("content-type")
1455        .and_then(|v| v.to_str().ok())
1456        .unwrap_or("application/octet-stream");
1457    let content_type = super::ContentType::from(content_type);
1458
1459    if !status.is_client_error() && !status.is_server_error() {
1460        let content = resp.text().await?;
1461        match content_type {
1462            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1463            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1464            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`")))),
1465        }
1466    } else {
1467        let content = resp.text().await?;
1468        let entity: Option<UpdateFedcmFlowError> = serde_json::from_str(&content).ok();
1469        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1470    }
1471}
1472
1473/// Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and responds with HTTP 200 and a application/json body with the session token on success; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after login URL or the `return_to` value if it was set and if the login succeeded; a HTTP 303 redirect to the login UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1474pub 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>> {
1475    // add a prefix to parameters to efficiently prevent name collisions
1476    let p_flow = flow;
1477    let p_update_login_flow_body = update_login_flow_body;
1478    let p_x_session_token = x_session_token;
1479    let p_cookie = cookie;
1480
1481    let uri_str = format!("{}/self-service/login", configuration.base_path);
1482    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1483
1484    req_builder = req_builder.query(&[("flow", &p_flow.to_string())]);
1485    if let Some(ref user_agent) = configuration.user_agent {
1486        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1487    }
1488    if let Some(param_value) = p_x_session_token {
1489        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1490    }
1491    if let Some(param_value) = p_cookie {
1492        req_builder = req_builder.header("Cookie", param_value.to_string());
1493    }
1494    req_builder = req_builder.json(&p_update_login_flow_body);
1495
1496    let req = req_builder.build()?;
1497    let resp = configuration.client.execute(req).await?;
1498
1499    let status = resp.status();
1500    let content_type = resp
1501        .headers()
1502        .get("content-type")
1503        .and_then(|v| v.to_str().ok())
1504        .unwrap_or("application/octet-stream");
1505    let content_type = super::ContentType::from(content_type);
1506
1507    if !status.is_client_error() && !status.is_server_error() {
1508        let content = resp.text().await?;
1509        match content_type {
1510            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1511            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1512            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`")))),
1513        }
1514    } else {
1515        let content = resp.text().await?;
1516        let entity: Option<UpdateLoginFlowError> = serde_json::from_str(&content).ok();
1517        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1518    }
1519}
1520
1521/// This endpoint logs out an identity in a self-service manner.  If the `Accept` HTTP header is not set to `application/json`, the browser will be redirected (HTTP 303 See Other) to the `return_to` parameter of the initial request or fall back to `urls.default_return_to`.  If the `Accept` HTTP header is set to `application/json`, a 204 No Content response will be sent on successful logout instead.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  More information can be found at [Ory Kratos User Logout Documentation](https://www.ory.sh/docs/next/kratos/self-service/flows/user-logout).
1522pub async fn update_logout_flow(configuration: &configuration::Configuration, token: Option<&str>, return_to: Option<&str>, cookie: Option<&str>) -> Result<(), Error<UpdateLogoutFlowError>> {
1523    // add a prefix to parameters to efficiently prevent name collisions
1524    let p_token = token;
1525    let p_return_to = return_to;
1526    let p_cookie = cookie;
1527
1528    let uri_str = format!("{}/self-service/logout", configuration.base_path);
1529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1530
1531    if let Some(ref param_value) = p_token {
1532        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1533    }
1534    if let Some(ref param_value) = p_return_to {
1535        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
1536    }
1537    if let Some(ref user_agent) = configuration.user_agent {
1538        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1539    }
1540    if let Some(param_value) = p_cookie {
1541        req_builder = req_builder.header("Cookie", param_value.to_string());
1542    }
1543
1544    let req = req_builder.build()?;
1545    let resp = configuration.client.execute(req).await?;
1546
1547    let status = resp.status();
1548
1549    if !status.is_client_error() && !status.is_server_error() {
1550        Ok(())
1551    } else {
1552        let content = resp.text().await?;
1553        let entity: Option<UpdateLogoutFlowError> = serde_json::from_str(&content).ok();
1554        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1555    }
1556}
1557
1558/// 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).
1559pub 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>> {
1560    // add a prefix to parameters to efficiently prevent name collisions
1561    let p_flow = flow;
1562    let p_update_recovery_flow_body = update_recovery_flow_body;
1563    let p_token = token;
1564    let p_cookie = cookie;
1565
1566    let uri_str = format!("{}/self-service/recovery", configuration.base_path);
1567    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1568
1569    req_builder = req_builder.query(&[("flow", &p_flow.to_string())]);
1570    if let Some(ref param_value) = p_token {
1571        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1572    }
1573    if let Some(ref user_agent) = configuration.user_agent {
1574        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1575    }
1576    if let Some(param_value) = p_cookie {
1577        req_builder = req_builder.header("Cookie", param_value.to_string());
1578    }
1579    req_builder = req_builder.json(&p_update_recovery_flow_body);
1580
1581    let req = req_builder.build()?;
1582    let resp = configuration.client.execute(req).await?;
1583
1584    let status = resp.status();
1585    let content_type = resp
1586        .headers()
1587        .get("content-type")
1588        .and_then(|v| v.to_str().ok())
1589        .unwrap_or("application/octet-stream");
1590    let content_type = super::ContentType::from(content_type);
1591
1592    if !status.is_client_error() && !status.is_server_error() {
1593        let content = resp.text().await?;
1594        match content_type {
1595            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1596            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1597            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`")))),
1598        }
1599    } else {
1600        let content = resp.text().await?;
1601        let entity: Option<UpdateRecoveryFlowError> = serde_json::from_str(&content).ok();
1602        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1603    }
1604}
1605
1606/// Use this endpoint to complete a registration flow by sending an identity's traits and password. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and respond with HTTP 200 and a application/json body with the created identity success - if the session hook is configured the `session` and `session_token` will also be included; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after registration URL or the `return_to` value if it was set and if the registration succeeded; a HTTP 303 redirect to the registration UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1607pub async fn update_registration_flow(configuration: &configuration::Configuration, flow: &str, update_registration_flow_body: models::UpdateRegistrationFlowBody, cookie: Option<&str>) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
1608    // add a prefix to parameters to efficiently prevent name collisions
1609    let p_flow = flow;
1610    let p_update_registration_flow_body = update_registration_flow_body;
1611    let p_cookie = cookie;
1612
1613    let uri_str = format!("{}/self-service/registration", 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_flow.to_string())]);
1617    if let Some(ref user_agent) = configuration.user_agent {
1618        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1619    }
1620    if let Some(param_value) = p_cookie {
1621        req_builder = req_builder.header("Cookie", param_value.to_string());
1622    }
1623    req_builder = req_builder.json(&p_update_registration_flow_body);
1624
1625    let req = req_builder.build()?;
1626    let resp = configuration.client.execute(req).await?;
1627
1628    let status = resp.status();
1629    let content_type = resp
1630        .headers()
1631        .get("content-type")
1632        .and_then(|v| v.to_str().ok())
1633        .unwrap_or("application/octet-stream");
1634    let content_type = super::ContentType::from(content_type);
1635
1636    if !status.is_client_error() && !status.is_server_error() {
1637        let content = resp.text().await?;
1638        match content_type {
1639            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1640            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeRegistration`"))),
1641            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`")))),
1642        }
1643    } else {
1644        let content = resp.text().await?;
1645        let entity: Option<UpdateRegistrationFlowError> = serde_json::from_str(&content).ok();
1646        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1647    }
1648}
1649
1650/// 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).
1651pub 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>> {
1652    // add a prefix to parameters to efficiently prevent name collisions
1653    let p_flow = flow;
1654    let p_update_settings_flow_body = update_settings_flow_body;
1655    let p_x_session_token = x_session_token;
1656    let p_cookie = cookie;
1657
1658    let uri_str = format!("{}/self-service/settings", configuration.base_path);
1659    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1660
1661    req_builder = req_builder.query(&[("flow", &p_flow.to_string())]);
1662    if let Some(ref user_agent) = configuration.user_agent {
1663        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1664    }
1665    if let Some(param_value) = p_x_session_token {
1666        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1667    }
1668    if let Some(param_value) = p_cookie {
1669        req_builder = req_builder.header("Cookie", param_value.to_string());
1670    }
1671    req_builder = req_builder.json(&p_update_settings_flow_body);
1672
1673    let req = req_builder.build()?;
1674    let resp = configuration.client.execute(req).await?;
1675
1676    let status = resp.status();
1677    let content_type = resp
1678        .headers()
1679        .get("content-type")
1680        .and_then(|v| v.to_str().ok())
1681        .unwrap_or("application/octet-stream");
1682    let content_type = super::ContentType::from(content_type);
1683
1684    if !status.is_client_error() && !status.is_server_error() {
1685        let content = resp.text().await?;
1686        match content_type {
1687            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1688            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1689            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`")))),
1690        }
1691    } else {
1692        let content = resp.text().await?;
1693        let entity: Option<UpdateSettingsFlowError> = serde_json::from_str(&content).ok();
1694        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1695    }
1696}
1697
1698/// Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states:  `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 303 See Other redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Verification UI URL with the Verification Flow ID appended. `sent_email` is the success state after `choose_method` when using the `link` method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a verification link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an error message that the verification link was invalid.  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1699pub 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>> {
1700    // add a prefix to parameters to efficiently prevent name collisions
1701    let p_flow = flow;
1702    let p_update_verification_flow_body = update_verification_flow_body;
1703    let p_token = token;
1704    let p_cookie = cookie;
1705
1706    let uri_str = format!("{}/self-service/verification", configuration.base_path);
1707    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1708
1709    req_builder = req_builder.query(&[("flow", &p_flow.to_string())]);
1710    if let Some(ref param_value) = p_token {
1711        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1712    }
1713    if let Some(ref user_agent) = configuration.user_agent {
1714        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1715    }
1716    if let Some(param_value) = p_cookie {
1717        req_builder = req_builder.header("Cookie", param_value.to_string());
1718    }
1719    req_builder = req_builder.json(&p_update_verification_flow_body);
1720
1721    let req = req_builder.build()?;
1722    let resp = configuration.client.execute(req).await?;
1723
1724    let status = resp.status();
1725    let content_type = resp
1726        .headers()
1727        .get("content-type")
1728        .and_then(|v| v.to_str().ok())
1729        .unwrap_or("application/octet-stream");
1730    let content_type = super::ContentType::from(content_type);
1731
1732    if !status.is_client_error() && !status.is_server_error() {
1733        let content = resp.text().await?;
1734        match content_type {
1735            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1736            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1737            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`")))),
1738        }
1739    } else {
1740        let content = resp.text().await?;
1741        let entity: Option<UpdateVerificationFlowError> = serde_json::from_str(&content).ok();
1742        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1743    }
1744}
1745