openlark_platform/admin/v1/
audit.rs1use crate::PlatformConfig;
10use openlark_core::{SDKResult, error::business_error, req_option::RequestOption};
11use std::sync::Arc;
12
13#[derive(Debug, Clone)]
15pub struct AuditApi {
16 config: Arc<PlatformConfig>,
17}
18
19impl AuditApi {
20 pub fn new(config: Arc<PlatformConfig>) -> Self {
22 Self { config }
23 }
24
25 pub fn query(&self) -> QueryAuditLogsRequest {
27 QueryAuditLogsRequest::new(self.config.clone())
28 }
29
30 pub fn get(&self) -> GetAuditLogRequest {
32 GetAuditLogRequest::new(self.config.clone())
33 }
34}
35
36pub struct QueryAuditLogsRequest {
38 _config: Arc<PlatformConfig>,
40 start_time: Option<String>,
41 end_time: Option<String>,
42 page_size: Option<u32>,
43}
44
45impl QueryAuditLogsRequest {
46 fn new(config: Arc<PlatformConfig>) -> Self {
47 Self {
48 _config: config,
49 start_time: None,
50 end_time: None,
51 page_size: None,
52 }
53 }
54
55 pub fn start_time(mut self, time: impl Into<String>) -> Self {
57 self.start_time = Some(time.into());
58 self
59 }
60
61 pub fn end_time(mut self, time: impl Into<String>) -> Self {
63 self.end_time = Some(time.into());
64 self
65 }
66
67 pub fn page_size(mut self, size: u32) -> Self {
69 self.page_size = Some(size);
70 self
71 }
72
73 pub async fn execute(self) -> SDKResult<serde_json::Value> {
75 self.execute_with_options(RequestOption::default()).await
76 }
77
78 pub async fn execute_with_options(
80 self,
81 _option: RequestOption,
82 ) -> SDKResult<serde_json::Value> {
83 Err(business_error(
84 "admin.audit.query: openlark-platform 尚未接入该 facade,请改用已实现的 admin.audit_info.list 等真实端点",
85 ))
86 }
87}
88
89pub struct GetAuditLogRequest {
91 _config: Arc<PlatformConfig>,
93 log_id: Option<String>,
94}
95
96impl GetAuditLogRequest {
97 fn new(config: Arc<PlatformConfig>) -> Self {
98 Self {
99 _config: config,
100 log_id: None,
101 }
102 }
103
104 pub fn log_id(mut self, log_id: impl Into<String>) -> Self {
106 self.log_id = Some(log_id.into());
107 self
108 }
109
110 pub async fn execute(self) -> SDKResult<serde_json::Value> {
112 self.execute_with_options(RequestOption::default()).await
113 }
114
115 pub async fn execute_with_options(
117 self,
118 _option: RequestOption,
119 ) -> SDKResult<serde_json::Value> {
120 Err(business_error(
121 "admin.audit.get: openlark-platform 尚未接入该 facade,请改用已实现的 admin.audit_info.list 等真实端点",
122 ))
123 }
124}
125
126#[cfg(test)]
127mod tests {
128 use super::*;
129
130 #[tokio::test]
131 async fn test_audit_stub_returns_explicit_error() {
132 let config = Arc::new(PlatformConfig::default());
133 let err = AuditApi::new(config)
134 .query()
135 .start_time("2026-01-01")
136 .end_time("2026-01-31")
137 .execute()
138 .await
139 .expect_err("audit stub should now fail explicitly");
140 assert!(err.to_string().contains("尚未接入"));
141 }
142}