openlark_platform/admin/v1/
mod.rs1use crate::PlatformConfig;
6use std::sync::Arc;
7
8pub mod admin_dept_stat;
10pub mod admin_user_stat;
12pub mod audit;
14pub mod audit_info;
16pub mod badge;
18pub mod badge_image;
20pub mod password;
22pub mod users;
24
25#[derive(Debug, Clone)]
27pub struct AdminV1 {
28 config: Arc<PlatformConfig>,
29}
30
31impl AdminV1 {
32 pub fn new(config: Arc<PlatformConfig>) -> Self {
34 Self { config }
35 }
36
37 pub fn badge(&self) -> badge::BadgeService {
39 badge::BadgeService::new(self.config.as_ref().clone())
40 }
41
42 pub fn badge_image(&self) -> badge_image::BadgeImageService {
44 badge_image::BadgeImageService::new(self.config.as_ref().clone())
45 }
46
47 pub fn password(&self) -> password::PasswordService {
49 password::PasswordService::new(self.config.as_ref().clone())
50 }
51
52 pub fn admin_dept_stat(&self) -> admin_dept_stat::AdminDeptStatService {
54 admin_dept_stat::AdminDeptStatService::new(self.config.as_ref().clone())
55 }
56
57 pub fn admin_user_stat(&self) -> admin_user_stat::AdminUserStatService {
59 admin_user_stat::AdminUserStatService::new(self.config.as_ref().clone())
60 }
61
62 pub fn audit_info(&self) -> audit_info::AuditInfoService {
64 audit_info::AuditInfoService::new(self.config.as_ref().clone())
65 }
66
67 pub fn audit(&self) -> audit::AuditApi {
69 audit::AuditApi::new(self.config.clone())
70 }
71
72 pub fn users(&self) -> users::UsersApi {
74 users::UsersApi::new(self.config.clone())
75 }
76}
77
78#[cfg(test)]
79mod tests {
80 use super::AdminV1;
81 use crate::PlatformConfig;
82
83 #[test]
84 fn test_admin_v1_creation() {
85 let config = PlatformConfig::builder()
86 .app_id("test_app_id")
87 .app_secret("test_app_secret")
88 .build();
89
90 let api = AdminV1::new(std::sync::Arc::new(config));
91 assert_eq!(api.config.app_id(), "test_app_id");
92 }
93
94 #[test]
95 fn test_admin_v1_chain_access() {
96 let config = PlatformConfig::builder()
97 .app_id("test_app_id")
98 .app_secret("test_app_secret")
99 .build();
100 let api = AdminV1::new(std::sync::Arc::new(config));
101 let _ = api.badge().create();
103 let _ = api.badge().list();
104 let _ = api.badge_image().create();
105 let _ = api.password().reset();
106 let _ = api.admin_dept_stat().list();
107 let _ = api.admin_user_stat().list();
108 let _ = api.audit_info().list();
109 let _ = api.badge().grant().list();
111 let _ = api.audit();
113 let _ = api.users();
114 }
115}