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<DeleteError>>;
31
32    /// DELETE /folders/all
33    async fn delete_all(&self) -> Result<(), Error<DeleteAllError>>;
34
35    /// GET /folders/{id}
36    async fn get<'a>(&self, id: &'a str) -> Result<models::FolderResponseModel, Error<GetError>>;
37
38    /// GET /folders
39    async fn get_all(
40        &self,
41    ) -> Result<models::FolderResponseModelListResponseModel, Error<GetAllError>>;
42
43    /// POST /folders
44    async fn post<'a>(
45        &self,
46        folder_request_model: Option<models::FolderRequestModel>,
47    ) -> Result<models::FolderResponseModel, Error<PostError>>;
48
49    /// PUT /folders/{id}
50    async fn put<'a>(
51        &self,
52        id: &'a str,
53        folder_request_model: Option<models::FolderRequestModel>,
54    ) -> Result<models::FolderResponseModel, Error<PutError>>;
55}
56
57pub struct FoldersApiClient {
58    configuration: Arc<configuration::Configuration>,
59}
60
61impl FoldersApiClient {
62    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
63        Self { configuration }
64    }
65}
66
67#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
68#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
69impl FoldersApi for FoldersApiClient {
70    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error<DeleteError>> {
71        let local_var_configuration = &self.configuration;
72
73        let local_var_client = &local_var_configuration.client;
74
75        let local_var_uri_str = format!(
76            "{}/folders/{id}",
77            local_var_configuration.base_path,
78            id = crate::apis::urlencode(id)
79        );
80        let mut local_var_req_builder =
81            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
82
83        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
84
85        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
86    }
87
88    async fn delete_all(&self) -> Result<(), Error<DeleteAllError>> {
89        let local_var_configuration = &self.configuration;
90
91        let local_var_client = &local_var_configuration.client;
92
93        let local_var_uri_str = format!("{}/folders/all", local_var_configuration.base_path);
94        let mut local_var_req_builder =
95            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
96
97        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
98
99        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
100    }
101
102    async fn get<'a>(&self, id: &'a str) -> Result<models::FolderResponseModel, Error<GetError>> {
103        let local_var_configuration = &self.configuration;
104
105        let local_var_client = &local_var_configuration.client;
106
107        let local_var_uri_str = format!(
108            "{}/folders/{id}",
109            local_var_configuration.base_path,
110            id = crate::apis::urlencode(id)
111        );
112        let mut local_var_req_builder =
113            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
114
115        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
116
117        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
118    }
119
120    async fn get_all(
121        &self,
122    ) -> Result<models::FolderResponseModelListResponseModel, Error<GetAllError>> {
123        let local_var_configuration = &self.configuration;
124
125        let local_var_client = &local_var_configuration.client;
126
127        let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path);
128        let mut local_var_req_builder =
129            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
130
131        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
132
133        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
134    }
135
136    async fn post<'a>(
137        &self,
138        folder_request_model: Option<models::FolderRequestModel>,
139    ) -> Result<models::FolderResponseModel, Error<PostError>> {
140        let local_var_configuration = &self.configuration;
141
142        let local_var_client = &local_var_configuration.client;
143
144        let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path);
145        let mut local_var_req_builder =
146            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
147
148        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
149        local_var_req_builder = local_var_req_builder.json(&folder_request_model);
150
151        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
152    }
153
154    async fn put<'a>(
155        &self,
156        id: &'a str,
157        folder_request_model: Option<models::FolderRequestModel>,
158    ) -> Result<models::FolderResponseModel, Error<PutError>> {
159        let local_var_configuration = &self.configuration;
160
161        let local_var_client = &local_var_configuration.client;
162
163        let local_var_uri_str = format!(
164            "{}/folders/{id}",
165            local_var_configuration.base_path,
166            id = crate::apis::urlencode(id)
167        );
168        let mut local_var_req_builder =
169            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
170
171        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
172        local_var_req_builder = local_var_req_builder.json(&folder_request_model);
173
174        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
175    }
176}
177
178/// struct for typed errors of method [`FoldersApi::delete`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum DeleteError {
182    UnknownValue(serde_json::Value),
183}
184/// struct for typed errors of method [`FoldersApi::delete_all`]
185#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(untagged)]
187pub enum DeleteAllError {
188    UnknownValue(serde_json::Value),
189}
190/// struct for typed errors of method [`FoldersApi::get`]
191#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum GetError {
194    UnknownValue(serde_json::Value),
195}
196/// struct for typed errors of method [`FoldersApi::get_all`]
197#[derive(Debug, Clone, Serialize, Deserialize)]
198#[serde(untagged)]
199pub enum GetAllError {
200    UnknownValue(serde_json::Value),
201}
202/// struct for typed errors of method [`FoldersApi::post`]
203#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum PostError {
206    UnknownValue(serde_json::Value),
207}
208/// struct for typed errors of method [`FoldersApi::put`]
209#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(untagged)]
211pub enum PutError {
212    UnknownValue(serde_json::Value),
213}