Skip to main content

bitwarden_api_identity/apis/
sso_api.rs

1/*
2 * Bitwarden Identity
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: v1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait SsoApi: Send + Sync {
29    /// GET /sso/ExternalCallback
30    async fn external_callback(&self) -> Result<(), Error<ExternalCallbackError>>;
31
32    /// GET /sso/ExternalChallenge
33    async fn external_challenge<'a>(
34        &self,
35        domain_hint: Option<&'a str>,
36        return_url: Option<&'a str>,
37        user_identifier: Option<&'a str>,
38        sso_token: Option<&'a str>,
39    ) -> Result<(), Error<ExternalChallengeError>>;
40
41    /// GET /sso/Login
42    async fn login<'a>(&self, return_url: Option<&'a str>) -> Result<(), Error<LoginError>>;
43
44    /// GET /sso/PreValidate
45    async fn pre_validate<'a>(
46        &self,
47        domain_hint: Option<&'a str>,
48    ) -> Result<(), Error<PreValidateError>>;
49}
50
51pub struct SsoApiClient {
52    configuration: Arc<configuration::Configuration>,
53}
54
55impl SsoApiClient {
56    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
57        Self { configuration }
58    }
59}
60
61#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
62#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
63impl SsoApi for SsoApiClient {
64    async fn external_callback(&self) -> Result<(), Error<ExternalCallbackError>> {
65        let local_var_configuration = &self.configuration;
66
67        let local_var_client = &local_var_configuration.client;
68
69        let local_var_uri_str =
70            format!("{}/sso/ExternalCallback", local_var_configuration.base_path);
71        let mut local_var_req_builder =
72            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
73
74        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
75    }
76
77    async fn external_challenge<'a>(
78        &self,
79        domain_hint: Option<&'a str>,
80        return_url: Option<&'a str>,
81        user_identifier: Option<&'a str>,
82        sso_token: Option<&'a str>,
83    ) -> Result<(), Error<ExternalChallengeError>> {
84        let local_var_configuration = &self.configuration;
85
86        let local_var_client = &local_var_configuration.client;
87
88        let local_var_uri_str = format!(
89            "{}/sso/ExternalChallenge",
90            local_var_configuration.base_path
91        );
92        let mut local_var_req_builder =
93            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
94
95        if let Some(ref param_value) = domain_hint {
96            local_var_req_builder =
97                local_var_req_builder.query(&[("domainHint", &param_value.to_string())]);
98        }
99        if let Some(ref param_value) = return_url {
100            local_var_req_builder =
101                local_var_req_builder.query(&[("returnUrl", &param_value.to_string())]);
102        }
103        if let Some(ref param_value) = user_identifier {
104            local_var_req_builder =
105                local_var_req_builder.query(&[("userIdentifier", &param_value.to_string())]);
106        }
107        if let Some(ref param_value) = sso_token {
108            local_var_req_builder =
109                local_var_req_builder.query(&[("ssoToken", &param_value.to_string())]);
110        }
111
112        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
113    }
114
115    async fn login<'a>(&self, return_url: Option<&'a str>) -> Result<(), Error<LoginError>> {
116        let local_var_configuration = &self.configuration;
117
118        let local_var_client = &local_var_configuration.client;
119
120        let local_var_uri_str = format!("{}/sso/Login", local_var_configuration.base_path);
121        let mut local_var_req_builder =
122            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124        if let Some(ref param_value) = return_url {
125            local_var_req_builder =
126                local_var_req_builder.query(&[("returnUrl", &param_value.to_string())]);
127        }
128
129        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
130    }
131
132    async fn pre_validate<'a>(
133        &self,
134        domain_hint: Option<&'a str>,
135    ) -> Result<(), Error<PreValidateError>> {
136        let local_var_configuration = &self.configuration;
137
138        let local_var_client = &local_var_configuration.client;
139
140        let local_var_uri_str = format!("{}/sso/PreValidate", local_var_configuration.base_path);
141        let mut local_var_req_builder =
142            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
143
144        if let Some(ref param_value) = domain_hint {
145            local_var_req_builder =
146                local_var_req_builder.query(&[("domainHint", &param_value.to_string())]);
147        }
148
149        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
150    }
151}
152
153/// struct for typed errors of method [`SsoApi::external_callback`]
154#[derive(Debug, Clone, Serialize, Deserialize)]
155#[serde(untagged)]
156pub enum ExternalCallbackError {
157    UnknownValue(serde_json::Value),
158}
159/// struct for typed errors of method [`SsoApi::external_challenge`]
160#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(untagged)]
162pub enum ExternalChallengeError {
163    UnknownValue(serde_json::Value),
164}
165/// struct for typed errors of method [`SsoApi::login`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum LoginError {
169    UnknownValue(serde_json::Value),
170}
171/// struct for typed errors of method [`SsoApi::pre_validate`]
172#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(untagged)]
174pub enum PreValidateError {
175    UnknownValue(serde_json::Value),
176}