Skip to main content

openlark_platform/app_engine/apaas/v1/application/
mod.rs

1//! 应用引擎模块
2
3pub mod audit_log;
4pub mod environment_variable;
5pub mod flow;
6pub mod function;
7pub mod object;
8pub mod record_permission;
9pub mod role;
10
11use crate::PlatformConfig;
12use std::sync::Arc;
13
14/// application 资源服务(中间级,绑定 namespace)
15#[derive(Debug, Clone)]
16pub struct ApplicationService {
17    config: Arc<PlatformConfig>,
18    namespace: String,
19}
20
21impl ApplicationService {
22    /// 创建新的 application 服务
23    pub fn new(config: Arc<PlatformConfig>, namespace: impl Into<String>) -> Self {
24        Self {
25            config,
26            namespace: namespace.into(),
27        }
28    }
29
30    /// application.object 子资源
31    pub fn object(&self, object_api_name: impl Into<String>) -> object::ObjectService {
32        object::ObjectService::new(self.config.clone(), self.namespace.clone(), object_api_name)
33    }
34
35    /// application.role 子资源
36    pub fn role(&self, role_api_name: impl Into<String>) -> role::RoleService {
37        role::RoleService::new(self.config.clone(), self.namespace.clone(), role_api_name)
38    }
39
40    /// application.record_permission 子资源
41    pub fn record_permission(
42        &self,
43        record_permission_api_name: impl Into<String>,
44    ) -> record_permission::RecordPermissionService {
45        record_permission::RecordPermissionService::new(
46            self.config.clone(),
47            self.namespace.clone(),
48            record_permission_api_name,
49        )
50    }
51
52    /// application.environment_variable 子资源(叶子级)
53    pub fn environment_variable(&self) -> environment_variable::EnvironmentVariableService {
54        environment_variable::EnvironmentVariableService::new(
55            self.config.as_ref().clone(),
56            self.namespace.clone(),
57        )
58    }
59
60    /// application.function 子资源
61    pub fn function(&self, function_api_name: impl Into<String>) -> function::FunctionService {
62        function::FunctionService::new(
63            self.config.as_ref().clone(),
64            self.namespace.clone(),
65            function_api_name,
66        )
67    }
68
69    /// application.flow 子资源
70    pub fn flow(&self, flow_id: impl Into<String>) -> flow::FlowService {
71        flow::FlowService::new(
72            self.config.as_ref().clone(),
73            self.namespace.clone(),
74            flow_id,
75        )
76    }
77
78    /// application.audit_log 子资源
79    pub fn audit_log(&self) -> audit_log::AuditLogService {
80        audit_log::AuditLogService::new(self.config.as_ref().clone(), self.namespace.clone())
81    }
82}