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::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, 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    // add a prefix to parameters to efficiently prevent name collisions
107    let p_id = id;
108    let p_send_access_request_model = send_access_request_model;
109
110    let uri_str = format!(
111        "{}/sends/access/{id}",
112        configuration.base_path,
113        id = crate::apis::urlencode(p_id)
114    );
115    let mut req_builder = configuration
116        .client
117        .request(reqwest::Method::POST, &uri_str);
118
119    if let Some(ref user_agent) = configuration.user_agent {
120        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
121    }
122    if let Some(ref token) = configuration.oauth_access_token {
123        req_builder = req_builder.bearer_auth(token.to_owned());
124    };
125    req_builder = req_builder.json(&p_send_access_request_model);
126
127    let req = req_builder.build()?;
128    let resp = configuration.client.execute(req).await?;
129
130    let status = resp.status();
131
132    if !status.is_client_error() && !status.is_server_error() {
133        Ok(())
134    } else {
135        let content = resp.text().await?;
136        let entity: Option<SendsAccessIdPostError> = serde_json::from_str(&content).ok();
137        Err(Error::ResponseError(ResponseContent {
138            status,
139            content,
140            entity,
141        }))
142    }
143}
144
145pub async fn sends_encoded_send_id_access_file_file_id_post(
146    configuration: &configuration::Configuration,
147    encoded_send_id: &str,
148    file_id: &str,
149    send_access_request_model: Option<models::SendAccessRequestModel>,
150) -> Result<(), Error<SendsEncodedSendIdAccessFileFileIdPostError>> {
151    // add a prefix to parameters to efficiently prevent name collisions
152    let p_encoded_send_id = encoded_send_id;
153    let p_file_id = file_id;
154    let p_send_access_request_model = send_access_request_model;
155
156    let uri_str = format!(
157        "{}/sends/{encodedSendId}/access/file/{fileId}",
158        configuration.base_path,
159        encodedSendId = crate::apis::urlencode(p_encoded_send_id),
160        fileId = crate::apis::urlencode(p_file_id)
161    );
162    let mut req_builder = configuration
163        .client
164        .request(reqwest::Method::POST, &uri_str);
165
166    if let Some(ref user_agent) = configuration.user_agent {
167        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
168    }
169    if let Some(ref token) = configuration.oauth_access_token {
170        req_builder = req_builder.bearer_auth(token.to_owned());
171    };
172    req_builder = req_builder.json(&p_send_access_request_model);
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178
179    if !status.is_client_error() && !status.is_server_error() {
180        Ok(())
181    } else {
182        let content = resp.text().await?;
183        let entity: Option<SendsEncodedSendIdAccessFileFileIdPostError> =
184            serde_json::from_str(&content).ok();
185        Err(Error::ResponseError(ResponseContent {
186            status,
187            content,
188            entity,
189        }))
190    }
191}
192
193pub async fn sends_file_v2_post(
194    configuration: &configuration::Configuration,
195    send_request_model: Option<models::SendRequestModel>,
196) -> Result<models::SendFileUploadDataResponseModel, Error<SendsFileV2PostError>> {
197    // add a prefix to parameters to efficiently prevent name collisions
198    let p_send_request_model = send_request_model;
199
200    let uri_str = format!("{}/sends/file/v2", configuration.base_path);
201    let mut req_builder = configuration
202        .client
203        .request(reqwest::Method::POST, &uri_str);
204
205    if let Some(ref user_agent) = configuration.user_agent {
206        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
207    }
208    if let Some(ref token) = configuration.oauth_access_token {
209        req_builder = req_builder.bearer_auth(token.to_owned());
210    };
211    req_builder = req_builder.json(&p_send_request_model);
212
213    let req = req_builder.build()?;
214    let resp = configuration.client.execute(req).await?;
215
216    let status = resp.status();
217    let content_type = resp
218        .headers()
219        .get("content-type")
220        .and_then(|v| v.to_str().ok())
221        .unwrap_or("application/octet-stream");
222    let content_type = super::ContentType::from(content_type);
223
224    if !status.is_client_error() && !status.is_server_error() {
225        let content = resp.text().await?;
226        match content_type {
227            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
228            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))),
229            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))),
230        }
231    } else {
232        let content = resp.text().await?;
233        let entity: Option<SendsFileV2PostError> = serde_json::from_str(&content).ok();
234        Err(Error::ResponseError(ResponseContent {
235            status,
236            content,
237            entity,
238        }))
239    }
240}
241
242pub async fn sends_file_validate_azure_post(
243    configuration: &configuration::Configuration,
244) -> Result<(), Error<SendsFileValidateAzurePostError>> {
245    let uri_str = format!("{}/sends/file/validate/azure", configuration.base_path);
246    let mut req_builder = configuration
247        .client
248        .request(reqwest::Method::POST, &uri_str);
249
250    if let Some(ref user_agent) = configuration.user_agent {
251        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252    }
253    if let Some(ref token) = configuration.oauth_access_token {
254        req_builder = req_builder.bearer_auth(token.to_owned());
255    };
256
257    let req = req_builder.build()?;
258    let resp = configuration.client.execute(req).await?;
259
260    let status = resp.status();
261
262    if !status.is_client_error() && !status.is_server_error() {
263        Ok(())
264    } else {
265        let content = resp.text().await?;
266        let entity: Option<SendsFileValidateAzurePostError> = serde_json::from_str(&content).ok();
267        Err(Error::ResponseError(ResponseContent {
268            status,
269            content,
270            entity,
271        }))
272    }
273}
274
275pub async fn sends_get(
276    configuration: &configuration::Configuration,
277) -> Result<models::SendResponseModelListResponseModel, Error<SendsGetError>> {
278    let uri_str = format!("{}/sends", configuration.base_path);
279    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
280
281    if let Some(ref user_agent) = configuration.user_agent {
282        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
283    }
284    if let Some(ref token) = configuration.oauth_access_token {
285        req_builder = req_builder.bearer_auth(token.to_owned());
286    };
287
288    let req = req_builder.build()?;
289    let resp = configuration.client.execute(req).await?;
290
291    let status = resp.status();
292    let content_type = resp
293        .headers()
294        .get("content-type")
295        .and_then(|v| v.to_str().ok())
296        .unwrap_or("application/octet-stream");
297    let content_type = super::ContentType::from(content_type);
298
299    if !status.is_client_error() && !status.is_server_error() {
300        let content = resp.text().await?;
301        match content_type {
302            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
303            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModelListResponseModel`"))),
304            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModelListResponseModel`")))),
305        }
306    } else {
307        let content = resp.text().await?;
308        let entity: Option<SendsGetError> = serde_json::from_str(&content).ok();
309        Err(Error::ResponseError(ResponseContent {
310            status,
311            content,
312            entity,
313        }))
314    }
315}
316
317pub async fn sends_id_delete(
318    configuration: &configuration::Configuration,
319    id: &str,
320) -> Result<(), Error<SendsIdDeleteError>> {
321    // add a prefix to parameters to efficiently prevent name collisions
322    let p_id = id;
323
324    let uri_str = format!(
325        "{}/sends/{id}",
326        configuration.base_path,
327        id = crate::apis::urlencode(p_id)
328    );
329    let mut req_builder = configuration
330        .client
331        .request(reqwest::Method::DELETE, &uri_str);
332
333    if let Some(ref user_agent) = configuration.user_agent {
334        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
335    }
336    if let Some(ref token) = configuration.oauth_access_token {
337        req_builder = req_builder.bearer_auth(token.to_owned());
338    };
339
340    let req = req_builder.build()?;
341    let resp = configuration.client.execute(req).await?;
342
343    let status = resp.status();
344
345    if !status.is_client_error() && !status.is_server_error() {
346        Ok(())
347    } else {
348        let content = resp.text().await?;
349        let entity: Option<SendsIdDeleteError> = serde_json::from_str(&content).ok();
350        Err(Error::ResponseError(ResponseContent {
351            status,
352            content,
353            entity,
354        }))
355    }
356}
357
358pub async fn sends_id_file_file_id_get(
359    configuration: &configuration::Configuration,
360    id: &str,
361    file_id: &str,
362) -> Result<models::SendFileUploadDataResponseModel, Error<SendsIdFileFileIdGetError>> {
363    // add a prefix to parameters to efficiently prevent name collisions
364    let p_id = id;
365    let p_file_id = file_id;
366
367    let uri_str = format!(
368        "{}/sends/{id}/file/{fileId}",
369        configuration.base_path,
370        id = crate::apis::urlencode(p_id),
371        fileId = crate::apis::urlencode(p_file_id)
372    );
373    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
374
375    if let Some(ref user_agent) = configuration.user_agent {
376        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
377    }
378    if let Some(ref token) = configuration.oauth_access_token {
379        req_builder = req_builder.bearer_auth(token.to_owned());
380    };
381
382    let req = req_builder.build()?;
383    let resp = configuration.client.execute(req).await?;
384
385    let status = resp.status();
386    let content_type = resp
387        .headers()
388        .get("content-type")
389        .and_then(|v| v.to_str().ok())
390        .unwrap_or("application/octet-stream");
391    let content_type = super::ContentType::from(content_type);
392
393    if !status.is_client_error() && !status.is_server_error() {
394        let content = resp.text().await?;
395        match content_type {
396            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
397            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))),
398            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))),
399        }
400    } else {
401        let content = resp.text().await?;
402        let entity: Option<SendsIdFileFileIdGetError> = serde_json::from_str(&content).ok();
403        Err(Error::ResponseError(ResponseContent {
404            status,
405            content,
406            entity,
407        }))
408    }
409}
410
411pub async fn sends_id_file_file_id_post(
412    configuration: &configuration::Configuration,
413    id: &str,
414    file_id: &str,
415) -> Result<(), Error<SendsIdFileFileIdPostError>> {
416    // add a prefix to parameters to efficiently prevent name collisions
417    let p_id = id;
418    let p_file_id = file_id;
419
420    let uri_str = format!(
421        "{}/sends/{id}/file/{fileId}",
422        configuration.base_path,
423        id = crate::apis::urlencode(p_id),
424        fileId = crate::apis::urlencode(p_file_id)
425    );
426    let mut req_builder = configuration
427        .client
428        .request(reqwest::Method::POST, &uri_str);
429
430    if let Some(ref user_agent) = configuration.user_agent {
431        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
432    }
433    if let Some(ref token) = configuration.oauth_access_token {
434        req_builder = req_builder.bearer_auth(token.to_owned());
435    };
436
437    let req = req_builder.build()?;
438    let resp = configuration.client.execute(req).await?;
439
440    let status = resp.status();
441
442    if !status.is_client_error() && !status.is_server_error() {
443        Ok(())
444    } else {
445        let content = resp.text().await?;
446        let entity: Option<SendsIdFileFileIdPostError> = serde_json::from_str(&content).ok();
447        Err(Error::ResponseError(ResponseContent {
448            status,
449            content,
450            entity,
451        }))
452    }
453}
454
455pub async fn sends_id_get(
456    configuration: &configuration::Configuration,
457    id: &str,
458) -> Result<models::SendResponseModel, Error<SendsIdGetError>> {
459    // add a prefix to parameters to efficiently prevent name collisions
460    let p_id = id;
461
462    let uri_str = format!(
463        "{}/sends/{id}",
464        configuration.base_path,
465        id = crate::apis::urlencode(p_id)
466    );
467    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
468
469    if let Some(ref user_agent) = configuration.user_agent {
470        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
471    }
472    if let Some(ref token) = configuration.oauth_access_token {
473        req_builder = req_builder.bearer_auth(token.to_owned());
474    };
475
476    let req = req_builder.build()?;
477    let resp = configuration.client.execute(req).await?;
478
479    let status = resp.status();
480    let content_type = resp
481        .headers()
482        .get("content-type")
483        .and_then(|v| v.to_str().ok())
484        .unwrap_or("application/octet-stream");
485    let content_type = super::ContentType::from(content_type);
486
487    if !status.is_client_error() && !status.is_server_error() {
488        let content = resp.text().await?;
489        match content_type {
490            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
491            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))),
492            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))),
493        }
494    } else {
495        let content = resp.text().await?;
496        let entity: Option<SendsIdGetError> = serde_json::from_str(&content).ok();
497        Err(Error::ResponseError(ResponseContent {
498            status,
499            content,
500            entity,
501        }))
502    }
503}
504
505pub async fn sends_id_put(
506    configuration: &configuration::Configuration,
507    id: &str,
508    send_request_model: Option<models::SendRequestModel>,
509) -> Result<models::SendResponseModel, Error<SendsIdPutError>> {
510    // add a prefix to parameters to efficiently prevent name collisions
511    let p_id = id;
512    let p_send_request_model = send_request_model;
513
514    let uri_str = format!(
515        "{}/sends/{id}",
516        configuration.base_path,
517        id = crate::apis::urlencode(p_id)
518    );
519    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
520
521    if let Some(ref user_agent) = configuration.user_agent {
522        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
523    }
524    if let Some(ref token) = configuration.oauth_access_token {
525        req_builder = req_builder.bearer_auth(token.to_owned());
526    };
527    req_builder = req_builder.json(&p_send_request_model);
528
529    let req = req_builder.build()?;
530    let resp = configuration.client.execute(req).await?;
531
532    let status = resp.status();
533    let content_type = resp
534        .headers()
535        .get("content-type")
536        .and_then(|v| v.to_str().ok())
537        .unwrap_or("application/octet-stream");
538    let content_type = super::ContentType::from(content_type);
539
540    if !status.is_client_error() && !status.is_server_error() {
541        let content = resp.text().await?;
542        match content_type {
543            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))),
545            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))),
546        }
547    } else {
548        let content = resp.text().await?;
549        let entity: Option<SendsIdPutError> = serde_json::from_str(&content).ok();
550        Err(Error::ResponseError(ResponseContent {
551            status,
552            content,
553            entity,
554        }))
555    }
556}
557
558pub async fn sends_id_remove_password_put(
559    configuration: &configuration::Configuration,
560    id: &str,
561) -> Result<models::SendResponseModel, Error<SendsIdRemovePasswordPutError>> {
562    // add a prefix to parameters to efficiently prevent name collisions
563    let p_id = id;
564
565    let uri_str = format!(
566        "{}/sends/{id}/remove-password",
567        configuration.base_path,
568        id = crate::apis::urlencode(p_id)
569    );
570    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
571
572    if let Some(ref user_agent) = configuration.user_agent {
573        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
574    }
575    if let Some(ref token) = configuration.oauth_access_token {
576        req_builder = req_builder.bearer_auth(token.to_owned());
577    };
578
579    let req = req_builder.build()?;
580    let resp = configuration.client.execute(req).await?;
581
582    let status = resp.status();
583    let content_type = resp
584        .headers()
585        .get("content-type")
586        .and_then(|v| v.to_str().ok())
587        .unwrap_or("application/octet-stream");
588    let content_type = super::ContentType::from(content_type);
589
590    if !status.is_client_error() && !status.is_server_error() {
591        let content = resp.text().await?;
592        match content_type {
593            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
594            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))),
595            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))),
596        }
597    } else {
598        let content = resp.text().await?;
599        let entity: Option<SendsIdRemovePasswordPutError> = serde_json::from_str(&content).ok();
600        Err(Error::ResponseError(ResponseContent {
601            status,
602            content,
603            entity,
604        }))
605    }
606}
607
608pub async fn sends_post(
609    configuration: &configuration::Configuration,
610    send_request_model: Option<models::SendRequestModel>,
611) -> Result<models::SendResponseModel, Error<SendsPostError>> {
612    // add a prefix to parameters to efficiently prevent name collisions
613    let p_send_request_model = send_request_model;
614
615    let uri_str = format!("{}/sends", configuration.base_path);
616    let mut req_builder = configuration
617        .client
618        .request(reqwest::Method::POST, &uri_str);
619
620    if let Some(ref user_agent) = configuration.user_agent {
621        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
622    }
623    if let Some(ref token) = configuration.oauth_access_token {
624        req_builder = req_builder.bearer_auth(token.to_owned());
625    };
626    req_builder = req_builder.json(&p_send_request_model);
627
628    let req = req_builder.build()?;
629    let resp = configuration.client.execute(req).await?;
630
631    let status = resp.status();
632    let content_type = resp
633        .headers()
634        .get("content-type")
635        .and_then(|v| v.to_str().ok())
636        .unwrap_or("application/octet-stream");
637    let content_type = super::ContentType::from(content_type);
638
639    if !status.is_client_error() && !status.is_server_error() {
640        let content = resp.text().await?;
641        match content_type {
642            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
643            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))),
644            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))),
645        }
646    } else {
647        let content = resp.text().await?;
648        let entity: Option<SendsPostError> = serde_json::from_str(&content).ok();
649        Err(Error::ResponseError(ResponseContent {
650            status,
651            content,
652            entity,
653        }))
654    }
655}