syntax = "proto3";

package idl;
import "hub.proto";

option go_package= "../idl";

service Agent {
    rpc Stop(StopAgentRequest) returns (StopAgentReply) {}
    rpc Status(StatusAgentRequest) returns (StatusAgentReply) {}
    rpc MakeSegment(MakeSegmentRequest) returns(MakeSegmentReply) {}
    rpc StartSegment(StartSegmentRequest) returns (StartSegmentReply){}
    rpc ValidateHostEnv(ValidateHostEnvRequest) returns(ValidateHostEnvReply) {}
    rpc GetInterfaceAddrs(GetInterfaceAddrsRequest) returns(GetInterfaceAddrsResponse) {}
    rpc UpdatePgHbaConfAndReload(UpdatePgHbaConfRequest) returns (UpdatePgHbaConfResponse) {}
    rpc UpdatePgConf(UpdatePgConfRequest) returns (UpdatePgConfRespoonse) {}
    rpc PgBasebackup(PgBasebackupRequest) returns (PgBasebackupResponse) {}
    rpc GetHostName(GetHostNameRequest) returns(GetHostNameReply){}
    rpc RemoveDirectory(RemoveDirectoryRequest) returns(RemoveDirectoryReply) {}
}

message GetHostNameReply{
    string hostname = 1;
}

message GetHostNameRequest {}

message StartSegmentRequest{
    string dataDir=1;
    bool wait=2;
    int32 timeout = 4;
    string options=5;
}

message StartSegmentReply {}

message StopAgentRequest {}

message StopAgentReply {}

message StatusAgentRequest {}

message StatusAgentReply {
    string status = 1;
    string uptime = 2;
    uint32 pid = 3;
}

message ValidateHostEnvRequest{
    repeated string hostAddressList = 1;
    repeated string DirectoryList = 2;
    repeated string portList = 3;
    Locale locale = 4;
    string gpVersion = 5;
    bool forced = 6;
}

message ValidateHostEnvReply {
    repeated LogMessage messages = 1;
}

message MakeSegmentRequest {
    Segment segment = 1;
    Locale locale = 2 ;
    string Encoding = 3;
    map<string, string> SegConfig = 4;
    repeated string coordinatorAddrs = 5;
    bool hbaHostNames = 6;
    bool dataChecksums = 7;
}

message MakeSegmentReply {}

message GetInterfaceAddrsRequest{}

message GetInterfaceAddrsResponse{
    repeated string addrs = 1;
}

message UpdatePgHbaConfRequest{
    string pgdata = 1;
    repeated string addrs = 2;
    bool replication = 3;
}

message UpdatePgHbaConfResponse {}

message UpdatePgConfRequest {
    string pgdata = 1;
    map<string, string> params = 2;
    bool overwrite = 3;
}

message UpdatePgConfRespoonse {}

message PgBasebackupRequest {
    string targetDir = 1;
    string sourceHost = 2;
    int32 sourcePort = 3;
    bool createSlot = 4;
    bool forceOverwrite = 5;
    int32 targetDbid = 6;
    bool writeRecoveryConf = 7;
    string replicationSlotName = 8;
    repeated string excludePaths = 9;
}

message PgBasebackupResponse {}

message RemoveDirectoryRequest {
    string dataDirectory = 1; 
}

message RemoveDirectoryReply {}
