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