Skip to main content

reifydb_core/interface/catalog/
policy.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4use serde::{Deserialize, Serialize};
5
6// Security policy types
7
8pub type PolicyId = u64;
9
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub enum PolicyTargetType {
12	Table,
13	Column,
14	Namespace,
15	Procedure,
16	Function,
17	Subscription,
18	Series,
19	Dictionary,
20	Session,
21	Feature,
22	View,
23	RingBuffer,
24}
25
26impl PolicyTargetType {
27	pub fn as_str(&self) -> &'static str {
28		match self {
29			Self::Table => "table",
30			Self::Column => "column",
31			Self::Namespace => "namespace",
32			Self::Procedure => "procedure",
33			Self::Function => "function",
34			Self::Subscription => "subscription",
35			Self::Series => "series",
36			Self::Dictionary => "dictionary",
37			Self::Session => "session",
38			Self::Feature => "feature",
39			Self::View => "view",
40			Self::RingBuffer => "ringbuffer",
41		}
42	}
43}
44
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
46pub struct PolicyDef {
47	pub id: PolicyId,
48	pub name: Option<String>,
49	pub target_type: PolicyTargetType,
50	pub target_namespace: Option<String>,
51	pub target_object: Option<String>,
52	pub enabled: bool,
53}
54
55#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
56pub struct PolicyOperationDef {
57	pub policy_id: PolicyId,
58	pub operation: String,
59	pub body_source: String,
60}
61
62pub struct PolicyToCreate {
63	pub name: Option<String>,
64	pub target_type: PolicyTargetType,
65	pub target_namespace: Option<String>,
66	pub target_object: Option<String>,
67	pub operations: Vec<PolicyOpToCreate>,
68}
69
70pub struct PolicyOpToCreate {
71	pub operation: String,
72	pub body_source: String,
73}