/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

syntax = "proto3";

option go_package = "github.com/featureform/proto";

package featureform.serving.proto;

service Feature {
  rpc TrainingData(TrainingDataRequest) returns (stream TrainingDataRow) {}
  rpc TrainingDataColumns(TrainingDataColumnsRequest) returns (TrainingColumns) {}
  rpc FeatureServe(FeatureServeRequest) returns (FeatureRow) {}
  rpc SourceData(SourceDataRequest) returns (stream SourceDataRow) {}
  rpc SourceColumns(SourceColumnRequest) returns (SourceDataColumns) {}
  rpc Nearest(NearestRequest) returns (NearestResponse) {}
}

message Model {
  string name = 1;
}

message TrainingDataRequest {
  TrainingDataID id = 1;
  Model model = 2;
}

message TrainingDataID {
  string name = 1;
  string version = 2;
}

message TrainingDataRow {
  repeated Value features = 1;
  Value label = 2;
}

message FeatureServeRequest {
    repeated FeatureID features = 1;
    repeated Entity entities = 2;
    Model model = 3;
}

message FeatureRow {
    repeated Value values = 1;
}

message FeatureID {
    string name = 1;
    string version = 2;
}

message Entity {
    string name = 1;
    string value = 2;
}

message Value {
    oneof value {
        string str_value = 1;
        int32 int_value = 2;
        float float_value = 3;
        double double_value = 4;
        int64  int64_value = 5;
        int32  int32_value = 6;
        bool   bool_value = 7;
        bytes on_demand_function = 8;
        Vector32 vector32_value = 9;
    }
}

message SourceID {
  string name = 1;
  string version = 2;
}

message SourceDataRequest {
  SourceID id = 1;
  int64 limit = 2;
}

message SourceColumnRequest {
  SourceID id = 1;
}

message SourceDataRow {
  repeated Value rows = 1;
}

message SourceDataColumns {
  repeated string columns = 1;
}

message TrainingDataColumnsRequest {
  TrainingDataID id = 1;
}

message TrainingColumns {
  repeated string features = 1;
  string label = 2;
}

message Vector32 {
  repeated float value = 1;
}

message NearestRequest {
  FeatureID id = 1;
  Vector32 vector = 2;
  int32 k = 3;
}

message NearestResponse {
  repeated string entities = 1;
}