syntax = "proto3";
package milvus.proto.milvus;

option go_package = "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb";

option java_multiple_files = true;
option java_package = "io.milvus.grpc";
option java_outer_classname = "MilvusProto";
option java_generate_equals_and_hash = true;

option csharp_namespace = "Milvus.Client.Grpc";

import "common.proto";
import "rg.proto";
import "schema.proto";
import "feder.proto";
import "msg.proto";
import "google/protobuf/descriptor.proto";

service MilvusService {
  rpc CreateCollection(CreateCollectionRequest) returns (common.Status) {}
  rpc DropCollection(DropCollectionRequest) returns (common.Status) {}
  rpc HasCollection(HasCollectionRequest) returns (BoolResponse) {}
  rpc LoadCollection(LoadCollectionRequest) returns (common.Status) {}
  rpc ReleaseCollection(ReleaseCollectionRequest) returns (common.Status) {}
  rpc DescribeCollection(DescribeCollectionRequest) returns (DescribeCollectionResponse) {}
  rpc GetCollectionStatistics(GetCollectionStatisticsRequest) returns (GetCollectionStatisticsResponse) {}
  rpc ShowCollections(ShowCollectionsRequest) returns (ShowCollectionsResponse) {}
  rpc AlterCollection(AlterCollectionRequest) returns (common.Status) {}

  rpc CreatePartition(CreatePartitionRequest) returns (common.Status) {}
  rpc DropPartition(DropPartitionRequest) returns (common.Status) {}
  rpc HasPartition(HasPartitionRequest) returns (BoolResponse) {}
  rpc LoadPartitions(LoadPartitionsRequest) returns (common.Status) {}
  rpc ReleasePartitions(ReleasePartitionsRequest) returns (common.Status) {}
  rpc GetPartitionStatistics(GetPartitionStatisticsRequest) returns (GetPartitionStatisticsResponse) {}
  rpc ShowPartitions(ShowPartitionsRequest) returns (ShowPartitionsResponse) {}

  rpc GetLoadingProgress(GetLoadingProgressRequest) returns (GetLoadingProgressResponse) {}
  rpc GetLoadState(GetLoadStateRequest) returns (GetLoadStateResponse) {}

  rpc CreateAlias(CreateAliasRequest) returns (common.Status) {}
  rpc DropAlias(DropAliasRequest) returns (common.Status) {}
  rpc AlterAlias(AlterAliasRequest) returns (common.Status) {}
  rpc DescribeAlias(DescribeAliasRequest) returns (DescribeAliasResponse) {}
  rpc ListAliases(ListAliasesRequest) returns (ListAliasesResponse) {}

  rpc CreateIndex(CreateIndexRequest) returns (common.Status) {}
  rpc AlterIndex(AlterIndexRequest) returns (common.Status) {}
  rpc DescribeIndex(DescribeIndexRequest) returns (DescribeIndexResponse) {}
  rpc GetIndexStatistics(GetIndexStatisticsRequest) returns (GetIndexStatisticsResponse) {}
  // Deprecated: use DescribeIndex instead
  rpc GetIndexState(GetIndexStateRequest) returns (GetIndexStateResponse) {
      option deprecated = true;
  }
  // Deprecated: use DescribeIndex instead
  rpc GetIndexBuildProgress(GetIndexBuildProgressRequest) returns (GetIndexBuildProgressResponse) {
      option deprecated = true;
  }
  rpc DropIndex(DropIndexRequest) returns (common.Status) {}

  rpc Insert(InsertRequest) returns (MutationResult) {}
  rpc Delete(DeleteRequest) returns (MutationResult) {}
  rpc Upsert(UpsertRequest) returns (MutationResult) {}
  rpc Search(SearchRequest) returns (SearchResults) {}
  rpc HybridSearch(HybridSearchRequest) returns (SearchResults) {}
  rpc Flush(FlushRequest) returns (FlushResponse) {}
  rpc Query(QueryRequest) returns (QueryResults) {}
  rpc CalcDistance(CalcDistanceRequest) returns (CalcDistanceResults) {}
  rpc FlushAll(FlushAllRequest) returns (FlushAllResponse) {}

  rpc GetFlushState(GetFlushStateRequest) returns (GetFlushStateResponse) {}
  rpc GetFlushAllState(GetFlushAllStateRequest) returns (GetFlushAllStateResponse) {}
  rpc GetPersistentSegmentInfo(GetPersistentSegmentInfoRequest) returns (GetPersistentSegmentInfoResponse) {}
  rpc GetQuerySegmentInfo(GetQuerySegmentInfoRequest) returns (GetQuerySegmentInfoResponse) {}
  rpc GetReplicas(GetReplicasRequest) returns (GetReplicasResponse) {}

  rpc Dummy(DummyRequest) returns (DummyResponse) {}

  // TODO: remove
  rpc RegisterLink(RegisterLinkRequest) returns (RegisterLinkResponse) {}

  // https://wiki.lfaidata.foundation/display/MIL/MEP+8+--+Add+metrics+for+proxy
  rpc GetMetrics(GetMetricsRequest) returns (GetMetricsResponse) {}
  rpc GetComponentStates(GetComponentStatesRequest) returns (ComponentStates) {}

  rpc LoadBalance(LoadBalanceRequest) returns (common.Status) {}
  rpc GetCompactionState(GetCompactionStateRequest) returns (GetCompactionStateResponse) {}
  rpc ManualCompaction(ManualCompactionRequest) returns (ManualCompactionResponse) {}
  rpc GetCompactionStateWithPlans(GetCompactionPlansRequest) returns (GetCompactionPlansResponse) {}

  // https://wiki.lfaidata.foundation/display/MIL/MEP+24+--+Support+bulk+load
  rpc Import(ImportRequest) returns (ImportResponse) {}
  rpc GetImportState(GetImportStateRequest) returns (GetImportStateResponse) {}
  rpc ListImportTasks(ListImportTasksRequest) returns (ListImportTasksResponse) {}

  // https://wiki.lfaidata.foundation/display/MIL/MEP+27+--+Support+Basic+Authentication
  rpc CreateCredential(CreateCredentialRequest) returns (common.Status) {}
  rpc UpdateCredential(UpdateCredentialRequest) returns (common.Status) {}
  rpc DeleteCredential(DeleteCredentialRequest) returns (common.Status) {}
  rpc ListCredUsers(ListCredUsersRequest) returns (ListCredUsersResponse) {}

  // https://wiki.lfaidata.foundation/display/MIL/MEP+29+--+Support+Role-Based+Access+Control
  rpc CreateRole(CreateRoleRequest) returns (common.Status) {}
  rpc DropRole(DropRoleRequest) returns (common.Status) {}
  rpc OperateUserRole(OperateUserRoleRequest) returns (common.Status) {}
  rpc SelectRole(SelectRoleRequest) returns (SelectRoleResponse) {}
  rpc SelectUser(SelectUserRequest) returns (SelectUserResponse) {}
  rpc OperatePrivilege(OperatePrivilegeRequest) returns (common.Status) {}
  rpc SelectGrant(SelectGrantRequest) returns (SelectGrantResponse) {}

  rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) {}
  rpc CheckHealth(CheckHealthRequest) returns (CheckHealthResponse) {}

  rpc CreateResourceGroup(CreateResourceGroupRequest) returns (common.Status) {}
  rpc DropResourceGroup(DropResourceGroupRequest) returns (common.Status) {}
  rpc UpdateResourceGroups(UpdateResourceGroupsRequest) returns (common.Status) {}
  rpc TransferNode(TransferNodeRequest) returns (common.Status) {}
  rpc TransferReplica(TransferReplicaRequest) returns (common.Status) {}
  rpc ListResourceGroups(ListResourceGroupsRequest) returns (ListResourceGroupsResponse) {}
  rpc DescribeResourceGroup(DescribeResourceGroupRequest) returns (DescribeResourceGroupResponse) {}

  rpc RenameCollection(RenameCollectionRequest) returns (common.Status) {}

  rpc ListIndexedSegment(feder.ListIndexedSegmentRequest) returns(feder.ListIndexedSegmentResponse) {}
  rpc DescribeSegmentIndexData(feder.DescribeSegmentIndexDataRequest) returns(feder.DescribeSegmentIndexDataResponse) {}

  rpc Connect(ConnectRequest) returns (ConnectResponse) {}

  rpc AllocTimestamp(AllocTimestampRequest) returns (AllocTimestampResponse) {}

  rpc CreateDatabase(CreateDatabaseRequest) returns (common.Status) {}
  rpc DropDatabase(DropDatabaseRequest) returns (common.Status) {}
  rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) {}
  rpc AlterDatabase(AlterDatabaseRequest) returns (common.Status) {}

  rpc ReplicateMessage(ReplicateMessageRequest) returns (ReplicateMessageResponse) {}
}

message CreateAliasRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateAlias
    object_name_index: -1
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string alias = 4;
}

message DropAliasRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropAlias
    object_name_index: -1
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string alias = 3;
}

message AlterAliasRequest{
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateAlias
    object_name_index: -1
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string alias = 4;
}

message DescribeAliasRequest{
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDescribeAlias
    object_name_index: -1
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string alias = 3;
}

/*
* Describe alias response
*/
message DescribeAliasResponse {
  // Response status
  common.Status status = 1;
  string db_name = 2;
  string alias = 3;
  string collection = 4;
}

message ListAliasesRequest{
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeListAliases
    object_name_index: -1
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
}

/*
* List aliases response
*/
message ListAliasesResponse {
  // Response status
  common.Status status = 1;
  string db_name = 2;
  string collection_name = 3;
  repeated string aliases = 4;
}

/**
* Create collection in milvus
*/
message CreateCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateCollection
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The unique collection name in milvus.(Required)
  string collection_name = 3;
  // The serialized `schema.CollectionSchema`(Required)
  bytes schema = 4;
  // Once set, no modification is allowed (Optional)
  // https://github.com/milvus-io/milvus/issues/6690
  int32 shards_num = 5;
  // The consistency level that the collection used, modification is not supported now.
  common.ConsistencyLevel consistency_level = 6;
  repeated common.KeyValuePair properties = 7;
  int64 num_partitions = 8; // num of default physical partitions, only used in partition key mode and changes are not supported
}

/**
* Drop collection in milvus, also will drop data in collection.
*/
message DropCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropCollection
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The unique collection name in milvus.(Required)
  string collection_name = 3;
}

/**
* Alter collection in milvus
*/
message AlterCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateCollection
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The unique collection name in milvus.(Required)
  string collection_name = 3;
  int64  collectionID = 4;
  repeated common.KeyValuePair properties = 5;
}

/**
* Check collection exist in milvus or not.
*/
message HasCollectionRequest {
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want to check.
  string collection_name = 3;
  // If time_stamp is not zero, will return true when time_stamp >= created collection timestamp, otherwise will return false.
  uint64 time_stamp = 4;
}


message BoolResponse {
  common.Status status = 1;
  bool value = 2;
}

message StringResponse {
  common.Status status = 1;
  string value = 2;
}

/**
* Get collection meta datas like: schema, collectionID, shards number ...
*/
message DescribeCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDescribeCollection
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want to describe, you can pass collection_name or collectionID
  string collection_name = 3;
  // The collection ID you want to describe
  int64 collectionID = 4;
  // If time_stamp is not zero, will describe collection success when time_stamp >= created collection timestamp, otherwise will throw error.
  uint64 time_stamp = 5;
}

/**
* DescribeCollection Response
*/
message DescribeCollectionResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // The schema param when you created collection.
  schema.CollectionSchema schema = 2;
  // The collection id
  int64 collectionID = 3;
  // System design related, users should not perceive
  repeated string virtual_channel_names = 4;
  // System design related, users should not perceive
  repeated string physical_channel_names = 5;
  // Hybrid timestamp in milvus
  uint64 created_timestamp = 6;
  // The utc timestamp calculated by created_timestamp
  uint64 created_utc_timestamp = 7;
  // The shards number you set.
  int32 shards_num = 8;
  // The aliases of this collection
  repeated string aliases = 9;
  // The message ID/posititon when collection is created
  repeated common.KeyDataPair start_positions = 10;
  // The consistency level that the collection used, modification is not supported now.
  common.ConsistencyLevel consistency_level = 11;
  // The collection name
  string collection_name = 12;
  repeated common.KeyValuePair properties = 13;
  string db_name = 14;
  int64 num_partitions = 15;
  int64 db_id = 16;
}

/**
* Load collection data into query nodes, then you can do vector search on this collection.
*/
message LoadCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeLoad
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want to load
  string collection_name = 3;
  // The replica number to load, default by 1
  int32 replica_number = 4;
  // create replica used resource group
  repeated string resource_groups = 5;
  // Whether to enable refresh mode.
  bool refresh = 6;
}

/**
* Release collection data from query nodes, then you can't do vector search on this collection.
*/
message ReleaseCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeRelease
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want to release
  string collection_name = 3;
}

/**
* Get statistics like row_count.
* WARNING: This API is experimental and not useful for now.
*/
message GetStatisticsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeGetStatistics
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want get statistics
  string collection_name = 3;
  // The partition names you want get statistics, empty for all partitions
  repeated string partition_names = 4;
  // Not useful for now, reserved for future
  uint64 guarantee_timestamp = 5;
}

/**
* Will return statistics in stats field like [{key:"row_count",value:"1"}]
* WARNING: This API is experimental and not useful for now.
*/
message GetStatisticsResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // Collection statistics data
  repeated common.KeyValuePair stats = 2;
}

/**
* Get collection statistics like row_count.
*/
message GetCollectionStatisticsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeGetStatistics
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want get statistics
  string collection_name = 3;
}

/**
* Will return collection statistics in stats field like [{key:"row_count",value:"1"}]
*/
message GetCollectionStatisticsResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // Collection statistics data
  repeated common.KeyValuePair stats = 2;
}

/*
* This is for ShowCollectionsRequest type field.
*/
// Deprecated: use GetLoadingProgress rpc instead
enum ShowType {
  option deprecated = true;
  // Will return all collections
  All = 0;
  // Will return loaded collections with their inMemory_percentages
  InMemory = 1;
}

/*
* List collections
*/
message ShowCollectionsRequest {
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // Not useful for now
  uint64 time_stamp = 3;
  // Decide return Loaded collections or All collections(Optional)
  ShowType type = 4;
  // When type is InMemory, will return these collection's inMemory_percentages.(Optional)
  // Deprecated: use GetLoadingProgress rpc instead
  repeated string collection_names = 5 [deprecated=true];
}

/*
* Return basic collection infos.
*/
message ShowCollectionsResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // Collection name array
  repeated string collection_names = 2;
  // Collection Id array
  repeated int64 collection_ids = 3;
  // Hybrid timestamps in milvus
  repeated uint64 created_timestamps = 4;
  // The utc timestamp calculated by created_timestamp
  repeated uint64 created_utc_timestamps = 5;
  // Load percentage on querynode when type is InMemory
  // Deprecated: use GetLoadingProgress rpc instead
  repeated int64 inMemory_percentages = 6 [deprecated=true];
  // Indicate whether query service is available
  repeated bool query_service_available = 7;
}

/*
* Create partition in created collection.
*/
message CreatePartitionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeCreatePartition
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition name you want to create.
  string partition_name = 4;
}

/*
* Drop partition in created collection.
*/
message DropPartitionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeDropPartition
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition name you want to drop
  string partition_name = 4;
}

/*
* Check if partition exist in collection or not.
*/
message HasPartitionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeHasPartition
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition name you want to check
  string partition_name = 4;
}

/*
* Load specific partitions data of one collection into query nodes
* Then you can get these data as result when you do vector search on this collection.
*/
message LoadPartitionsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeLoad
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition names you want to load
  repeated string partition_names = 4;
  // The replicas number you would load, 1 by default
  int32 replica_number = 5;
  // create replica used resource group
  repeated string resource_groups = 6;
  // Whether to enable refresh mode.
  bool refresh = 7;
}

/*
* Release specific partitions data of one collection from query nodes.
* Then you can not get these data as result when you do vector search on this collection.
*/
message ReleasePartitionsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeRelease
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition names you want to release
  repeated string partition_names = 4;
}

/*
* Get partition statistics like row_count.
*/
message GetPartitionStatisticsRequest {
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name in milvus
  string collection_name = 3;
  // The partition name you want to collect statistics
  string partition_name = 4;
}

message GetPartitionStatisticsResponse {
  common.Status status = 1;
  repeated common.KeyValuePair stats = 2;
}

/*
* List all partitions for particular collection
*/
message ShowPartitionsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeShowPartitions
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The collection name you want to describe, you can pass collection_name or collectionID
  string collection_name = 3;
  // The collection id in milvus
  int64 collectionID = 4;
  // When type is InMemory, will return these patitions's inMemory_percentages.(Optional)
  repeated string partition_names = 5;
  // Decide return Loaded partitions or All partitions(Optional)
  // Deprecated: use GetLoadingProgress rpc instead
  ShowType type = 6 [deprecated=true];
}

/*
* List all partitions for particular collection response.
* The returned datas are all rows, we can format to columns by therir index.
*/
message ShowPartitionsResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // All partition names for this collection
  repeated string partition_names = 2;
  // All partition ids for this collection
  repeated int64 partitionIDs = 3;
  // All hybrid timestamps
  repeated uint64 created_timestamps = 4;
  // All utc timestamps calculated by created_timestamps
  repeated uint64 created_utc_timestamps = 5;
  // Load percentage on querynode
  // Deprecated: use GetLoadingProgress rpc instead
  repeated int64 inMemory_percentages = 6 [deprecated=true];
}

message DescribeSegmentRequest {
  common.MsgBase base = 1;
  int64 collectionID = 2;
  int64 segmentID = 3;
}

message DescribeSegmentResponse {
  common.Status status = 1;
  int64 indexID = 2;
  int64 buildID = 3;
  bool enable_index = 4;
  int64 fieldID = 5;
}

message ShowSegmentsRequest {
  common.MsgBase base = 1;
  int64 collectionID = 2;
  int64 partitionID = 3;
}

message ShowSegmentsResponse {
  common.Status status = 1;
  repeated int64 segmentIDs = 2;
}

/*
* Create index for vector datas
*/
message CreateIndexRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeCreateIndex
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The particular collection name you want to create index.
  string collection_name = 3;
  // The vector field name in this particular collection
  string field_name = 4;
  // Support keys: index_type,metric_type, params. Different index_type may has different params.
  repeated common.KeyValuePair extra_params = 5;
  // Version before 2.0.2 doesn't contain index_name, we use default index name.
  string index_name = 6;
}

/*
* Alter index
*/
message AlterIndexRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeCreateIndex
    object_name_index: 3
  };

  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string index_name = 4;
  repeated common.KeyValuePair extra_params = 5;
}

/*
* Get created index information.
* Current release of Milvus only supports showing latest built index.
*/
message DescribeIndexRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeIndexDetail
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2;
  // The particular collection name in Milvus
  string collection_name = 3;
  // The vector field name in this particular collection
  string field_name = 4;
  // No need to set up for now @2021.06.30
  string index_name = 5;
  uint64 timestamp = 6;
}

/*
* Index informations
*/
message IndexDescription {
  // Index name
  string index_name = 1;
  // Index id
  int64 indexID = 2;
  // Will return index_type, metric_type, params(like nlist).
  repeated common.KeyValuePair params = 3;
  // The vector field name
  string field_name = 4;
  // index build progress
  int64 indexed_rows = 5;
  int64 total_rows = 6;
  // index state
  common.IndexState state = 7;
  string index_state_fail_reason = 8;
  int64 pending_index_rows = 9;
}

/*
* Describe index response
*/
message DescribeIndexResponse {
  // Response status
  common.Status status = 1;
  // All index informations, for now only return tha latest index you created for the collection.
  repeated IndexDescription index_descriptions = 2;
}

/*
*  Get index building progress
*/
message GetIndexBuildProgressRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeIndexDetail
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  string db_name = 2 ;
  // The collection name in milvus
  string collection_name = 3;
  // The vector field name in this collection
  string field_name = 4;
  // Not useful for now
  string index_name = 5;
}

message GetIndexBuildProgressResponse {
  common.Status status = 1;
  int64 indexed_rows = 2;
  int64 total_rows = 3;
}

message GetIndexStateRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeIndexDetail
    object_name_index: 3
  };
  common.MsgBase base = 1; // must
  string db_name = 2 ;
  string collection_name = 3; // must
  string field_name = 4;
  string index_name = 5; // No need to set up for now @2021.06.30
}

message GetIndexStateResponse {
  common.Status status = 1;
  common.IndexState state = 2;
  string fail_reason = 3;
}

message DropIndexRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeDropIndex
    object_name_index: 3
  };
  common.MsgBase base = 1; // must
  string db_name = 2;
  string collection_name = 3; // must
  // Deprecated: not be used in the milvus
  string field_name = 4;
  string index_name = 5;
}

message InsertRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeInsert
    object_name_index: 3
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string partition_name = 4;
  repeated schema.FieldData fields_data = 5;
  repeated uint32 hash_keys = 6;
  uint32 num_rows = 7;
}

message UpsertRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeUpsert
    object_name_index: 3
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string partition_name = 4;
  repeated schema.FieldData fields_data = 5;
  repeated uint32 hash_keys = 6;
  uint32 num_rows = 7;
}

message MutationResult {
  common.Status status = 1;
  schema.IDs IDs = 2; // required for insert, delete, upsert
  repeated uint32 succ_index = 3; // error indexes indicate
  repeated uint32 err_index = 4; // error indexes indicate
  bool acknowledged = 5;
  int64 insert_cnt = 6;
  int64 delete_cnt = 7;
  int64 upsert_cnt = 8;
  uint64 timestamp = 9;
}

message DeleteRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeDelete
    object_name_index: 3
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string partition_name = 4;
  string expr = 5;
  repeated uint32 hash_keys = 6;
  common.ConsistencyLevel consistency_level = 7;
}


message SubSearchRequest {
  string dsl = 1; // must
  // serialized `PlaceholderGroup`
  bytes placeholder_group = 2; // must
  common.DslType dsl_type = 3; // must
  repeated common.KeyValuePair search_params = 4; // must
  int64  nq = 5;
}


message SearchRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeSearch
    object_name_index: 3
  };
  common.MsgBase base = 1; // must
  string db_name = 2;
  string collection_name = 3; // must
  repeated string partition_names = 4; // must
  string dsl = 5; // must
  // serialized `PlaceholderGroup`
  bytes placeholder_group = 6; // must
  common.DslType dsl_type = 7; // must
  repeated string output_fields = 8;
  repeated common.KeyValuePair search_params = 9; // must
  uint64 travel_timestamp = 10;
  uint64 guarantee_timestamp = 11; // guarantee_timestamp
  int64  nq = 12;
  bool not_return_all_meta = 13;
  common.ConsistencyLevel consistency_level = 14;
  bool use_default_consistency = 15;
  bool search_by_primary_keys = 16;
  repeated SubSearchRequest sub_reqs = 17;
}

message Hits {
  repeated int64 IDs = 1;
  repeated bytes row_data = 2;
  repeated float scores = 3;
}

message SearchResults {
  common.Status status = 1;
  schema.SearchResultData results = 2;
  string collection_name = 3;
}

message HybridSearchRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeSearch
    object_name_index: 3
  };
  common.MsgBase base = 1; // must
  string db_name = 2;
  string collection_name = 3; // must
  repeated string partition_names = 4; // must
  repeated SearchRequest requests = 5;
  repeated common.KeyValuePair rank_params = 6; // must
  uint64 travel_timestamp = 7;
  uint64 guarantee_timestamp = 8; // guarantee_timestamp
  bool not_return_all_meta = 9;
  repeated string output_fields = 10;
  common.ConsistencyLevel consistency_level = 11;
  bool use_default_consistency = 12;
}

message FlushRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeFlush
    object_name_indexs: 3
  };
  common.MsgBase base = 1;
  string db_name = 2;
  repeated string collection_names = 3;
}

message FlushResponse{
  common.Status status = 1;
  string db_name = 2;
  map<string, schema.LongArray> coll_segIDs = 3;
  map<string, schema.LongArray> flush_coll_segIDs = 4;
  map<string, int64> coll_seal_times = 5; // physical time for backup tool
  map<string, uint64> coll_flush_ts = 6; // hybrid ts for geting flush tate
  map<string, msg.MsgPosition> channel_cps = 7;
}

message QueryRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeQuery
    object_name_index: 3
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string expr = 4;
  repeated string output_fields = 5;
  repeated string partition_names = 6;
  uint64 travel_timestamp = 7;
  uint64 guarantee_timestamp = 8; // guarantee_timestamp
  repeated common.KeyValuePair query_params = 9; // optional
  bool not_return_all_meta = 10;
  common.ConsistencyLevel consistency_level = 11;
  bool use_default_consistency = 12;
}

message QueryResults {
  common.Status status = 1;
  repeated schema.FieldData fields_data = 2;
  string collection_name = 3;
  repeated string output_fields = 4;
}

message VectorIDs {
  string collection_name = 1;
  string field_name = 2;
  schema.IDs id_array = 3;
  repeated string partition_names = 4;
}

message VectorsArray {
  oneof array {
    VectorIDs id_array = 1; // vector ids
    schema.VectorField data_array = 2; // vectors data
  }
}

message CalcDistanceRequest {
  common.MsgBase base = 1;
  VectorsArray op_left = 2; // vectors on the left of operator
  VectorsArray op_right = 3; // vectors on the right of operator
  repeated common.KeyValuePair params = 4; // "metric":"L2"/"IP"/"HAMMIN"/"TANIMOTO"
}

message CalcDistanceResults {
  common.Status status = 1;
  // num(op_left)*num(op_right) distance values, "HAMMIN" return integer distance
  oneof array {
    schema.IntArray int_dist = 2;
    schema.FloatArray float_dist = 3;
  }
}

message FlushAllRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeFlushAll
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string db_name = 2;
}

message FlushAllResponse {
  common.Status status = 1;
  uint64 flush_all_ts = 2;
}

message PersistentSegmentInfo {
  int64 segmentID = 1;
  int64 collectionID = 2;
  int64 partitionID = 3;
  int64 num_rows = 4;
  common.SegmentState state = 5;
}

message GetPersistentSegmentInfoRequest {
  common.MsgBase base = 1; // must
  string dbName = 2;
  string collectionName = 3; // must
}

message GetPersistentSegmentInfoResponse {
  common.Status status = 1;
  repeated PersistentSegmentInfo infos = 2;
}

message QuerySegmentInfo {
  int64 segmentID = 1;
  int64 collectionID = 2;
  int64 partitionID = 3;
  int64 mem_size = 4;
  int64 num_rows = 5;
  string index_name = 6;
  int64 indexID = 7;
  // deprecated, check node_ids(NodeIds) field
  int64 nodeID = 8 [deprecated=true];
  common.SegmentState state = 9;
  repeated int64 nodeIds = 10;
}

message GetQuerySegmentInfoRequest {
  common.MsgBase base = 1; // must
  string dbName = 2;
  string collectionName = 3; // must
}

message GetQuerySegmentInfoResponse {
  common.Status status = 1;
  repeated QuerySegmentInfo infos = 2;
}

message DummyRequest {
  string request_type = 1;
}

message DummyResponse {
  string response = 1;
}

message RegisterLinkRequest {
}

message RegisterLinkResponse {
  common.Address address = 1;
  common.Status status = 2;
}

message GetMetricsRequest {
  common.MsgBase base = 1;
  string request = 2; // request is of jsonic format
}

message GetMetricsResponse {
  common.Status status = 1;
  string response = 2;  // response is of jsonic format
  string component_name = 3; // metrics from which component
}

message ComponentInfo {
  int64 nodeID = 1;
  string role = 2;
  common.StateCode state_code = 3;
  repeated common.KeyValuePair extra_info = 4;
}

message ComponentStates {
  ComponentInfo state = 1;
  repeated ComponentInfo subcomponent_states = 2;
  common.Status status = 3;
}

message GetComponentStatesRequest {
}

/*
* Do load balancing operation from src_nodeID to dst_nodeID.
*/
message LoadBalanceRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeLoadBalance
    object_name_index: 5
  };
  common.MsgBase base = 1;
  int64 src_nodeID = 2;
  repeated int64 dst_nodeIDs = 3;
  repeated int64 sealed_segmentIDs = 4;
  string collectionName = 5;
  string db_name = 6;
}

message ManualCompactionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeCompaction
    object_name_index: 1
  };
  int64 collectionID = 1;
  uint64 timetravel = 2;
  bool majorCompaction = 3;
}

message ManualCompactionResponse {
  common.Status status = 1;
  int64 compactionID = 2;
  int32 compactionPlanCount = 3;
}

message GetCompactionStateRequest {
  int64 compactionID = 1;
}

message GetCompactionStateResponse {
  common.Status status = 1;
  common.CompactionState state = 2;
  int64 executingPlanNo = 3;
  int64 timeoutPlanNo = 4;
  int64 completedPlanNo = 5;
  int64 failedPlanNo = 6;
}

message GetCompactionPlansRequest {
  int64 compactionID = 1;
}

message GetCompactionPlansResponse {
  common.Status status = 1;
  common.CompactionState state = 2;
  repeated CompactionMergeInfo mergeInfos = 3;
}

message CompactionMergeInfo {
  repeated int64 sources = 1;
  int64 target = 2;
}

message GetFlushStateRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeGetFlushState
    object_name_index: 4
  };
  repeated int64 segmentIDs = 1;
  uint64 flush_ts = 2;
  string db_name = 3;
  string collection_name = 4;
}

message GetFlushStateResponse {
  common.Status status = 1;
  bool flushed = 2;
}

message GetFlushAllStateRequest {
  common.MsgBase base = 1;
  uint64 flush_all_ts = 2;
  string db_name = 3;
}

message GetFlushAllStateResponse {
  common.Status status = 1;
  bool flushed = 2;
}

message ImportRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeImport
    object_name_index: 1
  };
  string collection_name = 1;                // target collection
  string partition_name = 2;                 // target partition
  repeated string channel_names = 3;         // channel names for the collection
  bool row_based = 4;                        // the file is row-based or column-based
  repeated string files = 5;                 // file paths to be imported
  repeated common.KeyValuePair options = 6;  // import options, bucket, etc.
  string db_name = 7;                        // target database
  bytes clustering_info = 8;                 // serialized `schema.ClusteringInfo`
}

message ImportResponse {
  common.Status status = 1;
  repeated int64 tasks = 2;  // id array of import tasks
}

message GetImportStateRequest {
  int64 task = 1;  // id of an import task
}

message GetImportStateResponse {
  common.Status status = 1;
  common.ImportState state = 2;                      // is this import task finished or not
  int64 row_count = 3;                               // if the task is finished, this value is how many rows are imported. if the task is not finished, this value is how many rows are parsed. return 0 if failed.
  repeated int64 id_list = 4;                        // auto generated ids if the primary key is autoid
  repeated common.KeyValuePair infos = 5;            // more information about the task, progress percent, file path, failed reason, etc.
  int64 id = 6;                                      // id of an import task
  int64 collection_id = 7;                           // collection ID of the import task.
  repeated int64 segment_ids = 8;                    // a list of segment IDs created by the import task.
  int64 create_ts = 9;                               // timestamp when the import task is created.
}

message ListImportTasksRequest {
  string collection_name = 1; // target collection, list all tasks if the name is empty
  int64 limit = 2;            // maximum number of tasks returned, list all tasks if the value is 0
  string db_name = 3;
}

message ListImportTasksResponse {
  common.Status status = 1;
  repeated GetImportStateResponse tasks = 2;  // list of all import tasks
}

message GetReplicasRequest {
  common.MsgBase base = 1;
  int64 collectionID = 2;
  bool with_shard_nodes = 3;
  string collection_name = 4;
  string db_name = 5;
}

message GetReplicasResponse {
  common.Status status = 1;
  repeated ReplicaInfo replicas = 2;
}

message ReplicaInfo {    // ReplicaGroup
  int64 replicaID = 1;
  int64 collectionID = 2;
  repeated int64 partition_ids = 3;    // empty indicates to load collection
  repeated ShardReplica shard_replicas = 4;
  repeated int64 node_ids = 5; // include leaders
  string resource_group_name = 6;
  // outbound access rg -> node num
  map<string, int32> num_outbound_node = 7;
}

message ShardReplica {
  int64 leaderID = 1;
  string leader_addr = 2; // IP:port
  string dm_channel_name = 3;
  // optional, DO NOT save it in meta, set it only for GetReplicas()
  // if with_shard_nodes is true
  repeated int64 node_ids = 4;
}

service ProxyService {
  rpc RegisterLink(RegisterLinkRequest) returns (RegisterLinkResponse) {}
}

// https://wiki.lfaidata.foundation/display/MIL/MEP+27+--+Support+Basic+Authentication

message CreateCredentialRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // username
  string username = 2;
  // ciphertext password
  string password = 3;
  // create time
  uint64 created_utc_timestamps = 4;
  // modify time
  uint64 modified_utc_timestamps = 5;
}

message UpdateCredentialRequest {
  option (common.privilege_ext_obj) = {
    object_type: User
    object_privilege: PrivilegeUpdateUser
    object_name_index: 2
  };
  // Not useful for now
  common.MsgBase base = 1;
  // username
  string username = 2;
  // old password
  string oldPassword = 3;
  // new password
  string newPassword = 4;
  // create time
  uint64 created_utc_timestamps = 5;
  // modify time
  uint64 modified_utc_timestamps = 6;
}

message DeleteCredentialRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // Not useful for now
  string username = 2;
}

message ListCredUsersResponse {
  // Contain error_code and reason
  common.Status status = 1;
  // username array
  repeated string usernames = 2;
}

message ListCredUsersRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeSelectOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
}

// https://wiki.lfaidata.foundation/display/MIL/MEP+29+--+Support+Role-Based+Access+Control
message RoleEntity {
  string name = 1;
}

message UserEntity {
  string name = 1;
}

message CreateRoleRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // role
  RoleEntity entity = 2;
}

message DropRoleRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // role name
  string role_name = 2;
}

enum OperateUserRoleType {
  AddUserToRole = 0;
  RemoveUserFromRole = 1;
}

message OperateUserRoleRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeManageOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // username
  string username = 2;
  // role name
  string role_name = 3;
  // operation type
  OperateUserRoleType type = 4;
}

message SelectRoleRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeSelectOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // role
  RoleEntity role = 2;
  // include user info
  bool include_user_info = 3;
}

message RoleResult {
  RoleEntity role = 1;
  repeated UserEntity users = 2;
}

message SelectRoleResponse {
  // Not useful for now
  common.Status status = 1;
  // role result array
  repeated RoleResult results = 2;
}

message SelectUserRequest {
  option (common.privilege_ext_obj) = {
    object_type: User
    object_privilege: PrivilegeSelectUser
    object_name_index: 2
  };
  // Not useful for now
  common.MsgBase base = 1;
  // user
  UserEntity user = 2;
  // include user info
  bool include_role_info = 3;
}

message UserResult {
  UserEntity user = 1;
  repeated RoleEntity roles = 2;
}

message SelectUserResponse {
  // Not useful for now
  common.Status status = 1;
  // user result array
  repeated UserResult results = 2;
}

message ObjectEntity {
  string name = 1;
}

message PrivilegeEntity {
  string name = 1;
}

message GrantorEntity {
  UserEntity user = 1;
  PrivilegeEntity privilege = 2;
}

message GrantPrivilegeEntity {
  repeated GrantorEntity entities = 1;
}

message GrantEntity {
  // role
  RoleEntity role = 1;
  // object
  ObjectEntity object = 2;
  // object name
  string object_name = 3;
  // privilege
  GrantorEntity grantor = 4;
  // db name
  string db_name = 5;
}

message SelectGrantRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeSelectOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // grant
  GrantEntity entity = 2;
}

message SelectGrantResponse {
  // Not useful for now
  common.Status status = 1;
  // grant info array
  repeated GrantEntity entities = 2;
}

enum OperatePrivilegeType {
  Grant = 0;
  Revoke = 1;
}

message OperatePrivilegeRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeManageOwnership
    object_name_index: -1
  };
  // Not useful for now
  common.MsgBase base = 1;
  // grant
  GrantEntity entity = 2;
  // operation type
  OperatePrivilegeType type = 3;
}

message GetLoadingProgressRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeLoad
    object_name_index: 2
  };
  // Not useful for now
  common.MsgBase base = 1;
  string collection_name = 2;
  repeated string partition_names = 3;
  string db_name = 4;
}

message GetLoadingProgressResponse {
  common.Status status = 1;
  int64 progress = 2;
  int64 refresh_progress = 3;
}

message GetLoadStateRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeLoad
    object_name_index: 2
  };
  // Not useful for now
  common.MsgBase base = 1;
  string collection_name = 2;
  repeated string partition_names = 3;
  string db_name = 4;
}

message GetLoadStateResponse {
  common.Status status = 1;
  common.LoadState state = 2;
}

message MilvusExt {
  string version = 1;
}

extend google.protobuf.FileOptions {
  MilvusExt milvus_ext_obj = 1001;
}

message GetVersionRequest {
}

message GetVersionResponse {
  common.Status status = 1;
  string version =2;
}

enum QuotaState {
  Unknown = 0;
  ReadLimited = 2;
  WriteLimited = 3;
  DenyToRead = 4;
  DenyToWrite = 5;
}

message CheckHealthRequest {
}

message CheckHealthResponse {
  common.Status status = 1;
  bool isHealthy = 2;
  repeated string reasons = 3;
  repeated QuotaState quota_states = 4;
}

message CreateResourceGroupRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateResourceGroup
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string resource_group = 2;
  rg.ResourceGroupConfig config = 3;
}

message UpdateResourceGroupsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeUpdateResourceGroups
    object_name_index: -1
  };
  common.MsgBase base = 1;
  map<string, rg.ResourceGroupConfig> resource_groups = 2;
}

message DropResourceGroupRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropResourceGroup
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string resource_group = 2;
}

// transfer `nodeNum` nodes from `source_resource_group` to `target_resource_group`
message TransferNodeRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeTransferNode
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string source_resource_group = 2;
  string target_resource_group = 3;
  int32  num_node = 4;
}

// transfer `replicaNum` replicas in `collectionID` from `source_resource_group` to `target_resource_group`
message TransferReplicaRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeTransferReplica
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string source_resource_group = 2;
  string target_resource_group = 3;
  string  collection_name = 4;
  int64  num_replica = 5;
  string db_name = 6;
}

message ListResourceGroupsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeListResourceGroups
    object_name_index: -1
  };
  common.MsgBase base = 1;
}

message ListResourceGroupsResponse {
  common.Status status = 1;
  repeated string  resource_groups = 2;
}

message DescribeResourceGroupRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDescribeResourceGroup
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string resource_group = 2;
}

message DescribeResourceGroupResponse {
  common.Status status = 1;
  ResourceGroup  resource_group = 2;
}

message ResourceGroup {
  string name = 1;
  int32 capacity = 2;
  int32 num_available_node = 3;
  // collection name -> loaded replica num
  map<string, int32> num_loaded_replica = 4;
  // collection name -> accessed other rg's node num
  map<string, int32> num_outgoing_node = 5;
  // collection name -> be accessed node num by other rg
  map<string, int32> num_incoming_node = 6;
  // resource group configuration.
  rg.ResourceGroupConfig config = 7;
  // query node belong to this resource group now.
  repeated common.NodeInfo nodes = 8;
}

message RenameCollectionRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeRenameCollection
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string oldName = 3;
  string newName = 4;
  string newDBName =5;
}

message GetIndexStatisticsRequest {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeIndexDetail
    object_name_index: 3
  };
  // Not useful for now
  common.MsgBase base = 1;
  // Not useful for now
  string db_name = 2;
  // The particular collection name in Milvus
  string collection_name = 3;
  // The index name in this particular collection
  string index_name = 4;
  uint64 timestamp = 5;
}

message GetIndexStatisticsResponse {
  // Response status
  common.Status status = 1;
  // All index information.
  repeated IndexDescription index_descriptions = 2;
}

message ConnectRequest {
  common.MsgBase base = 1;
  common.ClientInfo client_info = 2;
}

message ConnectResponse {
  common.Status status = 1;
  common.ServerInfo server_info = 2;
  int64 identifier = 3;
}

message AllocTimestampRequest {
  common.MsgBase base = 1;
}

message AllocTimestampResponse {
  common.Status status = 1;
  uint64 timestamp = 2;
}

message CreateDatabaseRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeCreateDatabase
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string db_name = 2;
}

message DropDatabaseRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeDropDatabase
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string db_name = 2;
}

message ListDatabasesRequest {
  common.MsgBase base = 1;
}

message ListDatabasesResponse {
  common.Status status = 1;
  repeated string db_names = 2;
  repeated uint64 created_timestamp = 3;
}

message AlterDatabaseRequest {
  option (common.privilege_ext_obj) = {
    object_type: Global
    object_privilege: PrivilegeAlterDatabase
    object_name_index: -1
  };
  common.MsgBase base = 1;
  string db_name = 2;
  string db_id = 3;
  repeated common.KeyValuePair properties = 4;
}

message ReplicateMessageRequest {
  common.MsgBase base = 1;
  string channel_name = 2;
  uint64 BeginTs = 3;
  uint64 EndTs = 4;
  repeated bytes Msgs = 5;
  repeated msg.MsgPosition  StartPositions = 6;
  repeated msg.MsgPosition  EndPositions = 7;
}

message ReplicateMessageResponse {
  common.Status status = 1;
  string position = 2;
}

message ImportAuthPlaceholder {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeImport
    object_name_index: 1
  };
  string db_name = 1;
  string collection_name = 2;
  string partition_name = 3;
}

message GetImportProgressAuthPlaceholder {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeImport
    object_name_index: 1
  };
  string db_name = 1;
}

message ListImportsAuthPlaceholder {
  option (common.privilege_ext_obj) = {
    object_type: Collection
    object_privilege: PrivilegeImport
    object_name_index: 1
  };
  string db_name = 3;
  string collection_name = 1;
}
