syntax = "proto3";

package gosdn.plugin_registry;

import "google/protobuf/timestamp.proto";

option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-registry";

service PluginRegistryService {
  rpc Get(GetRequest) returns (GetResponse);
  rpc GetAll(GetAllRequest) returns (GetResponse);
  rpc Download(GetDownloadRequest) returns (stream GetDownloadPayload);
  rpc Delete(DeleteRequest) returns (DeleteResponse);
}

message GetRequest {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
  repeated Query query = 2;
}

message GetAllRequest {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
}

message Query {
  oneof identifier {
    string id = 1;
    string name = 2;
  }
}

message GetResponse {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
  repeated Plugin plugins = 2;
}

message GetDownloadRequest {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
  string id = 2;
}

message GetDownloadPayload {
  bytes chunk = 1;
}

message DeleteRequest {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
  repeated string id = 2;
}

message DeleteResponse {
  int64 timestamp = 1;          // Timestamp in nanoseconds since Epoch.
  enum Status {
    STATUS_UNSPECIFIED = 0;
    STATUS_OK = 1;
    STATUS_ERROR = 2;
  }
  Status status = 2;
}

message Plugin {
  string id = 1;
  Manifest manifest = 2;
}

message Manifest {
  string name = 1;
  string firmware = 2;
  string author = 3;
  string version = 4;
}
