Skip to main content

bitwarden_api_api/apis/
secrets_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 SecretsApi: Send + Sync {
29    /// POST /secrets/delete
30    async fn bulk_delete<'a>(
31        &self,
32        uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
33    ) -> Result<models::BulkDeleteResponseModelListResponseModel, Error<BulkDeleteError>>;
34
35    /// POST /organizations/{organizationId}/secrets
36    async fn create<'a>(
37        &self,
38        organization_id: uuid::Uuid,
39        secret_create_request_model: Option<models::SecretCreateRequestModel>,
40    ) -> Result<models::SecretResponseModel, Error<CreateError>>;
41
42    /// GET /secrets/{id}
43    async fn get<'a>(&self, id: uuid::Uuid)
44    -> Result<models::SecretResponseModel, Error<GetError>>;
45
46    /// POST /secrets/get-by-ids
47    async fn get_secrets_by_ids<'a>(
48        &self,
49        get_secrets_request_model: Option<models::GetSecretsRequestModel>,
50    ) -> Result<models::BaseSecretResponseModelListResponseModel, Error<GetSecretsByIdsError>>;
51
52    /// GET /projects/{projectId}/secrets
53    async fn get_secrets_by_project<'a>(
54        &self,
55        project_id: uuid::Uuid,
56    ) -> Result<models::SecretWithProjectsListResponseModel, Error<GetSecretsByProjectError>>;
57
58    /// GET /organizations/{organizationId}/secrets/sync
59    async fn get_secrets_sync<'a>(
60        &self,
61        organization_id: uuid::Uuid,
62        last_synced_date: Option<String>,
63    ) -> Result<models::SecretsSyncResponseModel, Error<GetSecretsSyncError>>;
64
65    /// GET /organizations/{organizationId}/secrets
66    async fn list_by_organization<'a>(
67        &self,
68        organization_id: uuid::Uuid,
69    ) -> Result<models::SecretWithProjectsListResponseModel, Error<ListByOrganizationError>>;
70
71    /// PUT /secrets/{id}
72    async fn update_secret<'a>(
73        &self,
74        id: uuid::Uuid,
75        secret_update_request_model: Option<models::SecretUpdateRequestModel>,
76    ) -> Result<models::SecretResponseModel, Error<UpdateSecretError>>;
77}
78
79pub struct SecretsApiClient {
80    configuration: Arc<configuration::Configuration>,
81}
82
83impl SecretsApiClient {
84    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
85        Self { configuration }
86    }
87}
88
89#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
90#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
91impl SecretsApi for SecretsApiClient {
92    async fn bulk_delete<'a>(
93        &self,
94        uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
95    ) -> Result<models::BulkDeleteResponseModelListResponseModel, Error<BulkDeleteError>> {
96        let local_var_configuration = &self.configuration;
97
98        let local_var_client = &local_var_configuration.client;
99
100        let local_var_uri_str = format!("{}/secrets/delete", local_var_configuration.base_path);
101        let mut local_var_req_builder =
102            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
103
104        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
105        local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
106
107        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
108    }
109
110    async fn create<'a>(
111        &self,
112        organization_id: uuid::Uuid,
113        secret_create_request_model: Option<models::SecretCreateRequestModel>,
114    ) -> Result<models::SecretResponseModel, Error<CreateError>> {
115        let local_var_configuration = &self.configuration;
116
117        let local_var_client = &local_var_configuration.client;
118
119        let local_var_uri_str = format!(
120            "{}/organizations/{organizationId}/secrets",
121            local_var_configuration.base_path,
122            organizationId = organization_id
123        );
124        let mut local_var_req_builder =
125            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
126
127        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
128        local_var_req_builder = local_var_req_builder.json(&secret_create_request_model);
129
130        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
131    }
132
133    async fn get<'a>(
134        &self,
135        id: uuid::Uuid,
136    ) -> Result<models::SecretResponseModel, Error<GetError>> {
137        let local_var_configuration = &self.configuration;
138
139        let local_var_client = &local_var_configuration.client;
140
141        let local_var_uri_str = format!(
142            "{}/secrets/{id}",
143            local_var_configuration.base_path,
144            id = id
145        );
146        let mut local_var_req_builder =
147            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
148
149        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
150
151        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
152    }
153
154    async fn get_secrets_by_ids<'a>(
155        &self,
156        get_secrets_request_model: Option<models::GetSecretsRequestModel>,
157    ) -> Result<models::BaseSecretResponseModelListResponseModel, Error<GetSecretsByIdsError>> {
158        let local_var_configuration = &self.configuration;
159
160        let local_var_client = &local_var_configuration.client;
161
162        let local_var_uri_str = format!("{}/secrets/get-by-ids", local_var_configuration.base_path);
163        let mut local_var_req_builder =
164            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
165
166        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
167        local_var_req_builder = local_var_req_builder.json(&get_secrets_request_model);
168
169        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
170    }
171
172    async fn get_secrets_by_project<'a>(
173        &self,
174        project_id: uuid::Uuid,
175    ) -> Result<models::SecretWithProjectsListResponseModel, Error<GetSecretsByProjectError>> {
176        let local_var_configuration = &self.configuration;
177
178        let local_var_client = &local_var_configuration.client;
179
180        let local_var_uri_str = format!(
181            "{}/projects/{projectId}/secrets",
182            local_var_configuration.base_path,
183            projectId = project_id
184        );
185        let mut local_var_req_builder =
186            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
187
188        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
189
190        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
191    }
192
193    async fn get_secrets_sync<'a>(
194        &self,
195        organization_id: uuid::Uuid,
196        last_synced_date: Option<String>,
197    ) -> Result<models::SecretsSyncResponseModel, Error<GetSecretsSyncError>> {
198        let local_var_configuration = &self.configuration;
199
200        let local_var_client = &local_var_configuration.client;
201
202        let local_var_uri_str = format!(
203            "{}/organizations/{organizationId}/secrets/sync",
204            local_var_configuration.base_path,
205            organizationId = organization_id
206        );
207        let mut local_var_req_builder =
208            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
209
210        if let Some(ref param_value) = last_synced_date {
211            local_var_req_builder =
212                local_var_req_builder.query(&[("lastSyncedDate", &param_value.to_string())]);
213        }
214        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
215
216        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
217    }
218
219    async fn list_by_organization<'a>(
220        &self,
221        organization_id: uuid::Uuid,
222    ) -> Result<models::SecretWithProjectsListResponseModel, Error<ListByOrganizationError>> {
223        let local_var_configuration = &self.configuration;
224
225        let local_var_client = &local_var_configuration.client;
226
227        let local_var_uri_str = format!(
228            "{}/organizations/{organizationId}/secrets",
229            local_var_configuration.base_path,
230            organizationId = organization_id
231        );
232        let mut local_var_req_builder =
233            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
234
235        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
236
237        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
238    }
239
240    async fn update_secret<'a>(
241        &self,
242        id: uuid::Uuid,
243        secret_update_request_model: Option<models::SecretUpdateRequestModel>,
244    ) -> Result<models::SecretResponseModel, Error<UpdateSecretError>> {
245        let local_var_configuration = &self.configuration;
246
247        let local_var_client = &local_var_configuration.client;
248
249        let local_var_uri_str = format!(
250            "{}/secrets/{id}",
251            local_var_configuration.base_path,
252            id = id
253        );
254        let mut local_var_req_builder =
255            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
256
257        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
258        local_var_req_builder = local_var_req_builder.json(&secret_update_request_model);
259
260        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
261    }
262}
263
264/// struct for typed errors of method [`SecretsApi::bulk_delete`]
265#[derive(Debug, Clone, Serialize, Deserialize)]
266#[serde(untagged)]
267pub enum BulkDeleteError {
268    UnknownValue(serde_json::Value),
269}
270/// struct for typed errors of method [`SecretsApi::create`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum CreateError {
274    UnknownValue(serde_json::Value),
275}
276/// struct for typed errors of method [`SecretsApi::get`]
277#[derive(Debug, Clone, Serialize, Deserialize)]
278#[serde(untagged)]
279pub enum GetError {
280    UnknownValue(serde_json::Value),
281}
282/// struct for typed errors of method [`SecretsApi::get_secrets_by_ids`]
283#[derive(Debug, Clone, Serialize, Deserialize)]
284#[serde(untagged)]
285pub enum GetSecretsByIdsError {
286    UnknownValue(serde_json::Value),
287}
288/// struct for typed errors of method [`SecretsApi::get_secrets_by_project`]
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum GetSecretsByProjectError {
292    UnknownValue(serde_json::Value),
293}
294/// struct for typed errors of method [`SecretsApi::get_secrets_sync`]
295#[derive(Debug, Clone, Serialize, Deserialize)]
296#[serde(untagged)]
297pub enum GetSecretsSyncError {
298    UnknownValue(serde_json::Value),
299}
300/// struct for typed errors of method [`SecretsApi::list_by_organization`]
301#[derive(Debug, Clone, Serialize, Deserialize)]
302#[serde(untagged)]
303pub enum ListByOrganizationError {
304    UnknownValue(serde_json::Value),
305}
306/// struct for typed errors of method [`SecretsApi::update_secret`]
307#[derive(Debug, Clone, Serialize, Deserialize)]
308#[serde(untagged)]
309pub enum UpdateSecretError {
310    UnknownValue(serde_json::Value),
311}