diff --git a/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java b/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java index ffc9aabf174412251d269e3c09aa9e9626597834..cc2bed0ee49cb8e7a369424bbd81969b214c5e19 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java +++ b/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java @@ -209,9 +209,14 @@ public class PolicyServiceImpl implements PolicyService { var empty = monitoringService.deleteKpi(policy.getKpiId()); empty .subscribe() - .with(emptyMessage -> LOGGER.infof("Policy [%s] has been deleted.\n", policyRuleId)); + .with(emptyMessage -> LOGGER.infof("Kpi [%s] has been deleted.\n", policyRuleId)); } + var empty = contextService.removePolicyRule(policyRuleId); + empty + .subscribe() + .with(emptyMessage -> LOGGER.infof("Policy [%s] has been removed.\n", policyRuleId)); + policyRuleBasic.setPolicyRuleState(REMOVED_POLICYRULE_STATE); contextService.setPolicyRule(policyRuleBasic); diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/ContextGateway.java b/src/policy/src/main/java/eu/teraflow/policy/context/ContextGateway.java index 1f1c2446aeeec7e2dc62d8732187255df8c477a1..4e90fe7b63cec0b3769842f79de4df774c848c01 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/ContextGateway.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/ContextGateway.java @@ -17,6 +17,7 @@ package eu.teraflow.policy.context; import eu.teraflow.policy.context.model.Device; +import eu.teraflow.policy.context.model.Empty; import eu.teraflow.policy.context.model.Service; import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.model.PolicyRuleBasic; @@ -35,4 +36,6 @@ public interface ContextGateway { Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId); Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic); + + Uni<Empty> removePolicyRule(String policyRuleId); } diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/ContextGatewayImpl.java b/src/policy/src/main/java/eu/teraflow/policy/context/ContextGatewayImpl.java index 568ff449a4a31d5ea9fe540b7267b9f2cbd50fe9..8b8f981d00be81588da624c062bdc18383c42acc 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/ContextGatewayImpl.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/ContextGatewayImpl.java @@ -20,6 +20,7 @@ import context.MutinyContextServiceGrpc.MutinyContextServiceStub; import context_policy.MutinyContextPolicyServiceGrpc.MutinyContextPolicyServiceStub; import eu.teraflow.policy.Serializer; import eu.teraflow.policy.context.model.Device; +import eu.teraflow.policy.context.model.Empty; import eu.teraflow.policy.context.model.Service; import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.model.PolicyRuleBasic; @@ -97,4 +98,14 @@ public class ContextGatewayImpl implements ContextGateway { .onItem() .transform(serializer::deserialize); } + + @Override + public Uni<Empty> removePolicyRule(String policyRuleId) { + final var serializedPolicyRuleId = serializer.serializePolicyRuleId(policyRuleId); + + return streamingDelegateContextPolicy + .removePolicyRule(serializedPolicyRuleId) + .onItem() + .transform(serializer::deserializeEmpty); + } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java b/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java index 133318a05bad7f8a2fd4b7d2ae423e1375d34287..41290e52a6a3ac8e84c3f010de137298dd969edf 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java @@ -17,6 +17,7 @@ package eu.teraflow.policy.context; import eu.teraflow.policy.context.model.Device; +import eu.teraflow.policy.context.model.Empty; import eu.teraflow.policy.context.model.Service; import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.model.PolicyRuleBasic; @@ -33,4 +34,6 @@ public interface ContextService { Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId); Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic); + + Uni<Empty> removePolicyRule(String policyRuleId); } diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/ContextServiceImpl.java b/src/policy/src/main/java/eu/teraflow/policy/context/ContextServiceImpl.java index bb5c8d61bd5f73375b531f43bcfb744dc5bf2c20..b8ffc44a4d6e5b4c6ee4ff4e02129272b098a21a 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/ContextServiceImpl.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/ContextServiceImpl.java @@ -17,6 +17,7 @@ package eu.teraflow.policy.context; import eu.teraflow.policy.context.model.Device; +import eu.teraflow.policy.context.model.Empty; import eu.teraflow.policy.context.model.Service; import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.model.PolicyRuleBasic; @@ -58,4 +59,9 @@ public class ContextServiceImpl implements ContextService { public Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic) { return contextGateway.setPolicyRule(policyRuleBasic); } + + @Override + public Uni<Empty> removePolicyRule(String policyRuleId) { + return contextGateway.removePolicyRule(policyRuleId); + } }