# generated by datamodel-codegen:
#   filename:  openapi.json
#   timestamp: 2022-12-08T02:46:08+00:00

from __future__ import annotations

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field

from models import common, schema


class AlterAliasRequest(BaseModel):
    alias: Optional[str] = None
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = None
    db_name: Optional[str] = None


class BoolResponse(BaseModel):
    status: Optional[common.Status] = None
    value: Optional[bool] = None


class CalcDistanceResults(BaseModel):
    array: Optional[Any] = Field(
        None,
        description='num(op_left)*num(op_right) distance values, "HAMMIN" return integer distance\n\nTypes that are assignable to Array:\n\t*CalcDistanceResults_IntDist\n\t*CalcDistanceResults_FloatDist',
    )
    status: Optional[common.Status] = None


class CompactionMergeInfo(BaseModel):
    sources: Optional[List[int]] = None
    target: Optional[int] = None


class CreateAliasRequest(BaseModel):
    alias: Optional[str] = None
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = None
    db_name: Optional[str] = None


class CreateCredentialRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    created_utc_timestamps: Optional[int] = Field(None, description='create time')
    modified_utc_timestamps: Optional[int] = Field(None, description='modify time')
    password: Optional[str] = Field(None, description='ciphertext password')
    username: Optional[str] = Field(None, description='username')


class CreateIndexRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The particular collection name you want to create index.'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    extra_params: Optional[List[common.KeyValuePair]] = Field(
        None,
        description='Support keys: index_type,metric_type, params. Different index_type may has different params.',
    )
    field_name: Optional[str] = Field(
        None, description='The vector field name in this particular collection'
    )
    index_name: Optional[str] = Field(
        None,
        description="Version before 2.0.2 doesn't contain index_name, we use default index name.",
    )


class CreatePartitionRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_name: Optional[str] = Field(
        None, description='The partition name you want to create.'
    )


class DeleteCredentialRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    username: Optional[str] = Field(None, description='Not useful for now')


class DeleteRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = None
    db_name: Optional[str] = None
    expr: Optional[str] = None
    hash_keys: Optional[List[int]] = None
    partition_name: Optional[str] = None


class DescribeIndexRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The particular collection name in Milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    field_name: Optional[str] = Field(
        None, description='The vector field name in this particular collection'
    )
    index_name: Optional[str] = Field(
        None, description='No need to set up for now @2021.06.30'
    )


class DropAliasRequest(BaseModel):
    alias: Optional[str] = None
    base: Optional[common.MsgBase] = None
    db_name: Optional[str] = None


class DropIndexRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(None, description='must')
    db_name: Optional[str] = None
    field_name: Optional[str] = None
    index_name: Optional[str] = Field(
        None, description='No need to set up for now @2021.06.30'
    )


class DropPartitionRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_name: Optional[str] = Field(
        None, description='The partition name you want to drop'
    )


class FlushRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_names: Optional[List[str]] = None
    db_name: Optional[str] = None


class FlushResponse(BaseModel):
    coll_segIDs: Optional[Dict[str, schema.LongArray]] = None
    db_name: Optional[str] = None
    status: Optional[common.Status] = None


class GetCollectionStatisticsResponse(BaseModel):
    stats: Optional[List[common.KeyValuePair]] = Field(
        None, description='Collection statistics data'
    )
    status: Optional[common.Status] = None


class GetCompactionPlansRequest(BaseModel):
    compactionID: Optional[int] = None


class GetCompactionPlansResponse(BaseModel):
    mergeInfos: Optional[List[CompactionMergeInfo]] = None
    state: Optional[int] = None
    status: Optional[common.Status] = None


class GetCompactionStateRequest(BaseModel):
    compactionID: Optional[int] = None


class GetCompactionStateResponse(BaseModel):
    completedPlanNo: Optional[int] = None
    executingPlanNo: Optional[int] = None
    state: Optional[int] = None
    status: Optional[common.Status] = None
    timeoutPlanNo: Optional[int] = None


class GetFlushStateRequest(BaseModel):
    segmentIDs: Optional[List[int]] = Field(None, alias='segment_ids')


class GetFlushStateResponse(BaseModel):
    flushed: Optional[bool] = None
    status: Optional[common.Status] = None


class GetImportStateRequest(BaseModel):
    task: Optional[int] = Field(None, description='id of an import task')


class GetImportStateResponse(BaseModel):
    id: Optional[int] = Field(None, description='id of an import task')
    id_list: Optional[List[int]] = Field(
        None, description='auto generated ids if the primary key is autoid'
    )
    infos: Optional[List[common.KeyValuePair]] = Field(
        None,
        description='more informations about the task, progress percent, file path, failed reason, etc.',
    )
    row_count: Optional[int] = Field(
        None,
        description='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.',
    )
    state: Optional[int] = Field(
        None, description='is this import task finished or not'
    )
    status: Optional[common.Status] = None


class GetIndexBuildProgressRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    field_name: Optional[str] = Field(
        None, description='The vector field name in this collection'
    )
    index_name: Optional[str] = Field(None, description='Not useful for now')


class GetIndexBuildProgressResponse(BaseModel):
    indexed_rows: Optional[int] = None
    status: Optional[common.Status] = None
    total_rows: Optional[int] = None


class GetIndexStateRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(None, description='must')
    db_name: Optional[str] = None
    field_name: Optional[str] = None
    index_name: Optional[str] = Field(
        None, description='No need to set up for now @2021.06.30'
    )


class GetIndexStateResponse(BaseModel):
    fail_reason: Optional[str] = None
    state: Optional[int] = None
    status: Optional[common.Status] = None


class GetMetricsRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    request: Optional[str] = Field(None, description='request is of jsonic format')


class GetMetricsResponse(BaseModel):
    component_name: Optional[str] = Field(
        None, description='metrics from which component'
    )
    response: Optional[str] = Field(None, description='response is of jsonic format')
    status: Optional[common.Status] = None


class GetPartitionStatisticsRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_name: Optional[str] = Field(
        None, description='The partition name you want to collect statistics'
    )


class GetPartitionStatisticsResponse(BaseModel):
    stats: Optional[List[common.KeyValuePair]] = None
    status: Optional[common.Status] = None


class GetPersistentSegmentInfoRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collectionName: Optional[str] = Field(None, alias="collection_name", description='must')
    dbName: Optional[str] = Field(None, alias="db_name")


class GetQuerySegmentInfoRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collectionName: Optional[str] = Field(None, alias="collection_name", description='must')
    dbName: Optional[str] = Field(None, alias="db_name")


class GetReplicasRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collectionID: Optional[int] = Field(None, alias="collection_id")
    with_shard_nodes: Optional[bool] = None


class HasPartitionRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_name: Optional[str] = Field(
        None, description='The partition name you want to check'
    )


class ImportRequest(BaseModel):
    channel_names: Optional[List[str]] = Field(
        None, description='channel names for the collection'
    )
    collection_name: Optional[str] = Field(None, description='target collection')
    files: Optional[List[str]] = Field(None, description='file paths to be imported')
    options: Optional[List[common.KeyValuePair]] = Field(
        None, description='import options, bucket, etc.'
    )
    partition_name: Optional[str] = Field(None, description='target partition')
    row_based: Optional[bool] = Field(
        None, description='the file is row-based or column-based'
    )


class ImportResponse(BaseModel):
    status: Optional[common.Status] = None
    tasks: Optional[List[int]] = Field(None, description='id array of import tasks')


class IndexDescription(BaseModel):
    field_name: Optional[str] = Field(None, description='The vector field name')
    index_name: Optional[str] = Field(None, description='Index name')
    indexID: Optional[int] = Field(None, description='Index id')
    params: Optional[List[common.KeyValuePair]] = Field(
        None, description='Will return index_type, metric_type, params(like nlist).'
    )


class ListCredUsersRequest(BaseModel):
    base: Optional[common.MsgBase] = None


class ListCredUsersResponse(BaseModel):
    status: Optional[common.Status] = None
    usernames: Optional[List[str]] = Field(None, description='username array')


class ListImportTasksRequest(BaseModel):
    pass


class ListImportTasksResponse(BaseModel):
    status: Optional[common.Status] = None
    tasks: Optional[List[GetImportStateResponse]] = Field(
        None, description='list of all import tasks'
    )


class LoadBalanceRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collectionName: Optional[str] = None
    dst_nodeIDs: Optional[List[int]] = None
    sealed_segmentIDs: Optional[List[int]] = None
    src_nodeID: Optional[int] = None


class LoadPartitionsRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_names: Optional[List[str]] = Field(
        None, description='The partition names you want to load'
    )
    replica_number: Optional[int] = Field(
        None, description='The replicas number you would load, 1 by default'
    )


class ManualCompactionRequest(BaseModel):
    collectionID: Optional[int] = None
    timetravel: Optional[int] = None


class ManualCompactionResponse(BaseModel):
    compactionID: Optional[int] = None
    status: Optional[common.Status] = None


class PersistentSegmentInfo(BaseModel):
    collectionID: Optional[int] = None
    num_rows: Optional[int] = None
    partitionID: Optional[int] = None
    segmentID: Optional[int] = None
    state: Optional[int] = None


class QueryRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = None
    db_name: Optional[str] = None
    expr: Optional[str] = None
    guarantee_timestamp: Optional[int] = Field(None, description='guarantee_timestamp')
    output_fields: Optional[List[str]] = None
    partition_names: Optional[List[str]] = None
    travel_timestamp: Optional[int] = None


class QueryResults(BaseModel):
    collection_name: Optional[str] = None
    fields_data: Optional[List[schema.FieldData]] = None
    status: Optional[common.Status] = None


class QuerySegmentInfo(BaseModel):
    collectionID: Optional[int] = None
    index_name: Optional[str] = None
    indexID: Optional[int] = None
    mem_size: Optional[int] = None
    nodeID: Optional[int] = None
    num_rows: Optional[int] = None
    partitionID: Optional[int] = None
    segmentID: Optional[int] = None
    state: Optional[int] = None


class ReleasePartitionsRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None, description='The collection name in milvus'
    )
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_names: Optional[List[str]] = Field(
        None, description='The partition names you want to release'
    )


class SearchRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(None, description='must')
    db_name: Optional[str] = None
    dsl: Optional[str] = Field(None, description='must')
    dsl_type: Optional[int] = Field(None, description='must')
    guarantee_timestamp: Optional[int] = Field(None, description='guarantee_timestamp')
    output_fields: Optional[List[str]] = None
    partition_names: Optional[List[str]] = Field(None, description='must')
    placeholder_group: Optional[List[int]] = Field(
        None, description='serialized `PlaceholderGroup`'
    )
    search_params: Optional[List[common.KeyValuePair]] = Field(None, description='must')
    travel_timestamp: Optional[int] = None


class SearchResults(BaseModel):
    collection_name: Optional[str] = None
    results: Optional[schema.SearchResultData] = None
    status: Optional[common.Status] = None


class ShardReplica(BaseModel):
    dm_channel_name: Optional[str] = None
    leader_addr: Optional[str] = Field(None, description='IP:port')
    leaderID: Optional[int] = None
    node_ids: Optional[List[int]] = Field(
        None,
        description='optional, DO NOT save it in meta, set it only for GetReplicas()\nif with_shard_nodes is true',
    )


class ShowCollectionsResponse(BaseModel):
    collection_ids: Optional[List[int]] = Field(None, description='Collection Id array')
    collection_names: Optional[List[str]] = Field(
        None, description='Collection name array'
    )
    created_timestamps: Optional[List[int]] = Field(
        None, description='Hybrid timestamps in milvus'
    )
    created_utc_timestamps: Optional[List[int]] = Field(
        None, description='The utc timestamp calculated by created_timestamp'
    )
    inMemory_percentages: Optional[List[int]] = Field(
        None, description='Load percentage on querynode when type is InMemory'
    )
    status: Optional[common.Status] = None


class ShowPartitionsRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    collection_name: Optional[str] = Field(
        None,
        description='The collection name you want to describe, you can pass collection_name or collectionID',
    )
    collectionID: Optional[int] = Field(None, description='The collection id in milvus')
    db_name: Optional[str] = Field(None, description='Not useful for now')
    partition_names: Optional[List[str]] = Field(
        None,
        description="When type is InMemory, will return these patitions' inMemory_percentages.(Optional)",
    )
    type: Optional[int] = Field(
        None, description='Decide return Loaded partitions or All partitions(Optional)'
    )


class ShowPartitionsResponse(BaseModel):
    created_timestamps: Optional[List[int]] = Field(
        None, description='All hybrid timestamps'
    )
    created_utc_timestamps: Optional[List[int]] = Field(
        None, description='All utc timestamps calculated by created_timestamps'
    )
    inMemory_percentages: Optional[List[int]] = Field(
        None, description='Load percentage on querynode'
    )
    partition_names: Optional[List[str]] = Field(
        None, description='All partition names for this collection'
    )
    partitionIDs: Optional[List[int]] = Field(
        None, description='All partition ids for this collection'
    )
    status: Optional[common.Status] = None


class UpdateCredentialRequest(BaseModel):
    base: Optional[common.MsgBase] = None
    created_utc_timestamps: Optional[int] = Field(None, description='create time')
    modified_utc_timestamps: Optional[int] = Field(None, description='modify time')
    newPassword: Optional[str] = Field(None, description='new password')
    oldPassword: Optional[str] = Field(None, description='old password')
    username: Optional[str] = Field(None, description='username')


class DescribeCollectionResponse(BaseModel):
    aliases: Optional[List[str]] = Field(
        None, description='The aliases of this collection'
    )
    collection_name: Optional[str] = Field(None, description='The collection name')
    collectionID: Optional[int] = Field(None, description='The collection id')
    consistency_level: Optional[int] = Field(
        None,
        description='The consistency level that the collection used, modification is not supported now.',
    )
    created_timestamp: Optional[int] = Field(
        None, description='Hybrid timestamp in milvus'
    )
    created_utc_timestamp: Optional[int] = Field(
        None, description='The utc timestamp calculated by created_timestamp'
    )
    physical_channel_names: Optional[List[str]] = Field(
        None, description='System design related, users should not perceive'
    )
    schema_: Optional[schema.CollectionSchema] = Field(None, alias='schema')
    shards_num: Optional[int] = Field(None, description='The shards number you set.')
    start_positions: Optional[List[common.KeyDataPair]] = Field(
        None, description='The message ID/posititon when collection is created'
    )
    status: Optional[common.Status] = None
    virtual_channel_names: Optional[List[str]] = Field(
        None, description='System design related, users should not perceive'
    )


class DescribeIndexResponse(BaseModel):
    index_descriptions: Optional[List[IndexDescription]] = Field(
        None,
        description='All index informations, for now only return tha latest index you created for the collection.',
    )
    status: Optional[common.Status] = None


class GetPersistentSegmentInfoResponse(BaseModel):
    infos: Optional[List[PersistentSegmentInfo]] = None
    status: Optional[common.Status] = None


class GetQuerySegmentInfoResponse(BaseModel):
    infos: Optional[List[QuerySegmentInfo]] = None
    status: Optional[common.Status] = None


class ReplicaInfo(BaseModel):
    collectionID: Optional[int] = None
    node_ids: Optional[List[int]] = Field(None, description='include leaders')
    partition_ids: Optional[List[int]] = Field(
        None, description='empty indicates to load collection'
    )
    replicaID: Optional[int] = None
    shard_replicas: Optional[List[ShardReplica]] = None


class GetReplicasResponse(BaseModel):
    replicas: Optional[List[ReplicaInfo]] = None
    status: Optional[common.Status] = None
