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::{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 ReportsApi: Send + Sync {
29 async fn add_password_health_report_application<'a>(
31 &self,
32 password_health_report_application_model: Option<
33 models::PasswordHealthReportApplicationModel,
34 >,
35 ) -> Result<
36 models::PasswordHealthReportApplication,
37 Error<AddPasswordHealthReportApplicationError>,
38 >;
39
40 async fn add_password_health_report_applications<'a>(
42 &self,
43 password_health_report_application_model: Option<
44 Vec<models::PasswordHealthReportApplicationModel>,
45 >,
46 ) -> Result<
47 Vec<models::PasswordHealthReportApplication>,
48 Error<AddPasswordHealthReportApplicationsError>,
49 >;
50
51 async fn drop_password_health_report_application<'a>(
53 &self,
54 drop_password_health_report_application_request: Option<
55 models::DropPasswordHealthReportApplicationRequest,
56 >,
57 ) -> Result<(), Error<DropPasswordHealthReportApplicationError>>;
58
59 async fn get_member_access_report<'a>(
61 &self,
62 org_id: uuid::Uuid,
63 ) -> Result<Vec<models::MemberAccessDetailReportResponseModel>, Error<GetMemberAccessReportError>>;
64
65 async fn get_member_cipher_details<'a>(
67 &self,
68 org_id: uuid::Uuid,
69 ) -> Result<Vec<models::MemberCipherDetailsResponseModel>, Error<GetMemberCipherDetailsError>>;
70
71 async fn get_password_health_report_applications<'a>(
73 &self,
74 org_id: uuid::Uuid,
75 ) -> Result<
76 Vec<models::PasswordHealthReportApplication>,
77 Error<GetPasswordHealthReportApplicationsError>,
78 >;
79}
80
81pub struct ReportsApiClient {
82 configuration: Arc<configuration::Configuration>,
83}
84
85impl ReportsApiClient {
86 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
87 Self { configuration }
88 }
89}
90
91#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
92#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
93impl ReportsApi for ReportsApiClient {
94 async fn add_password_health_report_application<'a>(
95 &self,
96 password_health_report_application_model: Option<
97 models::PasswordHealthReportApplicationModel,
98 >,
99 ) -> Result<
100 models::PasswordHealthReportApplication,
101 Error<AddPasswordHealthReportApplicationError>,
102 > {
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 "{}/reports/password-health-report-application",
109 local_var_configuration.base_path
110 );
111 let mut local_var_req_builder =
112 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
113
114 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
115 local_var_req_builder = local_var_req_builder
116 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
117 }
118 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
119 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
120 };
121 local_var_req_builder =
122 local_var_req_builder.json(&password_health_report_application_model);
123
124 let local_var_req = local_var_req_builder.build()?;
125 let local_var_resp = local_var_client.execute(local_var_req).await?;
126
127 let local_var_status = local_var_resp.status();
128 let local_var_content_type = local_var_resp
129 .headers()
130 .get("content-type")
131 .and_then(|v| v.to_str().ok())
132 .unwrap_or("application/octet-stream");
133 let local_var_content_type = super::ContentType::from(local_var_content_type);
134 let local_var_content = local_var_resp.text().await?;
135
136 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
137 match local_var_content_type {
138 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
139 ContentType::Text => {
140 return Err(Error::from(serde_json::Error::custom(
141 "Received `text/plain` content type response that cannot be converted to `models::PasswordHealthReportApplication`",
142 )));
143 }
144 ContentType::Unsupported(local_var_unknown_type) => {
145 return Err(Error::from(serde_json::Error::custom(format!(
146 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PasswordHealthReportApplication`"
147 ))));
148 }
149 }
150 } else {
151 let local_var_entity: Option<AddPasswordHealthReportApplicationError> =
152 serde_json::from_str(&local_var_content).ok();
153 let local_var_error = ResponseContent {
154 status: local_var_status,
155 content: local_var_content,
156 entity: local_var_entity,
157 };
158 Err(Error::ResponseError(local_var_error))
159 }
160 }
161
162 async fn add_password_health_report_applications<'a>(
163 &self,
164 password_health_report_application_model: Option<
165 Vec<models::PasswordHealthReportApplicationModel>,
166 >,
167 ) -> Result<
168 Vec<models::PasswordHealthReportApplication>,
169 Error<AddPasswordHealthReportApplicationsError>,
170 > {
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 "{}/reports/password-health-report-applications",
177 local_var_configuration.base_path
178 );
179 let mut local_var_req_builder =
180 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
181
182 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183 local_var_req_builder = local_var_req_builder
184 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
185 }
186 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
187 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
188 };
189 local_var_req_builder =
190 local_var_req_builder.json(&password_health_report_application_model);
191
192 let local_var_req = local_var_req_builder.build()?;
193 let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195 let local_var_status = local_var_resp.status();
196 let local_var_content_type = local_var_resp
197 .headers()
198 .get("content-type")
199 .and_then(|v| v.to_str().ok())
200 .unwrap_or("application/octet-stream");
201 let local_var_content_type = super::ContentType::from(local_var_content_type);
202 let local_var_content = local_var_resp.text().await?;
203
204 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
205 match local_var_content_type {
206 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
207 ContentType::Text => {
208 return Err(Error::from(serde_json::Error::custom(
209 "Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`",
210 )));
211 }
212 ContentType::Unsupported(local_var_unknown_type) => {
213 return Err(Error::from(serde_json::Error::custom(format!(
214 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"
215 ))));
216 }
217 }
218 } else {
219 let local_var_entity: Option<AddPasswordHealthReportApplicationsError> =
220 serde_json::from_str(&local_var_content).ok();
221 let local_var_error = ResponseContent {
222 status: local_var_status,
223 content: local_var_content,
224 entity: local_var_entity,
225 };
226 Err(Error::ResponseError(local_var_error))
227 }
228 }
229
230 async fn drop_password_health_report_application<'a>(
231 &self,
232 drop_password_health_report_application_request: Option<
233 models::DropPasswordHealthReportApplicationRequest,
234 >,
235 ) -> Result<(), Error<DropPasswordHealthReportApplicationError>> {
236 let local_var_configuration = &self.configuration;
237
238 let local_var_client = &local_var_configuration.client;
239
240 let local_var_uri_str = format!(
241 "{}/reports/password-health-report-application",
242 local_var_configuration.base_path
243 );
244 let mut local_var_req_builder =
245 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
246
247 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
248 local_var_req_builder = local_var_req_builder
249 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
250 }
251 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
252 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
253 };
254 local_var_req_builder =
255 local_var_req_builder.json(&drop_password_health_report_application_request);
256
257 let local_var_req = local_var_req_builder.build()?;
258 let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260 let local_var_status = local_var_resp.status();
261 let local_var_content = local_var_resp.text().await?;
262
263 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264 Ok(())
265 } else {
266 let local_var_entity: Option<DropPasswordHealthReportApplicationError> =
267 serde_json::from_str(&local_var_content).ok();
268 let local_var_error = ResponseContent {
269 status: local_var_status,
270 content: local_var_content,
271 entity: local_var_entity,
272 };
273 Err(Error::ResponseError(local_var_error))
274 }
275 }
276
277 async fn get_member_access_report<'a>(
278 &self,
279 org_id: uuid::Uuid,
280 ) -> Result<Vec<models::MemberAccessDetailReportResponseModel>, Error<GetMemberAccessReportError>>
281 {
282 let local_var_configuration = &self.configuration;
283
284 let local_var_client = &local_var_configuration.client;
285
286 let local_var_uri_str = format!(
287 "{}/reports/member-access/{orgId}",
288 local_var_configuration.base_path,
289 orgId = org_id
290 );
291 let mut local_var_req_builder =
292 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
293
294 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
295 local_var_req_builder = local_var_req_builder
296 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
297 }
298 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
299 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
300 };
301
302 let local_var_req = local_var_req_builder.build()?;
303 let local_var_resp = local_var_client.execute(local_var_req).await?;
304
305 let local_var_status = local_var_resp.status();
306 let local_var_content_type = local_var_resp
307 .headers()
308 .get("content-type")
309 .and_then(|v| v.to_str().ok())
310 .unwrap_or("application/octet-stream");
311 let local_var_content_type = super::ContentType::from(local_var_content_type);
312 let local_var_content = local_var_resp.text().await?;
313
314 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315 match local_var_content_type {
316 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
317 ContentType::Text => {
318 return Err(Error::from(serde_json::Error::custom(
319 "Received `text/plain` content type response that cannot be converted to `Vec<models::MemberAccessDetailReportResponseModel>`",
320 )));
321 }
322 ContentType::Unsupported(local_var_unknown_type) => {
323 return Err(Error::from(serde_json::Error::custom(format!(
324 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberAccessDetailReportResponseModel>`"
325 ))));
326 }
327 }
328 } else {
329 let local_var_entity: Option<GetMemberAccessReportError> =
330 serde_json::from_str(&local_var_content).ok();
331 let local_var_error = ResponseContent {
332 status: local_var_status,
333 content: local_var_content,
334 entity: local_var_entity,
335 };
336 Err(Error::ResponseError(local_var_error))
337 }
338 }
339
340 async fn get_member_cipher_details<'a>(
341 &self,
342 org_id: uuid::Uuid,
343 ) -> Result<Vec<models::MemberCipherDetailsResponseModel>, Error<GetMemberCipherDetailsError>>
344 {
345 let local_var_configuration = &self.configuration;
346
347 let local_var_client = &local_var_configuration.client;
348
349 let local_var_uri_str = format!(
350 "{}/reports/member-cipher-details/{orgId}",
351 local_var_configuration.base_path,
352 orgId = org_id
353 );
354 let mut local_var_req_builder =
355 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
356
357 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
358 local_var_req_builder = local_var_req_builder
359 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
360 }
361 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
362 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
363 };
364
365 let local_var_req = local_var_req_builder.build()?;
366 let local_var_resp = local_var_client.execute(local_var_req).await?;
367
368 let local_var_status = local_var_resp.status();
369 let local_var_content_type = local_var_resp
370 .headers()
371 .get("content-type")
372 .and_then(|v| v.to_str().ok())
373 .unwrap_or("application/octet-stream");
374 let local_var_content_type = super::ContentType::from(local_var_content_type);
375 let local_var_content = local_var_resp.text().await?;
376
377 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
378 match local_var_content_type {
379 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
380 ContentType::Text => {
381 return Err(Error::from(serde_json::Error::custom(
382 "Received `text/plain` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`",
383 )));
384 }
385 ContentType::Unsupported(local_var_unknown_type) => {
386 return Err(Error::from(serde_json::Error::custom(format!(
387 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`"
388 ))));
389 }
390 }
391 } else {
392 let local_var_entity: Option<GetMemberCipherDetailsError> =
393 serde_json::from_str(&local_var_content).ok();
394 let local_var_error = ResponseContent {
395 status: local_var_status,
396 content: local_var_content,
397 entity: local_var_entity,
398 };
399 Err(Error::ResponseError(local_var_error))
400 }
401 }
402
403 async fn get_password_health_report_applications<'a>(
404 &self,
405 org_id: uuid::Uuid,
406 ) -> Result<
407 Vec<models::PasswordHealthReportApplication>,
408 Error<GetPasswordHealthReportApplicationsError>,
409 > {
410 let local_var_configuration = &self.configuration;
411
412 let local_var_client = &local_var_configuration.client;
413
414 let local_var_uri_str = format!(
415 "{}/reports/password-health-report-applications/{orgId}",
416 local_var_configuration.base_path,
417 orgId = org_id
418 );
419 let mut local_var_req_builder =
420 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
421
422 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
423 local_var_req_builder = local_var_req_builder
424 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
425 }
426 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
427 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
428 };
429
430 let local_var_req = local_var_req_builder.build()?;
431 let local_var_resp = local_var_client.execute(local_var_req).await?;
432
433 let local_var_status = local_var_resp.status();
434 let local_var_content_type = local_var_resp
435 .headers()
436 .get("content-type")
437 .and_then(|v| v.to_str().ok())
438 .unwrap_or("application/octet-stream");
439 let local_var_content_type = super::ContentType::from(local_var_content_type);
440 let local_var_content = local_var_resp.text().await?;
441
442 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
443 match local_var_content_type {
444 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
445 ContentType::Text => {
446 return Err(Error::from(serde_json::Error::custom(
447 "Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`",
448 )));
449 }
450 ContentType::Unsupported(local_var_unknown_type) => {
451 return Err(Error::from(serde_json::Error::custom(format!(
452 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"
453 ))));
454 }
455 }
456 } else {
457 let local_var_entity: Option<GetPasswordHealthReportApplicationsError> =
458 serde_json::from_str(&local_var_content).ok();
459 let local_var_error = ResponseContent {
460 status: local_var_status,
461 content: local_var_content,
462 entity: local_var_entity,
463 };
464 Err(Error::ResponseError(local_var_error))
465 }
466 }
467}
468
469#[derive(Debug, Clone, Serialize, Deserialize)]
471#[serde(untagged)]
472pub enum AddPasswordHealthReportApplicationError {
473 UnknownValue(serde_json::Value),
474}
475#[derive(Debug, Clone, Serialize, Deserialize)]
477#[serde(untagged)]
478pub enum AddPasswordHealthReportApplicationsError {
479 UnknownValue(serde_json::Value),
480}
481#[derive(Debug, Clone, Serialize, Deserialize)]
483#[serde(untagged)]
484pub enum DropPasswordHealthReportApplicationError {
485 UnknownValue(serde_json::Value),
486}
487#[derive(Debug, Clone, Serialize, Deserialize)]
489#[serde(untagged)]
490pub enum GetMemberAccessReportError {
491 UnknownValue(serde_json::Value),
492}
493#[derive(Debug, Clone, Serialize, Deserialize)]
495#[serde(untagged)]
496pub enum GetMemberCipherDetailsError {
497 UnknownValue(serde_json::Value),
498}
499#[derive(Debug, Clone, Serialize, Deserialize)]
501#[serde(untagged)]
502pub enum GetPasswordHealthReportApplicationsError {
503 UnknownValue(serde_json::Value),
504}