Skip to main content

unitycatalog_server/api/
mod.rs

1pub use agent_skills::AgentSkillHandler;
2pub use agents::AgentHandler;
3pub use catalogs::CatalogHandler;
4pub use credentials::CredentialHandler;
5pub use entity_tag_assignments::EntityTagAssignmentHandler;
6pub use external_locations::ExternalLocationHandler;
7pub use functions::FunctionHandler;
8pub use model_versions::ModelVersionHandler;
9pub use policies::PolicyHandler;
10pub use providers::ProviderHandler;
11pub use recipients::RecipientHandler;
12pub use registered_models::RegisteredModelHandler;
13pub use schemas::SchemaHandler;
14pub use shares::ShareHandler;
15pub use staging_tables::StagingTableHandler;
16pub use tables::TableHandler;
17pub use tag_policies::TagPolicyHandler;
18pub use temporary_credentials::TemporaryCredentialHandler;
19pub use volumes::VolumeHandler;
20
21use crate::policy::{Permission, Principal};
22use unitycatalog_common::models::ResourceIdent;
23
24// TODO: implement once AssociationLabel::CreatedBy and AssociationLabel::UpdatedBy variants are
25// added to unitycatalog_common (they are currently absent from the AssociationLabel enum in
26// crates/common/src/models/mod.rs). Once those variants exist, this function should be called
27// from create_* and update_* handlers to record who created or last updated a resource.
28//
29// Proposed signature:
30// pub async fn record_audit<S: ResourceStore>(
31//     store: &S,
32//     resource: &ResourceIdent,
33//     principal: &Principal,
34//     action: &str, // "created" | "updated"
35// ) -> Result<()>
36
37pub mod agent_skills;
38pub mod agents;
39pub mod catalogs;
40pub mod credentials;
41pub mod entity_tag_assignments;
42pub mod external_locations;
43pub mod functions;
44pub mod model_versions;
45pub mod policies;
46pub mod providers;
47pub mod recipients;
48pub mod registered_models;
49pub mod schemas;
50pub mod shares;
51pub mod staging_tables;
52pub mod tables;
53pub mod tag_policies;
54pub mod temporary_credentials;
55pub mod volumes;
56
57#[derive(Debug, Clone)]
58pub struct RequestContext {
59    pub recipient: Principal,
60}
61
62impl RequestContext {
63    pub fn recipient(&self) -> &Principal {
64        &self.recipient
65    }
66}
67
68impl AsRef<Principal> for RequestContext {
69    fn as_ref(&self) -> &Principal {
70        &self.recipient
71    }
72}
73
74pub trait SecuredAction: Send + Sync {
75    /// The resource that the action is performed on.
76    fn resource(&self) -> ResourceIdent;
77
78    /// The permission required to perform the action.
79    fn permission(&self) -> &'static Permission;
80}