/********************************************************************************
 * Copyright (c) 2021 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License 2.0 which is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * SPDX-License-Identifier: Apache-2.0
 ********************************************************************************/

syntax = "proto3";

package kuksa;
import "google/protobuf/timestamp.proto";


option go_package = "/kuksa_grpc_proto";


// The connecting service definition.
service kuksa_grpc_if {
  rpc get (GetRequest) returns (GetResponse) {}
  rpc set (SetRequest) returns (SetResponse) {}
  rpc subscribe (stream SubscribeRequest) returns (stream SubscribeResponse) {}
  rpc authorize (AuthRequest) returns (AuthResponse) {}
}

message AuthRequest {
  string token = 1;
}

message GetRequest {
  RequestType type = 1;
  repeated string path = 2;
}

message GetResponse {
  repeated Value values = 1;
  Status status = 2;
}

message SetRequest {
  RequestType type = 1;
  repeated Value values = 2;
}

message SetResponse {
  Status status = 1;
}

message AuthResponse {
  string connectionId = 1;
  Status status = 2;
}

message SubscribeRequest {
  RequestType type = 1;
  string path = 2;
  bool start = 3;
}

message SubscribeResponse {
  Value values = 1;
  Status status = 2;
}

message Value {
  string path =  1;
  oneof val {
    uint32 valueUint32 = 2;
    int32 valueInt32 = 3;
    uint64 valueUint64 = 4;
    int64 valueInt64 = 5;
    bool valueBool = 6;
    float valueFloat = 7;
    double valueDouble = 8;
    string valueString = 9;
  }
  google.protobuf.Timestamp timestamp=10; 
}

message Status {
  uint32 statusCode = 1;
  string statusDescription = 2;
}

enum RequestType {
  UNKNOWN_TYPE = 0;
  CURRENT_VALUE = 1;
  TARGET_VALUE = 2;
  METADATA = 3;
};
