add entity for roles and firewall rules
This commit is contained in:
parent
b8d2afe5c3
commit
30432e216b
|
@ -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<String>,
|
||||
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 {}
|
|
@ -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;
|
||||
|
|
|
@ -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<super::network::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<super::role::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Role.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::User.def()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<super::organization::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Organization.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
Loading…
Reference in New Issue