bitwarden_api_api/apis/
auth_requests_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
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 [`auth_requests_admin_request_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AuthRequestsAdminRequestPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`auth_requests_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum AuthRequestsGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`auth_requests_id_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AuthRequestsIdGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`auth_requests_id_put`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum AuthRequestsIdPutError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`auth_requests_id_response_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum AuthRequestsIdResponseGetError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`auth_requests_post`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum AuthRequestsPostError {
56    UnknownValue(serde_json::Value),
57}
58
59pub async fn auth_requests_admin_request_post(
60    configuration: &configuration::Configuration,
61    auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
62) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsAdminRequestPostError>> {
63    let local_var_configuration = configuration;
64
65    let local_var_client = &local_var_configuration.client;
66
67    let local_var_uri_str = format!(
68        "{}/auth-requests/admin-request",
69        local_var_configuration.base_path
70    );
71    let mut local_var_req_builder =
72        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
73
74    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
75        local_var_req_builder =
76            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
77    }
78    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
79        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
80    };
81    local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model);
82
83    let local_var_req = local_var_req_builder.build()?;
84    let local_var_resp = local_var_client.execute(local_var_req).await?;
85
86    let local_var_status = local_var_resp.status();
87    let local_var_content = local_var_resp.text().await?;
88
89    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
90        serde_json::from_str(&local_var_content).map_err(Error::from)
91    } else {
92        let local_var_entity: Option<AuthRequestsAdminRequestPostError> =
93            serde_json::from_str(&local_var_content).ok();
94        let local_var_error = ResponseContent {
95            status: local_var_status,
96            content: local_var_content,
97            entity: local_var_entity,
98        };
99        Err(Error::ResponseError(local_var_error))
100    }
101}
102
103pub async fn auth_requests_get(
104    configuration: &configuration::Configuration,
105) -> Result<models::AuthRequestResponseModelListResponseModel, Error<AuthRequestsGetError>> {
106    let local_var_configuration = configuration;
107
108    let local_var_client = &local_var_configuration.client;
109
110    let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path);
111    let mut local_var_req_builder =
112        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
115        local_var_req_builder =
116            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
117    }
118    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
119        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
120    };
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        serde_json::from_str(&local_var_content).map_err(Error::from)
130    } else {
131        let local_var_entity: Option<AuthRequestsGetError> =
132            serde_json::from_str(&local_var_content).ok();
133        let local_var_error = ResponseContent {
134            status: local_var_status,
135            content: local_var_content,
136            entity: local_var_entity,
137        };
138        Err(Error::ResponseError(local_var_error))
139    }
140}
141
142pub async fn auth_requests_id_get(
143    configuration: &configuration::Configuration,
144    id: uuid::Uuid,
145) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdGetError>> {
146    let local_var_configuration = configuration;
147
148    let local_var_client = &local_var_configuration.client;
149
150    let local_var_uri_str = format!(
151        "{}/auth-requests/{id}",
152        local_var_configuration.base_path,
153        id = crate::apis::urlencode(id.to_string())
154    );
155    let mut local_var_req_builder =
156        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
157
158    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
159        local_var_req_builder =
160            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
161    }
162    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
163        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
164    };
165
166    let local_var_req = local_var_req_builder.build()?;
167    let local_var_resp = local_var_client.execute(local_var_req).await?;
168
169    let local_var_status = local_var_resp.status();
170    let local_var_content = local_var_resp.text().await?;
171
172    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
173        serde_json::from_str(&local_var_content).map_err(Error::from)
174    } else {
175        let local_var_entity: Option<AuthRequestsIdGetError> =
176            serde_json::from_str(&local_var_content).ok();
177        let local_var_error = ResponseContent {
178            status: local_var_status,
179            content: local_var_content,
180            entity: local_var_entity,
181        };
182        Err(Error::ResponseError(local_var_error))
183    }
184}
185
186pub async fn auth_requests_id_put(
187    configuration: &configuration::Configuration,
188    id: uuid::Uuid,
189    auth_request_update_request_model: Option<models::AuthRequestUpdateRequestModel>,
190) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdPutError>> {
191    let local_var_configuration = configuration;
192
193    let local_var_client = &local_var_configuration.client;
194
195    let local_var_uri_str = format!(
196        "{}/auth-requests/{id}",
197        local_var_configuration.base_path,
198        id = crate::apis::urlencode(id.to_string())
199    );
200    let mut local_var_req_builder =
201        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
202
203    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204        local_var_req_builder =
205            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210    local_var_req_builder = local_var_req_builder.json(&auth_request_update_request_model);
211
212    let local_var_req = local_var_req_builder.build()?;
213    let local_var_resp = local_var_client.execute(local_var_req).await?;
214
215    let local_var_status = local_var_resp.status();
216    let local_var_content = local_var_resp.text().await?;
217
218    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
219        serde_json::from_str(&local_var_content).map_err(Error::from)
220    } else {
221        let local_var_entity: Option<AuthRequestsIdPutError> =
222            serde_json::from_str(&local_var_content).ok();
223        let local_var_error = ResponseContent {
224            status: local_var_status,
225            content: local_var_content,
226            entity: local_var_entity,
227        };
228        Err(Error::ResponseError(local_var_error))
229    }
230}
231
232pub async fn auth_requests_id_response_get(
233    configuration: &configuration::Configuration,
234    id: uuid::Uuid,
235    code: Option<&str>,
236) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdResponseGetError>> {
237    let local_var_configuration = configuration;
238
239    let local_var_client = &local_var_configuration.client;
240
241    let local_var_uri_str = format!(
242        "{}/auth-requests/{id}/response",
243        local_var_configuration.base_path,
244        id = crate::apis::urlencode(id.to_string())
245    );
246    let mut local_var_req_builder =
247        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
248
249    if let Some(ref local_var_str) = code {
250        local_var_req_builder =
251            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
252    }
253    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
254        local_var_req_builder =
255            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
256    }
257    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
258        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
259    };
260
261    let local_var_req = local_var_req_builder.build()?;
262    let local_var_resp = local_var_client.execute(local_var_req).await?;
263
264    let local_var_status = local_var_resp.status();
265    let local_var_content = local_var_resp.text().await?;
266
267    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
268        serde_json::from_str(&local_var_content).map_err(Error::from)
269    } else {
270        let local_var_entity: Option<AuthRequestsIdResponseGetError> =
271            serde_json::from_str(&local_var_content).ok();
272        let local_var_error = ResponseContent {
273            status: local_var_status,
274            content: local_var_content,
275            entity: local_var_entity,
276        };
277        Err(Error::ResponseError(local_var_error))
278    }
279}
280
281pub async fn auth_requests_post(
282    configuration: &configuration::Configuration,
283    auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
284) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsPostError>> {
285    let local_var_configuration = configuration;
286
287    let local_var_client = &local_var_configuration.client;
288
289    let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path);
290    let mut local_var_req_builder =
291        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
292
293    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294        local_var_req_builder =
295            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296    }
297    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
298        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
299    };
300    local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model);
301
302    let local_var_req = local_var_req_builder.build()?;
303    let local_var_resp = local_var_client.execute(local_var_req).await?;
304
305    let local_var_status = local_var_resp.status();
306    let local_var_content = local_var_resp.text().await?;
307
308    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
309        serde_json::from_str(&local_var_content).map_err(Error::from)
310    } else {
311        let local_var_entity: Option<AuthRequestsPostError> =
312            serde_json::from_str(&local_var_content).ok();
313        let local_var_error = ResponseContent {
314            status: local_var_status,
315            content: local_var_content,
316            entity: local_var_entity,
317        };
318        Err(Error::ResponseError(local_var_error))
319    }
320}