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) {}
    rpc ReportDeployingProgress(DeployingProgress) returns (Empty) {}
}

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

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

message OperationQueryRequest {
    string hostname = 1;
    string public_ip = 4;
    string private_ip =5;

    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;
}

message DeployingProgress {
    string hostname = 1;
    string name = 2;
    string version = 3;
    string state = 4;
    int64 progress = 5;
    int64 total = 6;
}