Skip to main content

ory_client/apis/
frontend_api.rs

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