use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;
pub struct AuditLogsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateOrganizationAuditLogsRetentionParams {
#[serde(skip)]
pub body: UpdateAuditLogsRetention,
}
impl UpdateOrganizationAuditLogsRetentionParams {
#[allow(deprecated)]
pub fn new(body: UpdateAuditLogsRetention) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListActionsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListActionSchemasParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateSchemaParams {
#[serde(skip)]
pub body: AuditLogSchema,
}
impl CreateSchemaParams {
#[allow(deprecated)]
pub fn new(body: AuditLogSchema) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateEventParams {
#[serde(skip)]
pub body: AuditLogEventIngestion,
}
impl CreateEventParams {
#[allow(deprecated)]
pub fn new(body: AuditLogEventIngestion) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateExportParams {
#[serde(skip)]
pub body: AuditLogExportCreation,
}
impl CreateExportParams {
#[allow(deprecated)]
pub fn new(body: AuditLogExportCreation) -> Self {
Self { body }
}
}
impl<'a> AuditLogsApi<'a> {
pub async fn get_organization_audit_logs_retention(
&self,
id: &str,
) -> Result<AuditLogsRetentionJson, Error> {
self.get_organization_audit_logs_retention_with_options(id, None)
.await
}
pub async fn get_organization_audit_logs_retention_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogsRetentionJson, Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}/audit_logs_retention");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn update_organization_audit_logs_retention(
&self,
id: &str,
params: UpdateOrganizationAuditLogsRetentionParams,
) -> Result<AuditLogsRetentionJson, Error> {
self.update_organization_audit_logs_retention_with_options(id, params, None)
.await
}
pub async fn update_organization_audit_logs_retention_with_options(
&self,
id: &str,
params: UpdateOrganizationAuditLogsRetentionParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogsRetentionJson, Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}/audit_logs_retention");
let method = http::Method::PUT;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn list_actions(
&self,
params: ListActionsParams,
) -> Result<Vec<AuditLogActionJson>, Error> {
self.list_actions_with_options(params, None).await
}
pub async fn list_actions_with_options(
&self,
params: ListActionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<AuditLogActionJson>, Error> {
let path = "/audit_logs/actions".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn list_action_schemas(
&self,
action_name: &str,
params: ListActionSchemasParams,
) -> Result<Vec<AuditLogSchemaJson>, Error> {
self.list_action_schemas_with_options(action_name, params, None)
.await
}
pub async fn list_action_schemas_with_options(
&self,
action_name: &str,
params: ListActionSchemasParams,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<AuditLogSchemaJson>, Error> {
let action_name = crate::client::path_segment(action_name);
let path = format!("/audit_logs/actions/{action_name}/schemas");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn create_schema(
&self,
action_name: &str,
params: CreateSchemaParams,
) -> Result<AuditLogSchemaJson, Error> {
self.create_schema_with_options(action_name, params, None)
.await
}
pub async fn create_schema_with_options(
&self,
action_name: &str,
params: CreateSchemaParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogSchemaJson, Error> {
let action_name = crate::client::path_segment(action_name);
let path = format!("/audit_logs/actions/{action_name}/schemas");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn create_event(
&self,
params: CreateEventParams,
) -> Result<AuditLogEventCreateResponse, Error> {
self.create_event_with_options(params, None).await
}
pub async fn create_event_with_options(
&self,
params: CreateEventParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogEventCreateResponse, Error> {
let path = "/audit_logs/events".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn create_export(
&self,
params: CreateExportParams,
) -> Result<AuditLogExportJson, Error> {
self.create_export_with_options(params, None).await
}
pub async fn create_export_with_options(
&self,
params: CreateExportParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogExportJson, Error> {
let path = "/audit_logs/exports".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_export(&self, audit_log_export_id: &str) -> Result<AuditLogExportJson, Error> {
self.get_export_with_options(audit_log_export_id, None)
.await
}
pub async fn get_export_with_options(
&self,
audit_log_export_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogExportJson, Error> {
let audit_log_export_id = crate::client::path_segment(audit_log_export_id);
let path = format!("/audit_logs/exports/{audit_log_export_id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
}