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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`sso_external_callback_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SsoExternalCallbackGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`sso_external_challenge_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SsoExternalChallengeGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`sso_login_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum SsoLoginGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`sso_pre_validate_get`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum SsoPreValidateGetError {
42    UnknownValue(serde_json::Value),
43}
44
45pub async fn sso_external_callback_get(
46    configuration: &configuration::Configuration,
47) -> Result<(), Error<SsoExternalCallbackGetError>> {
48    let local_var_configuration = configuration;
49
50    let local_var_client = &local_var_configuration.client;
51
52    let local_var_uri_str = format!("{}/sso/ExternalCallback", local_var_configuration.base_path);
53    let mut local_var_req_builder =
54        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
55
56    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57        local_var_req_builder =
58            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
59    }
60
61    let local_var_req = local_var_req_builder.build()?;
62    let local_var_resp = local_var_client.execute(local_var_req).await?;
63
64    let local_var_status = local_var_resp.status();
65    let local_var_content = local_var_resp.text().await?;
66
67    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
68        Ok(())
69    } else {
70        let local_var_entity: Option<SsoExternalCallbackGetError> =
71            serde_json::from_str(&local_var_content).ok();
72        let local_var_error = ResponseContent {
73            status: local_var_status,
74            content: local_var_content,
75            entity: local_var_entity,
76        };
77        Err(Error::ResponseError(local_var_error))
78    }
79}
80
81pub async fn sso_external_challenge_get(
82    configuration: &configuration::Configuration,
83    domain_hint: Option<&str>,
84    return_url: Option<&str>,
85    user_identifier: Option<&str>,
86    sso_token: Option<&str>,
87) -> Result<(), Error<SsoExternalChallengeGetError>> {
88    let local_var_configuration = configuration;
89
90    let local_var_client = &local_var_configuration.client;
91
92    let local_var_uri_str = format!(
93        "{}/sso/ExternalChallenge",
94        local_var_configuration.base_path
95    );
96    let mut local_var_req_builder =
97        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
98
99    if let Some(ref local_var_str) = domain_hint {
100        local_var_req_builder =
101            local_var_req_builder.query(&[("domainHint", &local_var_str.to_string())]);
102    }
103    if let Some(ref local_var_str) = return_url {
104        local_var_req_builder =
105            local_var_req_builder.query(&[("returnUrl", &local_var_str.to_string())]);
106    }
107    if let Some(ref local_var_str) = user_identifier {
108        local_var_req_builder =
109            local_var_req_builder.query(&[("userIdentifier", &local_var_str.to_string())]);
110    }
111    if let Some(ref local_var_str) = sso_token {
112        local_var_req_builder =
113            local_var_req_builder.query(&[("ssoToken", &local_var_str.to_string())]);
114    }
115    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
116        local_var_req_builder =
117            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
118    }
119
120    let local_var_req = local_var_req_builder.build()?;
121    let local_var_resp = local_var_client.execute(local_var_req).await?;
122
123    let local_var_status = local_var_resp.status();
124    let local_var_content = local_var_resp.text().await?;
125
126    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
127        Ok(())
128    } else {
129        let local_var_entity: Option<SsoExternalChallengeGetError> =
130            serde_json::from_str(&local_var_content).ok();
131        let local_var_error = ResponseContent {
132            status: local_var_status,
133            content: local_var_content,
134            entity: local_var_entity,
135        };
136        Err(Error::ResponseError(local_var_error))
137    }
138}
139
140pub async fn sso_login_get(
141    configuration: &configuration::Configuration,
142    return_url: Option<&str>,
143) -> Result<(), Error<SsoLoginGetError>> {
144    let local_var_configuration = configuration;
145
146    let local_var_client = &local_var_configuration.client;
147
148    let local_var_uri_str = format!("{}/sso/Login", local_var_configuration.base_path);
149    let mut local_var_req_builder =
150        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
151
152    if let Some(ref local_var_str) = return_url {
153        local_var_req_builder =
154            local_var_req_builder.query(&[("returnUrl", &local_var_str.to_string())]);
155    }
156    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
157        local_var_req_builder =
158            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
159    }
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        Ok(())
169    } else {
170        let local_var_entity: Option<SsoLoginGetError> =
171            serde_json::from_str(&local_var_content).ok();
172        let local_var_error = ResponseContent {
173            status: local_var_status,
174            content: local_var_content,
175            entity: local_var_entity,
176        };
177        Err(Error::ResponseError(local_var_error))
178    }
179}
180
181pub async fn sso_pre_validate_get(
182    configuration: &configuration::Configuration,
183    domain_hint: Option<&str>,
184) -> Result<(), Error<SsoPreValidateGetError>> {
185    let local_var_configuration = configuration;
186
187    let local_var_client = &local_var_configuration.client;
188
189    let local_var_uri_str = format!("{}/sso/PreValidate", local_var_configuration.base_path);
190    let mut local_var_req_builder =
191        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
192
193    if let Some(ref local_var_str) = domain_hint {
194        local_var_req_builder =
195            local_var_req_builder.query(&[("domainHint", &local_var_str.to_string())]);
196    }
197    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
198        local_var_req_builder =
199            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
200    }
201
202    let local_var_req = local_var_req_builder.build()?;
203    let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205    let local_var_status = local_var_resp.status();
206    let local_var_content = local_var_resp.text().await?;
207
208    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
209        Ok(())
210    } else {
211        let local_var_entity: Option<SsoPreValidateGetError> =
212            serde_json::from_str(&local_var_content).ok();
213        let local_var_error = ResponseContent {
214            status: local_var_status,
215            content: local_var_content,
216            entity: local_var_entity,
217        };
218        Err(Error::ResponseError(local_var_error))
219    }
220}