syntax = "proto3";
package device;

import "context.proto";
import "kpi_manager.proto";
import "kpi_sample_types.proto";

service AnalyticsFrontendService {
  rpc StartAnalyzer  (Analyzer      ) returns (AnalyzerId   ) {}
  rpc StopAnalyzer   (AnalyzerId    ) returns (context.Empty) {}
  rpc SelectAnalyzers(AnalyzerFilter) returns (AnalyzerList ) {}
}

message AnalyzerId {
  context.Uuid analyzer_id = 1;
}

enum AnalyzerMode {
  ANALYZERMODE_BATCH    = 0;
  ANALYZERMODE_STRAMING = 1;
}

message Analyzer {
  repeated kpi_manager.KpiId kpi_id               = 1; // The KPI Ids to be processed by the analyzer
  AnalyzerMode                  mode                 = 2; // Operation mode of the analyzer
  float                         batch_min_duration_s = 3; // In batch mode, min duration to collect before executing batch
  float                         batch_max_duration_s = 4; // In batch mode, max duration collected to execute the batch
  uint64                        batch_min_size       = 5; // In batch mode, min number of samples to collect before executing batch
  uint64                        batch_max_size       = 6; // In batch mode, max number of samples collected to execute the batch
}

message AnalyzerFilter {
  // Analyzer that fulfill the filter are those that match ALL the following fields.
  // An empty list means: any value is accepted.
  // All fields empty means: list all Analyzers
  repeated AnalyzerId                     analyzer_id    = 1;
  repeated kpi_manager.KpiId           kpi_id          = 2;
  repeated kpi_sample_types.KpiSampleType kpi_sample_type = 3;
  repeated context.DeviceId               device_id       = 4;
  repeated context.EndPointId             endpoint_id     = 5;
  repeated context.ServiceId              service_id      = 6;
  repeated context.SliceId                slice_id        = 7;
  repeated context.ConnectionId           connection_id   = 8;
  repeated context.LinkId                 link_id         = 9;
}

message AnalyzerList {
  repeated Analyzer analyzer_list = 1;
}
