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.79
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    Status403(models::ErrorGeneric),
24    DefaultResponse(models::ErrorGeneric),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`create_browser_logout_flow`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateBrowserLogoutFlowError {
32    Status400(models::ErrorGeneric),
33    Status401(models::ErrorGeneric),
34    Status500(models::ErrorGeneric),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`create_browser_recovery_flow`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum CreateBrowserRecoveryFlowError {
42    Status400(models::ErrorGeneric),
43    DefaultResponse(models::ErrorGeneric),
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`create_browser_registration_flow`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum CreateBrowserRegistrationFlowError {
51    DefaultResponse(models::ErrorGeneric),
52    UnknownValue(serde_json::Value),
53}
54
55/// struct for typed errors of method [`create_browser_settings_flow`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum CreateBrowserSettingsFlowError {
59    Status400(models::ErrorGeneric),
60    Status401(models::ErrorGeneric),
61    Status403(models::ErrorGeneric),
62    DefaultResponse(models::ErrorGeneric),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`create_browser_verification_flow`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum CreateBrowserVerificationFlowError {
70    DefaultResponse(models::ErrorGeneric),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`create_fedcm_flow`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum CreateFedcmFlowError {
78    Status400(models::ErrorGeneric),
79    DefaultResponse(models::ErrorGeneric),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`create_id_p_initiated_saml_browser_login_flow`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum CreateIdPInitiatedSamlBrowserLoginFlowError {
87    DefaultResponse(models::ErrorGeneric),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`create_native_login_flow`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum CreateNativeLoginFlowError {
95    Status400(models::ErrorGeneric),
96    Status403(models::ErrorGeneric),
97    DefaultResponse(models::ErrorGeneric),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`create_native_recovery_flow`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum CreateNativeRecoveryFlowError {
105    Status400(models::ErrorGeneric),
106    DefaultResponse(models::ErrorGeneric),
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`create_native_registration_flow`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum CreateNativeRegistrationFlowError {
114    Status400(models::ErrorGeneric),
115    DefaultResponse(models::ErrorGeneric),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`create_native_settings_flow`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum CreateNativeSettingsFlowError {
123    Status400(models::ErrorGeneric),
124    DefaultResponse(models::ErrorGeneric),
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`create_native_verification_flow`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum CreateNativeVerificationFlowError {
132    Status400(models::ErrorGeneric),
133    DefaultResponse(models::ErrorGeneric),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`delete_test_login_flow`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum DeleteTestLoginFlowError {
141    Status400(models::ErrorGeneric),
142    Status403(models::ErrorGeneric),
143    Status404(models::ErrorGeneric),
144    DefaultResponse(models::ErrorGeneric),
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`disable_my_other_sessions`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum DisableMyOtherSessionsError {
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 [`disable_my_session`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum DisableMySessionError {
162    Status400(models::ErrorGeneric),
163    Status401(models::ErrorGeneric),
164    DefaultResponse(models::ErrorGeneric),
165    UnknownValue(serde_json::Value),
166}
167
168/// struct for typed errors of method [`exchange_session_token`]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum ExchangeSessionTokenError {
172    Status403(models::ErrorGeneric),
173    Status404(models::ErrorGeneric),
174    Status410(models::ErrorGeneric),
175    Status422(models::ErrorGeneric),
176    DefaultResponse(models::ErrorGeneric),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`get_flow_error`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum GetFlowErrorError {
184    Status403(models::ErrorGeneric),
185    Status404(models::ErrorGeneric),
186    Status500(models::ErrorGeneric),
187    UnknownValue(serde_json::Value),
188}
189
190/// struct for typed errors of method [`get_login_flow`]
191#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum GetLoginFlowError {
194    Status403(models::ErrorGeneric),
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_recovery_flow`]
202#[derive(Debug, Clone, Serialize, Deserialize)]
203#[serde(untagged)]
204pub enum GetRecoveryFlowError {
205    Status404(models::ErrorGeneric),
206    Status410(models::ErrorGeneric),
207    DefaultResponse(models::ErrorGeneric),
208    UnknownValue(serde_json::Value),
209}
210
211/// struct for typed errors of method [`get_registration_flow`]
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(untagged)]
214pub enum GetRegistrationFlowError {
215    Status403(models::ErrorGeneric),
216    Status404(models::ErrorGeneric),
217    Status410(models::ErrorGeneric),
218    DefaultResponse(models::ErrorGeneric),
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`get_saml_metadata`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum GetSamlMetadataError {
226    Status404(models::ErrorGeneric),
227    DefaultResponse(models::ErrorGeneric),
228    UnknownValue(serde_json::Value),
229}
230
231/// struct for typed errors of method [`get_saml_provider_metadata`]
232#[derive(Debug, Clone, Serialize, Deserialize)]
233#[serde(untagged)]
234pub enum GetSamlProviderMetadataError {
235    Status404(models::ErrorGeneric),
236    DefaultResponse(models::ErrorGeneric),
237    UnknownValue(serde_json::Value),
238}
239
240/// struct for typed errors of method [`get_settings_flow`]
241#[derive(Debug, Clone, Serialize, Deserialize)]
242#[serde(untagged)]
243pub enum GetSettingsFlowError {
244    Status401(models::ErrorGeneric),
245    Status403(models::ErrorGeneric),
246    Status404(models::ErrorGeneric),
247    Status410(models::ErrorGeneric),
248    DefaultResponse(models::ErrorGeneric),
249    UnknownValue(serde_json::Value),
250}
251
252/// struct for typed errors of method [`get_verification_flow`]
253#[derive(Debug, Clone, Serialize, Deserialize)]
254#[serde(untagged)]
255pub enum GetVerificationFlowError {
256    Status403(models::ErrorGeneric),
257    Status404(models::ErrorGeneric),
258    DefaultResponse(models::ErrorGeneric),
259    UnknownValue(serde_json::Value),
260}
261
262/// struct for typed errors of method [`get_web_authn_java_script`]
263#[derive(Debug, Clone, Serialize, Deserialize)]
264#[serde(untagged)]
265pub enum GetWebAuthnJavaScriptError {
266    UnknownValue(serde_json::Value),
267}
268
269/// struct for typed errors of method [`get_web_authn_related_origins`]
270#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum GetWebAuthnRelatedOriginsError {
273    UnknownValue(serde_json::Value),
274}
275
276/// struct for typed errors of method [`get_well_known_change_password`]
277#[derive(Debug, Clone, Serialize, Deserialize)]
278#[serde(untagged)]
279pub enum GetWellKnownChangePasswordError {
280    DefaultResponse(models::ErrorGeneric),
281    UnknownValue(serde_json::Value),
282}
283
284/// struct for typed errors of method [`init_saml_login`]
285#[derive(Debug, Clone, Serialize, Deserialize)]
286#[serde(untagged)]
287pub enum InitSamlLoginError {
288    Status400(models::ErrorGeneric),
289    Status404(models::ErrorGeneric),
290    DefaultResponse(models::ErrorGeneric),
291    UnknownValue(serde_json::Value),
292}
293
294/// struct for typed errors of method [`init_saml_login_request`]
295#[derive(Debug, Clone, Serialize, Deserialize)]
296#[serde(untagged)]
297pub enum InitSamlLoginRequestError {
298    Status400(models::ErrorGeneric),
299    Status404(models::ErrorGeneric),
300    DefaultResponse(models::ErrorGeneric),
301    UnknownValue(serde_json::Value),
302}
303
304/// struct for typed errors of method [`list_my_sessions`]
305#[derive(Debug, Clone, Serialize, Deserialize)]
306#[serde(untagged)]
307pub enum ListMySessionsError {
308    Status400(models::ErrorGeneric),
309    Status401(models::ErrorGeneric),
310    Status403(models::ErrorGeneric),
311    DefaultResponse(models::ErrorGeneric),
312    UnknownValue(serde_json::Value),
313}
314
315/// struct for typed errors of method [`perform_native_logout`]
316#[derive(Debug, Clone, Serialize, Deserialize)]
317#[serde(untagged)]
318pub enum PerformNativeLogoutError {
319    Status400(models::ErrorGeneric),
320    DefaultResponse(models::ErrorGeneric),
321    UnknownValue(serde_json::Value),
322}
323
324/// struct for typed errors of method [`submit_saml_assertion`]
325#[derive(Debug, Clone, Serialize, Deserialize)]
326#[serde(untagged)]
327pub enum SubmitSamlAssertionError {
328    Status400(models::ErrorGeneric),
329    DefaultResponse(models::ErrorGeneric),
330    UnknownValue(serde_json::Value),
331}
332
333/// struct for typed errors of method [`to_session`]
334#[derive(Debug, Clone, Serialize, Deserialize)]
335#[serde(untagged)]
336pub enum ToSessionError {
337    Status401(models::ErrorGeneric),
338    Status403(models::ErrorGeneric),
339    DefaultResponse(models::ErrorGeneric),
340    UnknownValue(serde_json::Value),
341}
342
343/// struct for typed errors of method [`update_fedcm_flow`]
344#[derive(Debug, Clone, Serialize, Deserialize)]
345#[serde(untagged)]
346pub enum UpdateFedcmFlowError {
347    Status400(models::LoginFlow),
348    Status410(models::ErrorGeneric),
349    Status422(models::ErrorBrowserLocationChangeRequired),
350    DefaultResponse(models::ErrorGeneric),
351    UnknownValue(serde_json::Value),
352}
353
354/// struct for typed errors of method [`update_login_flow`]
355#[derive(Debug, Clone, Serialize, Deserialize)]
356#[serde(untagged)]
357pub enum UpdateLoginFlowError {
358    Status400(models::LoginFlow),
359    Status410(models::ErrorGeneric),
360    Status422(models::ErrorBrowserLocationChangeRequired),
361    DefaultResponse(models::ErrorGeneric),
362    UnknownValue(serde_json::Value),
363}
364
365/// struct for typed errors of method [`update_logout_flow`]
366#[derive(Debug, Clone, Serialize, Deserialize)]
367#[serde(untagged)]
368pub enum UpdateLogoutFlowError {
369    DefaultResponse(models::ErrorGeneric),
370    UnknownValue(serde_json::Value),
371}
372
373/// struct for typed errors of method [`update_recovery_flow`]
374#[derive(Debug, Clone, Serialize, Deserialize)]
375#[serde(untagged)]
376pub enum UpdateRecoveryFlowError {
377    Status400(models::RecoveryFlow),
378    Status410(models::ErrorGeneric),
379    Status422(models::ErrorBrowserLocationChangeRequired),
380    DefaultResponse(models::ErrorGeneric),
381    UnknownValue(serde_json::Value),
382}
383
384/// struct for typed errors of method [`update_registration_flow`]
385#[derive(Debug, Clone, Serialize, Deserialize)]
386#[serde(untagged)]
387pub enum UpdateRegistrationFlowError {
388    Status400(models::RegistrationFlow),
389    Status410(models::ErrorGeneric),
390    Status422(models::ErrorBrowserLocationChangeRequired),
391    DefaultResponse(models::ErrorGeneric),
392    UnknownValue(serde_json::Value),
393}
394
395/// struct for typed errors of method [`update_settings_flow`]
396#[derive(Debug, Clone, Serialize, Deserialize)]
397#[serde(untagged)]
398pub enum UpdateSettingsFlowError {
399    Status400(models::SettingsFlow),
400    Status401(models::ErrorGeneric),
401    Status403(models::ErrorGeneric),
402    Status410(models::ErrorGeneric),
403    Status422(models::ErrorBrowserLocationChangeRequired),
404    DefaultResponse(models::ErrorGeneric),
405    UnknownValue(serde_json::Value),
406}
407
408/// struct for typed errors of method [`update_verification_flow`]
409#[derive(Debug, Clone, Serialize, Deserialize)]
410#[serde(untagged)]
411pub enum UpdateVerificationFlowError {
412    Status400(models::VerificationFlow),
413    Status410(models::ErrorGeneric),
414    DefaultResponse(models::ErrorGeneric),
415    UnknownValue(serde_json::Value),
416}
417
418
419/// 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. - `session_aal2_enrollment_required`: Second-factor auth is required but the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one. - `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).
420pub 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>> {
421    // add a prefix to parameters to efficiently prevent name collisions
422    let p_query_refresh = refresh;
423    let p_query_aal = aal;
424    let p_query_return_to = return_to;
425    let p_header_cookie = cookie;
426    let p_query_login_challenge = login_challenge;
427    let p_query_organization = organization;
428    let p_query_via = via;
429    let p_query_identity_schema = identity_schema;
430
431    let uri_str = format!("{}/self-service/login/browser", configuration.base_path);
432    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
433
434    if let Some(ref param_value) = p_query_refresh {
435        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
436    }
437    if let Some(ref param_value) = p_query_aal {
438        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
439    }
440    if let Some(ref param_value) = p_query_return_to {
441        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
442    }
443    if let Some(ref param_value) = p_query_login_challenge {
444        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
445    }
446    if let Some(ref param_value) = p_query_organization {
447        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
448    }
449    if let Some(ref param_value) = p_query_via {
450        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
451    }
452    if let Some(ref param_value) = p_query_identity_schema {
453        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
454    }
455    if let Some(ref user_agent) = configuration.user_agent {
456        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
457    }
458    if let Some(param_value) = p_header_cookie {
459        req_builder = req_builder.header("Cookie", param_value.to_string());
460    }
461
462    let req = req_builder.build()?;
463    let resp = configuration.client.execute(req).await?;
464
465    let status = resp.status();
466    let content_type = resp
467        .headers()
468        .get("content-type")
469        .and_then(|v| v.to_str().ok())
470        .unwrap_or("application/octet-stream");
471    let content_type = super::ContentType::from(content_type);
472
473    if !status.is_client_error() && !status.is_server_error() {
474        let content = resp.text().await?;
475        match content_type {
476            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
477            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
478            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`")))),
479        }
480    } else {
481        let content = resp.text().await?;
482        let entity: Option<CreateBrowserLoginFlowError> = serde_json::from_str(&content).ok();
483        Err(Error::ResponseError(ResponseContent { status, content, entity }))
484    }
485}
486
487/// 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.
488pub async fn create_browser_logout_flow(configuration: &configuration::Configuration, cookie: Option<&str>, return_to: Option<&str>) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
489    // add a prefix to parameters to efficiently prevent name collisions
490    let p_header_cookie = cookie;
491    let p_query_return_to = return_to;
492
493    let uri_str = format!("{}/self-service/logout/browser", configuration.base_path);
494    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
495
496    if let Some(ref param_value) = p_query_return_to {
497        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
498    }
499    if let Some(ref user_agent) = configuration.user_agent {
500        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501    }
502    if let Some(param_value) = p_header_cookie {
503        req_builder = req_builder.header("cookie", param_value.to_string());
504    }
505
506    let req = req_builder.build()?;
507    let resp = configuration.client.execute(req).await?;
508
509    let status = resp.status();
510    let content_type = resp
511        .headers()
512        .get("content-type")
513        .and_then(|v| v.to_str().ok())
514        .unwrap_or("application/octet-stream");
515    let content_type = super::ContentType::from(content_type);
516
517    if !status.is_client_error() && !status.is_server_error() {
518        let content = resp.text().await?;
519        match content_type {
520            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
521            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LogoutFlow`"))),
522            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`")))),
523        }
524    } else {
525        let content = resp.text().await?;
526        let entity: Option<CreateBrowserLogoutFlowError> = serde_json::from_str(&content).ok();
527        Err(Error::ResponseError(ResponseContent { status, content, entity }))
528    }
529}
530
531/// 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).
532pub async fn create_browser_recovery_flow(configuration: &configuration::Configuration, return_to: Option<&str>, skip_settings: Option<&str>) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
533    // add a prefix to parameters to efficiently prevent name collisions
534    let p_query_return_to = return_to;
535    let p_query_skip_settings = skip_settings;
536
537    let uri_str = format!("{}/self-service/recovery/browser", configuration.base_path);
538    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
539
540    if let Some(ref param_value) = p_query_return_to {
541        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
542    }
543    if let Some(ref param_value) = p_query_skip_settings {
544        req_builder = req_builder.query(&[("skip_settings", &param_value.to_string())]);
545    }
546    if let Some(ref user_agent) = configuration.user_agent {
547        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
548    }
549
550    let req = req_builder.build()?;
551    let resp = configuration.client.execute(req).await?;
552
553    let status = resp.status();
554    let content_type = resp
555        .headers()
556        .get("content-type")
557        .and_then(|v| v.to_str().ok())
558        .unwrap_or("application/octet-stream");
559    let content_type = super::ContentType::from(content_type);
560
561    if !status.is_client_error() && !status.is_server_error() {
562        let content = resp.text().await?;
563        match content_type {
564            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
565            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
566            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`")))),
567        }
568    } else {
569        let content = resp.text().await?;
570        let entity: Option<CreateBrowserRecoveryFlowError> = serde_json::from_str(&content).ok();
571        Err(Error::ResponseError(ResponseContent { status, content, entity }))
572    }
573}
574
575/// 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).
576pub 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>> {
577    // add a prefix to parameters to efficiently prevent name collisions
578    let p_query_return_to = return_to;
579    let p_query_login_challenge = login_challenge;
580    let p_query_after_verification_return_to = after_verification_return_to;
581    let p_query_organization = organization;
582    let p_query_identity_schema = identity_schema;
583
584    let uri_str = format!("{}/self-service/registration/browser", configuration.base_path);
585    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
586
587    if let Some(ref param_value) = p_query_return_to {
588        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
589    }
590    if let Some(ref param_value) = p_query_login_challenge {
591        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
592    }
593    if let Some(ref param_value) = p_query_after_verification_return_to {
594        req_builder = req_builder.query(&[("after_verification_return_to", &param_value.to_string())]);
595    }
596    if let Some(ref param_value) = p_query_organization {
597        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
598    }
599    if let Some(ref param_value) = p_query_identity_schema {
600        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
601    }
602    if let Some(ref user_agent) = configuration.user_agent {
603        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
604    }
605
606    let req = req_builder.build()?;
607    let resp = configuration.client.execute(req).await?;
608
609    let status = resp.status();
610    let content_type = resp
611        .headers()
612        .get("content-type")
613        .and_then(|v| v.to_str().ok())
614        .unwrap_or("application/octet-stream");
615    let content_type = super::ContentType::from(content_type);
616
617    if !status.is_client_error() && !status.is_server_error() {
618        let content = resp.text().await?;
619        match content_type {
620            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
621            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
622            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`")))),
623        }
624    } else {
625        let content = resp.text().await?;
626        let entity: Option<CreateBrowserRegistrationFlowError> = serde_json::from_str(&content).ok();
627        Err(Error::ResponseError(ResponseContent { status, content, entity }))
628    }
629}
630
631/// 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).
632pub async fn create_browser_settings_flow(configuration: &configuration::Configuration, return_to: Option<&str>, cookie: Option<&str>, organization: Option<&str>) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
633    // add a prefix to parameters to efficiently prevent name collisions
634    let p_query_return_to = return_to;
635    let p_header_cookie = cookie;
636    let p_query_organization = organization;
637
638    let uri_str = format!("{}/self-service/settings/browser", configuration.base_path);
639    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
640
641    if let Some(ref param_value) = p_query_return_to {
642        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
643    }
644    if let Some(ref param_value) = p_query_organization {
645        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
646    }
647    if let Some(ref user_agent) = configuration.user_agent {
648        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
649    }
650    if let Some(param_value) = p_header_cookie {
651        req_builder = req_builder.header("Cookie", param_value.to_string());
652    }
653
654    let req = req_builder.build()?;
655    let resp = configuration.client.execute(req).await?;
656
657    let status = resp.status();
658    let content_type = resp
659        .headers()
660        .get("content-type")
661        .and_then(|v| v.to_str().ok())
662        .unwrap_or("application/octet-stream");
663    let content_type = super::ContentType::from(content_type);
664
665    if !status.is_client_error() && !status.is_server_error() {
666        let content = resp.text().await?;
667        match content_type {
668            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
669            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
670            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`")))),
671        }
672    } else {
673        let content = resp.text().await?;
674        let entity: Option<CreateBrowserSettingsFlowError> = serde_json::from_str(&content).ok();
675        Err(Error::ResponseError(ResponseContent { status, content, entity }))
676    }
677}
678
679/// 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).
680pub async fn create_browser_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
681    // add a prefix to parameters to efficiently prevent name collisions
682    let p_query_return_to = return_to;
683
684    let uri_str = format!("{}/self-service/verification/browser", configuration.base_path);
685    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
686
687    if let Some(ref param_value) = p_query_return_to {
688        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
689    }
690    if let Some(ref user_agent) = configuration.user_agent {
691        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
692    }
693
694    let req = req_builder.build()?;
695    let resp = configuration.client.execute(req).await?;
696
697    let status = resp.status();
698    let content_type = resp
699        .headers()
700        .get("content-type")
701        .and_then(|v| v.to_str().ok())
702        .unwrap_or("application/octet-stream");
703    let content_type = super::ContentType::from(content_type);
704
705    if !status.is_client_error() && !status.is_server_error() {
706        let content = resp.text().await?;
707        match content_type {
708            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
709            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
710            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`")))),
711        }
712    } else {
713        let content = resp.text().await?;
714        let entity: Option<CreateBrowserVerificationFlowError> = serde_json::from_str(&content).ok();
715        Err(Error::ResponseError(ResponseContent { status, content, entity }))
716    }
717}
718
719/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
720pub async fn create_fedcm_flow(configuration: &configuration::Configuration, ) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
721
722    let uri_str = format!("{}/self-service/fed-cm/parameters", configuration.base_path);
723    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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
729    let req = req_builder.build()?;
730    let resp = configuration.client.execute(req).await?;
731
732    let status = resp.status();
733    let content_type = resp
734        .headers()
735        .get("content-type")
736        .and_then(|v| v.to_str().ok())
737        .unwrap_or("application/octet-stream");
738    let content_type = super::ContentType::from(content_type);
739
740    if !status.is_client_error() && !status.is_server_error() {
741        let content = resp.text().await?;
742        match content_type {
743            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
744            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateFedcmFlowResponse`"))),
745            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`")))),
746        }
747    } else {
748        let content = resp.text().await?;
749        let entity: Option<CreateFedcmFlowError> = serde_json::from_str(&content).ok();
750        Err(Error::ResponseError(ResponseContent { status, content, entity }))
751    }
752}
753
754/// This endpoint is the entry point for IdP-initiated login through Ory Polis. Ory Polis redirects the browser here with a single-use authorization code after validating an unsolicited SAML response; Kratos then starts a regular browser login flow and forwards the code as a `code_hint` so Polis can complete the flow without a second round-trip to the identity provider.  The provider must be a `jackson` provider with `idp_initiated_login_enabled` set to `true` in its configuration.  This endpoint is NOT INTENDED for API clients and only works with browsers.
755pub async fn create_id_p_initiated_saml_browser_login_flow(configuration: &configuration::Configuration, provider: &str, code: &str) -> Result<models::ErrorGeneric, Error<CreateIdPInitiatedSamlBrowserLoginFlowError>> {
756    // add a prefix to parameters to efficiently prevent name collisions
757    let p_path_provider = provider;
758    let p_query_code = code;
759
760    let uri_str = format!("{}/self-service/methods/saml/idp-initiated/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
761    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
762
763    req_builder = req_builder.query(&[("code", &p_query_code.to_string())]);
764    if let Some(ref user_agent) = configuration.user_agent {
765        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
766    }
767
768    let req = req_builder.build()?;
769    let resp = configuration.client.execute(req).await?;
770
771    let status = resp.status();
772    let content_type = resp
773        .headers()
774        .get("content-type")
775        .and_then(|v| v.to_str().ok())
776        .unwrap_or("application/octet-stream");
777    let content_type = super::ContentType::from(content_type);
778
779    if !status.is_client_error() && !status.is_server_error() {
780        let content = resp.text().await?;
781        match content_type {
782            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
783            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorGeneric`"))),
784            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`")))),
785        }
786    } else {
787        let content = resp.text().await?;
788        let entity: Option<CreateIdPInitiatedSamlBrowserLoginFlowError> = serde_json::from_str(&content).ok();
789        Err(Error::ResponseError(ResponseContent { status, content, entity }))
790    }
791}
792
793/// 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. - `session_aal2_enrollment_required`: Second-factor auth is required but the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one. - `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).
794pub 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>> {
795    // add a prefix to parameters to efficiently prevent name collisions
796    let p_query_refresh = refresh;
797    let p_query_aal = aal;
798    let p_header_x_session_token = x_session_token;
799    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
800    let p_query_return_to = return_to;
801    let p_query_organization = organization;
802    let p_query_via = via;
803    let p_query_identity_schema = identity_schema;
804
805    let uri_str = format!("{}/self-service/login/api", configuration.base_path);
806    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
807
808    if let Some(ref param_value) = p_query_refresh {
809        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
810    }
811    if let Some(ref param_value) = p_query_aal {
812        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
813    }
814    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
815        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
816    }
817    if let Some(ref param_value) = p_query_return_to {
818        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
819    }
820    if let Some(ref param_value) = p_query_organization {
821        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
822    }
823    if let Some(ref param_value) = p_query_via {
824        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
825    }
826    if let Some(ref param_value) = p_query_identity_schema {
827        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
828    }
829    if let Some(ref user_agent) = configuration.user_agent {
830        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
831    }
832    if let Some(param_value) = p_header_x_session_token {
833        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
834    }
835
836    let req = req_builder.build()?;
837    let resp = configuration.client.execute(req).await?;
838
839    let status = resp.status();
840    let content_type = resp
841        .headers()
842        .get("content-type")
843        .and_then(|v| v.to_str().ok())
844        .unwrap_or("application/octet-stream");
845    let content_type = super::ContentType::from(content_type);
846
847    if !status.is_client_error() && !status.is_server_error() {
848        let content = resp.text().await?;
849        match content_type {
850            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
851            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
852            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`")))),
853        }
854    } else {
855        let content = resp.text().await?;
856        let entity: Option<CreateNativeLoginFlowError> = serde_json::from_str(&content).ok();
857        Err(Error::ResponseError(ResponseContent { status, content, entity }))
858    }
859}
860
861/// 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).
862pub async fn create_native_recovery_flow(configuration: &configuration::Configuration, ) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
863
864    let uri_str = format!("{}/self-service/recovery/api", configuration.base_path);
865    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
866
867    if let Some(ref user_agent) = configuration.user_agent {
868        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
869    }
870
871    let req = req_builder.build()?;
872    let resp = configuration.client.execute(req).await?;
873
874    let status = resp.status();
875    let content_type = resp
876        .headers()
877        .get("content-type")
878        .and_then(|v| v.to_str().ok())
879        .unwrap_or("application/octet-stream");
880    let content_type = super::ContentType::from(content_type);
881
882    if !status.is_client_error() && !status.is_server_error() {
883        let content = resp.text().await?;
884        match content_type {
885            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
886            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
887            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
888        }
889    } else {
890        let content = resp.text().await?;
891        let entity: Option<CreateNativeRecoveryFlowError> = serde_json::from_str(&content).ok();
892        Err(Error::ResponseError(ResponseContent { status, content, entity }))
893    }
894}
895
896/// 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).
897pub 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>> {
898    // add a prefix to parameters to efficiently prevent name collisions
899    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
900    let p_query_return_to = return_to;
901    let p_query_organization = organization;
902    let p_query_identity_schema = identity_schema;
903
904    let uri_str = format!("{}/self-service/registration/api", configuration.base_path);
905    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
906
907    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
908        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
909    }
910    if let Some(ref param_value) = p_query_return_to {
911        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
912    }
913    if let Some(ref param_value) = p_query_organization {
914        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
915    }
916    if let Some(ref param_value) = p_query_identity_schema {
917        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
918    }
919    if let Some(ref user_agent) = configuration.user_agent {
920        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
921    }
922
923    let req = req_builder.build()?;
924    let resp = configuration.client.execute(req).await?;
925
926    let status = resp.status();
927    let content_type = resp
928        .headers()
929        .get("content-type")
930        .and_then(|v| v.to_str().ok())
931        .unwrap_or("application/octet-stream");
932    let content_type = super::ContentType::from(content_type);
933
934    if !status.is_client_error() && !status.is_server_error() {
935        let content = resp.text().await?;
936        match content_type {
937            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
938            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
939            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`")))),
940        }
941    } else {
942        let content = resp.text().await?;
943        let entity: Option<CreateNativeRegistrationFlowError> = serde_json::from_str(&content).ok();
944        Err(Error::ResponseError(ResponseContent { status, content, entity }))
945    }
946}
947
948/// 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).
949pub async fn create_native_settings_flow(configuration: &configuration::Configuration, x_session_token: Option<&str>, organization: Option<&str>) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
950    // add a prefix to parameters to efficiently prevent name collisions
951    let p_header_x_session_token = x_session_token;
952    let p_query_organization = organization;
953
954    let uri_str = format!("{}/self-service/settings/api", configuration.base_path);
955    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
956
957    if let Some(ref param_value) = p_query_organization {
958        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
959    }
960    if let Some(ref user_agent) = configuration.user_agent {
961        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
962    }
963    if let Some(param_value) = p_header_x_session_token {
964        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
965    }
966
967    let req = req_builder.build()?;
968    let resp = configuration.client.execute(req).await?;
969
970    let status = resp.status();
971    let content_type = resp
972        .headers()
973        .get("content-type")
974        .and_then(|v| v.to_str().ok())
975        .unwrap_or("application/octet-stream");
976    let content_type = super::ContentType::from(content_type);
977
978    if !status.is_client_error() && !status.is_server_error() {
979        let content = resp.text().await?;
980        match content_type {
981            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
982            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
983            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`")))),
984        }
985    } else {
986        let content = resp.text().await?;
987        let entity: Option<CreateNativeSettingsFlowError> = serde_json::from_str(&content).ok();
988        Err(Error::ResponseError(ResponseContent { status, content, entity }))
989    }
990}
991
992/// 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).
993pub async fn create_native_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
994    // add a prefix to parameters to efficiently prevent name collisions
995    let p_query_return_to = return_to;
996
997    let uri_str = format!("{}/self-service/verification/api", configuration.base_path);
998    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
999
1000    if let Some(ref param_value) = p_query_return_to {
1001        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
1002    }
1003    if let Some(ref user_agent) = configuration.user_agent {
1004        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1005    }
1006
1007    let req = req_builder.build()?;
1008    let resp = configuration.client.execute(req).await?;
1009
1010    let status = resp.status();
1011    let content_type = resp
1012        .headers()
1013        .get("content-type")
1014        .and_then(|v| v.to_str().ok())
1015        .unwrap_or("application/octet-stream");
1016    let content_type = super::ContentType::from(content_type);
1017
1018    if !status.is_client_error() && !status.is_server_error() {
1019        let content = resp.text().await?;
1020        match content_type {
1021            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1022            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1023            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`")))),
1024        }
1025    } else {
1026        let content = resp.text().await?;
1027        let entity: Option<CreateNativeVerificationFlowError> = serde_json::from_str(&content).ok();
1028        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1029    }
1030}
1031
1032/// 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).
1033pub async fn delete_test_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<(), Error<DeleteTestLoginFlowError>> {
1034    // add a prefix to parameters to efficiently prevent name collisions
1035    let p_query_id = id;
1036    let p_header_cookie = cookie;
1037
1038    let uri_str = format!("{}/self-service/login/test", configuration.base_path);
1039    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1040
1041    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1042    if let Some(ref user_agent) = configuration.user_agent {
1043        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1044    }
1045    if let Some(param_value) = p_header_cookie {
1046        req_builder = req_builder.header("Cookie", param_value.to_string());
1047    }
1048
1049    let req = req_builder.build()?;
1050    let resp = configuration.client.execute(req).await?;
1051
1052    let status = resp.status();
1053
1054    if !status.is_client_error() && !status.is_server_error() {
1055        Ok(())
1056    } else {
1057        let content = resp.text().await?;
1058        let entity: Option<DeleteTestLoginFlowError> = serde_json::from_str(&content).ok();
1059        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1060    }
1061}
1062
1063/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
1064pub async fn disable_my_other_sessions(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
1065    // add a prefix to parameters to efficiently prevent name collisions
1066    let p_header_x_session_token = x_session_token;
1067    let p_header_cookie = cookie;
1068
1069    let uri_str = format!("{}/sessions", configuration.base_path);
1070    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1071
1072    if let Some(ref user_agent) = configuration.user_agent {
1073        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1074    }
1075    if let Some(param_value) = p_header_x_session_token {
1076        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1077    }
1078    if let Some(param_value) = p_header_cookie {
1079        req_builder = req_builder.header("Cookie", param_value.to_string());
1080    }
1081
1082    let req = req_builder.build()?;
1083    let resp = configuration.client.execute(req).await?;
1084
1085    let status = resp.status();
1086    let content_type = resp
1087        .headers()
1088        .get("content-type")
1089        .and_then(|v| v.to_str().ok())
1090        .unwrap_or("application/octet-stream");
1091    let content_type = super::ContentType::from(content_type);
1092
1093    if !status.is_client_error() && !status.is_server_error() {
1094        let content = resp.text().await?;
1095        match content_type {
1096            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1097            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMySessionsCount`"))),
1098            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`")))),
1099        }
1100    } else {
1101        let content = resp.text().await?;
1102        let entity: Option<DisableMyOtherSessionsError> = serde_json::from_str(&content).ok();
1103        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1104    }
1105}
1106
1107/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
1108pub async fn disable_my_session(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<(), Error<DisableMySessionError>> {
1109    // add a prefix to parameters to efficiently prevent name collisions
1110    let p_path_id = id;
1111    let p_header_x_session_token = x_session_token;
1112    let p_header_cookie = cookie;
1113
1114    let uri_str = format!("{}/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1115    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1116
1117    if let Some(ref user_agent) = configuration.user_agent {
1118        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1119    }
1120    if let Some(param_value) = p_header_x_session_token {
1121        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1122    }
1123    if let Some(param_value) = p_header_cookie {
1124        req_builder = req_builder.header("Cookie", param_value.to_string());
1125    }
1126
1127    let req = req_builder.build()?;
1128    let resp = configuration.client.execute(req).await?;
1129
1130    let status = resp.status();
1131
1132    if !status.is_client_error() && !status.is_server_error() {
1133        Ok(())
1134    } else {
1135        let content = resp.text().await?;
1136        let entity: Option<DisableMySessionError> = serde_json::from_str(&content).ok();
1137        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1138    }
1139}
1140
1141pub async fn exchange_session_token(configuration: &configuration::Configuration, init_code: &str, return_to_code: &str) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
1142    // add a prefix to parameters to efficiently prevent name collisions
1143    let p_query_init_code = init_code;
1144    let p_query_return_to_code = return_to_code;
1145
1146    let uri_str = format!("{}/sessions/token-exchange", configuration.base_path);
1147    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1148
1149    req_builder = req_builder.query(&[("init_code", &p_query_init_code.to_string())]);
1150    req_builder = req_builder.query(&[("return_to_code", &p_query_return_to_code.to_string())]);
1151    if let Some(ref user_agent) = configuration.user_agent {
1152        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1153    }
1154
1155    let req = req_builder.build()?;
1156    let resp = configuration.client.execute(req).await?;
1157
1158    let status = resp.status();
1159    let content_type = resp
1160        .headers()
1161        .get("content-type")
1162        .and_then(|v| v.to_str().ok())
1163        .unwrap_or("application/octet-stream");
1164    let content_type = super::ContentType::from(content_type);
1165
1166    if !status.is_client_error() && !status.is_server_error() {
1167        let content = resp.text().await?;
1168        match content_type {
1169            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1170            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1171            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`")))),
1172        }
1173    } else {
1174        let content = resp.text().await?;
1175        let entity: Option<ExchangeSessionTokenError> = serde_json::from_str(&content).ok();
1176        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1177    }
1178}
1179
1180/// 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).
1181pub async fn get_flow_error(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowError, Error<GetFlowErrorError>> {
1182    // add a prefix to parameters to efficiently prevent name collisions
1183    let p_query_id = id;
1184
1185    let uri_str = format!("{}/self-service/errors", configuration.base_path);
1186    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1187
1188    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1189    if let Some(ref user_agent) = configuration.user_agent {
1190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1191    }
1192
1193    let req = req_builder.build()?;
1194    let resp = configuration.client.execute(req).await?;
1195
1196    let status = resp.status();
1197    let content_type = resp
1198        .headers()
1199        .get("content-type")
1200        .and_then(|v| v.to_str().ok())
1201        .unwrap_or("application/octet-stream");
1202    let content_type = super::ContentType::from(content_type);
1203
1204    if !status.is_client_error() && !status.is_server_error() {
1205        let content = resp.text().await?;
1206        match content_type {
1207            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1208            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowError`"))),
1209            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`")))),
1210        }
1211    } else {
1212        let content = resp.text().await?;
1213        let entity: Option<GetFlowErrorError> = serde_json::from_str(&content).ok();
1214        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1215    }
1216}
1217
1218/// 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).
1219pub async fn get_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
1220    // add a prefix to parameters to efficiently prevent name collisions
1221    let p_query_id = id;
1222    let p_header_cookie = cookie;
1223
1224    let uri_str = format!("{}/self-service/login/flows", configuration.base_path);
1225    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1226
1227    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1228    if let Some(ref user_agent) = configuration.user_agent {
1229        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1230    }
1231    if let Some(param_value) = p_header_cookie {
1232        req_builder = req_builder.header("Cookie", param_value.to_string());
1233    }
1234
1235    let req = req_builder.build()?;
1236    let resp = configuration.client.execute(req).await?;
1237
1238    let status = resp.status();
1239    let content_type = resp
1240        .headers()
1241        .get("content-type")
1242        .and_then(|v| v.to_str().ok())
1243        .unwrap_or("application/octet-stream");
1244    let content_type = super::ContentType::from(content_type);
1245
1246    if !status.is_client_error() && !status.is_server_error() {
1247        let content = resp.text().await?;
1248        match content_type {
1249            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1250            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
1251            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`")))),
1252        }
1253    } else {
1254        let content = resp.text().await?;
1255        let entity: Option<GetLoginFlowError> = serde_json::from_str(&content).ok();
1256        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1257    }
1258}
1259
1260/// 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).
1261pub async fn get_recovery_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
1262    // add a prefix to parameters to efficiently prevent name collisions
1263    let p_query_id = id;
1264    let p_header_cookie = cookie;
1265
1266    let uri_str = format!("{}/self-service/recovery/flows", configuration.base_path);
1267    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1268
1269    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1270    if let Some(ref user_agent) = configuration.user_agent {
1271        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1272    }
1273    if let Some(param_value) = p_header_cookie {
1274        req_builder = req_builder.header("Cookie", param_value.to_string());
1275    }
1276
1277    let req = req_builder.build()?;
1278    let resp = configuration.client.execute(req).await?;
1279
1280    let status = resp.status();
1281    let content_type = resp
1282        .headers()
1283        .get("content-type")
1284        .and_then(|v| v.to_str().ok())
1285        .unwrap_or("application/octet-stream");
1286    let content_type = super::ContentType::from(content_type);
1287
1288    if !status.is_client_error() && !status.is_server_error() {
1289        let content = resp.text().await?;
1290        match content_type {
1291            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1292            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1293            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`")))),
1294        }
1295    } else {
1296        let content = resp.text().await?;
1297        let entity: Option<GetRecoveryFlowError> = serde_json::from_str(&content).ok();
1298        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1299    }
1300}
1301
1302/// 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).
1303pub async fn get_registration_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
1304    // add a prefix to parameters to efficiently prevent name collisions
1305    let p_query_id = id;
1306    let p_header_cookie = cookie;
1307
1308    let uri_str = format!("{}/self-service/registration/flows", configuration.base_path);
1309    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1310
1311    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1312    if let Some(ref user_agent) = configuration.user_agent {
1313        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1314    }
1315    if let Some(param_value) = p_header_cookie {
1316        req_builder = req_builder.header("Cookie", param_value.to_string());
1317    }
1318
1319    let req = req_builder.build()?;
1320    let resp = configuration.client.execute(req).await?;
1321
1322    let status = resp.status();
1323    let content_type = resp
1324        .headers()
1325        .get("content-type")
1326        .and_then(|v| v.to_str().ok())
1327        .unwrap_or("application/octet-stream");
1328    let content_type = super::ContentType::from(content_type);
1329
1330    if !status.is_client_error() && !status.is_server_error() {
1331        let content = resp.text().await?;
1332        match content_type {
1333            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1334            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
1335            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`")))),
1336        }
1337    } else {
1338        let content = resp.text().await?;
1339        let entity: Option<GetRegistrationFlowError> = serde_json::from_str(&content).ok();
1340        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1341    }
1342}
1343
1344/// This endpoint serves the per-project SAML Service Provider metadata document: the SP entity ID and certificates this Ory Network project presents to every SAML identity provider by default. It is a public, unauthenticated, cacheable endpoint and never contains a private key.  By SAML SP convention, the returned entity ID is this endpoint's own URL. The native engine derives and uses it automatically as the default SP entity ID for every connection, so there is nothing to copy; share it with an identity provider administrator setting up SSO. A connection can present a different SP entity ID via `sp_entity_id_override`.  This endpoint 404s if no native SAML connection has been configured for this project yet (no SP signing key exists to publish).
1345pub async fn get_saml_metadata(configuration: &configuration::Configuration, ) -> Result<String, Error<GetSamlMetadataError>> {
1346
1347    let uri_str = format!("{}/self-service/methods/saml/metadata", configuration.base_path);
1348    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1349
1350    if let Some(ref user_agent) = configuration.user_agent {
1351        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1352    }
1353
1354    let req = req_builder.build()?;
1355    let resp = configuration.client.execute(req).await?;
1356
1357    let status = resp.status();
1358    let content_type = resp
1359        .headers()
1360        .get("content-type")
1361        .and_then(|v| v.to_str().ok())
1362        .unwrap_or("application/octet-stream");
1363    let content_type = super::ContentType::from(content_type);
1364
1365    if !status.is_client_error() && !status.is_server_error() {
1366        let content = resp.text().await?;
1367        match content_type {
1368            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1369            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1370            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`")))),
1371        }
1372    } else {
1373        let content = resp.text().await?;
1374        let entity: Option<GetSamlMetadataError> = serde_json::from_str(&content).ok();
1375        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1376    }
1377}
1378
1379/// This endpoint serves per-connection SAML Service Provider metadata: the identity and certificate a single native connection presents to its identity provider, including the connection's own Assertion Consumer Service (ACS) URL. It serves a document for any native connection; when the connection sets `sp_entity_id_override` the SP entity ID is that value, otherwise it is the project default.  It 404s -- with the identical generic response -- for an unknown connection ID, a connection disabled by invalid configuration, and a non-native connection, which manages its SP identity out of band.
1380pub async fn get_saml_provider_metadata(configuration: &configuration::Configuration, provider: &str) -> Result<String, Error<GetSamlProviderMetadataError>> {
1381    // add a prefix to parameters to efficiently prevent name collisions
1382    let p_path_provider = provider;
1383
1384    let uri_str = format!("{}/self-service/methods/saml/metadata/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
1385    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1386
1387    if let Some(ref user_agent) = configuration.user_agent {
1388        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1389    }
1390
1391    let req = req_builder.build()?;
1392    let resp = configuration.client.execute(req).await?;
1393
1394    let status = resp.status();
1395    let content_type = resp
1396        .headers()
1397        .get("content-type")
1398        .and_then(|v| v.to_str().ok())
1399        .unwrap_or("application/octet-stream");
1400    let content_type = super::ContentType::from(content_type);
1401
1402    if !status.is_client_error() && !status.is_server_error() {
1403        let content = resp.text().await?;
1404        match content_type {
1405            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1406            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1407            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`")))),
1408        }
1409    } else {
1410        let content = resp.text().await?;
1411        let entity: Option<GetSamlProviderMetadataError> = serde_json::from_str(&content).ok();
1412        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1413    }
1414}
1415
1416/// 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).
1417pub async fn get_settings_flow(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
1418    // add a prefix to parameters to efficiently prevent name collisions
1419    let p_query_id = id;
1420    let p_header_x_session_token = x_session_token;
1421    let p_header_cookie = cookie;
1422
1423    let uri_str = format!("{}/self-service/settings/flows", configuration.base_path);
1424    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1425
1426    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1427    if let Some(ref user_agent) = configuration.user_agent {
1428        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1429    }
1430    if let Some(param_value) = p_header_x_session_token {
1431        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1432    }
1433    if let Some(param_value) = p_header_cookie {
1434        req_builder = req_builder.header("Cookie", param_value.to_string());
1435    }
1436
1437    let req = req_builder.build()?;
1438    let resp = configuration.client.execute(req).await?;
1439
1440    let status = resp.status();
1441    let content_type = resp
1442        .headers()
1443        .get("content-type")
1444        .and_then(|v| v.to_str().ok())
1445        .unwrap_or("application/octet-stream");
1446    let content_type = super::ContentType::from(content_type);
1447
1448    if !status.is_client_error() && !status.is_server_error() {
1449        let content = resp.text().await?;
1450        match content_type {
1451            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1452            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1453            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`")))),
1454        }
1455    } else {
1456        let content = resp.text().await?;
1457        let entity: Option<GetSettingsFlowError> = serde_json::from_str(&content).ok();
1458        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1459    }
1460}
1461
1462/// 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).
1463pub async fn get_verification_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1464    // add a prefix to parameters to efficiently prevent name collisions
1465    let p_query_id = id;
1466    let p_header_cookie = cookie;
1467
1468    let uri_str = format!("{}/self-service/verification/flows", configuration.base_path);
1469    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1470
1471    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1472    if let Some(ref user_agent) = configuration.user_agent {
1473        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1474    }
1475    if let Some(param_value) = p_header_cookie {
1476        req_builder = req_builder.header("Cookie", param_value.to_string());
1477    }
1478
1479    let req = req_builder.build()?;
1480    let resp = configuration.client.execute(req).await?;
1481
1482    let status = resp.status();
1483    let content_type = resp
1484        .headers()
1485        .get("content-type")
1486        .and_then(|v| v.to_str().ok())
1487        .unwrap_or("application/octet-stream");
1488    let content_type = super::ContentType::from(content_type);
1489
1490    if !status.is_client_error() && !status.is_server_error() {
1491        let content = resp.text().await?;
1492        match content_type {
1493            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1494            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1495            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`")))),
1496        }
1497    } else {
1498        let content = resp.text().await?;
1499        let entity: Option<GetVerificationFlowError> = serde_json::from_str(&content).ok();
1500        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1501    }
1502}
1503
1504/// 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).
1505pub async fn get_web_authn_java_script(configuration: &configuration::Configuration, ) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1506
1507    let uri_str = format!("{}/.well-known/ory/webauthn.js", configuration.base_path);
1508    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1509
1510    if let Some(ref user_agent) = configuration.user_agent {
1511        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1512    }
1513
1514    let req = req_builder.build()?;
1515    let resp = configuration.client.execute(req).await?;
1516
1517    let status = resp.status();
1518    let content_type = resp
1519        .headers()
1520        .get("content-type")
1521        .and_then(|v| v.to_str().ok())
1522        .unwrap_or("application/octet-stream");
1523    let content_type = super::ContentType::from(content_type);
1524
1525    if !status.is_client_error() && !status.is_server_error() {
1526        let content = resp.text().await?;
1527        match content_type {
1528            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1529            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1530            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`")))),
1531        }
1532    } else {
1533        let content = resp.text().await?;
1534        let entity: Option<GetWebAuthnJavaScriptError> = serde_json::from_str(&content).ok();
1535        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1536    }
1537}
1538
1539/// This endpoint serves the WebAuthn Related Origin Requests document specified in https://www.w3.org/TR/webauthn-3/#sctn-related-origins. It lists the web origins allowed to use this domain as their WebAuthn relying party ID. Browsers fetch it when a page requests a relying party ID that does not match the page's own origin.  The document contains the relying party origins configured for the enabled WebAuthn and passkey methods.
1540pub async fn get_web_authn_related_origins(configuration: &configuration::Configuration, ) -> Result<models::WebAuthnRelatedOrigins, Error<GetWebAuthnRelatedOriginsError>> {
1541
1542    let uri_str = format!("{}/.well-known/webauthn", configuration.base_path);
1543    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1544
1545    if let Some(ref user_agent) = configuration.user_agent {
1546        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1547    }
1548
1549    let req = req_builder.build()?;
1550    let resp = configuration.client.execute(req).await?;
1551
1552    let status = resp.status();
1553    let content_type = resp
1554        .headers()
1555        .get("content-type")
1556        .and_then(|v| v.to_str().ok())
1557        .unwrap_or("application/octet-stream");
1558    let content_type = super::ContentType::from(content_type);
1559
1560    if !status.is_client_error() && !status.is_server_error() {
1561        let content = resp.text().await?;
1562        match content_type {
1563            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1564            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnRelatedOrigins`"))),
1565            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::WebAuthnRelatedOrigins`")))),
1566        }
1567    } else {
1568        let content = resp.text().await?;
1569        let entity: Option<GetWebAuthnRelatedOriginsError> = serde_json::from_str(&content).ok();
1570        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1571    }
1572}
1573
1574/// 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.
1575pub async fn get_well_known_change_password(configuration: &configuration::Configuration, ) -> Result<models::ErrorGeneric, Error<GetWellKnownChangePasswordError>> {
1576
1577    let uri_str = format!("{}/.well-known/change-password", configuration.base_path);
1578    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1579
1580    if let Some(ref user_agent) = configuration.user_agent {
1581        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1582    }
1583
1584    let req = req_builder.build()?;
1585    let resp = configuration.client.execute(req).await?;
1586
1587    let status = resp.status();
1588    let content_type = resp
1589        .headers()
1590        .get("content-type")
1591        .and_then(|v| v.to_str().ok())
1592        .unwrap_or("application/octet-stream");
1593    let content_type = super::ContentType::from(content_type);
1594
1595    if !status.is_client_error() && !status.is_server_error() {
1596        let content = resp.text().await?;
1597        match content_type {
1598            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1599            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorGeneric`"))),
1600            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`")))),
1601        }
1602    } else {
1603        let content = resp.text().await?;
1604        let entity: Option<GetWellKnownChangePasswordError> = serde_json::from_str(&content).ok();
1605        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1606    }
1607}
1608
1609/// This endpoint starts a native SP-initiated SAML sign-in for the given connection. It checks that the flow named by the `flow` query parameter exists as the kind named by `purpose`, builds a SAML AuthnRequest, and forwards the browser to the identity provider's Single Sign-On endpoint -- either with an HTTP 302 redirect (HTTP-Redirect binding) or by returning a self-submitting HTML form (HTTP-POST binding).  A login, registration, or settings flow redirects here as a browser navigation once a SAML connection has been selected. This endpoint is NOT INTENDED to be called directly by API clients: it is a browser navigation target, not a JSON API.
1610pub async fn init_saml_login(configuration: &configuration::Configuration, provider: &str, flow: &str, purpose: &str) -> Result<String, Error<InitSamlLoginError>> {
1611    // add a prefix to parameters to efficiently prevent name collisions
1612    let p_path_provider = provider;
1613    let p_query_flow = flow;
1614    let p_query_purpose = purpose;
1615
1616    let uri_str = format!("{}/self-service/methods/saml/init/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
1617    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1618
1619    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1620    req_builder = req_builder.query(&[("purpose", &p_query_purpose.to_string())]);
1621    if let Some(ref user_agent) = configuration.user_agent {
1622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1623    }
1624
1625    let req = req_builder.build()?;
1626    let resp = configuration.client.execute(req).await?;
1627
1628    let status = resp.status();
1629    let content_type = resp
1630        .headers()
1631        .get("content-type")
1632        .and_then(|v| v.to_str().ok())
1633        .unwrap_or("application/octet-stream");
1634    let content_type = super::ContentType::from(content_type);
1635
1636    if !status.is_client_error() && !status.is_server_error() {
1637        let content = resp.text().await?;
1638        match content_type {
1639            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1640            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1641            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1642        }
1643    } else {
1644        let content = resp.text().await?;
1645        let entity: Option<InitSamlLoginError> = serde_json::from_str(&content).ok();
1646        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1647    }
1648}
1649
1650/// Identical to `GET /self-service/methods/saml/init/{provider}`, except the caller POSTs directly to this endpoint -- validated by the anti-CSRF middleware -- instead of being redirected here as a GET.
1651pub async fn init_saml_login_request(configuration: &configuration::Configuration, provider: &str, flow: &str, purpose: &str) -> Result<String, Error<InitSamlLoginRequestError>> {
1652    // add a prefix to parameters to efficiently prevent name collisions
1653    let p_path_provider = provider;
1654    let p_query_flow = flow;
1655    let p_query_purpose = purpose;
1656
1657    let uri_str = format!("{}/self-service/methods/saml/init/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
1658    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1659
1660    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1661    req_builder = req_builder.query(&[("purpose", &p_query_purpose.to_string())]);
1662    if let Some(ref user_agent) = configuration.user_agent {
1663        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1664    }
1665
1666    let req = req_builder.build()?;
1667    let resp = configuration.client.execute(req).await?;
1668
1669    let status = resp.status();
1670    let content_type = resp
1671        .headers()
1672        .get("content-type")
1673        .and_then(|v| v.to_str().ok())
1674        .unwrap_or("application/octet-stream");
1675    let content_type = super::ContentType::from(content_type);
1676
1677    if !status.is_client_error() && !status.is_server_error() {
1678        let content = resp.text().await?;
1679        match content_type {
1680            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1681            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1682            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`")))),
1683        }
1684    } else {
1685        let content = resp.text().await?;
1686        let entity: Option<InitSamlLoginRequestError> = serde_json::from_str(&content).ok();
1687        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1688    }
1689}
1690
1691/// 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.
1692pub 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>> {
1693    // add a prefix to parameters to efficiently prevent name collisions
1694    let p_query_per_page = per_page;
1695    let p_query_page = page;
1696    let p_query_page_size = page_size;
1697    let p_query_page_token = page_token;
1698    let p_header_x_session_token = x_session_token;
1699    let p_header_cookie = cookie;
1700
1701    let uri_str = format!("{}/sessions", configuration.base_path);
1702    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1703
1704    if let Some(ref param_value) = p_query_per_page {
1705        req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
1706    }
1707    if let Some(ref param_value) = p_query_page {
1708        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1709    }
1710    if let Some(ref param_value) = p_query_page_size {
1711        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1712    }
1713    if let Some(ref param_value) = p_query_page_token {
1714        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
1715    }
1716    if let Some(ref user_agent) = configuration.user_agent {
1717        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1718    }
1719    if let Some(param_value) = p_header_x_session_token {
1720        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1721    }
1722    if let Some(param_value) = p_header_cookie {
1723        req_builder = req_builder.header("Cookie", param_value.to_string());
1724    }
1725
1726    let req = req_builder.build()?;
1727    let resp = configuration.client.execute(req).await?;
1728
1729    let status = resp.status();
1730    let content_type = resp
1731        .headers()
1732        .get("content-type")
1733        .and_then(|v| v.to_str().ok())
1734        .unwrap_or("application/octet-stream");
1735    let content_type = super::ContentType::from(content_type);
1736
1737    if !status.is_client_error() && !status.is_server_error() {
1738        let content = resp.text().await?;
1739        match content_type {
1740            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1741            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;`"))),
1742            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;`")))),
1743        }
1744    } else {
1745        let content = resp.text().await?;
1746        let entity: Option<ListMySessionsError> = serde_json::from_str(&content).ok();
1747        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1748    }
1749}
1750
1751/// 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.
1752pub async fn perform_native_logout(configuration: &configuration::Configuration, perform_native_logout_body: models::PerformNativeLogoutBody) -> Result<(), Error<PerformNativeLogoutError>> {
1753    // add a prefix to parameters to efficiently prevent name collisions
1754    let p_body_perform_native_logout_body = perform_native_logout_body;
1755
1756    let uri_str = format!("{}/self-service/logout/api", configuration.base_path);
1757    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1758
1759    if let Some(ref user_agent) = configuration.user_agent {
1760        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1761    }
1762    req_builder = req_builder.json(&p_body_perform_native_logout_body);
1763
1764    let req = req_builder.build()?;
1765    let resp = configuration.client.execute(req).await?;
1766
1767    let status = resp.status();
1768
1769    if !status.is_client_error() && !status.is_server_error() {
1770        Ok(())
1771    } else {
1772        let content = resp.text().await?;
1773        let entity: Option<PerformNativeLogoutError> = serde_json::from_str(&content).ok();
1774        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1775    }
1776}
1777
1778/// This is the Assertion Consumer Service (ACS) for the native SAML engine. The identity provider delivers its SAML Response here via the HTTP-POST binding, carrying the RelayState token that correlates it with the AuthnRequest issued by the init endpoint. On success the browser is redirected to complete the login, registration, or settings-link flow that started the sign-in.  This endpoint is posted to directly by the identity provider's browser and is NOT INTENDED to be called by API clients.  Every failure -- a replayed or unknown token, a malformed request, a provider mismatch, a response delivered to a browser other than the one that started the flow, or a signature/assertion validation failure -- is reported with the identical generic error, so the response body cannot be used to probe which check failed.
1779pub async fn submit_saml_assertion(configuration: &configuration::Configuration, provider: &str, relay_state: &str, saml_response: &str) -> Result<models::ErrorGeneric, Error<SubmitSamlAssertionError>> {
1780    // add a prefix to parameters to efficiently prevent name collisions
1781    let p_path_provider = provider;
1782    let p_form_relay_state = relay_state;
1783    let p_form_saml_response = saml_response;
1784
1785    let uri_str = format!("{}/self-service/methods/saml/acs/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
1786    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1787
1788    if let Some(ref user_agent) = configuration.user_agent {
1789        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1790    }
1791    let mut multipart_form_params = std::collections::HashMap::new();
1792    multipart_form_params.insert("RelayState", p_form_relay_state.to_string());
1793    multipart_form_params.insert("SAMLResponse", p_form_saml_response.to_string());
1794    req_builder = req_builder.form(&multipart_form_params);
1795
1796    let req = req_builder.build()?;
1797    let resp = configuration.client.execute(req).await?;
1798
1799    let status = resp.status();
1800    let content_type = resp
1801        .headers()
1802        .get("content-type")
1803        .and_then(|v| v.to_str().ok())
1804        .unwrap_or("application/octet-stream");
1805    let content_type = super::ContentType::from(content_type);
1806
1807    if !status.is_client_error() && !status.is_server_error() {
1808        let content = resp.text().await?;
1809        match content_type {
1810            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1811            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorGeneric`"))),
1812            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`")))),
1813        }
1814    } else {
1815        let content = resp.text().await?;
1816        let entity: Option<SubmitSamlAssertionError> = serde_json::from_str(&content).ok();
1817        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1818    }
1819}
1820
1821/// 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. - `session_aal2_enrollment_required`: An active session was found but the required Authenticator Assurance Level can not be reached because the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one.
1822pub async fn to_session(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>, tokenize_as: Option<&str>) -> Result<models::Session, Error<ToSessionError>> {
1823    // add a prefix to parameters to efficiently prevent name collisions
1824    let p_header_x_session_token = x_session_token;
1825    let p_header_cookie = cookie;
1826    let p_query_tokenize_as = tokenize_as;
1827
1828    let uri_str = format!("{}/sessions/whoami", configuration.base_path);
1829    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1830
1831    if let Some(ref param_value) = p_query_tokenize_as {
1832        req_builder = req_builder.query(&[("tokenize_as", &param_value.to_string())]);
1833    }
1834    if let Some(ref user_agent) = configuration.user_agent {
1835        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1836    }
1837    if let Some(param_value) = p_header_x_session_token {
1838        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1839    }
1840    if let Some(param_value) = p_header_cookie {
1841        req_builder = req_builder.header("Cookie", param_value.to_string());
1842    }
1843
1844    let req = req_builder.build()?;
1845    let resp = configuration.client.execute(req).await?;
1846
1847    let status = resp.status();
1848    let content_type = resp
1849        .headers()
1850        .get("content-type")
1851        .and_then(|v| v.to_str().ok())
1852        .unwrap_or("application/octet-stream");
1853    let content_type = super::ContentType::from(content_type);
1854
1855    if !status.is_client_error() && !status.is_server_error() {
1856        let content = resp.text().await?;
1857        match content_type {
1858            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1859            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
1860            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`")))),
1861        }
1862    } else {
1863        let content = resp.text().await?;
1864        let entity: Option<ToSessionError> = serde_json::from_str(&content).ok();
1865        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1866    }
1867}
1868
1869/// 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`.
1870pub async fn update_fedcm_flow(configuration: &configuration::Configuration, update_fedcm_flow_body: models::UpdateFedcmFlowBody) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1871    // add a prefix to parameters to efficiently prevent name collisions
1872    let p_body_update_fedcm_flow_body = update_fedcm_flow_body;
1873
1874    let uri_str = format!("{}/self-service/fed-cm/token", configuration.base_path);
1875    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1876
1877    if let Some(ref user_agent) = configuration.user_agent {
1878        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1879    }
1880    req_builder = req_builder.json(&p_body_update_fedcm_flow_body);
1881
1882    let req = req_builder.build()?;
1883    let resp = configuration.client.execute(req).await?;
1884
1885    let status = resp.status();
1886    let content_type = resp
1887        .headers()
1888        .get("content-type")
1889        .and_then(|v| v.to_str().ok())
1890        .unwrap_or("application/octet-stream");
1891    let content_type = super::ContentType::from(content_type);
1892
1893    if !status.is_client_error() && !status.is_server_error() {
1894        let content = resp.text().await?;
1895        match content_type {
1896            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1897            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1898            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`")))),
1899        }
1900    } else {
1901        let content = resp.text().await?;
1902        let entity: Option<UpdateFedcmFlowError> = serde_json::from_str(&content).ok();
1903        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1904    }
1905}
1906
1907/// 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).
1908pub 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>> {
1909    // add a prefix to parameters to efficiently prevent name collisions
1910    let p_query_flow = flow;
1911    let p_body_update_login_flow_body = update_login_flow_body;
1912    let p_header_x_session_token = x_session_token;
1913    let p_header_cookie = cookie;
1914
1915    let uri_str = format!("{}/self-service/login", configuration.base_path);
1916    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1917
1918    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1919    if let Some(ref user_agent) = configuration.user_agent {
1920        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1921    }
1922    if let Some(param_value) = p_header_x_session_token {
1923        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1924    }
1925    if let Some(param_value) = p_header_cookie {
1926        req_builder = req_builder.header("Cookie", param_value.to_string());
1927    }
1928    req_builder = req_builder.json(&p_body_update_login_flow_body);
1929
1930    let req = req_builder.build()?;
1931    let resp = configuration.client.execute(req).await?;
1932
1933    let status = resp.status();
1934    let content_type = resp
1935        .headers()
1936        .get("content-type")
1937        .and_then(|v| v.to_str().ok())
1938        .unwrap_or("application/octet-stream");
1939    let content_type = super::ContentType::from(content_type);
1940
1941    if !status.is_client_error() && !status.is_server_error() {
1942        let content = resp.text().await?;
1943        match content_type {
1944            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1945            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1946            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`")))),
1947        }
1948    } else {
1949        let content = resp.text().await?;
1950        let entity: Option<UpdateLoginFlowError> = serde_json::from_str(&content).ok();
1951        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1952    }
1953}
1954
1955/// 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).
1956pub async fn update_logout_flow(configuration: &configuration::Configuration, token: Option<&str>, return_to: Option<&str>, cookie: Option<&str>) -> Result<(), Error<UpdateLogoutFlowError>> {
1957    // add a prefix to parameters to efficiently prevent name collisions
1958    let p_query_token = token;
1959    let p_query_return_to = return_to;
1960    let p_header_cookie = cookie;
1961
1962    let uri_str = format!("{}/self-service/logout", configuration.base_path);
1963    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1964
1965    if let Some(ref param_value) = p_query_token {
1966        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1967    }
1968    if let Some(ref param_value) = p_query_return_to {
1969        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
1970    }
1971    if let Some(ref user_agent) = configuration.user_agent {
1972        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1973    }
1974    if let Some(param_value) = p_header_cookie {
1975        req_builder = req_builder.header("Cookie", param_value.to_string());
1976    }
1977
1978    let req = req_builder.build()?;
1979    let resp = configuration.client.execute(req).await?;
1980
1981    let status = resp.status();
1982
1983    if !status.is_client_error() && !status.is_server_error() {
1984        Ok(())
1985    } else {
1986        let content = resp.text().await?;
1987        let entity: Option<UpdateLogoutFlowError> = serde_json::from_str(&content).ok();
1988        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1989    }
1990}
1991
1992/// 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).
1993pub 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>> {
1994    // add a prefix to parameters to efficiently prevent name collisions
1995    let p_query_flow = flow;
1996    let p_body_update_recovery_flow_body = update_recovery_flow_body;
1997    let p_query_token = token;
1998    let p_header_cookie = cookie;
1999
2000    let uri_str = format!("{}/self-service/recovery", configuration.base_path);
2001    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2002
2003    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
2004    if let Some(ref param_value) = p_query_token {
2005        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
2006    }
2007    if let Some(ref user_agent) = configuration.user_agent {
2008        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2009    }
2010    if let Some(param_value) = p_header_cookie {
2011        req_builder = req_builder.header("Cookie", param_value.to_string());
2012    }
2013    req_builder = req_builder.json(&p_body_update_recovery_flow_body);
2014
2015    let req = req_builder.build()?;
2016    let resp = configuration.client.execute(req).await?;
2017
2018    let status = resp.status();
2019    let content_type = resp
2020        .headers()
2021        .get("content-type")
2022        .and_then(|v| v.to_str().ok())
2023        .unwrap_or("application/octet-stream");
2024    let content_type = super::ContentType::from(content_type);
2025
2026    if !status.is_client_error() && !status.is_server_error() {
2027        let content = resp.text().await?;
2028        match content_type {
2029            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2030            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
2031            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`")))),
2032        }
2033    } else {
2034        let content = resp.text().await?;
2035        let entity: Option<UpdateRecoveryFlowError> = serde_json::from_str(&content).ok();
2036        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2037    }
2038}
2039
2040/// 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).
2041pub async fn update_registration_flow(configuration: &configuration::Configuration, flow: &str, update_registration_flow_body: models::UpdateRegistrationFlowBody, cookie: Option<&str>) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
2042    // add a prefix to parameters to efficiently prevent name collisions
2043    let p_query_flow = flow;
2044    let p_body_update_registration_flow_body = update_registration_flow_body;
2045    let p_header_cookie = cookie;
2046
2047    let uri_str = format!("{}/self-service/registration", configuration.base_path);
2048    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2049
2050    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
2051    if let Some(ref user_agent) = configuration.user_agent {
2052        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2053    }
2054    if let Some(param_value) = p_header_cookie {
2055        req_builder = req_builder.header("Cookie", param_value.to_string());
2056    }
2057    req_builder = req_builder.json(&p_body_update_registration_flow_body);
2058
2059    let req = req_builder.build()?;
2060    let resp = configuration.client.execute(req).await?;
2061
2062    let status = resp.status();
2063    let content_type = resp
2064        .headers()
2065        .get("content-type")
2066        .and_then(|v| v.to_str().ok())
2067        .unwrap_or("application/octet-stream");
2068    let content_type = super::ContentType::from(content_type);
2069
2070    if !status.is_client_error() && !status.is_server_error() {
2071        let content = resp.text().await?;
2072        match content_type {
2073            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2074            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeRegistration`"))),
2075            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`")))),
2076        }
2077    } else {
2078        let content = resp.text().await?;
2079        let entity: Option<UpdateRegistrationFlowError> = serde_json::from_str(&content).ok();
2080        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2081    }
2082}
2083
2084/// 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).
2085pub 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>> {
2086    // add a prefix to parameters to efficiently prevent name collisions
2087    let p_query_flow = flow;
2088    let p_body_update_settings_flow_body = update_settings_flow_body;
2089    let p_header_x_session_token = x_session_token;
2090    let p_header_cookie = cookie;
2091
2092    let uri_str = format!("{}/self-service/settings", configuration.base_path);
2093    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2094
2095    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
2096    if let Some(ref user_agent) = configuration.user_agent {
2097        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2098    }
2099    if let Some(param_value) = p_header_x_session_token {
2100        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
2101    }
2102    if let Some(param_value) = p_header_cookie {
2103        req_builder = req_builder.header("Cookie", param_value.to_string());
2104    }
2105    req_builder = req_builder.json(&p_body_update_settings_flow_body);
2106
2107    let req = req_builder.build()?;
2108    let resp = configuration.client.execute(req).await?;
2109
2110    let status = resp.status();
2111    let content_type = resp
2112        .headers()
2113        .get("content-type")
2114        .and_then(|v| v.to_str().ok())
2115        .unwrap_or("application/octet-stream");
2116    let content_type = super::ContentType::from(content_type);
2117
2118    if !status.is_client_error() && !status.is_server_error() {
2119        let content = resp.text().await?;
2120        match content_type {
2121            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2122            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
2123            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`")))),
2124        }
2125    } else {
2126        let content = resp.text().await?;
2127        let entity: Option<UpdateSettingsFlowError> = serde_json::from_str(&content).ok();
2128        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2129    }
2130}
2131
2132/// 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).
2133pub 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>> {
2134    // add a prefix to parameters to efficiently prevent name collisions
2135    let p_query_flow = flow;
2136    let p_body_update_verification_flow_body = update_verification_flow_body;
2137    let p_query_token = token;
2138    let p_header_cookie = cookie;
2139
2140    let uri_str = format!("{}/self-service/verification", configuration.base_path);
2141    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2142
2143    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
2144    if let Some(ref param_value) = p_query_token {
2145        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
2146    }
2147    if let Some(ref user_agent) = configuration.user_agent {
2148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2149    }
2150    if let Some(param_value) = p_header_cookie {
2151        req_builder = req_builder.header("Cookie", param_value.to_string());
2152    }
2153    req_builder = req_builder.json(&p_body_update_verification_flow_body);
2154
2155    let req = req_builder.build()?;
2156    let resp = configuration.client.execute(req).await?;
2157
2158    let status = resp.status();
2159    let content_type = resp
2160        .headers()
2161        .get("content-type")
2162        .and_then(|v| v.to_str().ok())
2163        .unwrap_or("application/octet-stream");
2164    let content_type = super::ContentType::from(content_type);
2165
2166    if !status.is_client_error() && !status.is_server_error() {
2167        let content = resp.text().await?;
2168        match content_type {
2169            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2170            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
2171            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`")))),
2172        }
2173    } else {
2174        let content = resp.text().await?;
2175        let entity: Option<UpdateVerificationFlowError> = serde_json::from_str(&content).ok();
2176        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2177    }
2178}
2179