syntax = "proto3";

package zsys;

option go_package = "github.com/ubuntu/zsys";

service Zsys {
  rpc Version(Empty) returns (stream VersionResponse);
  rpc CreateUserData(CreateUserDataRequest) returns (stream LogResponse);
  rpc ChangeHomeOnUserData(ChangeHomeOnUserDataRequest) returns (stream LogResponse);
  rpc DissociateUser(DissociateUserRequest) returns (stream LogResponse);
  rpc PrepareBoot(Empty) returns (stream PrepareBootResponse);
  rpc CommitBoot(Empty) returns (stream CommitBootResponse);
  rpc UpdateBootMenu(UpdateBootMenuRequest) returns (stream LogResponse);
  rpc UpdateLastUsed(Empty) returns (stream LogResponse);

  rpc SaveSystemState(SaveSystemStateRequest) returns (stream CreateSaveStateResponse);
  rpc SaveUserState(SaveUserStateRequest) returns (stream CreateSaveStateResponse);
  rpc RemoveSystemState(RemoveSystemStateRequest) returns (stream LogResponse);
  rpc RemoveUserState(RemoveUserStateRequest) returns (stream LogResponse);

  rpc DumpStates(Empty) returns (stream DumpStatesResponse);
  rpc DaemonStop(Empty) returns (stream LogResponse);
  rpc LoggingLevel(LoggingLevelRequest) returns (stream LogResponse);
  rpc Refresh(Empty) returns  (stream LogResponse);
  rpc Trace(TraceRequest) returns  (stream TraceResponse);
  rpc Status(Empty) returns (stream LogResponse);
  rpc Reload(Empty) returns (stream LogResponse);
  rpc GC(GCRequest) returns (stream LogResponse);

  rpc MachineShow(MachineShowRequest) returns (stream MachineShowResponse);
  rpc MachineList(Empty) returns (stream MachineListResponse);

}

message Empty {}

message LogResponse {
  string log = 1;
}

message VersionResponse {
  oneof reply {
    string log = 1;
    string version = 2;
  }
}

message CreateUserDataRequest {
  string user = 1;
  string homepath = 2;
}

message ChangeHomeOnUserDataRequest {
  string home = 1;
  string newHome = 2;
}

message DissociateUserRequest {
  string user = 1;
  bool removeHome = 2;
}

message PrepareBootResponse {
  oneof reply {
    string log = 1;
    bool changed = 2;
  }
}

message CommitBootResponse {
  oneof reply {
    string log = 1;
    bool changed = 2;
  }
}

message UpdateBootMenuRequest {
  bool auto = 1;
}

message SaveSystemStateRequest {
  string stateName = 1;
  bool updateBootMenu = 2;
  bool autosave = 3;
}

message SaveUserStateRequest {
  string userName = 1;
  string stateName = 2;
}

message CreateSaveStateResponse {
  oneof reply {
    string log = 1;
    string stateName = 2;
  }
}

message RemoveSystemStateRequest {
  string stateName = 1;
  bool force = 2;
  bool dryrun = 3;
}

message RemoveUserStateRequest {
  string userName = 1;
  string stateName = 2;
  bool force = 3;
  bool dryrun = 4;
}

message DumpStatesResponse {
  oneof reply {
    string log = 1;
    string states = 2;
  }
}

message LoggingLevelRequest {
  int32 logginglevel = 1;
}

message TraceRequest {
  string type = 1;
  int32 duration = 2;
}

message TraceResponse {
  oneof reply {
    string log = 1;
    bytes trace = 2;
  }
}

message GCRequest {
  bool all = 1;
}

message MachineShowRequest {
  string machineId = 1;
  bool full = 2;
}

message MachineShowResponse {
  oneof reply {
    string log = 1;
    string machineInfo = 2;
  }
}

message MachineListResponse {
  oneof reply {
    string log = 1;
    string machineList = 2;
  }
}