Skip to main content

unitycatalog_common/models/_gen/
unitycatalog.policies.v1.rs

1// @generated
2// This file is @generated by prost-build.
3/// A column referenced by a policy, together with the alias it is bound to in the
4/// row-filter or column-mask function invocation.
5#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
6#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
7pub struct MatchColumn {
8    /// The name of the alias the column is bound to when invoking the row-filter or
9    /// column-mask function.
10    #[prost(string, tag="1")]
11    pub alias: ::prost::alloc::string::String,
12    /// The condition on the column, e.g. its name, that must match for this binding to apply.
13    #[prost(string, tag="2")]
14    pub condition: ::prost::alloc::string::String,
15}
16/// An argument passed to a row-filter or column-mask function.
17#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
18#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
19pub struct FunctionArg {
20    #[prost(oneof="function_arg::Value", tags="1, 2")]
21    pub value: ::core::option::Option<function_arg::Value>,
22}
23/// Nested message and enum types in `FunctionArg`.
24pub mod function_arg {
25    #[cfg_attr(feature = "python", ::pyo3::pyclass)]
26    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
27    pub enum Value {
28        /// References a column via its `MatchColumn.alias`.
29        #[prost(string, tag="1")]
30        Alias(::prost::alloc::string::String),
31        /// A literal constant value, passed as-is to the function.
32        #[prost(string, tag="2")]
33        Constant(::prost::alloc::string::String),
34    }
35}
36/// A reference to the SQL function that implements a row-filter or column-mask policy,
37/// together with the arguments it is invoked with.
38#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
39#[derive(Clone, PartialEq, ::prost::Message)]
40pub struct FunctionRef {
41    /// Fully qualified name of the function (catalog.schema.function) to invoke.
42    #[prost(string, tag="1")]
43    pub function_name: ::prost::alloc::string::String,
44    /// The arguments passed to the function, in declaration order.
45    #[prost(message, repeated, tag="2")]
46    pub using: ::prost::alloc::vec::Vec<FunctionArg>,
47}
48/// A row-filter or column-mask policy bound to principals and scoped to a securable.
49///
50/// Policies are read as whole documents; enforcement is performed by the query engine,
51/// not by this service. `when_condition` is stored and returned opaque — this service does
52/// not parse or evaluate it.
53#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
54#[derive(Clone, PartialEq, ::prost::Message)]
55pub struct PolicyInfo {
56    /// The name of the policy. Unique within the securable it is defined on.
57    #[prost(string, tag="1")]
58    pub name: ::prost::alloc::string::String,
59    /// Server-assigned unique identifier for the policy.
60    #[prost(string, optional, tag="2")]
61    pub id: ::core::option::Option<::prost::alloc::string::String>,
62    /// The type of securable the policy is defined on.
63    ///
64    /// Supported values: catalogs, schemas, tables.
65    #[prost(string, tag="3")]
66    pub on_securable_type: ::prost::alloc::string::String,
67    /// The fully qualified name of the securable the policy is defined on.
68    #[prost(string, tag="4")]
69    pub on_securable_fullname: ::prost::alloc::string::String,
70    /// The kind of enforcement this policy applies.
71    #[prost(enumeration="PolicyType", tag="5")]
72    pub policy_type: i32,
73    /// The principals the policy applies to. Empty means "all principals".
74    #[prost(string, repeated, tag="6")]
75    pub to_principals: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
76    /// The principals explicitly excluded from the policy, even if matched by to_principals.
77    #[prost(string, repeated, tag="7")]
78    pub except_principals: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
79    /// An opaque condition expression, e.g. "hasTagValue('env','prod')", evaluated by the
80    /// query engine at enforcement time. Stored and returned as-is; not parsed server-side.
81    #[prost(string, optional, tag="8")]
82    pub when_condition: ::core::option::Option<::prost::alloc::string::String>,
83    /// The columns referenced by the row-filter or column-mask function, and the aliases
84    /// they are bound to.
85    #[prost(message, repeated, tag="9")]
86    pub match_columns: ::prost::alloc::vec::Vec<MatchColumn>,
87    /// User-provided free-form text description of the policy.
88    #[prost(string, optional, tag="12")]
89    pub comment: ::core::option::Option<::prost::alloc::string::String>,
90    /// Time at which this policy was created, in epoch milliseconds.
91    #[prost(int64, optional, tag="13")]
92    pub created_at: ::core::option::Option<i64>,
93    /// Time at which this policy was last updated, in epoch milliseconds.
94    #[prost(int64, optional, tag="14")]
95    pub updated_at: ::core::option::Option<i64>,
96    #[prost(oneof="policy_info::Function", tags="10, 11")]
97    pub function: ::core::option::Option<policy_info::Function>,
98}
99/// Nested message and enum types in `PolicyInfo`.
100pub mod policy_info {
101    #[cfg_attr(feature = "python", ::pyo3::pyclass)]
102    #[derive(Clone, PartialEq, ::prost::Oneof)]
103    pub enum Function {
104        /// The row-filter function to invoke. Set only when policy_type is POLICY_TYPE_ROW_FILTER.
105        #[prost(message, tag="10")]
106        RowFilter(super::FunctionRef),
107        /// The column-mask function to invoke. Set only when policy_type is POLICY_TYPE_COLUMN_MASK.
108        #[prost(message, tag="11")]
109        ColumnMask(super::FunctionRef),
110    }
111}
112/// The kind of enforcement a policy applies.
113#[cfg_attr(feature = "python", ::pyo3::pyclass)]
114#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
115#[repr(i32)]
116pub enum PolicyType {
117    Unspecified = 0,
118    /// Filters rows returned from the securable based on the when_condition and match_columns.
119    RowFilter = 1,
120    /// Masks a column's values for callers matched by the when_condition.
121    ColumnMask = 2,
122}
123impl PolicyType {
124    /// String value of the enum field names used in the ProtoBuf definition.
125    ///
126    /// The values are not transformed in any way and thus are considered stable
127    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
128    pub fn as_str_name(&self) -> &'static str {
129        match self {
130            Self::Unspecified => "POLICY_TYPE_UNSPECIFIED",
131            Self::RowFilter => "POLICY_TYPE_ROW_FILTER",
132            Self::ColumnMask => "POLICY_TYPE_COLUMN_MASK",
133        }
134    }
135    /// Creates an enum from field names used in the ProtoBuf definition.
136    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
137        match value {
138            "POLICY_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
139            "POLICY_TYPE_ROW_FILTER" => Some(Self::RowFilter),
140            "POLICY_TYPE_COLUMN_MASK" => Some(Self::ColumnMask),
141            _ => None,
142        }
143    }
144}
145/// List policies defined on a securable.
146#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
147#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
148pub struct ListPoliciesRequest {
149    /// The type of the securable to list policies on.
150    ///
151    /// Supported values: catalogs, schemas, tables.
152    #[prost(string, tag="1")]
153    pub on_securable_type: ::prost::alloc::string::String,
154    /// The fully qualified name of the securable to list policies on.
155    #[prost(string, tag="2")]
156    pub on_securable_fullname: ::prost::alloc::string::String,
157    /// When true, also return policies defined on the securable's ancestors
158    /// (e.g. for a table: its schema and catalog). Each returned PolicyInfo still
159    /// carries its own on_securable_type / on_securable_fullname, so callers can see
160    /// where it was defined.
161    #[prost(bool, optional, tag="3")]
162    pub include_inherited: ::core::option::Option<bool>,
163    /// The maximum number of results per page that should be returned.
164    #[prost(int32, optional, tag="4")]
165    pub max_results: ::core::option::Option<i32>,
166    /// Opaque pagination token to go to next page based on previous query.
167    #[prost(string, optional, tag="5")]
168    pub page_token: ::core::option::Option<::prost::alloc::string::String>,
169}
170/// List policies response.
171#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
172#[derive(Clone, PartialEq, ::prost::Message)]
173pub struct ListPoliciesResponse {
174    /// The policies returned.
175    #[prost(message, repeated, tag="1")]
176    pub policies: ::prost::alloc::vec::Vec<PolicyInfo>,
177    /// The next_page_token value to include in the next List request.
178    #[prost(string, optional, tag="2")]
179    pub next_page_token: ::core::option::Option<::prost::alloc::string::String>,
180}
181/// Create a new policy on a securable.
182#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
183#[derive(Clone, PartialEq, ::prost::Message)]
184pub struct CreatePolicyRequest {
185    /// The type of the securable to create the policy on.
186    ///
187    /// Supported values: catalogs, schemas, tables.
188    #[prost(string, tag="1")]
189    pub on_securable_type: ::prost::alloc::string::String,
190    /// The fully qualified name of the securable to create the policy on.
191    #[prost(string, tag="2")]
192    pub on_securable_fullname: ::prost::alloc::string::String,
193    /// The policy to create.
194    #[prost(message, optional, tag="3")]
195    pub policy_info: ::core::option::Option<PolicyInfo>,
196}
197/// Get a policy defined on a securable.
198#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
199#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
200pub struct GetPolicyRequest {
201    /// The type of the securable the policy is defined on.
202    ///
203    /// Supported values: catalogs, schemas, tables.
204    #[prost(string, tag="1")]
205    pub on_securable_type: ::prost::alloc::string::String,
206    /// The fully qualified name of the securable the policy is defined on.
207    #[prost(string, tag="2")]
208    pub on_securable_fullname: ::prost::alloc::string::String,
209    /// The name of the policy.
210    #[prost(string, tag="3")]
211    pub name: ::prost::alloc::string::String,
212}
213/// Update a policy defined on a securable.
214#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
215#[derive(Clone, PartialEq, ::prost::Message)]
216pub struct UpdatePolicyRequest {
217    /// The type of the securable the policy is defined on.
218    ///
219    /// Supported values: catalogs, schemas, tables.
220    #[prost(string, tag="1")]
221    pub on_securable_type: ::prost::alloc::string::String,
222    /// The fully qualified name of the securable the policy is defined on.
223    #[prost(string, tag="2")]
224    pub on_securable_fullname: ::prost::alloc::string::String,
225    /// The name of the policy to update.
226    #[prost(string, tag="3")]
227    pub name: ::prost::alloc::string::String,
228    /// The policy with the updated fields.
229    #[prost(message, optional, tag="4")]
230    pub policy_info: ::core::option::Option<PolicyInfo>,
231    /// The list of fields to update, as a comma-separated string.
232    #[prost(string, optional, tag="5")]
233    pub update_mask: ::core::option::Option<::prost::alloc::string::String>,
234}
235/// Delete a policy defined on a securable.
236#[cfg_attr(feature = "python", ::pyo3::pyclass(get_all, set_all))]
237#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
238pub struct DeletePolicyRequest {
239    /// The type of the securable the policy is defined on.
240    ///
241    /// Supported values: catalogs, schemas, tables.
242    #[prost(string, tag="1")]
243    pub on_securable_type: ::prost::alloc::string::String,
244    /// The fully qualified name of the securable the policy is defined on.
245    #[prost(string, tag="2")]
246    pub on_securable_fullname: ::prost::alloc::string::String,
247    /// The name of the policy to delete.
248    #[prost(string, tag="3")]
249    pub name: ::prost::alloc::string::String,
250}
251include!("unitycatalog.policies.v1.serde.rs");
252// @@protoc_insertion_point(module)