syntax = "proto3";
package node;
option go_package = ".;localserver";

enum NodeAuthType {
    token = 0;
    key = 1;
    mac = 2;
    none = 3;
}

message NodeAuthParams {
    string nodeId = 1;
    string authKey = 2;
    NodeAuthType authType = 3;
}

message OperatorAuthParams {
    string operatorId = 1;
    string authKey = 2;
    NodeAuthType authType = 3;
}

message Node {
    string id = 1;
    string name = 2;
    string pubKey = 3;
    bool active = 4;
    repeated string operators = 5;
    repeated string operatorRequests = 6;
}

message CreateNodeRequest {
    string nodeId = 1;
    string nodeKey = 2;
    string nodeUsername = 3;
}

message CreateNodeResponse {
    bool success = 1;
    string nodeId = 2;
}

message GetNodesRequest {
    OperatorAuthParams authParams = 1;
    int64 lastIndex = 2;
    int64 limit = 3;
}
message GetNodesResponse {
    repeated Node nodes = 1;
    bool success = 2;
}

message GetNodeRequest {
    string nodeId = 1;
}

message GetNodeResponse {
    Node node = 1;
    bool success = 2;
}

message DeleteNodeRequest {
    NodeAuthParams authParams = 1;
    string nodeId = 2;
}
message DeleteNodeResponse {
    bool success = 1;
}

message AddPeerOperatorRequest {
    OperatorAuthParams authParams = 1;
    string nodeId = 2;
    string operatorId = 3;
}

message AddPeerOperatorResponse {
    bool success = 1;
}

message RejectPeerOperatorRequest {
    NodeAuthParams authParams = 1;
    string nodeId = 2;
    string operatorId = 3;
}

message RejectPeerOperatorResponse {
    bool success = 1;
}

message AcceptPeerOperatorRequest {
    NodeAuthParams authParams = 1;
    string nodeId = 2;
    string operatorId = 3;
}

message AcceptPeerOperatorResponse {
    bool success = 1;
}

message RemovePeerOperatorRequest {
    OperatorAuthParams authParams = 1;
    string nodeId = 2;
    string operatorId = 3;
}

message RemovePeerOperatorResponse {
    bool success = 1;
}

service NodeService {
    rpc CreateNode (CreateNodeRequest) returns (CreateNodeResponse);
    rpc GetNodes (GetNodesRequest) returns (GetNodesResponse);
    rpc GetNode (GetNodeRequest) returns (GetNodeResponse);
    rpc DeleteNode (DeleteNodeRequest) returns (DeleteNodeResponse);
    rpc NewPeerOperatorRequest (AddPeerOperatorRequest) returns (AddPeerOperatorResponse);
    rpc DeletePeerOperatorRequest (RejectPeerOperatorRequest) returns (RejectPeerOperatorResponse);
    rpc AcceptNewPeerOperator (AcceptPeerOperatorRequest) returns (AcceptPeerOperatorResponse);
    rpc RemovePeerOperator (RemovePeerOperatorRequest) returns (RemovePeerOperatorResponse);
}  