Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • tfs/controller
1 result
Show changes
Commits on Source (5)
Showing
with 362 additions and 132 deletions
...@@ -50,6 +50,7 @@ message PolicyRuleId { ...@@ -50,6 +50,7 @@ message PolicyRuleId {
message PolicyRuleState { message PolicyRuleState {
PolicyRuleStateEnum policyRuleState = 1; PolicyRuleStateEnum policyRuleState = 1;
string policyRuleStateMessage = 2;
} }
// Basic policy rule attributes // Basic policy rule attributes
......
...@@ -66,25 +66,35 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -66,25 +66,35 @@ public class PolicyServiceImpl implements PolicyService {
private static final String INVALID_MESSAGE = "%s is invalid."; private static final String INVALID_MESSAGE = "%s is invalid.";
private static final String VALID_MESSAGE = "%s is valid."; private static final String VALID_MESSAGE = "%s is valid.";
private static final PolicyRuleState INSERTED_POLICYRULE_STATE = private static final PolicyRuleState INSERTED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_INSERTED, "Successfully set to INSERTED STATE");
private static final PolicyRuleState VALIDATED_POLICYRULE_STATE = private static final PolicyRuleState VALIDATED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_VALIDATED); new PolicyRuleState(
private static final PolicyRuleState FAILED_POLICYRULE_STATE = PolicyRuleStateEnum.POLICY_VALIDATED, "Successfully transitioned to VALIDATED STATE");
new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED);
private static final PolicyRuleState PROVISIONED_POLICYRULE_STATE = private static final PolicyRuleState PROVISIONED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_PROVISIONED); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_PROVISIONED,
"Successfully transitioned from VALIDATED to PROVISIONED STATE");
private static final PolicyRuleState ACTIVE_POLICYRULE_STATE = private static final PolicyRuleState ACTIVE_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_ACTIVE); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_ACTIVE,
"Successfully transitioned from PROVISIONED to ACTIVE STATE");
private static final PolicyRuleState ENFORCED_POLICYRULE_STATE = private static final PolicyRuleState ENFORCED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_ENFORCED,
"Successfully transitioned from ACTIVE to ENFORCED STATE");
private static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE = private static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_INEFFECTIVE); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_INEFFECTIVE,
"Transitioned from ENFORCED to INEFFECTIVE state");
private static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE = private static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); new PolicyRuleState(
PolicyRuleStateEnum.POLICY_EFFECTIVE,
"Successfully transitioned from ENFORCED to EFFECTIVE state");
private static final PolicyRuleState UPDATED_POLICYRULE_STATE = private static final PolicyRuleState UPDATED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_UPDATED); new PolicyRuleState(PolicyRuleStateEnum.POLICY_UPDATED, "Successfully set to UPDATED STATE");
private static final PolicyRuleState REMOVED_POLICYRULE_STATE = private static final PolicyRuleState REMOVED_POLICYRULE_STATE =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED); new PolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED, "Successfully set to REMOVED STATE");
private final ContextService contextService; private final ContextService contextService;
private final MonitoringService monitoringService; private final MonitoringService monitoringService;
...@@ -115,6 +125,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -115,6 +125,10 @@ public class PolicyServiceImpl implements PolicyService {
this.policyRuleConditionFieldsGetter = policyRuleConditionFieldsGetter; this.policyRuleConditionFieldsGetter = policyRuleConditionFieldsGetter;
} }
private static PolicyRuleState createFailedPolicyRuleState(String message) {
return new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, message);
}
private static String gen() { private static String gen() {
Random r = new Random(System.currentTimeMillis()); Random r = new Random(System.currentTimeMillis());
return String.valueOf((1 + r.nextInt(2)) * 10000 + r.nextInt(10000)); return String.valueOf((1 + r.nextInt(2)) * 10000 + r.nextInt(10000));
...@@ -132,13 +146,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -132,13 +146,10 @@ public class PolicyServiceImpl implements PolicyService {
final var policyRuleBasic = policyRuleService.getPolicyRuleBasic(); final var policyRuleBasic = policyRuleService.getPolicyRuleBasic();
policyRuleBasic.setPolicyRuleState(INSERTED_POLICYRULE_STATE); policyRuleBasic.setPolicyRuleState(INSERTED_POLICYRULE_STATE);
new Thread( contextService
() -> { .setPolicyRule(policyRuleBasic)
validateService(policyRuleService); .subscribe()
}) .with(id -> validateService(policyRuleService));
.start();
contextService.setPolicyRule(policyRuleBasic);
return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState()); return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState());
} }
...@@ -150,13 +161,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -150,13 +161,10 @@ public class PolicyServiceImpl implements PolicyService {
final var policyRuleBasic = policyRuleService.getPolicyRuleBasic(); final var policyRuleBasic = policyRuleService.getPolicyRuleBasic();
policyRuleBasic.setPolicyRuleState(UPDATED_POLICYRULE_STATE); policyRuleBasic.setPolicyRuleState(UPDATED_POLICYRULE_STATE);
new Thread( contextService
() -> { .setPolicyRule(policyRuleBasic)
validateUpdatedPolicyService(policyRuleService); .subscribe()
}) .with(id -> validateUpdatedPolicyService(policyRuleService));
.start();
contextService.setPolicyRule(policyRuleBasic);
return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState()); return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState());
} }
...@@ -168,13 +176,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -168,13 +176,10 @@ public class PolicyServiceImpl implements PolicyService {
final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic(); final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic();
policyRuleBasic.setPolicyRuleState(INSERTED_POLICYRULE_STATE); policyRuleBasic.setPolicyRuleState(INSERTED_POLICYRULE_STATE);
new Thread( contextService
() -> { .setPolicyRule(policyRuleBasic)
validateDevice(policyRuleDevice); .subscribe()
}) .with(id -> validateDevice(policyRuleDevice));
.start();
contextService.setPolicyRule(policyRuleBasic);
return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState()); return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState());
} }
...@@ -185,13 +190,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -185,13 +190,10 @@ public class PolicyServiceImpl implements PolicyService {
final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic(); final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic();
policyRuleBasic.setPolicyRuleState(UPDATED_POLICYRULE_STATE); policyRuleBasic.setPolicyRuleState(UPDATED_POLICYRULE_STATE);
new Thread( contextService
() -> { .setPolicyRule(policyRuleBasic)
validateUpdatedPolicyDevice(policyRuleDevice); .subscribe()
}) .with(id -> validateUpdatedPolicyDevice(policyRuleDevice));
.start();
contextService.setPolicyRule(policyRuleBasic);
return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState()); return Uni.createFrom().item(policyRuleBasic.getPolicyRuleState());
} }
...@@ -200,6 +202,7 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -200,6 +202,7 @@ public class PolicyServiceImpl implements PolicyService {
public Uni<PolicyRuleState> deletePolicy(String policyRuleId) { public Uni<PolicyRuleState> deletePolicy(String policyRuleId) {
LOGGER.infof("Received %s", policyRuleId); LOGGER.infof("Received %s", policyRuleId);
// TODO: Specify timeout in case of connectivity issue
PolicyRuleBasic policyRuleBasic = PolicyRuleBasic policyRuleBasic =
contextService.getPolicyRule(policyRuleId).await().indefinitely(); contextService.getPolicyRule(policyRuleId).await().indefinitely();
List<PolicyRuleCondition> policyRuleConditions = policyRuleBasic.getPolicyRuleConditions(); List<PolicyRuleCondition> policyRuleConditions = policyRuleBasic.getPolicyRuleConditions();
...@@ -208,9 +211,14 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -208,9 +211,14 @@ public class PolicyServiceImpl implements PolicyService {
var empty = monitoringService.deleteKpi(policy.getKpiId()); var empty = monitoringService.deleteKpi(policy.getKpiId());
empty empty
.subscribe() .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); policyRuleBasic.setPolicyRuleState(REMOVED_POLICYRULE_STATE);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
...@@ -249,9 +257,9 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -249,9 +257,9 @@ public class PolicyServiceImpl implements PolicyService {
alarmResponse -> { alarmResponse -> {
LOGGER.info(alarmResponse); LOGGER.info(alarmResponse);
if (isService) { if (isService) {
activateService(alarmResponse.getAlarmId()); applyActionService(alarmResponse.getAlarmId());
} else { } else {
activateDevices(alarmResponse.getAlarmId()); applyActionDevice(alarmResponse.getAlarmId());
} }
}); });
...@@ -280,15 +288,15 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -280,15 +288,15 @@ public class PolicyServiceImpl implements PolicyService {
alarmResponse -> { alarmResponse -> {
LOGGER.info(alarmResponse); LOGGER.info(alarmResponse);
if (isService) { if (isService) {
activateService(alarmResponse.getAlarmId()); applyActionService(alarmResponse.getAlarmId());
} else { } else {
activateDevices(alarmResponse.getAlarmId()); applyActionDevice(alarmResponse.getAlarmId());
} }
}); });
} }
} }
private void activateDevices(String alarmId) { private void applyActionDevice(String alarmId) {
PolicyRuleDevice policyRuleDevice = alarmPolicyRuleDeviceMap.get(alarmId); PolicyRuleDevice policyRuleDevice = alarmPolicyRuleDeviceMap.get(alarmId);
PolicyRuleBasic policyRuleBasic = policyRuleDevice.getPolicyRuleBasic(); PolicyRuleBasic policyRuleBasic = policyRuleDevice.getPolicyRuleBasic();
...@@ -420,7 +428,7 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -420,7 +428,7 @@ public class PolicyServiceImpl implements PolicyService {
}); });
} }
private void activateService(String alarmId) { private void applyActionService(String alarmId) {
PolicyRuleService policyRuleService = alarmPolicyRuleServiceMap.get(alarmId); PolicyRuleService policyRuleService = alarmPolicyRuleServiceMap.get(alarmId);
PolicyRuleBasic policyRuleBasic = policyRuleService.getPolicyRuleBasic(); PolicyRuleBasic policyRuleBasic = policyRuleService.getPolicyRuleBasic();
PolicyRuleAction policyRuleAction = policyRuleActionMap.get(alarmId); PolicyRuleAction policyRuleAction = policyRuleActionMap.get(alarmId);
...@@ -443,11 +451,15 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -443,11 +451,15 @@ public class PolicyServiceImpl implements PolicyService {
private void validateDevice(PolicyRuleDevice policyRuleDevice) { private void validateDevice(PolicyRuleDevice policyRuleDevice) {
final var deviceIds = policyRuleDevice.getDeviceIds(); final var deviceIds = policyRuleDevice.getDeviceIds();
final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic(); final var policyRuleBasic = policyRuleDevice.getPolicyRuleBasic();
final var policyRuleId = policyRuleBasic.getPolicyRuleId();
final var invalidDeviceIds = returnInvalidDeviceIds(deviceIds); final var invalidDeviceIds = returnInvalidDeviceIds(deviceIds);
if (!invalidDeviceIds.isEmpty()) { if (!invalidDeviceIds.isEmpty()) {
LOGGER.infof("Setting Policy Rule state to [%s]", FAILED_POLICYRULE_STATE.toString()); var policyRuleState =
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); createFailedPolicyRuleState(
"The Devices of PolicyRuleDevice " + policyRuleId + " are not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} }
...@@ -456,8 +468,11 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -456,8 +468,11 @@ public class PolicyServiceImpl implements PolicyService {
parsePolicyRuleCondition(policyRuleDevice.getPolicyRuleBasic()); parsePolicyRuleCondition(policyRuleDevice.getPolicyRuleBasic());
if (alarmDescriptorList.isEmpty()) { if (alarmDescriptorList.isEmpty()) {
LOGGER.infof("Setting Policy Rule state to [%s]", FAILED_POLICYRULE_STATE.toString()); var policyRuleState =
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); createFailedPolicyRuleState(
"The PolicyRuleConditions of PolicyRuleDevice " + policyRuleId + " are not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} }
...@@ -480,14 +495,19 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -480,14 +495,19 @@ public class PolicyServiceImpl implements PolicyService {
.subscribe() .subscribe()
.with( .with(
policyRuleBoolean -> { policyRuleBoolean -> {
if (Boolean.TRUE.equals(isUpdatedPolicyRuleValid)) { if (Boolean.FALSE.equals(isUpdatedPolicyRuleValid)) {
validateService(policyRuleService); var policyRuleState =
return; createFailedPolicyRuleState(
} else { "The requested PolicyRuleService to update: "
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); + policyRuleBasic.getPolicyRuleId()
+ " is not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} }
validateService(policyRuleService);
}); });
} }
...@@ -501,14 +521,18 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -501,14 +521,18 @@ public class PolicyServiceImpl implements PolicyService {
.subscribe() .subscribe()
.with( .with(
policyRuleBoolean -> { policyRuleBoolean -> {
if (Boolean.TRUE.equals(isUpdatedPolicyRuleValid)) { if (Boolean.FALSE.equals(isUpdatedPolicyRuleValid)) {
validateDevice(policyRuleDevice); var policyRuleState =
return; createFailedPolicyRuleState(
} else { "The requested PolicyRuleDevice to update: "
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); + policyRuleBasic.getPolicyRuleId()
+ " is not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} }
validateDevice(policyRuleDevice);
}); });
} }
...@@ -530,8 +554,13 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -530,8 +554,13 @@ public class PolicyServiceImpl implements PolicyService {
if (invalidDeviceIds.isEmpty()) { if (invalidDeviceIds.isEmpty()) {
LOGGER.info("All Device Ids are valid."); LOGGER.info("All Device Ids are valid.");
} }
var policyRuleState =
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); createFailedPolicyRuleState(
"The Service of PolicyRuleService "
+ policyRuleBasic.getPolicyRuleId()
+ " is not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} else { } else {
...@@ -540,7 +569,13 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -540,7 +569,13 @@ public class PolicyServiceImpl implements PolicyService {
final var invalidDeviceIds = returnInvalidDeviceIds(deviceIds); final var invalidDeviceIds = returnInvalidDeviceIds(deviceIds);
if (!invalidDeviceIds.isEmpty()) { if (!invalidDeviceIds.isEmpty()) {
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); var policyRuleState =
createFailedPolicyRuleState(
"The Devices of PolicyRuleService "
+ policyRuleBasic.getPolicyRuleId()
+ " are not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} else { } else {
...@@ -561,8 +596,13 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -561,8 +596,13 @@ public class PolicyServiceImpl implements PolicyService {
parsePolicyRuleCondition(policyRuleService.getPolicyRuleBasic()); parsePolicyRuleCondition(policyRuleService.getPolicyRuleBasic());
if (alarmDescriptorList.isEmpty()) { if (alarmDescriptorList.isEmpty()) {
LOGGER.infof("Setting Policy Rule state to [%s]", FAILED_POLICYRULE_STATE.toString()); var policyRuleState =
policyRuleBasic.setPolicyRuleState(FAILED_POLICYRULE_STATE); createFailedPolicyRuleState(
"The PolicyRuleConditions of PolicyRuleDevice "
+ policyRuleBasic.getPolicyRuleId()
+ " are not valid");
LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString());
policyRuleBasic.setPolicyRuleState(policyRuleState);
contextService.setPolicyRule(policyRuleBasic); contextService.setPolicyRule(policyRuleBasic);
return; return;
} }
......
...@@ -1379,20 +1379,23 @@ public class Serializer { ...@@ -1379,20 +1379,23 @@ public class Serializer {
final var builder = Policy.PolicyRuleState.newBuilder(); final var builder = Policy.PolicyRuleState.newBuilder();
final var ruleState = policyRuleState.getRuleState(); final var ruleState = policyRuleState.getRuleState();
final var policyRuleStateMessage = policyRuleState.getPolicyRuleStateMessage();
final var serializedRuleState = serialize(ruleState); final var serializedRuleState = serialize(ruleState);
builder.setPolicyRuleState(serializedRuleState); builder.setPolicyRuleState(serializedRuleState);
builder.setPolicyRuleStateMessage(policyRuleStateMessage);
return builder.build(); return builder.build();
} }
public PolicyRuleState deserialize(Policy.PolicyRuleState serializedPolicyRuleState) { public PolicyRuleState deserialize(Policy.PolicyRuleState serializedPolicyRuleState) {
final var serializedRuleState = serializedPolicyRuleState.getPolicyRuleState(); final var serializedRuleState = serializedPolicyRuleState.getPolicyRuleState();
final var serializedRuleStateMessage = serializedPolicyRuleState.getPolicyRuleStateMessage();
final var ruleState = deserialize(serializedRuleState); final var ruleState = deserialize(serializedRuleState);
return new PolicyRuleState(ruleState); return new PolicyRuleState(ruleState, serializedRuleStateMessage);
} }
public PolicyCondition.NumericalOperator serialize(NumericalOperator numericalOperator) { public PolicyCondition.NumericalOperator serialize(NumericalOperator numericalOperator) {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package eu.teraflow.policy.context; package eu.teraflow.policy.context;
import eu.teraflow.policy.context.model.Device; 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.Service;
import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.context.model.ServiceId;
import eu.teraflow.policy.model.PolicyRuleBasic; import eu.teraflow.policy.model.PolicyRuleBasic;
...@@ -35,4 +36,6 @@ public interface ContextGateway { ...@@ -35,4 +36,6 @@ public interface ContextGateway {
Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId); Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId);
Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic); Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic);
Uni<Empty> removePolicyRule(String policyRuleId);
} }
...@@ -20,6 +20,7 @@ import context.MutinyContextServiceGrpc.MutinyContextServiceStub; ...@@ -20,6 +20,7 @@ import context.MutinyContextServiceGrpc.MutinyContextServiceStub;
import context_policy.MutinyContextPolicyServiceGrpc.MutinyContextPolicyServiceStub; import context_policy.MutinyContextPolicyServiceGrpc.MutinyContextPolicyServiceStub;
import eu.teraflow.policy.Serializer; import eu.teraflow.policy.Serializer;
import eu.teraflow.policy.context.model.Device; 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.Service;
import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.context.model.ServiceId;
import eu.teraflow.policy.model.PolicyRuleBasic; import eu.teraflow.policy.model.PolicyRuleBasic;
...@@ -97,4 +98,14 @@ public class ContextGatewayImpl implements ContextGateway { ...@@ -97,4 +98,14 @@ public class ContextGatewayImpl implements ContextGateway {
.onItem() .onItem()
.transform(serializer::deserialize); .transform(serializer::deserialize);
} }
@Override
public Uni<Empty> removePolicyRule(String policyRuleId) {
final var serializedPolicyRuleId = serializer.serializePolicyRuleId(policyRuleId);
return streamingDelegateContextPolicy
.removePolicyRule(serializedPolicyRuleId)
.onItem()
.transform(serializer::deserializeEmpty);
}
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package eu.teraflow.policy.context; package eu.teraflow.policy.context;
import eu.teraflow.policy.context.model.Device; 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.Service;
import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.context.model.ServiceId;
import eu.teraflow.policy.model.PolicyRuleBasic; import eu.teraflow.policy.model.PolicyRuleBasic;
...@@ -33,4 +34,6 @@ public interface ContextService { ...@@ -33,4 +34,6 @@ public interface ContextService {
Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId); Uni<PolicyRuleBasic> getPolicyRule(String policyRuleId);
Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic); Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic);
Uni<Empty> removePolicyRule(String policyRuleId);
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package eu.teraflow.policy.context; package eu.teraflow.policy.context;
import eu.teraflow.policy.context.model.Device; 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.Service;
import eu.teraflow.policy.context.model.ServiceId; import eu.teraflow.policy.context.model.ServiceId;
import eu.teraflow.policy.model.PolicyRuleBasic; import eu.teraflow.policy.model.PolicyRuleBasic;
...@@ -58,4 +59,9 @@ public class ContextServiceImpl implements ContextService { ...@@ -58,4 +59,9 @@ public class ContextServiceImpl implements ContextService {
public Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic) { public Uni<String> setPolicyRule(PolicyRuleBasic policyRuleBasic) {
return contextGateway.setPolicyRule(policyRuleBasic); return contextGateway.setPolicyRule(policyRuleBasic);
} }
@Override
public Uni<Empty> removePolicyRule(String policyRuleId) {
return contextGateway.removePolicyRule(policyRuleId);
}
} }
...@@ -19,9 +19,11 @@ package eu.teraflow.policy.model; ...@@ -19,9 +19,11 @@ package eu.teraflow.policy.model;
public class PolicyRuleState { public class PolicyRuleState {
private PolicyRuleStateEnum policyRuleStateEnum; private PolicyRuleStateEnum policyRuleStateEnum;
private String policyRuleStateMessage;
public PolicyRuleState(PolicyRuleStateEnum policyRuleStateEnum) { public PolicyRuleState(PolicyRuleStateEnum policyRuleStateEnum, String policyRuleStateMessage) {
this.policyRuleStateEnum = policyRuleStateEnum; this.policyRuleStateEnum = policyRuleStateEnum;
this.policyRuleStateMessage = policyRuleStateMessage;
} }
public void setRuleState(PolicyRuleStateEnum policyRuleStateEnum) { public void setRuleState(PolicyRuleStateEnum policyRuleStateEnum) {
...@@ -32,6 +34,14 @@ public class PolicyRuleState { ...@@ -32,6 +34,14 @@ public class PolicyRuleState {
return policyRuleStateEnum; return policyRuleStateEnum;
} }
public void setPolicyRuleStateMessage(String policyRuleStateMessage) {
this.policyRuleStateMessage = policyRuleStateMessage;
}
public String getPolicyRuleStateMessage() {
return this.policyRuleStateMessage;
}
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
......
...@@ -83,7 +83,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -83,7 +83,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
assertThatExceptionOfType(NullPointerException.class) assertThatExceptionOfType(NullPointerException.class)
.isThrownBy( .isThrownBy(
...@@ -109,7 +109,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -109,7 +109,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1");
assertThatExceptionOfType(IllegalArgumentException.class) assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy( .isThrownBy(
...@@ -135,7 +135,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -135,7 +135,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1");
assertThatExceptionOfType(IllegalArgumentException.class) assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy( .isThrownBy(
...@@ -161,7 +161,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -161,7 +161,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -184,7 +184,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -184,7 +184,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -208,7 +208,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -208,7 +208,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -236,7 +236,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -236,7 +236,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_VALIDATED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_VALIDATED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -260,7 +260,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -260,7 +260,7 @@ class PolicyRuleBasicValidationTestHelper {
NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN,
new IntegerKpiValue(3)); new IntegerKpiValue(3));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_PROVISIONED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_PROVISIONED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -285,7 +285,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -285,7 +285,7 @@ class PolicyRuleBasicValidationTestHelper {
new IntegerKpiValue(3)); new IntegerKpiValue(3));
final var policyRuleActions = Collections.<PolicyRuleAction>emptyList(); final var policyRuleActions = Collections.<PolicyRuleAction>emptyList();
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "1");
final var policyRuleId = UUID.randomUUID().toString(); final var policyRuleId = UUID.randomUUID().toString();
...@@ -304,7 +304,8 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -304,7 +304,8 @@ class PolicyRuleBasicValidationTestHelper {
@Test @Test
void shouldCreatePolicyRuleBasicObject() { void shouldCreatePolicyRuleBasicObject() {
final var expectedPolicyRuleId = "expectedPolicyRuleId"; final var expectedPolicyRuleId = "expectedPolicyRuleId";
final var expectedPolicyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var expectedPolicyRuleState =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var expectedPriority = 3; final var expectedPriority = 3;
final var firstKpiValue = new IntegerKpiValue(22); final var firstKpiValue = new IntegerKpiValue(22);
...@@ -345,7 +346,7 @@ class PolicyRuleBasicValidationTestHelper { ...@@ -345,7 +346,7 @@ class PolicyRuleBasicValidationTestHelper {
PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS,
List.of("parameter1", "parameter2")); List.of("parameter1", "parameter2"));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
......
...@@ -100,7 +100,7 @@ class PolicyRuleDeviceValidationTest { ...@@ -100,7 +100,7 @@ class PolicyRuleDeviceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
...@@ -127,7 +127,7 @@ class PolicyRuleDeviceValidationTest { ...@@ -127,7 +127,7 @@ class PolicyRuleDeviceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
...@@ -156,7 +156,7 @@ class PolicyRuleDeviceValidationTest { ...@@ -156,7 +156,7 @@ class PolicyRuleDeviceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
......
...@@ -106,7 +106,7 @@ class PolicyRuleServiceValidationTest { ...@@ -106,7 +106,7 @@ class PolicyRuleServiceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var deviceIds = createDeviceIds(); final var deviceIds = createDeviceIds();
...@@ -137,7 +137,7 @@ class PolicyRuleServiceValidationTest { ...@@ -137,7 +137,7 @@ class PolicyRuleServiceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
...@@ -167,7 +167,7 @@ class PolicyRuleServiceValidationTest { ...@@ -167,7 +167,7 @@ class PolicyRuleServiceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
...@@ -201,7 +201,7 @@ class PolicyRuleServiceValidationTest { ...@@ -201,7 +201,7 @@ class PolicyRuleServiceValidationTest {
PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT,
List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1");
final var policyRuleBasic = final var policyRuleBasic =
createPolicyRuleBasic( createPolicyRuleBasic(
......
...@@ -146,7 +146,8 @@ class SerializerTest { ...@@ -146,7 +146,8 @@ class SerializerTest {
private PolicyRuleBasic createPolicyRuleBasic() { private PolicyRuleBasic createPolicyRuleBasic() {
final var expectedPolicyRuleId = "expectedPolicyRuleId"; final var expectedPolicyRuleId = "expectedPolicyRuleId";
final var expectedPolicyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE); final var expectedPolicyRuleState =
new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "Policy was effective");
final var expectedPriority = 3; final var expectedPriority = 3;
final var firstKpiValue = new IntegerKpiValue(22); final var firstKpiValue = new IntegerKpiValue(22);
...@@ -2276,7 +2277,7 @@ class SerializerTest { ...@@ -2276,7 +2277,7 @@ class SerializerTest {
@Test @Test
void shouldSerializePolicyRuleState() { void shouldSerializePolicyRuleState() {
final var expectedRuleState = PolicyRuleStateEnum.POLICY_ACTIVE; final var expectedRuleState = PolicyRuleStateEnum.POLICY_ACTIVE;
final var policyRuleState = new PolicyRuleState(expectedRuleState); final var policyRuleState = new PolicyRuleState(expectedRuleState, "");
final var serializedRuleState = serializer.serialize(expectedRuleState); final var serializedRuleState = serializer.serialize(expectedRuleState);
...@@ -2293,7 +2294,7 @@ class SerializerTest { ...@@ -2293,7 +2294,7 @@ class SerializerTest {
@Test @Test
void shouldDeserializePolicyRuleState() { void shouldDeserializePolicyRuleState() {
final var expectedRuleState = PolicyRuleStateEnum.POLICY_ENFORCED; final var expectedRuleState = PolicyRuleStateEnum.POLICY_ENFORCED;
final var expectedPolicyRuleState = new PolicyRuleState(expectedRuleState); final var expectedPolicyRuleState = new PolicyRuleState(expectedRuleState, "");
final var serializedPolicyRuleState = serializer.serialize(expectedPolicyRuleState); final var serializedPolicyRuleState = serializer.serialize(expectedPolicyRuleState);
......
...@@ -926,6 +926,18 @@ public final class Policy { ...@@ -926,6 +926,18 @@ public final class Policy {
* @return The policyRuleState. * @return The policyRuleState.
*/ */
policy.Policy.PolicyRuleStateEnum getPolicyRuleState(); policy.Policy.PolicyRuleStateEnum getPolicyRuleState();
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The policyRuleStateMessage.
*/
java.lang.String getPolicyRuleStateMessage();
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The bytes for policyRuleStateMessage.
*/
com.google.protobuf.ByteString
getPolicyRuleStateMessageBytes();
} }
/** /**
* Protobuf type {@code policy.PolicyRuleState} * Protobuf type {@code policy.PolicyRuleState}
...@@ -941,6 +953,7 @@ public final class Policy { ...@@ -941,6 +953,7 @@ public final class Policy {
} }
private PolicyRuleState() { private PolicyRuleState() {
policyRuleState_ = 0; policyRuleState_ = 0;
policyRuleStateMessage_ = "";
} }
@java.lang.Override @java.lang.Override
...@@ -979,6 +992,12 @@ public final class Policy { ...@@ -979,6 +992,12 @@ public final class Policy {
policyRuleState_ = rawValue; policyRuleState_ = rawValue;
break; break;
} }
case 18: {
java.lang.String s = input.readStringRequireUtf8();
policyRuleStateMessage_ = s;
break;
}
default: { default: {
if (!parseUnknownField( if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) { input, unknownFields, extensionRegistry, tag)) {
...@@ -1030,6 +1049,44 @@ public final class Policy { ...@@ -1030,6 +1049,44 @@ public final class Policy {
return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result; return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result;
} }
public static final int POLICYRULESTATEMESSAGE_FIELD_NUMBER = 2;
private volatile java.lang.Object policyRuleStateMessage_;
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The policyRuleStateMessage.
*/
@java.lang.Override
public java.lang.String getPolicyRuleStateMessage() {
java.lang.Object ref = policyRuleStateMessage_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
policyRuleStateMessage_ = s;
return s;
}
}
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The bytes for policyRuleStateMessage.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getPolicyRuleStateMessageBytes() {
java.lang.Object ref = policyRuleStateMessage_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
policyRuleStateMessage_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
@java.lang.Override @java.lang.Override
public final boolean isInitialized() { public final boolean isInitialized() {
...@@ -1047,6 +1104,9 @@ public final class Policy { ...@@ -1047,6 +1104,9 @@ public final class Policy {
if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) { if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) {
output.writeEnum(1, policyRuleState_); output.writeEnum(1, policyRuleState_);
} }
if (!getPolicyRuleStateMessageBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, policyRuleStateMessage_);
}
unknownFields.writeTo(output); unknownFields.writeTo(output);
} }
...@@ -1060,6 +1120,9 @@ public final class Policy { ...@@ -1060,6 +1120,9 @@ public final class Policy {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeEnumSize(1, policyRuleState_); .computeEnumSize(1, policyRuleState_);
} }
if (!getPolicyRuleStateMessageBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, policyRuleStateMessage_);
}
size += unknownFields.getSerializedSize(); size += unknownFields.getSerializedSize();
memoizedSize = size; memoizedSize = size;
return size; return size;
...@@ -1076,6 +1139,8 @@ public final class Policy { ...@@ -1076,6 +1139,8 @@ public final class Policy {
policy.Policy.PolicyRuleState other = (policy.Policy.PolicyRuleState) obj; policy.Policy.PolicyRuleState other = (policy.Policy.PolicyRuleState) obj;
if (policyRuleState_ != other.policyRuleState_) return false; if (policyRuleState_ != other.policyRuleState_) return false;
if (!getPolicyRuleStateMessage()
.equals(other.getPolicyRuleStateMessage())) return false;
if (!unknownFields.equals(other.unknownFields)) return false; if (!unknownFields.equals(other.unknownFields)) return false;
return true; return true;
} }
...@@ -1089,6 +1154,8 @@ public final class Policy { ...@@ -1089,6 +1154,8 @@ public final class Policy {
hash = (19 * hash) + getDescriptor().hashCode(); hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + POLICYRULESTATE_FIELD_NUMBER; hash = (37 * hash) + POLICYRULESTATE_FIELD_NUMBER;
hash = (53 * hash) + policyRuleState_; hash = (53 * hash) + policyRuleState_;
hash = (37 * hash) + POLICYRULESTATEMESSAGE_FIELD_NUMBER;
hash = (53 * hash) + getPolicyRuleStateMessage().hashCode();
hash = (29 * hash) + unknownFields.hashCode(); hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
...@@ -1224,6 +1291,8 @@ public final class Policy { ...@@ -1224,6 +1291,8 @@ public final class Policy {
super.clear(); super.clear();
policyRuleState_ = 0; policyRuleState_ = 0;
policyRuleStateMessage_ = "";
return this; return this;
} }
...@@ -1251,6 +1320,7 @@ public final class Policy { ...@@ -1251,6 +1320,7 @@ public final class Policy {
public policy.Policy.PolicyRuleState buildPartial() { public policy.Policy.PolicyRuleState buildPartial() {
policy.Policy.PolicyRuleState result = new policy.Policy.PolicyRuleState(this); policy.Policy.PolicyRuleState result = new policy.Policy.PolicyRuleState(this);
result.policyRuleState_ = policyRuleState_; result.policyRuleState_ = policyRuleState_;
result.policyRuleStateMessage_ = policyRuleStateMessage_;
onBuilt(); onBuilt();
return result; return result;
} }
...@@ -1302,6 +1372,10 @@ public final class Policy { ...@@ -1302,6 +1372,10 @@ public final class Policy {
if (other.policyRuleState_ != 0) { if (other.policyRuleState_ != 0) {
setPolicyRuleStateValue(other.getPolicyRuleStateValue()); setPolicyRuleStateValue(other.getPolicyRuleStateValue());
} }
if (!other.getPolicyRuleStateMessage().isEmpty()) {
policyRuleStateMessage_ = other.policyRuleStateMessage_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields); this.mergeUnknownFields(other.unknownFields);
onChanged(); onChanged();
return this; return this;
...@@ -1384,6 +1458,82 @@ public final class Policy { ...@@ -1384,6 +1458,82 @@ public final class Policy {
onChanged(); onChanged();
return this; return this;
} }
private java.lang.Object policyRuleStateMessage_ = "";
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The policyRuleStateMessage.
*/
public java.lang.String getPolicyRuleStateMessage() {
java.lang.Object ref = policyRuleStateMessage_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
policyRuleStateMessage_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return The bytes for policyRuleStateMessage.
*/
public com.google.protobuf.ByteString
getPolicyRuleStateMessageBytes() {
java.lang.Object ref = policyRuleStateMessage_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
policyRuleStateMessage_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string policyRuleStateMessage = 2;</code>
* @param value The policyRuleStateMessage to set.
* @return This builder for chaining.
*/
public Builder setPolicyRuleStateMessage(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
policyRuleStateMessage_ = value;
onChanged();
return this;
}
/**
* <code>string policyRuleStateMessage = 2;</code>
* @return This builder for chaining.
*/
public Builder clearPolicyRuleStateMessage() {
policyRuleStateMessage_ = getDefaultInstance().getPolicyRuleStateMessage();
onChanged();
return this;
}
/**
* <code>string policyRuleStateMessage = 2;</code>
* @param value The bytes for policyRuleStateMessage to set.
* @return This builder for chaining.
*/
public Builder setPolicyRuleStateMessageBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
policyRuleStateMessage_ = value;
onChanged();
return this;
}
@java.lang.Override @java.lang.Override
public final Builder setUnknownFields( public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) { final com.google.protobuf.UnknownFieldSet unknownFields) {
...@@ -9389,51 +9539,52 @@ public final class Policy { ...@@ -9389,51 +9539,52 @@ public final class Policy {
"\n\014policy.proto\022\006policy\032\rcontext.proto\032\026p" + "\n\014policy.proto\022\006policy\032\rcontext.proto\032\026p" +
"olicy_condition.proto\032\023policy_action.pro" + "olicy_condition.proto\032\023policy_action.pro" +
"to\"+\n\014PolicyRuleId\022\033\n\004uuid\030\001 \001(\0132\r.conte" + "to\"+\n\014PolicyRuleId\022\033\n\004uuid\030\001 \001(\0132\r.conte" +
"xt.Uuid\"G\n\017PolicyRuleState\0224\n\017policyRule" + "xt.Uuid\"g\n\017PolicyRuleState\0224\n\017policyRule" +
"State\030\001 \001(\0162\033.policy.PolicyRuleStateEnum" + "State\030\001 \001(\0162\033.policy.PolicyRuleStateEnum" +
"\"\225\002\n\017PolicyRuleBasic\022*\n\014policyRuleId\030\001 \001" + "\022\036\n\026policyRuleStateMessage\030\002 \001(\t\"\225\002\n\017Pol" +
"(\0132\024.policy.PolicyRuleId\0220\n\017policyRuleSt" + "icyRuleBasic\022*\n\014policyRuleId\030\001 \001(\0132\024.pol" +
"ate\030\002 \001(\0132\027.policy.PolicyRuleState\022\020\n\010pr" + "icy.PolicyRuleId\0220\n\017policyRuleState\030\002 \001(" +
"iority\030\003 \001(\r\0222\n\rconditionList\030\004 \003(\0132\033.po" + "\0132\027.policy.PolicyRuleState\022\020\n\010priority\030\003" +
"licy.PolicyRuleCondition\0220\n\017booleanOpera" + " \001(\r\0222\n\rconditionList\030\004 \003(\0132\033.policy.Pol" +
"tor\030\005 \001(\0162\027.policy.BooleanOperator\022,\n\nac" + "icyRuleCondition\0220\n\017booleanOperator\030\005 \001(" +
"tionList\030\006 \003(\0132\030.policy.PolicyRuleAction" + "\0162\027.policy.BooleanOperator\022,\n\nactionList" +
"\"\223\001\n\021PolicyRuleService\0220\n\017policyRuleBasi" + "\030\006 \003(\0132\030.policy.PolicyRuleAction\"\223\001\n\021Pol" +
"c\030\001 \001(\0132\027.policy.PolicyRuleBasic\022%\n\tserv" + "icyRuleService\0220\n\017policyRuleBasic\030\001 \001(\0132" +
"iceId\030\002 \001(\0132\022.context.ServiceId\022%\n\ndevic" + "\027.policy.PolicyRuleBasic\022%\n\tserviceId\030\002 " +
"eList\030\003 \003(\0132\021.context.DeviceId\"k\n\020Policy" + "\001(\0132\022.context.ServiceId\022%\n\ndeviceList\030\003 " +
"RuleDevice\0220\n\017policyRuleBasic\030\001 \001(\0132\027.po" + "\003(\0132\021.context.DeviceId\"k\n\020PolicyRuleDevi" +
"licy.PolicyRuleBasic\022%\n\ndeviceList\030\002 \003(\013" + "ce\0220\n\017policyRuleBasic\030\001 \001(\0132\027.policy.Pol" +
"2\021.context.DeviceId\"B\n\020PolicyRuleIdList\022" + "icyRuleBasic\022%\n\ndeviceList\030\002 \003(\0132\021.conte" +
".\n\020policyRuleIdList\030\001 \003(\0132\024.policy.Polic" + "xt.DeviceId\"B\n\020PolicyRuleIdList\022.\n\020polic" +
"yRuleId\"Q\n\025PolicyRuleServiceList\0228\n\025poli" + "yRuleIdList\030\001 \003(\0132\024.policy.PolicyRuleId\"" +
"cyRuleServiceList\030\001 \003(\0132\031.policy.PolicyR" + "Q\n\025PolicyRuleServiceList\0228\n\025policyRuleSe" +
"uleService\"N\n\024PolicyRuleDeviceList\0226\n\024po" + "rviceList\030\001 \003(\0132\031.policy.PolicyRuleServi" +
"licyRuleDeviceList\030\001 \003(\0132\030.policy.Policy" + "ce\"N\n\024PolicyRuleDeviceList\0226\n\024policyRule" +
"RuleDevice\";\n\016PolicyRuleList\022)\n\013policyRu" + "DeviceList\030\001 \003(\0132\030.policy.PolicyRuleDevi" +
"les\030\001 \003(\0132\024.policy.PolicyRuleId*\377\001\n\023Poli" + "ce\";\n\016PolicyRuleList\022)\n\013policyRules\030\001 \003(" +
"cyRuleStateEnum\022\024\n\020POLICY_UNDEFINED\020\000\022\021\n" + "\0132\024.policy.PolicyRuleId*\377\001\n\023PolicyRuleSt" +
"\rPOLICY_FAILED\020\001\022\023\n\017POLICY_INSERTED\020\002\022\024\n" + "ateEnum\022\024\n\020POLICY_UNDEFINED\020\000\022\021\n\rPOLICY_" +
"\020POLICY_VALIDATED\020\003\022\026\n\022POLICY_PROVISIONE" + "FAILED\020\001\022\023\n\017POLICY_INSERTED\020\002\022\024\n\020POLICY_" +
"D\020\004\022\021\n\rPOLICY_ACTIVE\020\005\022\023\n\017POLICY_ENFORCE" + "VALIDATED\020\003\022\026\n\022POLICY_PROVISIONED\020\004\022\021\n\rP" +
"D\020\006\022\026\n\022POLICY_INEFFECTIVE\020\007\022\024\n\020POLICY_EF" + "OLICY_ACTIVE\020\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022P" +
"FECTIVE\020\010\022\022\n\016POLICY_UPDATED\020\t\022\022\n\016POLICY_" + "OLICY_INEFFECTIVE\020\007\022\024\n\020POLICY_EFFECTIVE\020" +
"REMOVED\020\n2\323\004\n\rPolicyService\022H\n\020PolicyAdd" + "\010\022\022\n\016POLICY_UPDATED\020\t\022\022\n\016POLICY_REMOVED\020" +
"Service\022\031.policy.PolicyRuleService\032\027.pol" + "\n2\323\004\n\rPolicyService\022H\n\020PolicyAddService\022" +
"icy.PolicyRuleState\"\000\022F\n\017PolicyAddDevice" + "\031.policy.PolicyRuleService\032\027.policy.Poli" +
"\022\030.policy.PolicyRuleDevice\032\027.policy.Poli" + "cyRuleState\"\000\022F\n\017PolicyAddDevice\022\030.polic" +
"cyRuleState\"\000\022K\n\023PolicyUpdateService\022\031.p" +
"olicy.PolicyRuleService\032\027.policy.PolicyR" +
"uleState\"\000\022I\n\022PolicyUpdateDevice\022\030.polic" +
"y.PolicyRuleDevice\032\027.policy.PolicyRuleSt" + "y.PolicyRuleDevice\032\027.policy.PolicyRuleSt" +
"ate\"\000\022?\n\014PolicyDelete\022\024.policy.PolicyRul" + "ate\"\000\022K\n\023PolicyUpdateService\022\031.policy.Po" +
"eId\032\027.policy.PolicyRuleState\"\000\022E\n\020GetPol" + "licyRuleService\032\027.policy.PolicyRuleState" +
"icyService\022\024.policy.PolicyRuleId\032\031.polic" + "\"\000\022I\n\022PolicyUpdateDevice\022\030.policy.Policy" +
"y.PolicyRuleService\"\000\022C\n\017GetPolicyDevice" + "RuleDevice\032\027.policy.PolicyRuleState\"\000\022?\n" +
"\022\024.policy.PolicyRuleId\032\030.policy.PolicyRu" + "\014PolicyDelete\022\024.policy.PolicyRuleId\032\027.po" +
"leDevice\"\000\022K\n\024GetPolicyByServiceId\022\022.con" + "licy.PolicyRuleState\"\000\022E\n\020GetPolicyServi" +
"text.ServiceId\032\035.policy.PolicyRuleServic" + "ce\022\024.policy.PolicyRuleId\032\031.policy.Policy" +
"eList\"\000b\006proto3" "RuleService\"\000\022C\n\017GetPolicyDevice\022\024.polic" +
"y.PolicyRuleId\032\030.policy.PolicyRuleDevice" +
"\"\000\022K\n\024GetPolicyByServiceId\022\022.context.Ser" +
"viceId\032\035.policy.PolicyRuleServiceList\"\000b" +
"\006proto3"
}; };
descriptor = com.google.protobuf.Descriptors.FileDescriptor descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData, .internalBuildGeneratedFileFrom(descriptorData,
...@@ -9453,7 +9604,7 @@ public final class Policy { ...@@ -9453,7 +9604,7 @@ public final class Policy {
internal_static_policy_PolicyRuleState_fieldAccessorTable = new internal_static_policy_PolicyRuleState_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_policy_PolicyRuleState_descriptor, internal_static_policy_PolicyRuleState_descriptor,
new java.lang.String[] { "PolicyRuleState", }); new java.lang.String[] { "PolicyRuleState", "PolicyRuleStateMessage", });
internal_static_policy_PolicyRuleBasic_descriptor = internal_static_policy_PolicyRuleBasic_descriptor =
getDescriptor().getMessageTypes().get(2); getDescriptor().getMessageTypes().get(2);
internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new
......