1use 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 EventsApi: Send + Sync {
29 async fn get_cipher<'a>(
31 &self,
32 id: &'a str,
33 start: Option<String>,
34 end: Option<String>,
35 continuation_token: Option<&'a str>,
36 ) -> Result<models::EventResponseModelListResponseModel, Error<GetCipherError>>;
37
38 async fn get_organization<'a>(
40 &self,
41 id: &'a str,
42 start: Option<String>,
43 end: Option<String>,
44 continuation_token: Option<&'a str>,
45 ) -> Result<models::EventResponseModelListResponseModel, Error<GetOrganizationError>>;
46
47 async fn get_organization_user<'a>(
49 &self,
50 org_id: &'a str,
51 id: &'a str,
52 start: Option<String>,
53 end: Option<String>,
54 continuation_token: Option<&'a str>,
55 ) -> Result<models::EventResponseModelListResponseModel, Error<GetOrganizationUserError>>;
56
57 async fn get_projects<'a>(
59 &self,
60 id: uuid::Uuid,
61 org_id: uuid::Uuid,
62 start: Option<String>,
63 end: Option<String>,
64 continuation_token: Option<&'a str>,
65 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProjectsError>>;
66
67 async fn get_provider<'a>(
69 &self,
70 provider_id: uuid::Uuid,
71 start: Option<String>,
72 end: Option<String>,
73 continuation_token: Option<&'a str>,
74 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProviderError>>;
75
76 async fn get_provider_user<'a>(
78 &self,
79 provider_id: uuid::Uuid,
80 id: uuid::Uuid,
81 start: Option<String>,
82 end: Option<String>,
83 continuation_token: Option<&'a str>,
84 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProviderUserError>>;
85
86 async fn get_secrets<'a>(
88 &self,
89 id: uuid::Uuid,
90 org_id: uuid::Uuid,
91 start: Option<String>,
92 end: Option<String>,
93 continuation_token: Option<&'a str>,
94 ) -> Result<models::EventResponseModelListResponseModel, Error<GetSecretsError>>;
95
96 async fn get_service_accounts<'a>(
98 &self,
99 org_id: uuid::Uuid,
100 id: uuid::Uuid,
101 start: Option<String>,
102 end: Option<String>,
103 continuation_token: Option<&'a str>,
104 ) -> Result<models::EventResponseModelListResponseModel, Error<GetServiceAccountsError>>;
105
106 async fn get_user<'a>(
108 &self,
109 start: Option<String>,
110 end: Option<String>,
111 continuation_token: Option<&'a str>,
112 ) -> Result<models::EventResponseModelListResponseModel, Error<GetUserError>>;
113}
114
115pub struct EventsApiClient {
116 configuration: Arc<configuration::Configuration>,
117}
118
119impl EventsApiClient {
120 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
121 Self { configuration }
122 }
123}
124
125#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
126#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
127impl EventsApi for EventsApiClient {
128 async fn get_cipher<'a>(
129 &self,
130 id: &'a str,
131 start: Option<String>,
132 end: Option<String>,
133 continuation_token: Option<&'a str>,
134 ) -> Result<models::EventResponseModelListResponseModel, Error<GetCipherError>> {
135 let local_var_configuration = &self.configuration;
136
137 let local_var_client = &local_var_configuration.client;
138
139 let local_var_uri_str = format!(
140 "{}/ciphers/{id}/events",
141 local_var_configuration.base_path,
142 id = crate::apis::urlencode(id)
143 );
144 let mut local_var_req_builder =
145 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
146
147 if let Some(ref param_value) = start {
148 local_var_req_builder =
149 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
150 }
151 if let Some(ref param_value) = end {
152 local_var_req_builder =
153 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
154 }
155 if let Some(ref param_value) = continuation_token {
156 local_var_req_builder =
157 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
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 get_organization<'a>(
165 &self,
166 id: &'a str,
167 start: Option<String>,
168 end: Option<String>,
169 continuation_token: Option<&'a str>,
170 ) -> Result<models::EventResponseModelListResponseModel, Error<GetOrganizationError>> {
171 let local_var_configuration = &self.configuration;
172
173 let local_var_client = &local_var_configuration.client;
174
175 let local_var_uri_str = format!(
176 "{}/organizations/{id}/events",
177 local_var_configuration.base_path,
178 id = crate::apis::urlencode(id)
179 );
180 let mut local_var_req_builder =
181 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
182
183 if let Some(ref param_value) = start {
184 local_var_req_builder =
185 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
186 }
187 if let Some(ref param_value) = end {
188 local_var_req_builder =
189 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
190 }
191 if let Some(ref param_value) = continuation_token {
192 local_var_req_builder =
193 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
194 }
195 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
196
197 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
198 }
199
200 async fn get_organization_user<'a>(
201 &self,
202 org_id: &'a str,
203 id: &'a str,
204 start: Option<String>,
205 end: Option<String>,
206 continuation_token: Option<&'a str>,
207 ) -> Result<models::EventResponseModelListResponseModel, Error<GetOrganizationUserError>> {
208 let local_var_configuration = &self.configuration;
209
210 let local_var_client = &local_var_configuration.client;
211
212 let local_var_uri_str = format!(
213 "{}/organizations/{orgId}/users/{id}/events",
214 local_var_configuration.base_path,
215 orgId = crate::apis::urlencode(org_id),
216 id = crate::apis::urlencode(id)
217 );
218 let mut local_var_req_builder =
219 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
220
221 if let Some(ref param_value) = start {
222 local_var_req_builder =
223 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
224 }
225 if let Some(ref param_value) = end {
226 local_var_req_builder =
227 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
228 }
229 if let Some(ref param_value) = continuation_token {
230 local_var_req_builder =
231 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
232 }
233 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
234
235 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
236 }
237
238 async fn get_projects<'a>(
239 &self,
240 id: uuid::Uuid,
241 org_id: uuid::Uuid,
242 start: Option<String>,
243 end: Option<String>,
244 continuation_token: Option<&'a str>,
245 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProjectsError>> {
246 let local_var_configuration = &self.configuration;
247
248 let local_var_client = &local_var_configuration.client;
249
250 let local_var_uri_str = format!(
251 "{}/organization/{orgId}/projects/{id}/events",
252 local_var_configuration.base_path,
253 id = id,
254 orgId = org_id
255 );
256 let mut local_var_req_builder =
257 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
258
259 if let Some(ref param_value) = start {
260 local_var_req_builder =
261 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
262 }
263 if let Some(ref param_value) = end {
264 local_var_req_builder =
265 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
266 }
267 if let Some(ref param_value) = continuation_token {
268 local_var_req_builder =
269 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
270 }
271 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
272
273 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
274 }
275
276 async fn get_provider<'a>(
277 &self,
278 provider_id: uuid::Uuid,
279 start: Option<String>,
280 end: Option<String>,
281 continuation_token: Option<&'a str>,
282 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProviderError>> {
283 let local_var_configuration = &self.configuration;
284
285 let local_var_client = &local_var_configuration.client;
286
287 let local_var_uri_str = format!(
288 "{}/providers/{providerId}/events",
289 local_var_configuration.base_path,
290 providerId = provider_id
291 );
292 let mut local_var_req_builder =
293 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
294
295 if let Some(ref param_value) = start {
296 local_var_req_builder =
297 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
298 }
299 if let Some(ref param_value) = end {
300 local_var_req_builder =
301 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
302 }
303 if let Some(ref param_value) = continuation_token {
304 local_var_req_builder =
305 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
306 }
307 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
308
309 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
310 }
311
312 async fn get_provider_user<'a>(
313 &self,
314 provider_id: uuid::Uuid,
315 id: uuid::Uuid,
316 start: Option<String>,
317 end: Option<String>,
318 continuation_token: Option<&'a str>,
319 ) -> Result<models::EventResponseModelListResponseModel, Error<GetProviderUserError>> {
320 let local_var_configuration = &self.configuration;
321
322 let local_var_client = &local_var_configuration.client;
323
324 let local_var_uri_str = format!(
325 "{}/providers/{providerId}/users/{id}/events",
326 local_var_configuration.base_path,
327 providerId = provider_id,
328 id = id
329 );
330 let mut local_var_req_builder =
331 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
332
333 if let Some(ref param_value) = start {
334 local_var_req_builder =
335 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
336 }
337 if let Some(ref param_value) = end {
338 local_var_req_builder =
339 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
340 }
341 if let Some(ref param_value) = continuation_token {
342 local_var_req_builder =
343 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
344 }
345 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
346
347 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
348 }
349
350 async fn get_secrets<'a>(
351 &self,
352 id: uuid::Uuid,
353 org_id: uuid::Uuid,
354 start: Option<String>,
355 end: Option<String>,
356 continuation_token: Option<&'a str>,
357 ) -> Result<models::EventResponseModelListResponseModel, Error<GetSecretsError>> {
358 let local_var_configuration = &self.configuration;
359
360 let local_var_client = &local_var_configuration.client;
361
362 let local_var_uri_str = format!(
363 "{}/organization/{orgId}/secrets/{id}/events",
364 local_var_configuration.base_path,
365 id = id,
366 orgId = org_id
367 );
368 let mut local_var_req_builder =
369 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
370
371 if let Some(ref param_value) = start {
372 local_var_req_builder =
373 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
374 }
375 if let Some(ref param_value) = end {
376 local_var_req_builder =
377 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
378 }
379 if let Some(ref param_value) = continuation_token {
380 local_var_req_builder =
381 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
382 }
383 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
384
385 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
386 }
387
388 async fn get_service_accounts<'a>(
389 &self,
390 org_id: uuid::Uuid,
391 id: uuid::Uuid,
392 start: Option<String>,
393 end: Option<String>,
394 continuation_token: Option<&'a str>,
395 ) -> Result<models::EventResponseModelListResponseModel, Error<GetServiceAccountsError>> {
396 let local_var_configuration = &self.configuration;
397
398 let local_var_client = &local_var_configuration.client;
399
400 let local_var_uri_str = format!(
401 "{}/organization/{orgId}/service-account/{id}/events",
402 local_var_configuration.base_path,
403 orgId = org_id,
404 id = id
405 );
406 let mut local_var_req_builder =
407 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
408
409 if let Some(ref param_value) = start {
410 local_var_req_builder =
411 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
412 }
413 if let Some(ref param_value) = end {
414 local_var_req_builder =
415 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
416 }
417 if let Some(ref param_value) = continuation_token {
418 local_var_req_builder =
419 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
420 }
421 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
422
423 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
424 }
425
426 async fn get_user<'a>(
427 &self,
428 start: Option<String>,
429 end: Option<String>,
430 continuation_token: Option<&'a str>,
431 ) -> Result<models::EventResponseModelListResponseModel, Error<GetUserError>> {
432 let local_var_configuration = &self.configuration;
433
434 let local_var_client = &local_var_configuration.client;
435
436 let local_var_uri_str = format!("{}/events", local_var_configuration.base_path);
437 let mut local_var_req_builder =
438 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
439
440 if let Some(ref param_value) = start {
441 local_var_req_builder =
442 local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
443 }
444 if let Some(ref param_value) = end {
445 local_var_req_builder =
446 local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
447 }
448 if let Some(ref param_value) = continuation_token {
449 local_var_req_builder =
450 local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
451 }
452 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
453
454 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
455 }
456}
457
458#[derive(Debug, Clone, Serialize, Deserialize)]
460#[serde(untagged)]
461pub enum GetCipherError {
462 UnknownValue(serde_json::Value),
463}
464#[derive(Debug, Clone, Serialize, Deserialize)]
466#[serde(untagged)]
467pub enum GetOrganizationError {
468 UnknownValue(serde_json::Value),
469}
470#[derive(Debug, Clone, Serialize, Deserialize)]
472#[serde(untagged)]
473pub enum GetOrganizationUserError {
474 UnknownValue(serde_json::Value),
475}
476#[derive(Debug, Clone, Serialize, Deserialize)]
478#[serde(untagged)]
479pub enum GetProjectsError {
480 UnknownValue(serde_json::Value),
481}
482#[derive(Debug, Clone, Serialize, Deserialize)]
484#[serde(untagged)]
485pub enum GetProviderError {
486 UnknownValue(serde_json::Value),
487}
488#[derive(Debug, Clone, Serialize, Deserialize)]
490#[serde(untagged)]
491pub enum GetProviderUserError {
492 UnknownValue(serde_json::Value),
493}
494#[derive(Debug, Clone, Serialize, Deserialize)]
496#[serde(untagged)]
497pub enum GetSecretsError {
498 UnknownValue(serde_json::Value),
499}
500#[derive(Debug, Clone, Serialize, Deserialize)]
502#[serde(untagged)]
503pub enum GetServiceAccountsError {
504 UnknownValue(serde_json::Value),
505}
506#[derive(Debug, Clone, Serialize, Deserialize)]
508#[serde(untagged)]
509pub enum GetUserError {
510 UnknownValue(serde_json::Value),
511}