Skip to main content

bitwarden_api_api/apis/
folders_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 FoldersApi: Send + Sync {
29    /// DELETE /folders/{id}
30    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error>;
31
32    /// DELETE /folders/all
33    async fn delete_all(&self) -> Result<(), Error>;
34
35    /// GET /folders/{id}
36    async fn get<'a>(&self, id: &'a str) -> Result<models::FolderResponseModel, Error>;
37
38    /// GET /folders
39    async fn get_all(&self) -> Result<models::FolderResponseModelListResponseModel, Error>;
40
41    /// POST /folders
42    async fn post<'a>(
43        &self,
44        folder_request_model: Option<models::FolderRequestModel>,
45    ) -> Result<models::FolderResponseModel, Error>;
46
47    /// PUT /folders/{id}
48    async fn put<'a>(
49        &self,
50        id: &'a str,
51        folder_request_model: Option<models::FolderRequestModel>,
52    ) -> Result<models::FolderResponseModel, Error>;
53}
54
55pub struct FoldersApiClient {
56    configuration: Arc<configuration::Configuration>,
57}
58
59impl FoldersApiClient {
60    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
61        Self { configuration }
62    }
63}
64
65#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
66#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
67impl FoldersApi for FoldersApiClient {
68    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error> {
69        let local_var_configuration = &self.configuration;
70
71        let local_var_client = &local_var_configuration.client;
72
73        let local_var_uri_str = format!(
74            "{}/folders/{id}",
75            local_var_configuration.base_path,
76            id = crate::apis::urlencode(id)
77        );
78        let mut local_var_req_builder =
79            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
80
81        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
82
83        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
84    }
85
86    async fn delete_all(&self) -> Result<(), Error> {
87        let local_var_configuration = &self.configuration;
88
89        let local_var_client = &local_var_configuration.client;
90
91        let local_var_uri_str = format!("{}/folders/all", local_var_configuration.base_path);
92        let mut local_var_req_builder =
93            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
94
95        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
96
97        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
98    }
99
100    async fn get<'a>(&self, id: &'a str) -> Result<models::FolderResponseModel, Error> {
101        let local_var_configuration = &self.configuration;
102
103        let local_var_client = &local_var_configuration.client;
104
105        let local_var_uri_str = format!(
106            "{}/folders/{id}",
107            local_var_configuration.base_path,
108            id = crate::apis::urlencode(id)
109        );
110        let mut local_var_req_builder =
111            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
112
113        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
114
115        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
116    }
117
118    async fn get_all(&self) -> Result<models::FolderResponseModelListResponseModel, Error> {
119        let local_var_configuration = &self.configuration;
120
121        let local_var_client = &local_var_configuration.client;
122
123        let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path);
124        let mut local_var_req_builder =
125            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
126
127        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
128
129        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
130    }
131
132    async fn post<'a>(
133        &self,
134        folder_request_model: Option<models::FolderRequestModel>,
135    ) -> Result<models::FolderResponseModel, Error> {
136        let local_var_configuration = &self.configuration;
137
138        let local_var_client = &local_var_configuration.client;
139
140        let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path);
141        let mut local_var_req_builder =
142            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
143
144        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
145        local_var_req_builder = local_var_req_builder.json(&folder_request_model);
146
147        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
148    }
149
150    async fn put<'a>(
151        &self,
152        id: &'a str,
153        folder_request_model: Option<models::FolderRequestModel>,
154    ) -> Result<models::FolderResponseModel, Error> {
155        let local_var_configuration = &self.configuration;
156
157        let local_var_client = &local_var_configuration.client;
158
159        let local_var_uri_str = format!(
160            "{}/folders/{id}",
161            local_var_configuration.base_path,
162            id = crate::apis::urlencode(id)
163        );
164        let mut local_var_req_builder =
165            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
166
167        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
168        local_var_req_builder = local_var_req_builder.json(&folder_request_model);
169
170        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
171    }
172}