diff --git a/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs b/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs new file mode 100644 index 0000000..6a8c64f --- /dev/null +++ b/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs @@ -0,0 +1,38 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "firewall_rule")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub id: String, + pub role: String, + pub protocol: String, + pub description: String, + pub allowed_role_id: Option, + pub port_range_from: i32, + pub port_range_to: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::role::Entity", + from = "Column::AllowedRoleId", + to = "super::role::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + Role2, + #[sea_orm( + belongs_to = "super::role::Entity", + from = "Column::Role", + to = "super::role::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Role1, +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_entities/src/entity/mod.rs b/trifid-api/trifid_api_entities/src/entity/mod.rs index 194bbb3..35ee697 100644 --- a/trifid-api/trifid_api_entities/src/entity/mod.rs +++ b/trifid-api/trifid_api_entities/src/entity/mod.rs @@ -5,9 +5,11 @@ pub mod prelude; pub mod api_key; pub mod api_key_scope; pub mod auth_token; +pub mod firewall_rule; pub mod magic_link; pub mod network; pub mod organization; +pub mod role; pub mod session_token; pub mod signing_ca; pub mod totp_authenticator; diff --git a/trifid-api/trifid_api_entities/src/entity/organization.rs b/trifid-api/trifid_api_entities/src/entity/organization.rs index f5f5026..25d4ff9 100644 --- a/trifid-api/trifid_api_entities/src/entity/organization.rs +++ b/trifid-api/trifid_api_entities/src/entity/organization.rs @@ -18,6 +18,8 @@ pub enum Relation { ApiKey, #[sea_orm(has_one = "super::network::Entity")] Network, + #[sea_orm(has_many = "super::role::Entity")] + Role, #[sea_orm( belongs_to = "super::user::Entity", from = "Column::Owner", @@ -40,6 +42,12 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Role.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::User.def() diff --git a/trifid-api/trifid_api_entities/src/entity/prelude.rs b/trifid-api/trifid_api_entities/src/entity/prelude.rs index 2fdea32..93cce0c 100644 --- a/trifid-api/trifid_api_entities/src/entity/prelude.rs +++ b/trifid-api/trifid_api_entities/src/entity/prelude.rs @@ -3,9 +3,11 @@ pub use super::api_key::Entity as ApiKey; pub use super::api_key_scope::Entity as ApiKeyScope; pub use super::auth_token::Entity as AuthToken; +pub use super::firewall_rule::Entity as FirewallRule; pub use super::magic_link::Entity as MagicLink; pub use super::network::Entity as Network; pub use super::organization::Entity as Organization; +pub use super::role::Entity as Role; pub use super::session_token::Entity as SessionToken; pub use super::signing_ca::Entity as SigningCa; pub use super::totp_authenticator::Entity as TotpAuthenticator; diff --git a/trifid-api/trifid_api_entities/src/entity/role.rs b/trifid-api/trifid_api_entities/src/entity/role.rs new file mode 100644 index 0000000..aa3f61f --- /dev/null +++ b/trifid-api/trifid_api_entities/src/entity/role.rs @@ -0,0 +1,33 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "role")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub id: String, + pub name: String, + pub description: String, + pub organization: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::organization::Entity", + from = "Column::Organization", + to = "super::organization::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Organization, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Organization.def() + } +} + +impl ActiveModelBehavior for ActiveModel {}