syntax = "proto3";

package kubevirt.cmd.v1;
option go_package = "v1";

service Cmd {
  rpc SyncVirtualMachine(VMIRequest) returns (Response) {}
  rpc PauseVirtualMachine(VMIRequest) returns (Response) {}
  rpc UnpauseVirtualMachine(VMIRequest) returns (Response) {}
  rpc FreezeVirtualMachine(VMIRequest) returns (Response) {}
  rpc UnfreezeVirtualMachine(VMIRequest) returns (Response) {}
  rpc ShutdownVirtualMachine(VMIRequest) returns (Response) {}
  rpc KillVirtualMachine(VMIRequest) returns (Response) {}
  rpc DeleteVirtualMachine(VMIRequest) returns (Response) {}
  rpc MigrateVirtualMachine(MigrationRequest) returns (Response) {}
  rpc SyncMigrationTarget(VMIRequest) returns (Response) {}
  rpc CancelVirtualMachineMigration(VMIRequest) returns (Response) {}
  rpc SignalTargetPodCleanup(VMIRequest) returns (Response) {}
  rpc FinalizeVirtualMachineMigration(VMIRequest) returns (Response) {}
  rpc GetDomain(EmptyRequest) returns (DomainResponse) {}
  rpc GetDomainStats(EmptyRequest) returns (DomainStatsResponse) {}
  rpc GetGuestInfo(EmptyRequest) returns (GuestInfoResponse) {}
  rpc GetUsers(EmptyRequest) returns (GuestUserListResponse) {}
  rpc GetFilesystems(EmptyRequest) returns (GuestFilesystemsResponse) {}
  rpc Ping(EmptyRequest) returns (Response) {}
  rpc Exec(ExecRequest) returns (ExecResponse) {}
  rpc GuestPing(GuestPingRequest) returns (GuestPingResponse) {}
}

message VMI {
  bytes vmiJson = 1;
}

message CPU {
  uint32 id = 1;
  repeated uint32 siblings = 2;
}

message Sibling {
  uint32 id = 1;
  uint64 value = 2;
}

message Pages {
    uint64 count = 1;
    string unit = 2;
    uint32 size = 3;
}

message Memory {
  uint64 amount = 1;
  string unit = 2;
}

message Cell {
  uint32 id = 1;
  Memory memory = 2;
  repeated Pages pages = 3;
  repeated Sibling distances = 4;
  repeated CPU cpus = 5;
}

message Topology {
  repeated Cell numa_cells = 1;
}

message SMBios {
  string manufacturer = 1;
  string product = 2;
  string version = 3;
  string sku = 4;
  string family = 5;
}

message VirtualMachineOptions {
  SMBios VirtualMachineSMBios = 1;
  uint32 MemBalloonStatsPeriod = 2;
  repeated string PreallocatedVolumes = 3;
  Topology topology = 4;
}

message VMIRequest {
  VMI vmi = 1;
  VirtualMachineOptions options = 2;
}

message MigrationRequest {
  VMI vmi = 1;
  bytes options = 2;
}

message ExecRequest {
  string domainName = 1;
  string Command = 2;
  repeated string Args = 3;
  int32 timeoutSeconds = 4;
}

message EmptyRequest {}

message Response {
  bool success = 1;
  string message = 2;
}

message DomainResponse {
  Response response = 1;
  string domain = 2;
}

message DomainStatsResponse {
  Response response = 1;
  string domainStats = 2;
}

message GuestInfoResponse {
  Response response = 1;
  string guestInfoResponse = 2;
}

message GuestUserListResponse {
  Response response = 1;
  string guestUserListResponse = 2;
}

message GuestFilesystemsResponse {
  Response response = 1;
  string guestFilesystemsResponse = 2;
}

message ExecResponse {
  Response response = 1;
  int32 exitCode = 2;
  string stdOut = 3;
}

message GuestPingRequest {
  string domainName = 1;
  int32 timeoutSeconds = 2;
}

message GuestPingResponse {
  Response response = 1;
}
