syntax = "proto3";
package policy;

import "context.proto";
import "service.proto";

service PolicyService {
  rpc PolicyAdd (PolicyRule) returns (PolicyRuleState) {}
  rpc PolicyUpdate (PolicyRule) returns (PolicyRuleState) {}
  rpc PolicyDelete (PolicyRule) returns (PolicyRuleState) {}
  rpc GetPolicy (PolicyRuleId) returns (PolicyRule) {}
  rpc GetPolicyByDeviceId (context.DeviceId) returns (PolicyRuleList) {}
  rpc GetPolicyByServiceId (service.ServiceId) returns (PolicyRuleList) {}
}

message PolicyRuleList {
  repeated PolicyRule policyRuleList = 1;
}

//according to IETF’s RFC 3060 [] and RFC 3460 []
message PolicyRule {
  PolicyRuleId policyRuleId = 1;
  repeated service.ServiceId serviceList = 2;
  repeated context.DeviceId deviceList = 3;
  string policyRuleType = 4;
  string PolicyRulePriority = 5;
  repeated PolicyRuleCondition polRuleConditionList = 6;
  repeated PolicyRuleAction polRuleActionList = 7;
}

message PolicyRuleId { 
  context.Uuid uuid = 1;
}

message PolicyRuleCondition {
  PolicyRuleVariable polRuleConditionVar = 1;
  PolicyRuleValue polRuleConditionVal = 2;
}

message PolicyRuleAction {
  PolicyRuleVariable polRuleActionVar = 1;
  PolicyRuleValue polRuleActionVal = 2;
}

message PolicyRuleVariable {
  string policyRuleVariable = 1;
}

message PolicyRuleValue {
  string policyRuleValue = 1;
}

message PolicyRuleState {
  context.Uuid policyRuleId = 1;
  RuleState policyRuleState = 2;
}

enum RuleState {
  PLANNED = 0;
  ACTIVE = 1;
}

