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