Skip to main content

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 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 AuthRequestsApi: Send + Sync {
29    /// GET /auth-requests/{id}
30    async fn get<'a>(
31        &self,
32        id: uuid::Uuid,
33    ) -> Result<models::AuthRequestResponseModel, Error<GetError>>;
34
35    /// GET /auth-requests
36    async fn get_all(
37        &self,
38    ) -> Result<models::AuthRequestResponseModelListResponseModel, Error<GetAllError>>;
39
40    /// GET /auth-requests/pending
41    async fn get_pending_auth_requests(
42        &self,
43    ) -> Result<
44        models::PendingAuthRequestResponseModelListResponseModel,
45        Error<GetPendingAuthRequestsError>,
46    >;
47
48    /// GET /auth-requests/{id}/response
49    async fn get_response<'a>(
50        &self,
51        id: uuid::Uuid,
52        code: Option<&'a str>,
53    ) -> Result<models::AuthRequestResponseModel, Error<GetResponseError>>;
54
55    /// POST /auth-requests
56    async fn post<'a>(
57        &self,
58        auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
59    ) -> Result<models::AuthRequestResponseModel, Error<PostError>>;
60
61    /// POST /auth-requests/admin-request
62    async fn post_admin_request<'a>(
63        &self,
64        auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
65    ) -> Result<models::AuthRequestResponseModel, Error<PostAdminRequestError>>;
66
67    /// PUT /auth-requests/{id}
68    async fn put<'a>(
69        &self,
70        id: uuid::Uuid,
71        auth_request_update_request_model: Option<models::AuthRequestUpdateRequestModel>,
72    ) -> Result<models::AuthRequestResponseModel, Error<PutError>>;
73}
74
75pub struct AuthRequestsApiClient {
76    configuration: Arc<configuration::Configuration>,
77}
78
79impl AuthRequestsApiClient {
80    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
81        Self { configuration }
82    }
83}
84
85#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
86#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
87impl AuthRequestsApi for AuthRequestsApiClient {
88    async fn get<'a>(
89        &self,
90        id: uuid::Uuid,
91    ) -> Result<models::AuthRequestResponseModel, Error<GetError>> {
92        let local_var_configuration = &self.configuration;
93
94        let local_var_client = &local_var_configuration.client;
95
96        let local_var_uri_str = format!(
97            "{}/auth-requests/{id}",
98            local_var_configuration.base_path,
99            id = id
100        );
101        let mut local_var_req_builder =
102            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
103
104        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
105
106        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
107    }
108
109    async fn get_all(
110        &self,
111    ) -> Result<models::AuthRequestResponseModelListResponseModel, Error<GetAllError>> {
112        let local_var_configuration = &self.configuration;
113
114        let local_var_client = &local_var_configuration.client;
115
116        let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path);
117        let mut local_var_req_builder =
118            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
119
120        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
121
122        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
123    }
124
125    async fn get_pending_auth_requests(
126        &self,
127    ) -> Result<
128        models::PendingAuthRequestResponseModelListResponseModel,
129        Error<GetPendingAuthRequestsError>,
130    > {
131        let local_var_configuration = &self.configuration;
132
133        let local_var_client = &local_var_configuration.client;
134
135        let local_var_uri_str = format!(
136            "{}/auth-requests/pending",
137            local_var_configuration.base_path
138        );
139        let mut local_var_req_builder =
140            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
141
142        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
143
144        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
145    }
146
147    async fn get_response<'a>(
148        &self,
149        id: uuid::Uuid,
150        code: Option<&'a str>,
151    ) -> Result<models::AuthRequestResponseModel, Error<GetResponseError>> {
152        let local_var_configuration = &self.configuration;
153
154        let local_var_client = &local_var_configuration.client;
155
156        let local_var_uri_str = format!(
157            "{}/auth-requests/{id}/response",
158            local_var_configuration.base_path,
159            id = id
160        );
161        let mut local_var_req_builder =
162            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
163
164        if let Some(ref param_value) = code {
165            local_var_req_builder =
166                local_var_req_builder.query(&[("code", &param_value.to_string())]);
167        }
168        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
169
170        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
171    }
172
173    async fn post<'a>(
174        &self,
175        auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
176    ) -> Result<models::AuthRequestResponseModel, Error<PostError>> {
177        let local_var_configuration = &self.configuration;
178
179        let local_var_client = &local_var_configuration.client;
180
181        let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path);
182        let mut local_var_req_builder =
183            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
184
185        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
186        local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model);
187
188        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
189    }
190
191    async fn post_admin_request<'a>(
192        &self,
193        auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
194    ) -> Result<models::AuthRequestResponseModel, Error<PostAdminRequestError>> {
195        let local_var_configuration = &self.configuration;
196
197        let local_var_client = &local_var_configuration.client;
198
199        let local_var_uri_str = format!(
200            "{}/auth-requests/admin-request",
201            local_var_configuration.base_path
202        );
203        let mut local_var_req_builder =
204            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
205
206        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
207        local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model);
208
209        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
210    }
211
212    async fn put<'a>(
213        &self,
214        id: uuid::Uuid,
215        auth_request_update_request_model: Option<models::AuthRequestUpdateRequestModel>,
216    ) -> Result<models::AuthRequestResponseModel, Error<PutError>> {
217        let local_var_configuration = &self.configuration;
218
219        let local_var_client = &local_var_configuration.client;
220
221        let local_var_uri_str = format!(
222            "{}/auth-requests/{id}",
223            local_var_configuration.base_path,
224            id = id
225        );
226        let mut local_var_req_builder =
227            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
228
229        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
230        local_var_req_builder = local_var_req_builder.json(&auth_request_update_request_model);
231
232        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
233    }
234}
235
236/// struct for typed errors of method [`AuthRequestsApi::get`]
237#[derive(Debug, Clone, Serialize, Deserialize)]
238#[serde(untagged)]
239pub enum GetError {
240    UnknownValue(serde_json::Value),
241}
242/// struct for typed errors of method [`AuthRequestsApi::get_all`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum GetAllError {
246    UnknownValue(serde_json::Value),
247}
248/// struct for typed errors of method [`AuthRequestsApi::get_pending_auth_requests`]
249#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum GetPendingAuthRequestsError {
252    UnknownValue(serde_json::Value),
253}
254/// struct for typed errors of method [`AuthRequestsApi::get_response`]
255#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum GetResponseError {
258    UnknownValue(serde_json::Value),
259}
260/// struct for typed errors of method [`AuthRequestsApi::post`]
261#[derive(Debug, Clone, Serialize, Deserialize)]
262#[serde(untagged)]
263pub enum PostError {
264    UnknownValue(serde_json::Value),
265}
266/// struct for typed errors of method [`AuthRequestsApi::post_admin_request`]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum PostAdminRequestError {
270    UnknownValue(serde_json::Value),
271}
272/// struct for typed errors of method [`AuthRequestsApi::put`]
273#[derive(Debug, Clone, Serialize, Deserialize)]
274#[serde(untagged)]
275pub enum PutError {
276    UnknownValue(serde_json::Value),
277}