use crate::core::api_resp::{ApiResponseTrait, ResponseFormat};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct OpenapiLogListRequest {
pub page_token: Option<String>,
pub page_size: Option<i32>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub app_ids: Option<String>,
pub apis: Option<String>,
pub response_codes: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct OpenapiLogItem {
pub timestamp: i64,
pub app_id: String,
pub app_name: String,
pub api: String,
pub method: String,
pub request_id: String,
pub response_code: i32,
pub response_time: i64,
pub user_id: Option<String>,
pub tenant_key: Option<String>,
pub ip: Option<String>,
pub user_agent: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct OpenapiLogListResponse {
pub has_more: bool,
pub page_token: Option<String>,
pub items: Vec<OpenapiLogItem>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AuditLogGetRequest {
pub data_type: String,
pub start_time: i64,
pub end_time: i64,
pub page: Option<i32>,
pub page_size: Option<i32>,
pub audit_types: Option<Vec<String>>,
pub operator_ids: Option<Vec<String>>,
pub object_ids: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AuditLogItem {
pub log_id: String,
pub timestamp: i64,
pub audit_type: String,
pub operator_id: String,
pub operator_name: String,
pub object_id: Option<String>,
pub object_name: Option<String>,
pub operation_detail: String,
pub ip: Option<String>,
pub device_info: Option<String>,
pub extend_info: Option<serde_json::Value>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AuditLogGetResponse {
pub total: i32,
pub page: i32,
pub page_size: i32,
pub items: Vec<AuditLogItem>,
}
impl Default for OpenapiLogListRequest {
fn default() -> Self {
Self {
page_token: None,
page_size: Some(100),
start_time: None,
end_time: None,
app_ids: None,
apis: None,
response_codes: None,
}
}
}
impl Default for AuditLogGetRequest {
fn default() -> Self {
Self {
data_type: "all".to_string(),
start_time: 0,
end_time: 0,
page: Some(1),
page_size: Some(100),
audit_types: None,
operator_ids: None,
object_ids: None,
}
}
}
impl ApiResponseTrait for OpenapiLogListResponse {
fn data_format() -> ResponseFormat {
ResponseFormat::Data
}
}
impl ApiResponseTrait for AuditLogGetResponse {
fn data_format() -> ResponseFormat {
ResponseFormat::Data
}
}