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 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 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
115 local_var_req_builder =
116 local_var_req_builder.json(&password_health_report_application_model);
117
118 let local_var_resp = local_var_req_builder.send().await?;
119
120 let local_var_status = local_var_resp.status();
121 let local_var_content_type = local_var_resp
122 .headers()
123 .get("content-type")
124 .and_then(|v| v.to_str().ok())
125 .unwrap_or("application/octet-stream");
126 let local_var_content_type = super::ContentType::from(local_var_content_type);
127 let local_var_content = local_var_resp.text().await?;
128
129 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130 match local_var_content_type {
131 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
132 ContentType::Text => {
133 return Err(Error::from(serde_json::Error::custom(
134 "Received `text/plain` content type response that cannot be converted to `models::PasswordHealthReportApplication`",
135 )));
136 }
137 ContentType::Unsupported(local_var_unknown_type) => {
138 return Err(Error::from(serde_json::Error::custom(format!(
139 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PasswordHealthReportApplication`"
140 ))));
141 }
142 }
143 } else {
144 let local_var_entity: Option<AddPasswordHealthReportApplicationError> =
145 serde_json::from_str(&local_var_content).ok();
146 let local_var_error = ResponseContent {
147 status: local_var_status,
148 content: local_var_content,
149 entity: local_var_entity,
150 };
151 Err(Error::ResponseError(local_var_error))
152 }
153 }
154
155 async fn add_password_health_report_applications<'a>(
156 &self,
157 password_health_report_application_model: Option<
158 Vec<models::PasswordHealthReportApplicationModel>,
159 >,
160 ) -> Result<
161 Vec<models::PasswordHealthReportApplication>,
162 Error<AddPasswordHealthReportApplicationsError>,
163 > {
164 let local_var_configuration = &self.configuration;
165
166 let local_var_client = &local_var_configuration.client;
167
168 let local_var_uri_str = format!(
169 "{}/reports/password-health-report-applications",
170 local_var_configuration.base_path
171 );
172 let mut local_var_req_builder =
173 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
174
175 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
176 local_var_req_builder =
177 local_var_req_builder.json(&password_health_report_application_model);
178
179 let local_var_resp = local_var_req_builder.send().await?;
180
181 let local_var_status = local_var_resp.status();
182 let local_var_content_type = local_var_resp
183 .headers()
184 .get("content-type")
185 .and_then(|v| v.to_str().ok())
186 .unwrap_or("application/octet-stream");
187 let local_var_content_type = super::ContentType::from(local_var_content_type);
188 let local_var_content = local_var_resp.text().await?;
189
190 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
191 match local_var_content_type {
192 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
193 ContentType::Text => {
194 return Err(Error::from(serde_json::Error::custom(
195 "Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`",
196 )));
197 }
198 ContentType::Unsupported(local_var_unknown_type) => {
199 return Err(Error::from(serde_json::Error::custom(format!(
200 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"
201 ))));
202 }
203 }
204 } else {
205 let local_var_entity: Option<AddPasswordHealthReportApplicationsError> =
206 serde_json::from_str(&local_var_content).ok();
207 let local_var_error = ResponseContent {
208 status: local_var_status,
209 content: local_var_content,
210 entity: local_var_entity,
211 };
212 Err(Error::ResponseError(local_var_error))
213 }
214 }
215
216 async fn drop_password_health_report_application<'a>(
217 &self,
218 drop_password_health_report_application_request: Option<
219 models::DropPasswordHealthReportApplicationRequest,
220 >,
221 ) -> Result<(), Error<DropPasswordHealthReportApplicationError>> {
222 let local_var_configuration = &self.configuration;
223
224 let local_var_client = &local_var_configuration.client;
225
226 let local_var_uri_str = format!(
227 "{}/reports/password-health-report-application",
228 local_var_configuration.base_path
229 );
230 let mut local_var_req_builder =
231 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
232
233 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
234 local_var_req_builder =
235 local_var_req_builder.json(&drop_password_health_report_application_request);
236
237 let local_var_resp = local_var_req_builder.send().await?;
238
239 let local_var_status = local_var_resp.status();
240 let local_var_content = local_var_resp.text().await?;
241
242 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
243 Ok(())
244 } else {
245 let local_var_entity: Option<DropPasswordHealthReportApplicationError> =
246 serde_json::from_str(&local_var_content).ok();
247 let local_var_error = ResponseContent {
248 status: local_var_status,
249 content: local_var_content,
250 entity: local_var_entity,
251 };
252 Err(Error::ResponseError(local_var_error))
253 }
254 }
255
256 async fn get_member_access_report<'a>(
257 &self,
258 org_id: uuid::Uuid,
259 ) -> Result<Vec<models::MemberAccessDetailReportResponseModel>, Error<GetMemberAccessReportError>>
260 {
261 let local_var_configuration = &self.configuration;
262
263 let local_var_client = &local_var_configuration.client;
264
265 let local_var_uri_str = format!(
266 "{}/reports/member-access/{orgId}",
267 local_var_configuration.base_path,
268 orgId = org_id
269 );
270 let mut local_var_req_builder =
271 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
272
273 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
274
275 let local_var_resp = local_var_req_builder.send().await?;
276
277 let local_var_status = local_var_resp.status();
278 let local_var_content_type = local_var_resp
279 .headers()
280 .get("content-type")
281 .and_then(|v| v.to_str().ok())
282 .unwrap_or("application/octet-stream");
283 let local_var_content_type = super::ContentType::from(local_var_content_type);
284 let local_var_content = local_var_resp.text().await?;
285
286 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287 match local_var_content_type {
288 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
289 ContentType::Text => {
290 return Err(Error::from(serde_json::Error::custom(
291 "Received `text/plain` content type response that cannot be converted to `Vec<models::MemberAccessDetailReportResponseModel>`",
292 )));
293 }
294 ContentType::Unsupported(local_var_unknown_type) => {
295 return Err(Error::from(serde_json::Error::custom(format!(
296 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberAccessDetailReportResponseModel>`"
297 ))));
298 }
299 }
300 } else {
301 let local_var_entity: Option<GetMemberAccessReportError> =
302 serde_json::from_str(&local_var_content).ok();
303 let local_var_error = ResponseContent {
304 status: local_var_status,
305 content: local_var_content,
306 entity: local_var_entity,
307 };
308 Err(Error::ResponseError(local_var_error))
309 }
310 }
311
312 async fn get_member_cipher_details<'a>(
313 &self,
314 org_id: uuid::Uuid,
315 ) -> Result<Vec<models::MemberCipherDetailsResponseModel>, Error<GetMemberCipherDetailsError>>
316 {
317 let local_var_configuration = &self.configuration;
318
319 let local_var_client = &local_var_configuration.client;
320
321 let local_var_uri_str = format!(
322 "{}/reports/member-cipher-details/{orgId}",
323 local_var_configuration.base_path,
324 orgId = org_id
325 );
326 let mut local_var_req_builder =
327 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
328
329 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
330
331 let local_var_resp = local_var_req_builder.send().await?;
332
333 let local_var_status = local_var_resp.status();
334 let local_var_content_type = local_var_resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let local_var_content_type = super::ContentType::from(local_var_content_type);
340 let local_var_content = local_var_resp.text().await?;
341
342 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
343 match local_var_content_type {
344 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
345 ContentType::Text => {
346 return Err(Error::from(serde_json::Error::custom(
347 "Received `text/plain` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`",
348 )));
349 }
350 ContentType::Unsupported(local_var_unknown_type) => {
351 return Err(Error::from(serde_json::Error::custom(format!(
352 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`"
353 ))));
354 }
355 }
356 } else {
357 let local_var_entity: Option<GetMemberCipherDetailsError> =
358 serde_json::from_str(&local_var_content).ok();
359 let local_var_error = ResponseContent {
360 status: local_var_status,
361 content: local_var_content,
362 entity: local_var_entity,
363 };
364 Err(Error::ResponseError(local_var_error))
365 }
366 }
367
368 async fn get_password_health_report_applications<'a>(
369 &self,
370 org_id: uuid::Uuid,
371 ) -> Result<
372 Vec<models::PasswordHealthReportApplication>,
373 Error<GetPasswordHealthReportApplicationsError>,
374 > {
375 let local_var_configuration = &self.configuration;
376
377 let local_var_client = &local_var_configuration.client;
378
379 let local_var_uri_str = format!(
380 "{}/reports/password-health-report-applications/{orgId}",
381 local_var_configuration.base_path,
382 orgId = org_id
383 );
384 let mut local_var_req_builder =
385 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
386
387 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
388
389 let local_var_resp = local_var_req_builder.send().await?;
390
391 let local_var_status = local_var_resp.status();
392 let local_var_content_type = local_var_resp
393 .headers()
394 .get("content-type")
395 .and_then(|v| v.to_str().ok())
396 .unwrap_or("application/octet-stream");
397 let local_var_content_type = super::ContentType::from(local_var_content_type);
398 let local_var_content = local_var_resp.text().await?;
399
400 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
401 match local_var_content_type {
402 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
403 ContentType::Text => {
404 return Err(Error::from(serde_json::Error::custom(
405 "Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`",
406 )));
407 }
408 ContentType::Unsupported(local_var_unknown_type) => {
409 return Err(Error::from(serde_json::Error::custom(format!(
410 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"
411 ))));
412 }
413 }
414 } else {
415 let local_var_entity: Option<GetPasswordHealthReportApplicationsError> =
416 serde_json::from_str(&local_var_content).ok();
417 let local_var_error = ResponseContent {
418 status: local_var_status,
419 content: local_var_content,
420 entity: local_var_entity,
421 };
422 Err(Error::ResponseError(local_var_error))
423 }
424 }
425}
426
427#[derive(Debug, Clone, Serialize, Deserialize)]
429#[serde(untagged)]
430pub enum AddPasswordHealthReportApplicationError {
431 UnknownValue(serde_json::Value),
432}
433#[derive(Debug, Clone, Serialize, Deserialize)]
435#[serde(untagged)]
436pub enum AddPasswordHealthReportApplicationsError {
437 UnknownValue(serde_json::Value),
438}
439#[derive(Debug, Clone, Serialize, Deserialize)]
441#[serde(untagged)]
442pub enum DropPasswordHealthReportApplicationError {
443 UnknownValue(serde_json::Value),
444}
445#[derive(Debug, Clone, Serialize, Deserialize)]
447#[serde(untagged)]
448pub enum GetMemberAccessReportError {
449 UnknownValue(serde_json::Value),
450}
451#[derive(Debug, Clone, Serialize, Deserialize)]
453#[serde(untagged)]
454pub enum GetMemberCipherDetailsError {
455 UnknownValue(serde_json::Value),
456}
457#[derive(Debug, Clone, Serialize, Deserialize)]
459#[serde(untagged)]
460pub enum GetPasswordHealthReportApplicationsError {
461 UnknownValue(serde_json::Value),
462}