
    j                         d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 ddlmZmZ ddlmZ dd	lmZmZmZmZmZmZ  G d
 d          ZdS )    )parse)
deprecated)MilvusException
ParamError)Config)Mapping   )is_legal_hostis_legal_port)GrpcHandler)BulkInsertStateCompactionPlansCompactionStateReplicaResourceGroupInfoResourceGroupConfigc            	       P   e Zd Zedej        ej        df	 dWd            Zdej        ej        fdZd Z	e
d             Ze
d             Zd Zd	 Zd
 ZdXdZdXdZdXdZdXdZdYdZdXdZdXdZdXdZdXdZdXdZdXdZdYdZdXdZdXdZdXdZdXdZdXdZ dXdZ!dXdZ"dXdZ#dZd!Z$d[d"Z%d[d#Z&d[d$Z'	 	 	 	 	 d\d&Z(dXd'Z)dXd(Z*dXd)Z+dXd*Z,dXd+Z-dXd,Z.dXd-Z/dXd.Z0	 	 	 d]d/Z1	 dXd0e2fd1Z3d^de4fd3Z5	 d^d4e4de6fd5Z7	 dXd4e4de6fd6Z8dXd4e4de9fd7Z:dXd0e2de;fd8Z<	 dXd0e2d9e2d:e=de4fd;Z>dXde?fd<Z@dXde=fd=ZAdXd>ZBdXd?ZCdXd@ZDdXdAZEdXdBZFdXdCZGdXdDZHdXdEZIdXdFZJdXdGZKdXdHZLdXdIZMdXdJZNdXdKZOdXdLZP	 dXdMZQdXdNZRdXdOZS	 dXdPeTe2eUf         fdQZVdXdRZWdXdSZXdXdeYfdTZZdXdUZ[	 dXdVZ\dS )_MilvusNreturnc                     |                      |||          | _        t          d| j        |d|| _        |                    dd          du r| j                                         d S d S )N)addresschannelpre_pingFT )_Milvus__get_addressr   r   _handlerget_wait_for_channel_ready)selfhostporturir   kwargss         ^/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/pymilvus/client/stub.py__init__zMilvus.__init__   sv     ))$c::#TDL'TTVTT::j%((D00M1133333 10    c                 ~   ||t          d          |N	 t          j        |d          }n)# t          $ r}t          d| d|           |d }~ww xY w|j        |j        }}t          |          t          |          }}t          |          rt          |          st          d| d| d          | d	| S )
Nz Host and uri cannot both be NonemessagetcpzIllegal uri [z]: zIllegal host [z] or port []:)	r   r   urlparse	Exceptionhostnamer!   strr
   r   )r   r    r!   r"   
parsed_uries         r$   __get_addresszMilvus.__get_address   s   <CK%GHHHH<M"^C77

 M M M )D)D)D)D)DEEE1LM $,jo$DYYD		dd## 	Pd(;(; 	P%Nd%N%Nt%N%N%NOOOOs   . 
AAAc                     | j         S N)handlerr   s    r$   _connectionzMilvus._connection1   s
    |r&   c                     | j         S r5   )_namer7   s    r$   namezMilvus.name4   s
    zr&   c                     | j         S r5   )r   r7   s    r$   r6   zMilvus.handler8   s
    }r&   c                 4    | j                                         S r5   )r   get_server_typer7   s    r$   r>   zMilvus.get_server_type<   s    },,...r&   c                 >    | j                             |||           d S r5   )r   reset_password)r   userold_passwordnew_passwords       r$   r@   zMilvus.reset_password?   s"    $$T<FFFFFr&   c                 t    | j         t          d          | j                                         d | _         d S )NzClosing on closed handlerr(   )r   r   r6   closer7   s    r$   rE   zMilvus.closeB   s;    = !*EFFFFr&   c                     |                                  5 } |j        ||fd|i|cddd           S # 1 swxY w Y   dS )a:  Creates a collection.

        :param collection_name: The name of the collection. A collection name can only include
        numbers, letters, and underscores, and must not begin with a number.
        :type  collection_name: str

        :param fields: Field parameters.
        :type  fields: dict

            ` {"fields": [
                    {"field": "A", "type": DataType.INT32}
                    {"field": "B", "type": DataType.INT64},
                    {"field": "C", "type": DataType.FLOAT},
                    {"field": "Vec", "type": DataType.FLOAT_VECTOR,
                     "params": {"dim": 128}}
                ],
            "auto_id": True}`

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :param kwargs:
            * *num_shards* (``int``) --
            How wide to scale collection. Corresponds to how many active datanodes can be used on insert.
            * *shards_num* (``int``, deprecated) --
            How wide to scale collection. Corresponds to how many active datanodes can be used on insert.
            * *consistency_level* (``str/int``) --
            Which consistency level to use when searching in the collection. For details, see
            https://github.com/milvus-io/milvus/blob/master/docs/developer_guides/how-guarantee-ts-works.md.
            Note: this parameter can be overwritten by the same parameter specified in search.
            * *properties* (``dict``) --


        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        timeoutN)r8   create_collection)r   collection_namefieldsrG   r#   r6   s         r$   rH   zMilvus.create_collectionH   s    T  	a7,7,_f``g`Y_``	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a   377c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS )a`  
        Delete a specified collection.

        :param collection_name: The name of the collection to delete.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   drop_collectionr   rI   rG   r6   s       r$   rN   zMilvus.drop_collectionu       $  	M7**?G*LL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M   9= =c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS )a  
        Checks whether a specified collection exists.

        :param collection_name: The name of the collection to check.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: If specified collection exists
        :rtype: bool

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   has_collectionrO   s       r$   rS   zMilvus.has_collection   s    $  	L7))/7)KK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	LrQ   c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS )a  
        Returns the schema of specified collection.
        Example: {'collection_name': 'create_collection_eXgbpOtn', 'auto_id': True, 'description': '',
                 'fields': [{'field_id': 100, 'name': 'INT32', 'description': '', 'type': 4, 'params': {},
                 {'field_id': 101, 'name': 'FLOAT_VECTOR', 'description': '', 'type': 101,
                 'params': {'dim': '128'}}]}

        :param collection_name: The name of the collection to describe.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: The schema of collection to describe.
        :rtype: dict

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   describe_collectionrO   s       r$   rU   zMilvus.describe_collection   s    ,  	Q7...PP	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	QrQ   r	   c                     |                                  5 } |j        ||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Loads a specified collection from disk to memory.

        :param collection_name: The name of the collection to load.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :param replica_number: Number of replication in memory to load
        :type replica_number: int

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   load_collection)r   rI   replica_numberrG   r#   r6   s         r$   rW   zMilvus.load_collection   s    *  	7*7* 9@DJ 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rK   c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS )aa  
        Clear collection data from memory.

        :param collection_name: The name of collection to release.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        )rI   rG   N)r8   release_collectionrO   s       r$   rZ   zMilvus.release_collection   s    $  	`7--oW^-__	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	` 	`rQ   c                     |                                  5 } |j        |fd|i|}d |D             }t          |d                   |d<   |cddd           S # 1 swxY w Y   dS )a  
        Returns collection statistics information.
        Example: {"row_count": 10}

        :param collection_name: The name of collection.
        :type  collection_name: str.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: statistics information
        :rtype: dict

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   c                 (    i | ]}|j         |j        S r   keyvalue.0stats     r$   
<dictcomp>z/Milvus.get_collection_stats.<locals>.<dictcomp>       ===tdh
===r&   	row_countN)r8   get_collection_statsint)r   rI   rG   r#   r6   statsresults          r$   rf   zMilvus.get_collection_stats   s    &  	70G0\\'\U[\\E==u===F"%f[&9":":F;		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   6AAAc                     |                                  5 }|                    |          cddd           S # 1 swxY w Y   dS )a8  
        Returns a list of all collection names.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: List of collection names, return when operation is successful
        :rtype: list[str]

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   list_collections)r   rG   r6   s      r$   rk   zMilvus.list_collections   s      	=7++G+<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   8<<c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS )a  
        Creates a partition in a specified collection. You only need to import the
        parameters of partition_name to create a partition. A collection cannot hold
        partitions of the same tag, whilst you can insert the same tag in different collections.

        :param collection_name: The name of the collection to create partitions in.
        :type  collection_name: str

        :param partition_name: The tag name of the partition to create.
        :type  partition_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   create_partitionr   rI   partition_namerG   r6   s        r$   rm   zMilvus.create_partition  s    .  	^7++O^U\+]]	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^   :>>c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS )a  
        Deletes the specified partition in a collection. Note that the default partition
        '_default' is not permitted to delete. When a partition deleted, all data stored in it
        will be deleted.

        :param collection_name: The name of the collection to delete partitions from.
        :type  collection_name: str

        :param partition_name: The tag name of the partition to delete.
        :type  partition_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   drop_partitionrn   s        r$   rr   zMilvus.drop_partition,  s    .  	\7))/>SZ)[[	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\rp   c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS )a  
        Checks if a specified partition exists in a collection.

        :param collection_name: The name of the collection to find the partition in.
        :type  collection_name: str

        :param partition_name: The tag name of the partition to check
        :type  partition_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: Whether a specified partition exists in a collection.
        :rtype: bool

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   has_partitionrn   s        r$   rt   zMilvus.has_partitionF  s    *  	[7((.RY(ZZ	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[rp   c                     |                                  5 }|                    ||||          cddd           S # 1 swxY w Y   dS )aK  
        Load specified partitions from disk to memory.

        :param collection_name: The collection name which partitions belong to.
        :type  collection_name: str

        :param partition_names: The specified partitions to load.
        :type  partition_names: list[str]

        :param replica_number: The replication numbers to load.
        :type  replica_number: int

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        )rI   partition_namesrX   rG   N)r8   load_partitions)r   rI   rv   rX   rG   r6   s         r$   rw   zMilvus.load_partitions^  s    0  	7** / /-	 +  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   ;??c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS )a  
        Clear partitions data from memory.

        :param collection_name: The collection name which partitions belong to.
        :type  collection_name: str

        :param partition_names: The specified partition to release.
        :type  partition_names: list[str]

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        )rI   rv   rG   N)r8   release_partitionsr   rI   rv   rG   r6   s        r$   rz   zMilvus.release_partitions~  s    *  	7-- /Za .  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rp   c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS )a  
        Returns a list of all partition tags in a specified collection.

        :param collection_name: The name of the collection to retrieve partition tags from.
        :type  collection_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: A list of all partition tags in specified collection.
        :rtype: list[str]

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   list_partitionsrO   s       r$   r}   zMilvus.list_partitions  rP   rQ   c                     |                                  5 } |j        ||fd|i|}d |D             }t          |d                   |d<   |cddd           S # 1 swxY w Y   dS )a  
        Returns partition statistics information.
        Example: {"row_count": 10}

        :param collection_name: The name of collection.
        :type  collection_name: str.

        :param partition_name: The name of partition.
        :type  partition_name: str.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: statistics information
        :rtype: dict

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   c                 (    i | ]}|j         |j        S r   r]   r`   s     r$   rc   z.Milvus.get_partition_stats.<locals>.<dictcomp>  rd   r&   re   N)r8   get_partition_statsrg   )r   rI   ro   rG   r#   r6   rh   ri   s           r$   r   zMilvus.get_partition_stats  s    ,  	7/G/ 9@DJ E >=u===F"%f[&9":":F;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   7AA Ac                     |                                  5 } |j        ||fd|i|cddd           S # 1 swxY w Y   dS )a!  
        Specify alias for a collection.
        Alias cannot be duplicated, you can't assign same alias to different collections.
        But you can specify multiple aliases for a collection, for example:
            before create_alias("collection_1", "bob"):
                collection_1's aliases = ["tom"]
            after create_alias("collection_1", "bob"):
                collection_1's aliases = ["tom", "bob"]

        :param collection_name: The name of collection.
        :type  collection_name: str.

        :param alias: The alias of the collection.
        :type  alias: str.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   create_aliasr   rI   aliasrG   r#   r6   s         r$   r   zMilvus.create_alias  s    6  	[7'7'ZZZSYZZ	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[rK   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )al  
        Delete an alias.
        This api no need to specify collection name because the milvus server knows which collection it belongs.
        For example:
            before drop_alias("bob"):
                collection_1's aliases = ["tom", "bob"]
            after drop_alias("bob"):
                collection_1's aliases = ["tom"]

        :param alias: The alias to be deleted.
        :type  alias: str.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   
drop_alias)r   r   rG   r#   r6   s        r$   r   zMilvus.drop_alias  s    0  	H7%7%eGGWGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H   266c                     |                                  5 } |j        ||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Change alias of a collection to another collection. If the alias doesn't exist, the api will return error.
        Alias cannot be duplicated, you can't assign same alias to different collections.
        This api can change alias owner collection, for example:
            before alter_alias("collection_2", "bob"):
                collection_1's aliases = ["bob"]
                collection_2's aliases = []
            after alter_alias("collection_2", "bob"):
                collection_1's aliases = []
                collection_2's aliases = ["bob"]

        :param collection_name: The name of collection.
        :type  collection_name: str.

        :param alias: The new alias of the collection.
        :type  alias: str.

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   alter_aliasr   s         r$   r   zMilvus.alter_alias  s    :  	Z7&7&YYwYRXYY	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	ZrK   c                     |                                  5 } |j        |||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Creates an index for a field in a specified collection. Milvus does not support creating multiple
        indexes for a field. In a scenario where the field already has an index, if you create another one,
        the server will replace the existing index files with the new ones.

        Note that you need to call load_collection() or load_partitions() to make the new index take effect
        on searching tasks.

        :param collection_name: The name of the collection to create field indexes.
        :type  collection_name: str

        :param field_name: The name of the field to create an index for.
        :type  field_name: str

        :param params: Indexing parameters.
        :type  params: dict
            There are examples of supported indexes:

            IVF_FLAT:
                ` {
                    "metric_type":"L2",
                    "index_type": "IVF_FLAT",
                    "params":{"nlist": 1024}
                }`

            IVF_PQ:
                `{
                    "metric_type": "L2",
                    "index_type": "IVF_PQ",
                    "params": {"nlist": 1024, "m": 8, "nbits": 8}
                }`

            IVF_SQ8:
                `{
                    "metric_type": "L2",
                    "index_type": "IVF_SQ8",
                    "params": {"nlist": 1024}
                }`

            BIN_IVF_FLAT:
                `{
                    "metric_type": "JACCARD",
                    "index_type": "BIN_IVF_FLAT",
                    "params": {"nlist": 1024}
                }`

            HNSW:
                `{
                    "metric_type": "L2",
                    "index_type": "HNSW",
                    "params": {"M": 48, "efConstruction": 50}
                }`

            RHNSW_FLAT:
                `{
                    "metric_type": "L2",
                    "index_type": "RHNSW_FLAT",
                    "params": {"M": 48, "efConstruction": 50}
                }`

            RHNSW_PQ:
                `{
                    "metric_type": "L2",
                    "index_type": "RHNSW_PQ",
                    "params": {"M": 48, "efConstruction": 50, "PQM": 8}
                }`

            RHNSW_SQ:
                `{
                    "metric_type": "L2",
                    "index_type": "RHNSW_SQ",
                    "params": {"M": 48, "efConstruction": 50}
                }`

            ANNOY:
                `{
                    "metric_type": "L2",
                    "index_type": "ANNOY",
                    "params": {"n_trees": 8}
                }`

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :param kwargs:
            * *_async* (``bool``) --
              Indicate if invoke asynchronously. When value is true, method returns a IndexFuture object;
              otherwise, method returns results from server.
            * *_callback* (``function``) --
              The callback function which is invoked after server response successfully. It only take
              effect when _async is set to True.
            * *index_name* (``str``) --
              The name of index which will be created. Then you can use the index name to check the state of index.
              If no index name is specified, default index name is used.

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   create_index)r   rI   
field_nameparamsrG   r#   r6   s          r$   r   zMilvus.create_index$  s    P  	7'7'V =DHN 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   488c                     |                                  5 }|                    ||d|          cddd           S # 1 swxY w Y   dS )a  
        Removes the index of a field in a specified collection.

        :param collection_name: The name of the collection to remove the field index from.
        :type  collection_name: str

        :param field_name: The name of the field to remove the index of.
        :type  field_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
         )rI   r   
index_namerG   N)r8   
drop_index)r   rI   r   rG   r6   s        r$   r   zMilvus.drop_index  s    *  	7%% /%	 &  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rx   r   c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS )aY  
        Returns the schema of index built on specified field.
        Example: {'index_type': 'FLAT', 'metric_type': 'L2', 'params': {'nlist': 128}}

        :param collection_name: The name of the collection which field belong to.
        :type  collection_name: str

        :param field_name: The name of field to describe.
        :type  field_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: the schema of index built on specified field.
        :rtype: dict

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rM   N)r8   describe_indexr   rI   r   rG   r6   s        r$   r   zMilvus.describe_index  s    ,  	X7))/:w)WW	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	Xrp   c                     |                                  5 } |j        |||fd|i|cddd           S # 1 swxY w Y   dS )ut  
        Inserts entities in a specified collection.

        :param collection_name: The name of the collection to insert entities in.
        :type  collection_name: str.

        :param entities: The entities to insert.
        :type  entities: list

        :param partition_name: The name of the partition to insert entities in. The default value is
         None. The server stores entities in the “_default” partition by default.
        :type  partition_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :param kwargs:
            * *_async* (``bool``) --
              Indicate if invoke asynchronously. When value is true, method returns a MutationFuture object;
              otherwise, method returns results from server.
            * *_callback* (``function``) --
              The callback function which is invoked after server response successfully. It only take
              effect when _async is set to True.

        :return: list of ids of the inserted vectors.
        :rtype: list[int]

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   batch_insert)r   rI   entitiesro   rG   r#   r6   s          r$   insertzMilvus.insert  s    B  	7'7'> CJNT 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                     |                                  5 } |j        |||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Delete entities with an expression condition.
        And return results to show which primary key is deleted successfully

        :param collection_name: Name of the collection to delete entities from
        :type  collection_name: str

        :param expr: The expression to specify entities to be deleted
        :type  expr: str

        :param partition_name: Name of partitions that contain entities
        :type  partition_name: str

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur
        :type  timeout: float

        :return: list of ids of the deleted vectors.
        :rtype: list

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   delete)r   rI   exprro   rG   r#   r6   s          r$   r   zMilvus.delete  s    2  	d7!7>/4ccQXc\bcc	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	dr   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )a  
        Internally, Milvus organizes data into segments, and indexes are built in a per-segment manner.
        By default, a segment will be sealed if it grows large enough (according to segment size configuration).
        If any index is specified on certain field, the index-creating task will be triggered automatically
        when a segment is sealed.

        The flush() call will seal all the growing segments immediately of the given collection,
        and force trigger the index-creating tasks.

        :param collection_names: The name of collection to flush.
        :type  collection_names: list[str]

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :param kwargs:
            * *_async* (``bool``) --
              Indicate if invoke asynchronously. When value is true, method returns a FlushFuture object;
              otherwise, method returns results from server.
            * *_callback* (``function``) --
              The callback function which is invoked after server response successfully. It only take
              effect when _async is set to True.

        :return: None
        :rtype: NoneType

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   flush)r   collection_namesrG   r#   r6   s        r$   r   zMilvus.flush	  s    @  	N7 7=!1MM7MfMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Nr   c                     |                                  5 } |j        ||||||||f|
|	d|cddd           S # 1 swxY w Y   dS )a%  
        Searches a collection based on the given expression and returns query results.

        :param collection_name: The name of the collection to search.
        :type  collection_name: str
        :param data: The vectors of search data, the length of data is number of query (nq), the dim of every vector in
                     data must be equal to vector field's of collection.
        :type  data: list[list[float]]
        :param anns_field: The vector field used to search of collection.
        :type  anns_field: str
        :param param: The parameters of search, such as nprobe, etc.
        :type  param: dict
        :param limit: The max number of returned record, we also called this parameter as topk.
        :type  limit: int
        :param expression: The boolean expression used to filter attribute.
        :type  expression: str
        :param partition_names: The names of partitions to search.
        :type  partition_names: list[str]
        :param output_fields: The fields to return in the search result, not supported now.
        :type  output_fields: list[str]
        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float
        :param round_decimal: The specified number of decimal places of returned distance
        :type  round_decimal: int
        :param kwargs:
            * *_async* (``bool``) --
              Indicate if invoke asynchronously. When value is true, method returns a SearchFuture object;
              otherwise, method returns results from server.
            * *_callback* (``function``) --
              The callback function which is invoked after server response successfully. It only take
              effect when _async is set to True.
            * *consistency_level* (``str/int``) --
              Which consistency level to use when searching in the collection. For details, see
              https://github.com/milvus-io/milvus/blob/master/docs/developer_guides/how-guarantee-ts-works.md.
              Note: this parameter will overwrite the same parameter user specified when creating the collection,
              if no consistency level was specified, search will use the collection consistency level.
            * *guarantee_timestamp* (``int``) --
              This function instructs Milvus to see all operations performed before a provided timestamp. If no
              such timestamp is provided, then Milvus will search all operations performed to date.
              Note: only used in Customized consistency level.
            * *graceful_time* (``int``) --
              Only used in bounded consistency level. If graceful_time is set, PyMilvus will use current timestamp minus
              the graceful_time as the `guarantee_timestamp`. This option is 5s by default if not set.

        :return: Query result. QueryResult is iterable and is a 2d-array-like class, the first dimension is
                 the number of vectors to query (nq), the second dimension is the number of limit(topk).
        :rtype: QueryResult

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        )round_decimalrG   N)r8   search)r   rI   data
anns_fieldparamlimit
expressionrv   output_fieldsrG   r   r#   r6   s                r$   r   zMilvus.search,  s    F  	7!7> ,   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rp   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )a  
        Notifies Proxy to return segments information from query nodes.

        :param collection_name: The name of the collection to get segments info.
        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur.
        :type  timeout: float

        :return: QuerySegmentInfo:
            QuerySegmentInfo is the growing segments's information in query cluster.
        :rtype: QuerySegmentInfo
        rG   N)r8   get_query_segment_infor   rI   rG   r#   r6   s        r$   r   zMilvus.get_query_segment_info~  s      	^7171/]]7]V\]]	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^r   c                     |                                  5 }|                    ||          cddd           S # 1 swxY w Y   dS z{
            'loading_progress': '100%',
            'num_loaded_partitions': 3,
            'not_loaded_partitions': [],
        }
        rM   N)r8   load_collection_progressrO   s       r$   r   zMilvus.load_collection_progress  s      	V733OW3UU	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	VrQ   c                     |                                  5 }|                    |||          cddd           S # 1 swxY w Y   dS r   )r8   load_partitions_progressr{   s        r$   r   zMilvus.load_partitions_progress  s      	733' 4  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rp   c                     |                                  5 }|                    ||          cd d d            S # 1 swxY w Y   d S NrM   )r8   wait_for_loading_collectionrO   s       r$   $wait_for_loading_collection_completez+Milvus.wait_for_loading_collection_complete  s     	Y766PW6XX	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	YrQ   c                     |                                  5 }|                    |||          cd d d            S # 1 swxY w Y   d S r   )r8   wait_for_loading_partitionsr{   s        r$   $wait_for_loading_partitions_completez+Milvus.wait_for_loading_partitions_complete  s     	766' 7  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rp   c                     |                                  5 }|                    |||          cd d d            S # 1 swxY w Y   d S r   )r8   get_index_build_progressr   s        r$   r   zMilvus.get_index_build_progress  s     	b733OZY`3aa	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	brp   c                     |                                  5 }|                    |||          cd d d            S # 1 swxY w Y   d S r   )r8   wait_for_creating_indexr   s        r$   r   zMilvus.wait_for_creating_index  s     	a722?JX_2``	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	arp   c                     |                                  5 }|                    ||          cd d d            S # 1 swxY w Y   d S r   )r8   dummy)r   request_typerG   r6   s       r$   r   zMilvus.dummy  s     	@7==w=??	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@rQ   c                     |                                  5 } |j        ||||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Query with a set of criteria, and results in a list of records that match the query exactly.

        :param collection_name: Name of the collection to retrieve entities from
        :type  collection_name: str

        :param expr: The query expression
        :type  expr: str

        :param output_fields: A list of fields to return
        :type  output_fields: list[str]

        :param partition_names: Name of partitions that contain entities
        :type  partition_names: list[str]

        :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout
                        is set to None, client waits until server response or error occur
        :type  timeout: float

        :return: A list that contains all results
        :rtype: list

        :param kwargs:
            * *consistency_level* (``str/int``) --
              Which consistency level to use during a query on the collection. For details, see
              https://github.com/milvus-io/milvus/blob/master/docs/developer_guides/how-guarantee-ts-works.md.
              Note: this parameter will overwrite the same parameter user specified when creating the collection,
              if no consistency level was specified, query will use the collection consistency level.
            * *guarantee_timestamp* (``int``) --
              This function instructs Milvus to see all operations performed before a provided timestamp. If no
              such timestamp is specified, Milvus queries all operations performed to date.
              Note: only used in Customized consistency level.
            * *graceful_time* (``int``) --
              Only used in bounded consistency level. If graceful_time is set, PyMilvus will use current timestamp minus
              the graceful_time as the `guarantee_timestamp`. This option is 5s by default if not set.

        :raises RpcError: If gRPC encounter an error
        :raises ParamError: If parameters are invalid
        :raises MilvusException: If the return result from server is not ok
        rG   N)r8   query)r   rI   r   r   rv   rG   r#   r6   s           r$   r   zMilvus.query  s    b  	7 7=}o OVZ` 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   599rI   c                     |                                  5 } |j        ||||fd|i|cddd           S # 1 swxY w Y   dS )a  
        Do load balancing operation from source query node to destination query node.
        :param collection_name: The collection to balance.
        :type  collection_name: str

        :param src_node_id: The source query node id to balance.
        :type  src_node_id: int

        :param dst_node_ids: The destination query node ids to balance.
        :type  dst_node_ids: list[int]

        :param sealed_segment_ids: Sealed segment ids to balance.
        :type  sealed_segment_ids: list[int]

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :raises MilvusException: If query nodes not exist.
        :raises MilvusException: If sealed segments not exist.
        rG   N)r8   load_balance)r   rI   src_node_iddst_node_idssealed_segment_idsrG   r#   r6   s           r$   r   zMilvus.load_balance  s    :  	7'7'"	 
    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   Fc                     |                                  5 } |j        |f||d|cddd           S # 1 swxY w Y   dS )a  
        Do compaction for the collection.

        :param collection_name: The collection name to compact
        :type  collection_name: str

        :param is_clustering: trigger clustering compaction
        :type  is_clustering: bool

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :return: the compaction ID
        :rtype: int

        :raises MilvusException: If collection name not exist.
        is_clusteringrG   N)r8   compact)r   rI   r   rG   r#   r6   s         r$   r   zMilvus.compact  s    $  	7"7?/<g QW 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rK   compaction_idc                     |                                  5 } |j        |f||d|cddd           S # 1 swxY w Y   dS )a  
        Get compaction states of a targeted compaction id

        :param compaction_id: the id returned by compact
        :type  compaction_id: int

        :param is_clustering: get clustering compaction
        :type  is_clustering: bool

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :return: the state of the compaction
        :rtype: CompactionState

        :raises MilvusException: If compaction_id doesn't exist.
        r   N)r8   get_compaction_state)r   r   r   rG   r#   r6   s         r$   r   zMilvus.get_compaction_state.  s    *  	7/7/-:G OU 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rK   c                 ~    |                                  5 } |j        |fd|i|cd d d            S # 1 swxY w Y   d S )NrG   )r8   wait_for_compaction_completedr   r   rG   r#   r6   s        r$   r   z$Milvus.wait_for_compaction_completedH  s      	c7878bbPWb[abb	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	c 	cr   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )a  
        Get compaction states of a targeted compaction id

        :param compaction_id: the id returned by compact
        :type  compaction_id: int

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :return: the state of the compaction
        :rtype: CompactionState

        :raises MilvusException: If compaction_id doesn't exist.
        rG   N)r8   get_compaction_plansr   s        r$   r   zMilvus.get_compaction_plansN  s      	Z7/7/YYwYRXYY	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Zr   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )ah  Get replica infos of a collection

        :param collection_name: the name of the collection
        :type  collection_name: str

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :return: the replica info
        :rtype: Replica

        :raises MilvusException: If collection_name doesn't exist.
        rG   N)r8   get_replicasr   s        r$   r   zMilvus.get_replicas`  s      	T7'7'SSSFSS	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	Tr   ro   filesc                     |                                  5 } |j        |||fd|i|cddd           S # 1 swxY w Y   dS )a/  do_bulk_insert inserts entities through files, currently supports row-based json file.
        User need to create the json file with a specified json format which is described in the official user guide.
        Let's say a collection has two fields: "id" and "vec"(dimension=8), the row-based json format is:
          {"rows": [
              {"id": "0", "vec": [0.190, 0.046, 0.143, 0.972, 0.592, 0.238, 0.266, 0.995]},
              {"id": "1", "vec": [0.149, 0.586, 0.012, 0.673, 0.588, 0.917, 0.949, 0.944]},
              ......
            ]
          }
        The json file must be uploaded to root path of MinIO/S3 storage which is accessed by milvus server.
        For example:
            the milvus.yml specify the MinIO/S3 storage bucketName as "a-bucket", user can upload his json file
             to a-bucket/xxx.json, then call do_bulk_insert(files=["a-bucket/xxx.json"])

        :param collection_name: the name of the collection
        :type  collection_name: str

        :param partition_name: the name of the partition
        :type  partition_name: str

        :param files: related path of the file to be imported. for row-based json file, only allow
                      one file each invocation.
        :type  files: list[str]

        :param timeout: The timeout for this method, unit: second
        :type  timeout: int

        :param kwargs: other infos

        :return: id of the task
        :rtype:  int

        :raises BaseException: If collection_name doesn't exist.
        :raises BaseException: If the files input is illegal.
        rG   N)r8   do_bulk_insert)r   rI   ro   r   rG   r#   r6   s          r$   r   zMilvus.do_bulk_insertq  s    L  	7)7) @GKQ 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                 ~    |                                  5 } |j        |fd|i|cddd           S # 1 swxY w Y   dS )zget_bulk_insert_state returns state of a certain task_id

        :param task_id: the task id returned by bulk_insert
        :type  task_id: int

        :return: BulkInsertState
        :rtype:  BulkInsertState
        rG   N)r8   get_bulk_insert_state)r   task_idrG   r#   r6   s        r$   r   zMilvus.get_bulk_insert_state  s      	U7070TT'TVTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	Ur   c                 |    |                                  5 } |j        dd|i|cddd           S # 1 swxY w Y   dS )a  list_bulk_insert_tasks lists all bulk load tasks

        :param limit: maximum number of tasks returned, list all tasks if the value is 0, else return the latest tasks
        :type  limit: int

        :param collection_name: target collection name, list all tasks if the name is empty
        :type  collection_name: str

        :return: list[BulkInsertState]
        :rtype:  list[BulkInsertState]

        rG   Nr   )r8   list_bulk_insert_tasksr   rG   r#   r6   s       r$   r   zMilvus.list_bulk_insert_tasks  s      	M7171LL'LVLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M   155c                     |                                  5 } |j        ||fd|i| ddd           dS # 1 swxY w Y   dS )a  Create a user using the given user and password.
        :param user: the user name.
        :type  user: str
        :param password: the password.
        :type  password: str
        :param timeout: The timeout for this method, unit: second
        :type  timeout: int
        rG   N)r8   create_user)r   rA   passwordrG   r#   r6   s         r$   r   zMilvus.create_user  s      	K7GhJJJ6JJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	Kr   c                     |                                  5 } |j        |||fd|i| ddd           dS # 1 swxY w Y   dS )a[  
            Update the user password using the given user and password.
            You must provide the original password to check if the operation is valid.
            Note: after this operation, PyMilvus won't change the related header of this connection.
            So if you update credential for this connection, the connection may be invalid.

        :param user: the user name.
        :type  user: str
        :param old_password: the original password.
        :type  old_password: str
        :param new_password: the newly password of this user.
        :type  new_password: str
        rG   N)r8   update_password)r   rA   rB   rC   rG   r#   r6   s          r$   r   zMilvus.update_password  s      	a7#G#D,``g`Y_```	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	a 	ar   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zDelete user corresponding to the username.
        :param user: the user name.
        :type  user: str
        :param timeout: The timeout for this method, unit: second
        :type  timeout: int
        rG   N)r8   delete_user)r   rA   rG   r#   r6   s        r$   r   zMilvus.delete_user  s      	A7G@@g@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	ArK   c                 |    |                                  5 } |j        dd|i|cddd           S # 1 swxY w Y   dS )zList all usernames.
        :param timeout: The timeout for this method, unit: second
        :type  timeout: int
        :return list of str:
            The usernames in Milvus instances.
        rG   Nr   )r8   list_usernamesr   s       r$   r   zMilvus.list_usernames  s      	E7)7)DD'DVDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Er   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )z[Create Role
        :param role_name: the role name.
        :type  role_name: str
        rG   N)r8   create_roler   	role_namerG   r#   r6   s        r$   r   zMilvus.create_role  s    
  	F7G	EE7EfEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	FrK   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zUDrop Role
        :param role_name: role name.
        :type  role_name: str
        rG   N)r8   	drop_roler   s        r$   r   zMilvus.drop_role  s    
  	D7GiCCCFCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	DrK   c                     |                                  5 } |j        ||fd|i| ddd           dS # 1 swxY w Y   dS )zAdd User To Role
        :param username: user name.
        :type  username: str
        :param role_name: role name.
        :type  role_name: str
        rG   N)r8   add_user_to_roler   usernamer   rG   r#   r6   s         r$   r   zMilvus.add_user_to_role  s      	U7$G$XyTT'TVTTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	Ur   c                     |                                  5 } |j        ||fd|i| ddd           dS # 1 swxY w Y   dS )zRemove User From Role
        :param username: user name.
        :type  username: str
        :param role_name: role name.
        :type  role_name: str
        rG   N)r8   remove_user_from_roler   s         r$   r   zMilvus.remove_user_from_role  s      	Z7)G)(IYYwYRXYYY	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Zr   c                     |                                  5 } |j        ||fd|i| ddd           dS # 1 swxY w Y   dS )zSelect One Role Info
        :param role_name: role name.
        :type  role_name: str
        :param include_user_info: whether to obtain the user information associated with the role
        :type  include_user_info: bool
        rG   N)r8   select_one_role)r   r   include_user_inforG   r#   r6   s         r$   r   zMilvus.select_one_role  s      	]7#G#I/@\\'\U[\\\	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	] 	]r   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zSelect All Role Info
        :param include_user_info: whether to obtain the user information associated with roles
        :type  include_user_info: bool
        rG   Nr8   select_all_role)r   r   rG   r#   r6   s        r$   r   zMilvus.select_all_role      
  	R7#G#$5QQwQ&QQQ	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	RrK   c                     |                                  5 } |j        ||fd|i| ddd           dS # 1 swxY w Y   dS )zSelect One User Info
        :param username: user name.
        :type  username: str
        :param include_role_info: whether to obtain the role information associated with the user
        :type  include_role_info: bool
        rG   N)r8   select_one_user)r   r   include_role_inforG   r#   r6   s         r$   r   zMilvus.select_one_user  s      	\7#G#H.?[[[TZ[[[	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\r   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zSelect All User Info
        :param include_role_info: whether to obtain the role information associated with users
        :type  include_role_info: bool
        rG   Nr   )r   r   rG   r#   r6   s        r$   select_all_userzMilvus.select_all_user)  r   rK   c                     |                                  5 } |j        ||||fd|i| ddd           dS # 1 swxY w Y   dS )aa  Grant Privilege
        :param role_name: role name.
        :type  role_name: str
        :param object: object that will be granted the privilege.
        :type  object: str
        :param object_name: identifies a specific resource name.
        :type  object_name: str
        :param privilege: privilege name.
        :type  privilege: str
        rG   N)r8   grant_privileger   r   objectobject_name	privilegerG   r#   r6   s           r$   r  zMilvus.grant_privilege1  s      	7#G#6;	 CJNT  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   6::c                     |                                  5 } |j        ||||fd|i| ddd           dS # 1 swxY w Y   dS )ab  Revoke Privilege
        :param role_name: role name.
        :type  role_name: str
        :param object: object that will be granted the privilege.
        :type  object: str
        :param object_name: identifies a specific resource name.
        :type  object_name: str
        :param privilege: privilege name.
        :type  privilege: str
        rG   N)r8   revoke_privileger  s           r$   r	  zMilvus.revoke_privilegeA  s      	7$G$6;	 CJNT  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zpSelect the grant info about the role
        :param role_name: role name.
        :type  role_name: str
        rG   N)r8   select_grant_for_one_roler   s        r$   r  z Milvus.select_grant_for_one_roleQ  s    
  	T7-G-iSSSFSSS	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	TrK   c                     |                                  5 } |j        |||fd|i| ddd           dS # 1 swxY w Y   dS )aH  Select the grant info about the role and specific object
        :param role_name: role name.
        :type  role_name: str
        :param object: object that will be selected the privilege info.
        :type  object: str
        :param object_name: identifies a specific resource name.
        :type  object_name: str
        rG   N)r8    select_grant_for_role_and_object)r   r   r  r  rG   r#   r6   s          r$   r  z'Milvus.select_grant_for_role_and_objectY  s      	74G46; 8?CI  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                 ~    |                                  5 } |j        dd|i| d d d            d S # 1 swxY w Y   d S )NrG   r   )r8   get_versionr   s       r$   r  zMilvus.get_versioni  s     	;7G:::6:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;r   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zscreate resource group with specific name

        :param name: resource group name
        :type name: str
        rG   N)r8   create_resource_groupr   r;   rG   r#   r6   s        r$   r  zMilvus.create_resource_groupm  s      	K7)G)$JJJ6JJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	KrK   configsc                     |                                  5 } |j        d||d| ddd           dS # 1 swxY w Y   dS )zupdate resource groups with specific configs

        :param configs: resource group configs
        :type name: Mapping
        )r  rG   Nr   )r8   update_resource_groups)r   r  rG   r#   r6   s        r$   r  zMilvus.update_resource_groupsv  s      	W7*G*V7GVVvVVV	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	WrK   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zqdrop resource group with specific name

        :param name: resource group name
        :type name: str
        rG   N)r8   drop_resource_groupr  s        r$   r  zMilvus.drop_resource_group  s      	I7'G'HHgHHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	IrK   c                 ~    |                                  5 } |j        dd|i| ddd           dS # 1 swxY w Y   dS )zlist all resource group namesrG   Nr   )r8   list_resource_groupsr   s       r$   r  zMilvus.list_resource_groups  s     	D7(G(CCCFCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Dr   c                     |                                  5 } |j        |fd|i| ddd           dS # 1 swxY w Y   dS )zdescribe resource group with specific name

        :param name: resource group info
        :type name: str
        :return: resource group info
        :rtype: ResourceGroupInfo
        rG   N)r8   describe_resource_groupr  s        r$   r  zMilvus.describe_resource_group  s      	M7+G+DLL'LVLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	MrK   c                     |                                  5 } |j        |||fd|i| ddd           dS # 1 swxY w Y   dS )a.  transfer num_node from source resource group to target resource_group

        :param source: source resource group name
        :type source: str
        :param target: target resource group name
        :type target: str
        :param num_node: transfer node num
        :type num_node: int
        rG   N)r8   transfer_node)r   sourcetargetnum_noderG   r#   r6   s          r$   r  zMilvus.transfer_node  s      	W7!G!&&(VVGVvVVV	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	Wr   c                     |                                  5 } |j        ||||fd|i| ddd           dS # 1 swxY w Y   dS )a  transfer num_replica from source resource group to target resource group

        :param source: source resource group name
        :type source: str
        :param target: target resource group name
        :type target: str
        :param collection_name: collection name which replica belong to
        :type collection_name: str
        :param num_replica: transfer replica num
        :type num_replica: int
        rG   N)r8   transfer_replica)r   r  r  rI   num_replicarG   r#   r6   s           r$   r"  zMilvus.transfer_replica  s      	7$G$ FMQW  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  )r   Nr5   )r	   N)r   N)NN)NNNNr   )NNN)FN)]__name__
__module____qualname__r   r   	GRPC_PORTGRPC_URIr%   r   r8   propertyr;   r6   r>   r@   rE   rH   rN   rS   rU   rW   rZ   rf   rk   rm   rr   rt   rw   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r0   r   rg   r   r   r   r   r   r   r   r   listr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r  r   r   r  r  r  r   r  r  r"  r   r&   r$   r   r      s       f.FOT4	4 4 4 Z4 "&F,<&/        $     X   X/ / /G G G  +a +a +a +aZM M M M*L L L L*Q Q Q Q2   4` ` ` `*   2= = = =$^ ^ ^ ^4\ \ \ \4[ [ [ [0   @   4M M M M*   <[ [ [ [<H H H H6Z Z Z Z@k k k kZ   :X X X X2$ $ $ $Ld d d d8!N !N !N !NT P P P Pd^ ^ ^ ^ V V V V
 
 
 
Y Y Y Y   b b b ba a a a@ @ @ @ 4 4 4 4x % %% % % %N WZ    0 @D  	   6 +/c c c	c c c cZ Z# ZRa Z Z Z Z$T TC TG T T T T$ OS) )")47)@D)	) ) ) )V
U 
U 
U 
U 
U 
UM M M M M M 
K 
K 
K 
Ka a a a"A A A AE E E EF F F FD D D DU U U UZ Z Z Z] ] ] ]R R R R\ \ \ \R R R R        T T T T 7;    ; ; ; ;K K K K CG	W 	Ws$778	W 	W 	W 	WI I I ID D D D
	M 	MGX 	M 	M 	M 	MW W W W EI     r&   r   N)urllibr   pymilvus.decoratorsr   pymilvus.exceptionsr   r   pymilvus.settingsr   typingr   checkr
   r   grpc_handlerr   typesr   r   r   r   r   r   r   r   r&   r$   <module>r3     s         * * * * * * ; ; ; ; ; ; ; ; $ $ $ $ $ $       / / / / / / / / % % % % % %               d d d d d d d d d dr&   