// Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
//
// 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";
package monitoring;

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

service MonitoringService {
  rpc CreateKpi               (KpiDescriptor        ) returns (KpiId            ) {}
  rpc GetKpiDescriptor        (KpiId                ) returns (KpiDescriptor    ) {}
  rpc IncludeKpi              (Kpi                  ) returns (context.Empty    ) {}
  rpc MonitorKpi              (MonitorKpiRequest    ) returns (context.Empty    ) {}
  rpc GetStreamKpi            (KpiId                ) returns (stream Kpi       ) {}
  rpc GetInstantKpi           (KpiId                ) returns (Kpi              ) {}
  rpc CreateMetrics           (MetricsDescriptor    ) returns (MetricsId        ) {}
  rpc GetMetricsDescriptor    (MetricsId            ) returns (MetricsDescriptor) {}
  rpc IncludeMetrics          (Metrics              ) returns (context.Empty    ) {}
  rpc MonitorMetrics          (MonitorMetricsRequest) returns (context.Empty    ) {}
  rpc GetStreamMetrics        (MetricsId            ) returns (stream Metrics   ) {}
  rpc GetInstantMetrics       (MetricsId            ) returns (Metrics          ) {}

}

message KpiDescriptor {
  string kpi_description = 1;
  kpi_sample_types.KpiSampleType kpi_sample_type = 2;
  context.DeviceId device_id = 3;
  context.EndPointId endpoint_id = 4;
  context.ServiceId  service_id  = 5;
//  context.SliceId    slice_id    = 6;
}

message MetricsDescriptor {
  string metrics_description = 1;
  kpi_sample_types.KpiSampleType kpi_sample_type = 2;
  context.DeviceId device_id = 3;
  context.EndPointId endpoint_id = 4;
  context.ServiceId  service_id  = 5;
//  context.SliceId    slice_id    = 6;
}

message MonitorKpiRequest{
  KpiId kpi_id = 1;
  float sampling_duration_s = 2;
  float sampling_interval_s = 3;
}

message MonitorMetricsRequest{
  MetricsId metrics_id = 1;
  float sampling_duration_s = 2;
  float sampling_interval_s = 3;
}

message KpiId {
  context.Uuid kpi_id = 1;
}

message MetricsId {
  context.Uuid kpi_id = 1;
}

message Kpi {
  KpiId kpi_id = 1;
  string timestamp = 2;
  KpiValue kpi_value = 4;
}

message Metrics {
  MetricsId metrics_id = 1;
  string timestamp = 2;
  MetricsValue metrics_value = 4;
}

message KpiValue {
  oneof value {
    uint32 intVal = 1;
    float floatVal = 2;
    string stringVal = 3;
    bool boolVal = 4;
  }
}

message MetricsValue {
  oneof value {
    uint32 intVal = 1;
    float floatVal = 2;
    string stringVal = 3;
    bool boolVal = 4;
  }
}

message KpiList {
    repeated Kpi kpi_list = 1;
}

message MetricsList {
    repeated Metrics metrics_list = 1;
}