Skip to main content

openlark_platform/
app_engine.rs

1//! 应用引擎模块
2//!
3//! 提供应用管理、多租户、应用市场等功能 (37 APIs)
4
5use crate::PlatformConfig;
6use std::sync::Arc;
7
8/// 应用引擎服务
9///
10/// 提供应用引擎相关 API 的访问入口。
11#[derive(Debug, Clone)]
12pub struct AppEngineService {
13    /// 客户端配置
14    config: Arc<PlatformConfig>,
15}
16
17impl AppEngineService {
18    /// 创建新的应用引擎服务实例
19    pub fn new(config: Arc<PlatformConfig>) -> Self {
20        Self { config }
21    }
22
23    /// 获取客户端配置
24    pub fn config(&self) -> Arc<PlatformConfig> {
25        self.config.clone()
26    }
27
28    /// V1 版本 API
29    #[cfg(feature = "v1")]
30    pub fn v1(&self) -> crate::app_engine::apaas::v1::ApaasV1 {
31        crate::app_engine::apaas::v1::ApaasV1::new(self.config.clone())
32    }
33}
34
35#[cfg(feature = "v1")]
36pub mod apaas;
37
38#[cfg(test)]
39mod tests {
40    use crate::{PlatformConfig, app_engine::AppEngineService};
41
42    #[test]
43    fn test_service_creation() {
44        let config = PlatformConfig::builder()
45            .app_id("test_app_id")
46            .app_secret("test_app_secret")
47            .build();
48
49        let service = AppEngineService::new(std::sync::Arc::new(config));
50        // PlatformConfig 实现了 Deref,可以直接访问 app_id
51        assert_eq!(service.config().app_id(), "test_app_id");
52    }
53}