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