syntax = "proto3";
option go_package = "common/protos";
import "protos/empty.proto";

service Operation {
    rpc Query(stream OperationQueryRequest) returns (stream OperationQueryResponse) {}
    rpc Refresh(OperationQueryRequest) returns (Empty) {}
}

message VersionAndArgs {
    string version = 1;
    repeated string args = 2;
    bool readonly = 3;
}

message DeployedVersions {
    string name = 1;
    repeated VersionAndArgs versions = 2;
}

message OperationQueryRequest {
    string hostname = 1;
    repeated ProcessDescription procs = 2;
    repeated DeployedVersions deploys = 3;
}

enum ProcessState {
    Stopped = 0;
    Stopping = 1;
    Running = 2;
    Restart = 3;
    Error = 4;
}

message ProcessDescription {
    string name = 1;
    repeated string args = 2;
    string version = 3;
    ProcessState state = 4;
    int32 pid = 5;
}

message OperationQueryResponse {
    string operation = 1;
    map<string, string> args = 2;
}