/*
 * Copyright 2020-2020 Exactpro (Exactpro Systems Limited)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = 'proto3';

import "google/protobuf/empty.proto";
import "th2_grpc_common/common.proto";

option java_multiple_files = true;
option java_package = "com.exactpro.th2.sim.grpc";

message RuleID {
  int32 id = 1;
}

/*
  Relation used to filter income and outcome messages to related rules.
  To configure this param please setup it on rule creation phase.
  Related rules sends and receives messages only from pins with same value in attributes.
 */
message RuleRelation {
  string relation = 1;
}

/*
  id: RuleID - id of rule generated by simulator side
  class_name: String - name of rule's class
  alias: String - attribute used to filter messages to specific rules
  relation: RuleRelation - attribute used to filter messages to specific rules
 */
message RuleInfo {
  RuleID id = 1;
  string class_name = 2;
  string alias = 3;
  RuleRelation relation = 4;
}

message RulesInfo {
  repeated RuleInfo info = 1;
}

message TouchRequest {
  RuleID id = 1;
  map<string, string> args = 2;
}

service Sim {
  rpc removeRule(RuleID) returns (google.protobuf.Empty) {}
  rpc getRulesInfo(google.protobuf.Empty) returns (RulesInfo) {}
  /*
    getRelatedRules method will return all rules configured with the given relation attribute
   */
  rpc getRelatedRules(RuleRelation) returns (RulesInfo) {}
  /*
    Calling 'touch' method on a rule that can send messages.
    You can set your own arguments for this request
   */
  rpc touchRule(TouchRequest) returns (google.protobuf.Empty) {}
}
