syntax = "proto3";
package milvus.proto.etcd;
option go_package="github.com/milvus-io/milvus/pkg/proto/etcdpb";

import "common.proto";
import "schema.proto";

// this proto only used to describe object that will persist into etcd

message IndexInfo {
  string index_name = 1;
  int64 indexID = 2;
  repeated common.KeyValuePair index_params = 3;
  bool deleted = 4;
  uint64 create_time = 5;
}

message FieldIndexInfo{
  int64 filedID = 1;
  int64 indexID = 2;
}

enum DatabaseState {
  DatabaseUnknown = 0;
  DatabaseCreated = 1;
  DatabaseCreating = 2;
  DatabaseDropping = 3;
  DatabaseDropped = 4;
}

enum CollectionState {
  CollectionCreated = 0;
  CollectionCreating = 1;
  CollectionDropping = 2;
  CollectionDropped = 3;
}

enum PartitionState {
  PartitionCreated = 0;
  PartitionCreating = 1;
  PartitionDropping = 2;
  PartitionDropped = 3;
}

enum AliasState {
  AliasCreated = 0;
  AliasCreating = 1;
  AliasDropping = 2;
  AliasDropped = 3;
}

message CollectionInfo {
  int64 ID = 1;
  schema.CollectionSchema schema = 2;
  uint64 create_time = 3;
  // deprecate
  repeated int64 partitionIDs = 4;
  // deprecate
  repeated string partitionNames = 5;
  // deprecate
  repeated FieldIndexInfo field_indexes = 6;
  repeated string virtual_channel_names = 7;
  repeated string physical_channel_names = 8;
  // deprecate
  repeated uint64 partition_created_timestamps = 9;
  int32 shards_num = 10;
  repeated common.KeyDataPair start_positions = 11;
  common.ConsistencyLevel consistency_level = 12;
  CollectionState state = 13; // To keep compatible with older version, default state is `Created`.
  repeated common.KeyValuePair properties = 14;
  int64 db_id = 15;
  uint64 UpdateTimestamp = 16;
}

message PartitionInfo {
  int64 partitionID = 1;
  string partitionName = 2;
  uint64 partition_created_timestamp = 3;
  int64 collection_id = 4;
  PartitionState state = 5; // To keep compatible with older version, default state is `Created`.
}

message AliasInfo {
  string alias_name = 1;
  int64 collection_id = 2;
  uint64 created_time = 3;
  AliasState state = 4; // To keep compatible with older version, default state is `Created`.
  int64 db_id = 5;
}

message DatabaseInfo {
  string tenant_id = 1;
  string  name = 2;
  int64 id = 3;
  DatabaseState state = 4;
  uint64 created_time = 5;
  repeated common.KeyValuePair properties = 6;
}

message SegmentIndexInfo {
  int64 collectionID = 1;
  int64 partitionID = 2;
  int64 segmentID = 3;
  int64 fieldID = 4;
  int64 indexID = 5;
  int64 buildID = 6;
  bool enable_index = 7;
  uint64 create_time = 8;
}

// TODO move to proto files of interprocess communication
message CollectionMeta {
  int64 ID=1;
  schema.CollectionSchema schema=2;
  uint64 create_time=3;
  repeated int64 segmentIDs=4;
  repeated string partition_tags=5;
  repeated int64 partitionIDs=6;
}

message CredentialInfo {
  string username = 1;
  // encrypted by bcrypt (for higher security level)
  string encrypted_password = 2;
  string tenant = 3;
  bool is_super = 4;
  // encrypted by sha256 (for good performance in cache mapping)
  string sha256_password = 5;
}
