diff --git a/cala-ledger/src/velocity/control/entity.rs b/cala-ledger/src/velocity/control/entity.rs index a019742d..1ddaac38 100644 --- a/cala-ledger/src/velocity/control/entity.rs +++ b/cala-ledger/src/velocity/control/entity.rs @@ -75,7 +75,7 @@ pub struct NewVelocityControl { #[builder(setter(into))] description: String, #[builder(setter(into), default)] - enforcement: VelocityEnforcement, + enforcement: NewVelocityEnforcement, #[builder(setter(strip_option, into), default)] condition: Option, } @@ -93,7 +93,7 @@ impl NewVelocityControl { id: self.id, name: self.name, description: self.description, - enforcement: self.enforcement, + enforcement: self.enforcement.action.into(), condition: self .condition .map(|expr| CelExpression::try_from(expr).expect("already validated")), @@ -116,3 +116,15 @@ fn validate_optional_expression(expr: &Option>) -> Result<(), Str } Ok(()) } + +#[derive(Builder, Debug, Clone, Default)] +pub struct NewVelocityEnforcement { + #[builder(setter(into), default)] + pub(super) action: VelocityEnforcementAction, +} + +impl NewVelocityEnforcement { + pub fn builder() -> NewVelocityEnforcementBuilder { + NewVelocityEnforcementBuilder::default() + } +} diff --git a/cala-server/src/graphql/schema.rs b/cala-server/src/graphql/schema.rs index 1fc6ae95..b1b63986 100644 --- a/cala-server/src/graphql/schema.rs +++ b/cala-server/src/graphql/schema.rs @@ -726,6 +726,13 @@ impl CoreMutation { new_velocity_control_builder.condition(condition); } + let mut new_velocity_enforcement_builder = + cala_ledger::velocity::NewVelocityEnforcement::builder(); + new_velocity_enforcement_builder.action(input.enforcement.velocity_enforcement_action); + let new_velocity_enforcement = new_velocity_enforcement_builder.build()?; + + new_velocity_control_builder.enforcement(new_velocity_enforcement); + let new_velocity_control = new_velocity_control_builder.build()?; let velocity_control = app .ledger()