syntax = "proto3";

package proto;

message LogicalVolume {
  string name = 1;
  uint64 size = 2;
  string uuid = 3;

  message Attributes {
    enum Type {
      MALFORMED_TYPE = 0;
      MIRRORED = 1;
      MIRRORED_WITHOUT_SYNC = 2;
      ORIGIN = 3;
      ORIGIN_WITH_MERGING_SNAPSHOT = 4;
      RAID = 5;
      RAID_WITHOUT_SYNC = 6;
      SNAPSHOT = 7;
      MERGING_SNAPSHOT = 8;
      PV_MOVE = 9;
      VIRTUAL_MIRROR = 10;
      VIRTUAL_RAID_IMAGE = 11;
      RAID_IMAGE_OUT_OF_SYNC = 12;
      MIRROR_LOG = 13;
      UNDER_CONVERSION = 14;
      THIN = 15;
      THIN_POOL = 16;
      THIN_POOL_DATA = 17;
      RAID_OR_THIN_POOL_METADATA = 18;
    }
    Type type = 1;

    enum Permissions {
      MALFORMED_PERMISSIONS = 0;
      WRITEABLE = 1;
      READ_ONLY = 2;
      READ_ONLY_ACTIVATION = 3;
    }
    Permissions permissions = 2;

    enum Allocation {
      MALFORMED_ALLOCATION = 0;
      ANYWHERE = 1;
      CONTIGUOUS = 2;
      INHERITED = 3;
      CLING = 4;
      NORMAL = 5;
      ANYWHERE_LOCKED = 6;
      CONTIGUOUS_LOCKED = 7;
      INHERITED_LOCKED = 8;
      CLING_LOCKED = 9;
      NORMAL_LOCKED = 10;
    }
    Allocation allocation = 3;

    bool fixed_minor = 4;

    enum State {
      MALFORMED_STATE = 0;
      ACTIVE = 1;
      SUSPENDED = 2;
      INVALID_SNAPSHOT = 3;
      INVALID_SUSPENDED_SNAPSHOT = 4;
      SNAPSHOT_MERGE_FAILED = 5;
      SUSPENDED_SNAPSHOT_MERGE_FAILED = 6;
      MAPPED_DEVICE_PRESENT_WITHOUT_TABLES = 7;
      MAPPED_DEVICE_PRESENT_WITH_INACTIVE_TABLE = 8;
    }
    State state = 5;

    bool open = 6;

    enum TargetType {
      MALFORMED_TARGET = 0;
      MIRROR_TARGET = 1;
      RAID_TARGET = 2;
      SNAPSHOT_TARGET = 3;
      THIN_TARGET = 4;
      UNKNOWN_TARGET = 5;
      VIRTUAL_TARGET = 6;
    }
    TargetType target_type = 7;

    bool zeroing = 8;

    enum Health {
      MALFORMED_HEALTH = 0;
      OK = 1;
      PARTIAL = 2;
      REFRESH_NEEDED = 3;
      MISMATCHES_EXIST = 4;
      WRITEMOSTLY = 5;
    }
    Health health = 9;

    bool activation_skipped = 10;
  }

  Attributes attributes = 4;
  string copy_percent = 5;
  uint32 actual_dev_major_number = 6;
  uint32 actual_dev_minor_number = 7;
  repeated string tags = 8;
}

message VolumeGroup {
  string name = 1;
  uint64 size = 2;
  uint64 free_size = 3;
  string uuid = 4;

  repeated string tags = 5;
  uint64 pv_count = 6;
}

message ListLVRequest {
  string volume_group = 1;
}

message ListLVReply {
  repeated LogicalVolume volumes = 1;
}

message CreateLVRequest {
  string volume_group = 1;
  string name = 2;
  uint64 size = 3;
  uint32 mirrors = 4;
  repeated string tags = 5;
  bool striping = 6;
}

message CreateLVReply {
  string command_output = 1;
}

message RemoveLVRequest {
  string volume_group = 1;
  string name = 2;
}

message RemoveLVReply {
  string command_output = 1;
}

message CloneLVRequest {
  string source_name = 1;
  string dest_name = 2;
}

message CloneLVReply {
  string command_output = 1;
}

message ListVGRequest {}
message ListVGReply {
  repeated VolumeGroup volume_groups = 1;
}

message CreateVGRequest {
  string name = 1;
  string physical_volume = 2;
  repeated string tags = 3;
}

message CreateVGReply {
  string command_output = 1;
}

message RemoveVGRequest {
  string name = 1;
}

message RemoveVGReply {
  string command_output = 1;
}

message AddTagLVRequest {
  string volume_group = 1;
  string name = 2;
  repeated string tags = 3;
}

message AddTagLVReply {
  string command_output = 1;
}

message RemoveTagLVRequest {
  string volume_group = 1;
  string name = 2;
  repeated string tags = 3;
}

message RemoveTagLVReply {
  string command_output = 1;
}

message CleanPathRequest {
  string path = 1;
}

message CleanPathReply {
  string command_output = 1;
}

message ListNamespaceRequest {
  string name_space = 1;
  string region = 2;
}

message NameSpace {
  string dev = 1;
  string mode = 2;
  string map_type = 3;
  int64 size = 4;
  string uuid = 5;
  int64 sector_size = 6;
  int64 align = 7;
  string block_dev = 8;
  string char_dev = 9;
  string name  = 10;
  string region = 11;
}

message ListNamespaceReply {
  repeated NameSpace name_space = 1;
}

message CreateNamespaceRequest {
  string region = 1;
  string name = 2;
  uint64 size = 3;
}

message CreateNamespaceReply {
  string command_output = 1;
}

message RemoveNamespaceRequest {
  string name_space = 1;
}

message RemoveNamespaceReply {
  string command_output = 1;
}

service LVM {
  rpc ListLV(ListLVRequest) returns (ListLVReply) {}
  rpc CreateLV(CreateLVRequest) returns (CreateLVReply) {}
  rpc RemoveLV(RemoveLVRequest) returns (RemoveLVReply) {}
  rpc CloneLV(CloneLVRequest) returns (CloneLVReply) {}

  rpc AddTagLV(AddTagLVRequest) returns (AddTagLVReply) {}
  rpc RemoveTagLV(RemoveTagLVRequest) returns (RemoveTagLVReply) {}

  rpc ListVG(ListVGRequest) returns (ListVGReply) {}
  rpc CreateVG(CreateVGRequest) returns (CreateVGReply) {}
  rpc RemoveVG(CreateVGRequest) returns (RemoveVGReply) {}
  rpc CleanPath(CleanPathRequest) returns (CleanPathReply) {}
  rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceReply) {}
  rpc CreateNamespace(CreateNamespaceRequest) returns (CreateNamespaceReply) {}
  rpc RemoveNamespace(RemoveNamespaceRequest) returns (RemoveNamespaceReply) {}
}