syntax = "proto3";

package occlumexec;

// Interface exported by the server.
service OcclumExec {
  // Client check the server status
  rpc StatusCheck(HealthCheckRequest) returns (HealthCheckResponse) {}

  // Client asks the server to execute the command
  rpc ExecCommand(ExecCommRequest) returns (ExecCommResponse) {}

  // Client gets the return value
  rpc GetResult(GetResultRequest) returns (GetResultResponse) {}

  // Client stops the server
  rpc StopServer(StopRequest) returns (StopResponse) {}

  // Client send signal to server
  rpc KillProcess(KillProcessRequest) returns (KillProcessResponse) {}
}

message KillProcessRequest {
  int32 process_id = 1;
  int32 signal = 2;
}

message KillProcessResponse {}

message GetResultRequest { int32 process_id = 1; }

message GetResultResponse {
  enum ExecutionStatus {
    UNKNOWN = 0;
    RUNNING = 1;
    STOPPED = 2;
  }
  ExecutionStatus status = 1;
  int32 result = 2;
}

message ExecCommRequest {
  uint32 process_id = 1;
  string sockpath = 2;
  string command = 3;
  repeated string parameters = 4;
  repeated string enviroments = 5;
}

message ExecCommResponse {
  enum ExecutionStatus {
    RUNNING = 0;
    LAUNCH_FAILED = 1;
  }
  ExecutionStatus status = 1;
  int32 process_id = 2;
}

message HealthCheckRequest {}

message HealthCheckResponse {
  enum ServingStatus {
    SERVING = 0;
    NOT_SERVING = 1;
  }
  ServingStatus status = 1;
}

message StopRequest { uint32 time = 1; }

message StopResponse {}