bitwarden_api_api/apis/
secret_versions_api.rs1use 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 SecretVersionsApi: Send + Sync {
29 async fn bulk_delete<'a>(
31 &self,
32 uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
33 ) -> Result<(), Error<BulkDeleteError>>;
34
35 async fn get_by_id<'a>(
37 &self,
38 id: uuid::Uuid,
39 ) -> Result<models::SecretVersionResponseModel, Error<GetByIdError>>;
40
41 async fn get_many_by_ids<'a>(
43 &self,
44 uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
45 ) -> Result<models::SecretVersionResponseModelListResponseModel, Error<GetManyByIdsError>>;
46
47 async fn get_versions_by_secret_id<'a>(
49 &self,
50 secret_id: uuid::Uuid,
51 ) -> Result<
52 models::SecretVersionResponseModelListResponseModel,
53 Error<GetVersionsBySecretIdError>,
54 >;
55
56 async fn restore_version<'a>(
58 &self,
59 secret_id: uuid::Uuid,
60 restore_secret_version_request_model: Option<models::RestoreSecretVersionRequestModel>,
61 ) -> Result<models::SecretResponseModel, Error<RestoreVersionError>>;
62}
63
64pub struct SecretVersionsApiClient {
65 configuration: Arc<configuration::Configuration>,
66}
67
68impl SecretVersionsApiClient {
69 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
70 Self { configuration }
71 }
72}
73
74#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
75#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
76impl SecretVersionsApi for SecretVersionsApiClient {
77 async fn bulk_delete<'a>(
78 &self,
79 uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
80 ) -> Result<(), Error<BulkDeleteError>> {
81 let local_var_configuration = &self.configuration;
82
83 let local_var_client = &local_var_configuration.client;
84
85 let local_var_uri_str = format!(
86 "{}/secret-versions/delete",
87 local_var_configuration.base_path
88 );
89 let mut local_var_req_builder =
90 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
91
92 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
93 local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
94
95 bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
96 }
97
98 async fn get_by_id<'a>(
99 &self,
100 id: uuid::Uuid,
101 ) -> Result<models::SecretVersionResponseModel, Error<GetByIdError>> {
102 let local_var_configuration = &self.configuration;
103
104 let local_var_client = &local_var_configuration.client;
105
106 let local_var_uri_str = format!(
107 "{}/secret-versions/{id}",
108 local_var_configuration.base_path,
109 id = id
110 );
111 let mut local_var_req_builder =
112 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
115
116 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
117 }
118
119 async fn get_many_by_ids<'a>(
120 &self,
121 uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
122 ) -> Result<models::SecretVersionResponseModelListResponseModel, Error<GetManyByIdsError>> {
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!(
128 "{}/secret-versions/get-by-ids",
129 local_var_configuration.base_path
130 );
131 let mut local_var_req_builder =
132 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
133
134 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
135 local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
136
137 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
138 }
139
140 async fn get_versions_by_secret_id<'a>(
141 &self,
142 secret_id: uuid::Uuid,
143 ) -> Result<
144 models::SecretVersionResponseModelListResponseModel,
145 Error<GetVersionsBySecretIdError>,
146 > {
147 let local_var_configuration = &self.configuration;
148
149 let local_var_client = &local_var_configuration.client;
150
151 let local_var_uri_str = format!(
152 "{}/secrets/{secretId}/versions",
153 local_var_configuration.base_path,
154 secretId = secret_id
155 );
156 let mut local_var_req_builder =
157 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
158
159 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
160
161 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
162 }
163
164 async fn restore_version<'a>(
165 &self,
166 secret_id: uuid::Uuid,
167 restore_secret_version_request_model: Option<models::RestoreSecretVersionRequestModel>,
168 ) -> Result<models::SecretResponseModel, Error<RestoreVersionError>> {
169 let local_var_configuration = &self.configuration;
170
171 let local_var_client = &local_var_configuration.client;
172
173 let local_var_uri_str = format!(
174 "{}/secrets/{secretId}/versions/restore",
175 local_var_configuration.base_path,
176 secretId = secret_id
177 );
178 let mut local_var_req_builder =
179 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
180
181 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
182 local_var_req_builder = local_var_req_builder.json(&restore_secret_version_request_model);
183
184 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
185 }
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(untagged)]
191pub enum BulkDeleteError {
192 UnknownValue(serde_json::Value),
193}
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum GetByIdError {
198 UnknownValue(serde_json::Value),
199}
200#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetManyByIdsError {
204 UnknownValue(serde_json::Value),
205}
206#[derive(Debug, Clone, Serialize, Deserialize)]
208#[serde(untagged)]
209pub enum GetVersionsBySecretIdError {
210 UnknownValue(serde_json::Value),
211}
212#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum RestoreVersionError {
216 UnknownValue(serde_json::Value),
217}