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 EventsApi: Send + Sync {
async fn get_cipher<'a>(
&self,
id: &'a str,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_organization<'a>(
&self,
id: &'a str,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_organization_user<'a>(
&self,
org_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_projects<'a>(
&self,
id: uuid::Uuid,
org_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_provider<'a>(
&self,
provider_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_provider_user<'a>(
&self,
provider_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_secrets<'a>(
&self,
id: uuid::Uuid,
org_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_service_accounts<'a>(
&self,
org_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
async fn get_user<'a>(
&self,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error>;
}
pub struct EventsApiClient {
configuration: Arc<configuration::Configuration>,
}
impl EventsApiClient {
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 EventsApi for EventsApiClient {
async fn get_cipher<'a>(
&self,
id: &'a str,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/ciphers/{id}/events",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_organization<'a>(
&self,
id: &'a str,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/organizations/{id}/events",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_organization_user<'a>(
&self,
org_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/organizations/{orgId}/users/{id}/events",
local_var_configuration.base_path,
orgId = org_id,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_projects<'a>(
&self,
id: uuid::Uuid,
org_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/organization/{orgId}/projects/{id}/events",
local_var_configuration.base_path,
id = id,
orgId = org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_provider<'a>(
&self,
provider_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/providers/{providerId}/events",
local_var_configuration.base_path,
providerId = provider_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_provider_user<'a>(
&self,
provider_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/providers/{providerId}/users/{id}/events",
local_var_configuration.base_path,
providerId = provider_id,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_secrets<'a>(
&self,
id: uuid::Uuid,
org_id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/organization/{orgId}/secrets/{id}/events",
local_var_configuration.base_path,
id = id,
orgId = org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_service_accounts<'a>(
&self,
org_id: uuid::Uuid,
id: uuid::Uuid,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/organization/{orgId}/service-account/{id}/events",
local_var_configuration.base_path,
orgId = org_id,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
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_user<'a>(
&self,
start: Option<String>,
end: Option<String>,
continuation_token: Option<&'a str>,
) -> Result<models::EventResponseModelListResponseModel, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/events", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = end {
local_var_req_builder =
local_var_req_builder.query(&[("end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = continuation_token {
local_var_req_builder =
local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
}
local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
bitwarden_api_base::process_with_json_response(local_var_req_builder).await
}
}