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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`sends_access_id_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SendsAccessIdPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`sends_encoded_send_id_access_file_file_id_post`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SendsEncodedSendIdAccessFileFileIdPostError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`sends_file_v2_post`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum SendsFileV2PostError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`sends_file_validate_azure_post`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum SendsFileValidateAzurePostError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`sends_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum SendsGetError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`sends_id_delete`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum SendsIdDeleteError {
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`sends_id_file_file_id_get`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum SendsIdFileFileIdGetError {
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`sends_id_file_file_id_post`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum SendsIdFileFileIdPostError {
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`sends_id_get`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum SendsIdGetError {
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`sends_id_put`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum SendsIdPutError {
84    UnknownValue(serde_json::Value),
85}
86
87/// struct for typed errors of method [`sends_id_remove_password_put`]
88#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum SendsIdRemovePasswordPutError {
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`sends_post`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum SendsPostError {
98    UnknownValue(serde_json::Value),
99}
100
101pub async fn sends_access_id_post(
102    configuration: &configuration::Configuration,
103    id: &str,
104    send_access_request_model: Option<models::SendAccessRequestModel>,
105) -> Result<(), Error<SendsAccessIdPostError>> {
106    let local_var_configuration = configuration;
107
108    let local_var_client = &local_var_configuration.client;
109
110    let local_var_uri_str = format!(
111        "{}/sends/access/{id}",
112        local_var_configuration.base_path,
113        id = crate::apis::urlencode(id)
114    );
115    let mut local_var_req_builder =
116        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
117
118    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
119        local_var_req_builder =
120            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
121    }
122    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
123        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
124    };
125    local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
126
127    let local_var_req = local_var_req_builder.build()?;
128    let local_var_resp = local_var_client.execute(local_var_req).await?;
129
130    let local_var_status = local_var_resp.status();
131    let local_var_content = local_var_resp.text().await?;
132
133    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
134        Ok(())
135    } else {
136        let local_var_entity: Option<SendsAccessIdPostError> =
137            serde_json::from_str(&local_var_content).ok();
138        let local_var_error = ResponseContent {
139            status: local_var_status,
140            content: local_var_content,
141            entity: local_var_entity,
142        };
143        Err(Error::ResponseError(local_var_error))
144    }
145}
146
147pub async fn sends_encoded_send_id_access_file_file_id_post(
148    configuration: &configuration::Configuration,
149    encoded_send_id: &str,
150    file_id: &str,
151    send_access_request_model: Option<models::SendAccessRequestModel>,
152) -> Result<(), Error<SendsEncodedSendIdAccessFileFileIdPostError>> {
153    let local_var_configuration = configuration;
154
155    let local_var_client = &local_var_configuration.client;
156
157    let local_var_uri_str = format!(
158        "{}/sends/{encodedSendId}/access/file/{fileId}",
159        local_var_configuration.base_path,
160        encodedSendId = crate::apis::urlencode(encoded_send_id),
161        fileId = crate::apis::urlencode(file_id)
162    );
163    let mut local_var_req_builder =
164        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
165
166    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167        local_var_req_builder =
168            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
169    }
170    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
171        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
172    };
173    local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
174
175    let local_var_req = local_var_req_builder.build()?;
176    let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178    let local_var_status = local_var_resp.status();
179    let local_var_content = local_var_resp.text().await?;
180
181    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182        Ok(())
183    } else {
184        let local_var_entity: Option<SendsEncodedSendIdAccessFileFileIdPostError> =
185            serde_json::from_str(&local_var_content).ok();
186        let local_var_error = ResponseContent {
187            status: local_var_status,
188            content: local_var_content,
189            entity: local_var_entity,
190        };
191        Err(Error::ResponseError(local_var_error))
192    }
193}
194
195pub async fn sends_file_v2_post(
196    configuration: &configuration::Configuration,
197    send_request_model: Option<models::SendRequestModel>,
198) -> Result<models::SendFileUploadDataResponseModel, Error<SendsFileV2PostError>> {
199    let local_var_configuration = configuration;
200
201    let local_var_client = &local_var_configuration.client;
202
203    let local_var_uri_str = format!("{}/sends/file/v2", local_var_configuration.base_path);
204    let mut local_var_req_builder =
205        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
206
207    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
208        local_var_req_builder =
209            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
210    }
211    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
212        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
213    };
214    local_var_req_builder = local_var_req_builder.json(&send_request_model);
215
216    let local_var_req = local_var_req_builder.build()?;
217    let local_var_resp = local_var_client.execute(local_var_req).await?;
218
219    let local_var_status = local_var_resp.status();
220    let local_var_content = local_var_resp.text().await?;
221
222    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
223        serde_json::from_str(&local_var_content).map_err(Error::from)
224    } else {
225        let local_var_entity: Option<SendsFileV2PostError> =
226            serde_json::from_str(&local_var_content).ok();
227        let local_var_error = ResponseContent {
228            status: local_var_status,
229            content: local_var_content,
230            entity: local_var_entity,
231        };
232        Err(Error::ResponseError(local_var_error))
233    }
234}
235
236pub async fn sends_file_validate_azure_post(
237    configuration: &configuration::Configuration,
238) -> Result<(), Error<SendsFileValidateAzurePostError>> {
239    let local_var_configuration = configuration;
240
241    let local_var_client = &local_var_configuration.client;
242
243    let local_var_uri_str = format!(
244        "{}/sends/file/validate/azure",
245        local_var_configuration.base_path
246    );
247    let mut local_var_req_builder =
248        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
249
250    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
251        local_var_req_builder =
252            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
253    }
254    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
255        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
256    };
257
258    let local_var_req = local_var_req_builder.build()?;
259    let local_var_resp = local_var_client.execute(local_var_req).await?;
260
261    let local_var_status = local_var_resp.status();
262    let local_var_content = local_var_resp.text().await?;
263
264    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
265        Ok(())
266    } else {
267        let local_var_entity: Option<SendsFileValidateAzurePostError> =
268            serde_json::from_str(&local_var_content).ok();
269        let local_var_error = ResponseContent {
270            status: local_var_status,
271            content: local_var_content,
272            entity: local_var_entity,
273        };
274        Err(Error::ResponseError(local_var_error))
275    }
276}
277
278pub async fn sends_get(
279    configuration: &configuration::Configuration,
280) -> Result<models::SendResponseModelListResponseModel, Error<SendsGetError>> {
281    let local_var_configuration = configuration;
282
283    let local_var_client = &local_var_configuration.client;
284
285    let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
286    let mut local_var_req_builder =
287        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
288
289    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
290        local_var_req_builder =
291            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
292    }
293    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
294        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
295    };
296
297    let local_var_req = local_var_req_builder.build()?;
298    let local_var_resp = local_var_client.execute(local_var_req).await?;
299
300    let local_var_status = local_var_resp.status();
301    let local_var_content = local_var_resp.text().await?;
302
303    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304        serde_json::from_str(&local_var_content).map_err(Error::from)
305    } else {
306        let local_var_entity: Option<SendsGetError> = serde_json::from_str(&local_var_content).ok();
307        let local_var_error = ResponseContent {
308            status: local_var_status,
309            content: local_var_content,
310            entity: local_var_entity,
311        };
312        Err(Error::ResponseError(local_var_error))
313    }
314}
315
316pub async fn sends_id_delete(
317    configuration: &configuration::Configuration,
318    id: &str,
319) -> Result<(), Error<SendsIdDeleteError>> {
320    let local_var_configuration = configuration;
321
322    let local_var_client = &local_var_configuration.client;
323
324    let local_var_uri_str = format!(
325        "{}/sends/{id}",
326        local_var_configuration.base_path,
327        id = crate::apis::urlencode(id)
328    );
329    let mut local_var_req_builder =
330        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
331
332    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
333        local_var_req_builder =
334            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
335    }
336    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
337        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
338    };
339
340    let local_var_req = local_var_req_builder.build()?;
341    let local_var_resp = local_var_client.execute(local_var_req).await?;
342
343    let local_var_status = local_var_resp.status();
344    let local_var_content = local_var_resp.text().await?;
345
346    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
347        Ok(())
348    } else {
349        let local_var_entity: Option<SendsIdDeleteError> =
350            serde_json::from_str(&local_var_content).ok();
351        let local_var_error = ResponseContent {
352            status: local_var_status,
353            content: local_var_content,
354            entity: local_var_entity,
355        };
356        Err(Error::ResponseError(local_var_error))
357    }
358}
359
360pub async fn sends_id_file_file_id_get(
361    configuration: &configuration::Configuration,
362    id: &str,
363    file_id: &str,
364) -> Result<models::SendFileUploadDataResponseModel, Error<SendsIdFileFileIdGetError>> {
365    let local_var_configuration = configuration;
366
367    let local_var_client = &local_var_configuration.client;
368
369    let local_var_uri_str = format!(
370        "{}/sends/{id}/file/{fileId}",
371        local_var_configuration.base_path,
372        id = crate::apis::urlencode(id),
373        fileId = crate::apis::urlencode(file_id)
374    );
375    let mut local_var_req_builder =
376        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
377
378    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
379        local_var_req_builder =
380            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
381    }
382    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
383        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
384    };
385
386    let local_var_req = local_var_req_builder.build()?;
387    let local_var_resp = local_var_client.execute(local_var_req).await?;
388
389    let local_var_status = local_var_resp.status();
390    let local_var_content = local_var_resp.text().await?;
391
392    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
393        serde_json::from_str(&local_var_content).map_err(Error::from)
394    } else {
395        let local_var_entity: Option<SendsIdFileFileIdGetError> =
396            serde_json::from_str(&local_var_content).ok();
397        let local_var_error = ResponseContent {
398            status: local_var_status,
399            content: local_var_content,
400            entity: local_var_entity,
401        };
402        Err(Error::ResponseError(local_var_error))
403    }
404}
405
406pub async fn sends_id_file_file_id_post(
407    configuration: &configuration::Configuration,
408    id: &str,
409    file_id: &str,
410) -> Result<(), Error<SendsIdFileFileIdPostError>> {
411    let local_var_configuration = configuration;
412
413    let local_var_client = &local_var_configuration.client;
414
415    let local_var_uri_str = format!(
416        "{}/sends/{id}/file/{fileId}",
417        local_var_configuration.base_path,
418        id = crate::apis::urlencode(id),
419        fileId = crate::apis::urlencode(file_id)
420    );
421    let mut local_var_req_builder =
422        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
423
424    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
425        local_var_req_builder =
426            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
427    }
428    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
429        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
430    };
431
432    let local_var_req = local_var_req_builder.build()?;
433    let local_var_resp = local_var_client.execute(local_var_req).await?;
434
435    let local_var_status = local_var_resp.status();
436    let local_var_content = local_var_resp.text().await?;
437
438    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
439        Ok(())
440    } else {
441        let local_var_entity: Option<SendsIdFileFileIdPostError> =
442            serde_json::from_str(&local_var_content).ok();
443        let local_var_error = ResponseContent {
444            status: local_var_status,
445            content: local_var_content,
446            entity: local_var_entity,
447        };
448        Err(Error::ResponseError(local_var_error))
449    }
450}
451
452pub async fn sends_id_get(
453    configuration: &configuration::Configuration,
454    id: &str,
455) -> Result<models::SendResponseModel, Error<SendsIdGetError>> {
456    let local_var_configuration = configuration;
457
458    let local_var_client = &local_var_configuration.client;
459
460    let local_var_uri_str = format!(
461        "{}/sends/{id}",
462        local_var_configuration.base_path,
463        id = crate::apis::urlencode(id)
464    );
465    let mut local_var_req_builder =
466        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
467
468    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
469        local_var_req_builder =
470            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
471    }
472    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
473        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
474    };
475
476    let local_var_req = local_var_req_builder.build()?;
477    let local_var_resp = local_var_client.execute(local_var_req).await?;
478
479    let local_var_status = local_var_resp.status();
480    let local_var_content = local_var_resp.text().await?;
481
482    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
483        serde_json::from_str(&local_var_content).map_err(Error::from)
484    } else {
485        let local_var_entity: Option<SendsIdGetError> =
486            serde_json::from_str(&local_var_content).ok();
487        let local_var_error = ResponseContent {
488            status: local_var_status,
489            content: local_var_content,
490            entity: local_var_entity,
491        };
492        Err(Error::ResponseError(local_var_error))
493    }
494}
495
496pub async fn sends_id_put(
497    configuration: &configuration::Configuration,
498    id: &str,
499    send_request_model: Option<models::SendRequestModel>,
500) -> Result<models::SendResponseModel, Error<SendsIdPutError>> {
501    let local_var_configuration = configuration;
502
503    let local_var_client = &local_var_configuration.client;
504
505    let local_var_uri_str = format!(
506        "{}/sends/{id}",
507        local_var_configuration.base_path,
508        id = crate::apis::urlencode(id)
509    );
510    let mut local_var_req_builder =
511        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
512
513    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
514        local_var_req_builder =
515            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
516    }
517    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
518        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
519    };
520    local_var_req_builder = local_var_req_builder.json(&send_request_model);
521
522    let local_var_req = local_var_req_builder.build()?;
523    let local_var_resp = local_var_client.execute(local_var_req).await?;
524
525    let local_var_status = local_var_resp.status();
526    let local_var_content = local_var_resp.text().await?;
527
528    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
529        serde_json::from_str(&local_var_content).map_err(Error::from)
530    } else {
531        let local_var_entity: Option<SendsIdPutError> =
532            serde_json::from_str(&local_var_content).ok();
533        let local_var_error = ResponseContent {
534            status: local_var_status,
535            content: local_var_content,
536            entity: local_var_entity,
537        };
538        Err(Error::ResponseError(local_var_error))
539    }
540}
541
542pub async fn sends_id_remove_password_put(
543    configuration: &configuration::Configuration,
544    id: &str,
545) -> Result<models::SendResponseModel, Error<SendsIdRemovePasswordPutError>> {
546    let local_var_configuration = configuration;
547
548    let local_var_client = &local_var_configuration.client;
549
550    let local_var_uri_str = format!(
551        "{}/sends/{id}/remove-password",
552        local_var_configuration.base_path,
553        id = crate::apis::urlencode(id)
554    );
555    let mut local_var_req_builder =
556        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
557
558    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
559        local_var_req_builder =
560            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
561    }
562    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
563        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
564    };
565
566    let local_var_req = local_var_req_builder.build()?;
567    let local_var_resp = local_var_client.execute(local_var_req).await?;
568
569    let local_var_status = local_var_resp.status();
570    let local_var_content = local_var_resp.text().await?;
571
572    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
573        serde_json::from_str(&local_var_content).map_err(Error::from)
574    } else {
575        let local_var_entity: Option<SendsIdRemovePasswordPutError> =
576            serde_json::from_str(&local_var_content).ok();
577        let local_var_error = ResponseContent {
578            status: local_var_status,
579            content: local_var_content,
580            entity: local_var_entity,
581        };
582        Err(Error::ResponseError(local_var_error))
583    }
584}
585
586pub async fn sends_post(
587    configuration: &configuration::Configuration,
588    send_request_model: Option<models::SendRequestModel>,
589) -> Result<models::SendResponseModel, Error<SendsPostError>> {
590    let local_var_configuration = configuration;
591
592    let local_var_client = &local_var_configuration.client;
593
594    let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
595    let mut local_var_req_builder =
596        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
597
598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599        local_var_req_builder =
600            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
601    }
602    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
603        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604    };
605    local_var_req_builder = local_var_req_builder.json(&send_request_model);
606
607    let local_var_req = local_var_req_builder.build()?;
608    let local_var_resp = local_var_client.execute(local_var_req).await?;
609
610    let local_var_status = local_var_resp.status();
611    let local_var_content = local_var_resp.text().await?;
612
613    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
614        serde_json::from_str(&local_var_content).map_err(Error::from)
615    } else {
616        let local_var_entity: Option<SendsPostError> =
617            serde_json::from_str(&local_var_content).ok();
618        let local_var_error = ResponseContent {
619            status: local_var_status,
620            content: local_var_content,
621            entity: local_var_entity,
622        };
623        Err(Error::ResponseError(local_var_error))
624    }
625}