Skip to main content

static_tr_plugin/
config.rs

1//! Configuration for the static tenant resolver plugin.
2
3use serde::Deserialize;
4use tenant_resolver_sdk::TenantStatus;
5use uuid::Uuid;
6
7/// Plugin configuration.
8#[derive(Debug, Clone, Deserialize)]
9#[serde(default, deny_unknown_fields)]
10pub struct StaticTrPluginConfig {
11    /// Vendor name for GTS instance registration.
12    pub vendor: String,
13
14    /// Plugin priority (lower = higher priority).
15    pub priority: i16,
16
17    /// Static tenant definitions.
18    pub tenants: Vec<TenantConfig>,
19
20    /// Static access rules.
21    pub access_rules: Vec<AccessRuleConfig>,
22}
23
24impl Default for StaticTrPluginConfig {
25    fn default() -> Self {
26        Self {
27            vendor: "hyperspot".to_owned(),
28            priority: 100,
29            tenants: Vec::new(),
30            access_rules: Vec::new(),
31        }
32    }
33}
34
35/// Configuration for a single tenant.
36#[derive(Debug, Clone, Deserialize)]
37#[serde(deny_unknown_fields)]
38pub struct TenantConfig {
39    /// Tenant ID.
40    pub id: Uuid,
41
42    /// Tenant name.
43    pub name: String,
44
45    /// Tenant status (defaults to Active).
46    #[serde(default)]
47    pub status: TenantStatus,
48
49    /// Tenant type classification.
50    #[serde(rename = "type", default)]
51    pub tenant_type: Option<String>,
52}
53
54/// Configuration for an access rule.
55///
56/// Defines that `source` tenant can access `target` tenant's data.
57#[derive(Debug, Clone, Deserialize)]
58#[serde(deny_unknown_fields)]
59pub struct AccessRuleConfig {
60    /// Source tenant ID (the one requesting access).
61    pub source: Uuid,
62
63    /// Target tenant ID (the one being accessed).
64    pub target: Uuid,
65}