use std::sync::Arc;
use async_trait::async_trait;
#[cfg(feature = "mockall")]
use mockall::automock;
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use super::{Error, configuration};
use crate::{
apis::{AuthRequired, ContentType, ResponseContent},
models,
};
#[cfg_attr(feature = "mockall", automock)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait ReportsApi: Send + Sync {
async fn add_password_health_report_application<'a>(
&self,
password_health_report_application_model: Option<
models::PasswordHealthReportApplicationModel,
>,
) -> Result<models::PasswordHealthReportApplication, Error>;
async fn add_password_health_report_applications<'a>(
&self,
password_health_report_application_model: Option<
Vec<models::PasswordHealthReportApplicationModel>,
>,
) -> Result<Vec<models::PasswordHealthReportApplication>, Error>;
async fn drop_password_health_report_application<'a>(
&self,
drop_password_health_report_application_request: Option<
models::DropPasswordHealthReportApplicationRequest,
>,
) -> Result<(), Error>;
async fn get_member_access_report<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::MemberAccessDetailReportResponseModel>, Error>;
async fn get_member_cipher_details<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::MemberCipherDetailsResponseModel>, Error>;
async fn get_password_health_report_applications<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::PasswordHealthReportApplication>, Error>;
}
pub struct ReportsApiClient {
configuration: Arc<configuration::Configuration>,
}
impl ReportsApiClient {
pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
Self { configuration }
}
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl ReportsApi for ReportsApiClient {
async fn add_password_health_report_application<'a>(
&self,
password_health_report_application_model: Option<
models::PasswordHealthReportApplicationModel,
>,
) -> Result<models::PasswordHealthReportApplication, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/password-health-report-application",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
local_var_req_builder =
local_var_req_builder.json(&password_health_report_application_model);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
async fn add_password_health_report_applications<'a>(
&self,
password_health_report_application_model: Option<
Vec<models::PasswordHealthReportApplicationModel>,
>,
) -> Result<Vec<models::PasswordHealthReportApplication>, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/password-health-report-applications",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
local_var_req_builder =
local_var_req_builder.json(&password_health_report_application_model);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
async fn drop_password_health_report_application<'a>(
&self,
drop_password_health_report_application_request: Option<
models::DropPasswordHealthReportApplicationRequest,
>,
) -> Result<(), Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/password-health-report-application",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
local_var_req_builder =
local_var_req_builder.json(&drop_password_health_report_application_request);
bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
}
async fn get_member_access_report<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::MemberAccessDetailReportResponseModel>, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/member-access/{orgId}",
local_var_configuration.base_path,
orgId = org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
async fn get_member_cipher_details<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::MemberCipherDetailsResponseModel>, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/member-cipher-details/{orgId}",
local_var_configuration.base_path,
orgId = org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
async fn get_password_health_report_applications<'a>(
&self,
org_id: uuid::Uuid,
) -> Result<Vec<models::PasswordHealthReportApplication>, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/reports/password-health-report-applications/{orgId}",
local_var_configuration.base_path,
orgId = org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
}