Skip to main content

bitwarden_api_api/apis/
sends_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 SendsApi: Send + Sync {
29    /// POST /sends/access
30    async fn access_using_auth<'a>(
31        &self,
32        access_token: &'a str,
33    ) -> Result<models::SendAccessResponseModel, Error>;
34
35    /// POST /sends/file/validate/azure
36    async fn azure_validate_file(&self) -> Result<(), Error>;
37
38    /// DELETE /sends/{id}
39    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error>;
40
41    /// GET /sends/{id}
42    async fn get<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error>;
43
44    /// GET /sends
45    async fn get_all(&self) -> Result<models::SendResponseModelListResponseModel, Error>;
46
47    /// POST /sends/access/file/{fileId}
48    async fn get_send_file_download_data_using_auth<'a>(
49        &self,
50        file_id: &'a str,
51        access_token: &'a str,
52    ) -> Result<models::SendFileDownloadDataResponseModel, Error>;
53
54    /// POST /sends
55    async fn post<'a>(
56        &self,
57        send_request_model: Option<models::SendRequestModel>,
58    ) -> Result<models::SendResponseModel, Error>;
59
60    /// POST /sends/file/v2
61    async fn post_file<'a>(
62        &self,
63        send_request_model: Option<models::SendRequestModel>,
64    ) -> Result<models::SendFileUploadDataResponseModel, Error>;
65
66    /// POST /sends/{id}/file/{fileId}
67    async fn post_file_for_existing_send<'a>(
68        &self,
69        id: &'a str,
70        file_id: &'a str,
71    ) -> Result<(), Error>;
72
73    /// PUT /sends/{id}
74    async fn put<'a>(
75        &self,
76        id: &'a str,
77        send_request_model: Option<models::SendRequestModel>,
78    ) -> Result<models::SendResponseModel, Error>;
79
80    /// PUT /sends/{id}/remove-auth
81    async fn put_remove_auth<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error>;
82
83    /// PUT /sends/{id}/remove-password
84    async fn put_remove_password<'a>(
85        &self,
86        id: &'a str,
87    ) -> Result<models::SendResponseModel, Error>;
88
89    /// GET /sends/{id}/file/{fileId}
90    async fn renew_file_upload<'a>(
91        &self,
92        id: &'a str,
93        file_id: &'a str,
94    ) -> Result<models::SendFileUploadDataResponseModel, Error>;
95}
96
97pub struct SendsApiClient {
98    configuration: Arc<configuration::Configuration>,
99}
100
101impl SendsApiClient {
102    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
103        Self { configuration }
104    }
105}
106
107#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
108#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
109impl SendsApi for SendsApiClient {
110    async fn access_using_auth<'a>(
111        &self,
112        access_token: &'a str,
113    ) -> Result<models::SendAccessResponseModel, Error> {
114        let local_var_configuration = &self.configuration;
115
116        let local_var_client = &local_var_configuration.client;
117
118        let local_var_uri_str = format!("{}/sends/access", local_var_configuration.base_path);
119        let mut local_var_req_builder =
120            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
121
122        local_var_req_builder = local_var_req_builder.header(
123            reqwest::header::AUTHORIZATION,
124            format!("Bearer {}", access_token),
125        );
126
127        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
128    }
129
130    async fn azure_validate_file(&self) -> Result<(), Error> {
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            "{}/sends/file/validate/azure",
137            local_var_configuration.base_path
138        );
139        let mut local_var_req_builder =
140            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
141
142        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
143    }
144
145    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error> {
146        let local_var_configuration = &self.configuration;
147
148        let local_var_client = &local_var_configuration.client;
149
150        let local_var_uri_str = format!(
151            "{}/sends/{id}",
152            local_var_configuration.base_path,
153            id = crate::apis::urlencode(id)
154        );
155        let mut local_var_req_builder =
156            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
157
158        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
159
160        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
161    }
162
163    async fn get<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error> {
164        let local_var_configuration = &self.configuration;
165
166        let local_var_client = &local_var_configuration.client;
167
168        let local_var_uri_str = format!(
169            "{}/sends/{id}",
170            local_var_configuration.base_path,
171            id = crate::apis::urlencode(id)
172        );
173        let mut local_var_req_builder =
174            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
175
176        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
177
178        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
179    }
180
181    async fn get_all(&self) -> Result<models::SendResponseModelListResponseModel, Error> {
182        let local_var_configuration = &self.configuration;
183
184        let local_var_client = &local_var_configuration.client;
185
186        let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
187        let mut local_var_req_builder =
188            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
189
190        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
191
192        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
193    }
194
195    async fn get_send_file_download_data_using_auth<'a>(
196        &self,
197        file_id: &'a str,
198        access_token: &'a str,
199    ) -> Result<models::SendFileDownloadDataResponseModel, Error> {
200        let local_var_configuration = &self.configuration;
201
202        let local_var_client = &local_var_configuration.client;
203
204        let local_var_uri_str = format!(
205            "{}/sends/access/file/{fileId}",
206            local_var_configuration.base_path,
207            fileId = crate::apis::urlencode(file_id)
208        );
209        let mut local_var_req_builder =
210            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
211
212        local_var_req_builder = local_var_req_builder.header(
213            reqwest::header::AUTHORIZATION,
214            format!("Bearer {}", access_token),
215        );
216
217        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
218    }
219
220    async fn post<'a>(
221        &self,
222        send_request_model: Option<models::SendRequestModel>,
223    ) -> Result<models::SendResponseModel, Error> {
224        let local_var_configuration = &self.configuration;
225
226        let local_var_client = &local_var_configuration.client;
227
228        let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
229        let mut local_var_req_builder =
230            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
231
232        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
233        local_var_req_builder = local_var_req_builder.json(&send_request_model);
234
235        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
236    }
237
238    async fn post_file<'a>(
239        &self,
240        send_request_model: Option<models::SendRequestModel>,
241    ) -> Result<models::SendFileUploadDataResponseModel, Error> {
242        let local_var_configuration = &self.configuration;
243
244        let local_var_client = &local_var_configuration.client;
245
246        let local_var_uri_str = format!("{}/sends/file/v2", local_var_configuration.base_path);
247        let mut local_var_req_builder =
248            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
249
250        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
251        local_var_req_builder = local_var_req_builder.json(&send_request_model);
252
253        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
254    }
255
256    async fn post_file_for_existing_send<'a>(
257        &self,
258        id: &'a str,
259        file_id: &'a str,
260    ) -> Result<(), Error> {
261        let local_var_configuration = &self.configuration;
262
263        let local_var_client = &local_var_configuration.client;
264
265        let local_var_uri_str = format!(
266            "{}/sends/{id}/file/{fileId}",
267            local_var_configuration.base_path,
268            id = crate::apis::urlencode(id),
269            fileId = crate::apis::urlencode(file_id)
270        );
271        let mut local_var_req_builder =
272            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
273
274        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
275
276        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
277    }
278
279    async fn put<'a>(
280        &self,
281        id: &'a str,
282        send_request_model: Option<models::SendRequestModel>,
283    ) -> Result<models::SendResponseModel, Error> {
284        let local_var_configuration = &self.configuration;
285
286        let local_var_client = &local_var_configuration.client;
287
288        let local_var_uri_str = format!(
289            "{}/sends/{id}",
290            local_var_configuration.base_path,
291            id = crate::apis::urlencode(id)
292        );
293        let mut local_var_req_builder =
294            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
295
296        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
297        local_var_req_builder = local_var_req_builder.json(&send_request_model);
298
299        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
300    }
301
302    async fn put_remove_auth<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error> {
303        let local_var_configuration = &self.configuration;
304
305        let local_var_client = &local_var_configuration.client;
306
307        let local_var_uri_str = format!(
308            "{}/sends/{id}/remove-auth",
309            local_var_configuration.base_path,
310            id = crate::apis::urlencode(id)
311        );
312        let mut local_var_req_builder =
313            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
314
315        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
316
317        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
318    }
319
320    async fn put_remove_password<'a>(
321        &self,
322        id: &'a str,
323    ) -> Result<models::SendResponseModel, Error> {
324        let local_var_configuration = &self.configuration;
325
326        let local_var_client = &local_var_configuration.client;
327
328        let local_var_uri_str = format!(
329            "{}/sends/{id}/remove-password",
330            local_var_configuration.base_path,
331            id = crate::apis::urlencode(id)
332        );
333        let mut local_var_req_builder =
334            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
335
336        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
337
338        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
339    }
340
341    async fn renew_file_upload<'a>(
342        &self,
343        id: &'a str,
344        file_id: &'a str,
345    ) -> Result<models::SendFileUploadDataResponseModel, Error> {
346        let local_var_configuration = &self.configuration;
347
348        let local_var_client = &local_var_configuration.client;
349
350        let local_var_uri_str = format!(
351            "{}/sends/{id}/file/{fileId}",
352            local_var_configuration.base_path,
353            id = crate::apis::urlencode(id),
354            fileId = crate::apis::urlencode(file_id)
355        );
356        let mut local_var_req_builder =
357            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
358
359        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
360
361        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
362    }
363}