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