o
    C©Ìh®|  ã                   @  sÆ  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZ ddl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 ddlmZmZmZ ddl m!Z! erdddlm"Z"m#Z# ee
ee$ee$ee%e$ee$ef f f f  ee$ef f Z&ee$e&f Z'G dd„ de$ej(ƒZ)G dd„ dee ƒZ*G dd„ dƒZ+G dd„ de+ƒZ,G dd„ de+ƒZ-G dd„ dee ƒZ.G dd„ dƒZ/G dd„ de/ƒZ0G dd„ de/ƒZ1G d d!„ d!ƒZ2G d"d#„ d#ƒZ3dS )$z~Operation class definitions.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚGenericÚMappingÚOptionalÚSequenceÚTupleÚUnion)ÚRawBSONDocument)Úhelpers_shared)Úvalidate_collation_or_none)Úvalidate_is_mappingÚvalidate_list)ÚInvalidOperation)Ú_gen_index_nameÚ_index_documentÚ_index_list)Ú_CollationInÚ_DocumentTypeÚ	_Pipeline)Úvalidate_boolean)Ú_AgnosticBulkÚ_AgnosticClientBulkc                   @  s€   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS )Ú_OpÚabortTransactionÚ	aggregateÚ	bulkWriteÚcommitTransactionÚcountÚcreateÚcreateIndexesÚcreateSearchIndexesÚdeleteÚdistinctÚdropÚdropDatabaseÚdropIndexesÚdropSearchIndexesÚendSessionsÚfindAndModifyÚfindÚinsertÚlistCollectionsÚlistIndexesÚlistSearchIndexesÚlistDatabasesÚupdateÚupdateIndexÚupdateSearchIndexÚrenameÚgetMoreÚkillCursorsÚtestOperationN) Ú__name__Ú
__module__Ú__qualname__ÚABORTÚ	AGGREGATEÚ
BULK_WRITEÚCOMMITÚCOUNTÚCREATEÚCREATE_INDEXESÚCREATE_SEARCH_INDEXESÚDELETEÚDISTINCTÚDROPÚDROP_DATABASEÚDROP_INDEXESÚDROP_SEARCH_INDEXESÚEND_SESSIONSÚFIND_AND_MODIFYÚFINDÚINSERTÚLIST_COLLECTIONSÚLIST_INDEXESÚLIST_SEARCH_INDEXÚLIST_DATABASESÚUPDATEÚUPDATE_INDEXÚUPDATE_SEARCH_INDEXÚRENAMEÚGETMOREÚKILL_CURSORSÚTEST© rX   rX   úa/var/www/html/Moveonwheels/move_on_wheels/venv/lib/python3.10/site-packages/pymongo/operations.pyr   5   s<    r   c                   @  sR   e Zd ZdZdZddd
d„Zddd„Zd dd„Zd!dd„Zd"dd„Z	d"dd„Z
dS )#Ú	InsertOnez#Represents an insert_one operation.©Ú_docÚ
_namespaceNÚdocumentr   Ú	namespaceúOptional[str]ÚreturnÚNonec                 C  s   || _ || _dS )av  Create an InsertOne instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param document: The document to insert. If the document is missing an
            _id field one will be added.
        :param namespace: (optional) The namespace in which to insert a document.

        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        Nr[   )Úselfr^   r_   rX   rX   rY   Ú__init__]   s   
zInsertOne.__init__Úbulkobjr   c                 C  s   |  | j¡ dS )ú>Add this operation to the _AsyncBulk/_Bulk instance `bulkobj`.N)Ú
add_insertr\   ©rc   re   rX   rX   rY   Ú_add_to_bulkm   s   zInsertOne._add_to_bulkr   c                 C  s"   | j stdƒ‚| | j | j¡ dS )úJAdd this operation to the _AsyncClientBulk/_ClientBulk instance `bulkobj`.úSMongoClient.bulk_write requires a namespace to be provided for each write operationN)r]   r   rg   r\   rh   rX   rX   rY   Ú_add_to_client_bulkq   s   ÿþzInsertOne._add_to_client_bulkÚstrc                 C  s:   | j r| jj› d| j›d| j ›d�S | jj› d| j›d�S )Nú(ú, ú))r]   Ú	__class__r8   r\   ©rc   rX   rX   rY   Ú__repr__|   s   zInsertOne.__repr__Úotherr   Úboolc                 C  s,   t |ƒt | ƒkr|j| jko|j| jkS tS ©N)Útyper\   r]   ÚNotImplemented©rc   rt   rX   rX   rY   Ú__eq__�   s   zInsertOne.__eq__c                 C  ó
   | |k S rv   rX   ry   rX   rX   rY   Ú__ne__†   ó   
zInsertOne.__ne__rv   )r^   r   r_   r`   ra   rb   ©re   r   ra   rb   ©re   r   ra   rb   ©ra   rm   ©rt   r   ra   ru   )r8   r9   r:   Ú__doc__Ú	__slots__rd   ri   rl   rs   rz   r|   rX   rX   rX   rY   rZ   U   s    



rZ   c                   @  sD   e Zd ZdZdZ			dddd„Zddd„Zddd„Zddd„ZdS )Ú	_DeleteOpz)Private base class for delete operations.)Ú_filterÚ
_collationÚ_hintr]   NÚfilterúMapping[str, Any]Ú	collationúOptional[_CollationIn]ÚhintúOptional[_IndexKeyHint]r_   r`   ra   rb   c                 C  sN   |d ur	t d|ƒ |d urt|tƒst |¡| _n|| _|| _|| _|| _d S )Nrˆ   )	r   Ú
isinstancerm   r   r   r‡   r…   r†   r]   ©rc   rˆ   rŠ   rŒ   r_   rX   rX   rY   rd   ”   s   

z_DeleteOp.__init__rt   r   ru   c                 C  s<   t |ƒt | ƒkr|j|j|j|jf| j| j| j| jfkS tS rv   )rw   r…   r†   r‡   r]   rx   ry   rX   rX   rY   rz   ¦   s   üüûz_DeleteOp.__eq__c                 C  r{   rv   rX   ry   rX   rX   rY   r|   µ   r}   z_DeleteOp.__ne__rm   c                 C  sJ   | j rd | jj| j| j| j| j ¡S | jj› d| j›d| j›d| j›d�S )Nz{}({!r}, {!r}, {!r}, {!r})rn   ro   rp   )r]   Úformatrq   r8   r…   r†   r‡   rr   rX   rX   rY   rs   ¸   s   û&z_DeleteOp.__repr__©NNN©
rˆ   r‰   rŠ   r‹   rŒ   r�   r_   r`   ra   rb   r�   r€   ©	r8   r9   r:   r‚   rƒ   rd   rz   r|   rs   rX   rX   rX   rY   r„   Š   s    
û

r„   c                      óB   e Zd ZdZdZ			dd‡ fdd„Zddd„Zddd„Z‡  ZS )Ú	DeleteOnez"Represents a delete_one operation.rX   Nrˆ   r‰   rŠ   r‹   rŒ   r�   r_   r`   ra   rb   c                   ó   t ƒ  ||||¡ dS )aÍ  Create a DeleteOne instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param filter: A query that matches the document to delete.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` or :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.
        :param namespace: (optional) The namespace in which to delete a document.

        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        N©Úsuperrd   r�   ©rq   rX   rY   rd   É   ó   zDeleteOne.__init__re   r   c                 C  ó    |j | jdt| jƒ| jd� dS )rf   é   ©rŠ   rŒ   N©Ú
add_deleter…   r   r†   r‡   rh   rX   rX   rY   ri   é   ó   
üzDeleteOne._add_to_bulkr   c                 C  ó2   | j stdƒ‚|j| j | jdt| jƒ| jd� dS )rj   rk   F©ÚmultirŠ   rŒ   N©r]   r   rŸ   r…   r   r†   r‡   rh   rX   rX   rY   rl   ò   ó   ÿ
ûzDeleteOne._add_to_client_bulkr‘   r’   r~   r   ©	r8   r9   r:   r‚   rƒ   rd   ri   rl   Ú__classcell__rX   rX   r™   rY   r•   Ä   ó    û
 	r•   c                      r”   )Ú
DeleteManyz#Represents a delete_many operation.rX   Nrˆ   r‰   rŠ   r‹   rŒ   r�   r_   r`   ra   rb   c                   r–   )aÎ  Create a DeleteMany instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param filter: A query that matches the documents to delete.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` or :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.
        :param namespace: (optional) The namespace in which to delete documents.

        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr—   r�   r™   rX   rY   rd     rš   zDeleteMany.__init__re   r   c                 C  r›   )rf   r   r�   Nrž   rh   rX   rX   rY   ri   &  r    zDeleteMany._add_to_bulkr   c                 C  r¡   )rj   rk   Tr¢   Nr¤   rh   rX   rX   rY   rl   /  r¥   zDeleteMany._add_to_client_bulkr‘   r’   r~   r   r¦   rX   rX   r™   rY   r©     r¨   r©   c                   @  s\   e Zd ZdZdZ					d'd(dd„Zd)dd„Zd*dd„Zd+d d!„Zd+d"d#„Z	d,d%d&„Z
dS )-Ú
ReplaceOnez#Represents a replace_one operation.)r…   r\   Ú_upsertr†   r‡   r]   Ú_sortNrˆ   r‰   Úreplacementú%Union[_DocumentType, RawBSONDocument]ÚupsertúOptional[bool]rŠ   r‹   rŒ   r�   r_   r`   ÚsortúOptional[Mapping[str, Any]]ra   rb   c                 C  sr   |dur	t d|ƒ |durtd|ƒ |dur"t|tƒs"t |¡| _n|| _|| _|| _|| _	|| _
|| _|| _dS )a]  Create a ReplaceOne instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param filter: A query that matches the document to replace.
        :param replacement: The new document.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` or :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.
        :param sort: Specify which document the operation updates if the query matches
            multiple documents. The first document matched by the sort order will be updated.
        :param namespace: (optional) The namespace in which to replace a document.

        .. versionchanged:: 4.10
            Added ``sort`` option.
        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the ``collation`` option.
        Nrˆ   r¯   )r   r   rŽ   rm   r   r   r‡   r¬   r…   r\   r«   r†   r]   )rc   rˆ   r­   r¯   rŠ   rŒ   r_   r±   rX   rX   rY   rd   K  s   (


zReplaceOne.__init__re   r   c                 C  s*   |j | j| j| jt| jƒ| j| jd� dS )rf   ©rŠ   rŒ   r±   N)Úadd_replacer…   r\   r«   r   r†   r‡   r¬   rh   rX   rX   rY   ri   ƒ  s   
úzReplaceOne._add_to_bulkr   c              	   C  s<   | j stdƒ‚|j| j | j| j| jt| jƒ| j| j	d� dS )rj   rk   r³   N)
r]   r   r´   r…   r\   r«   r   r†   r‡   r¬   rh   rX   rX   rY   rl   Ž  s   ÿ
ùzReplaceOne._add_to_client_bulkrt   r   ru   c                 C  sT   t |ƒt | ƒkr(|j|j|j|j|j|j|jf| j| j| j| j| j| j| jfkS tS rv   )	rw   r…   r\   r«   r†   r‡   r]   r¬   rx   ry   rX   rX   rY   rz   ž  s&   ù	ùøzReplaceOne.__eq__c                 C  r{   rv   rX   ry   rX   rX   rY   r|   ³  r}   zReplaceOne.__ne__rm   c              
   C  sV   | j rd | jj| j| j| j| j| j| j | j	¡S d | jj| j| j| j| j| j| j	¡S )Nú,{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})z&{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}))
r]   r�   rq   r8   r…   r\   r«   r†   r‡   r¬   rr   rX   rX   rY   rs   ¶  s(   ø
ùzReplaceOne.__repr__©NNNNN)rˆ   r‰   r­   r®   r¯   r°   rŠ   r‹   rŒ   r�   r_   r`   r±   r²   ra   rb   r~   r   r�   r€   )r8   r9   r:   r‚   rƒ   rd   ri   rl   rz   r|   rs   rX   rX   rX   rY   rª   >  s    ø
8


rª   c                   @  s<   e Zd ZdZdZd"dd„Zd#dd„Zd$dd„Zd%dd „Zd!S )&Ú	_UpdateOpz)Private base class for update operations.)r…   r\   r«   r†   Ú_array_filtersr‡   r]   r¬   rˆ   r‰   Údocú#Union[Mapping[str, Any], _Pipeline]r¯   r°   rŠ   r‹   Úarray_filtersú!Optional[list[Mapping[str, Any]]]rŒ   r�   r_   r`   r±   r²   c	           	      C  sŠ   |d ur	t d|ƒ |d urtd|ƒ |d urtd|ƒ |d ur+t|tƒs+t |¡| _n|| _|| _|| _	|| _
|| _|| _|| _|| _d S )Nrˆ   r¯   r»   )r   r   r   rŽ   rm   r   r   r‡   r…   r\   r«   r†   r¸   r]   r¬   )	rc   rˆ   r¹   r¯   rŠ   r»   rŒ   r_   r±   rX   rX   rY   rd   Û  s    



z_UpdateOp.__init__rt   Úobjectra   ru   c              	   C  sZ   t |t| ƒƒr+|j|j|j|j|j|j|j|j	f| j| j| j| j| j| j| j| j	fkS t
S rv   )rŽ   rw   r…   r\   r«   r†   r¸   r‡   r]   r¬   rx   ry   rX   rX   rY   rz   ø  s*   ø
ø÷z_UpdateOp.__eq__r   c                 C  r{   rv   rX   ry   rX   rX   rY   r|     r}   z_UpdateOp.__ne__rm   c                 C  s^   | j rd | jj| j| j| j| j| j| j	| j | j
¡	S d | jj| j| j| j| j| j| j	| j
¡S )Nz2{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})rµ   )r]   r�   rq   r8   r…   r\   r«   r†   r¸   r‡   r¬   rr   rX   rX   rY   rs     s,   ÷øz_UpdateOp.__repr__N)rˆ   r‰   r¹   rº   r¯   r°   rŠ   r‹   r»   r¼   rŒ   r�   r_   r`   r±   r²   )rt   r½   ra   ru   r�   r€   r“   rX   rX   rX   rY   r·   Í  s    


r·   c                      sH   e Zd ZdZdZ						dd ‡ fdd„Zd!dd„Zd"dd„Z‡  ZS )#Ú	UpdateOnez#Represents an update_one operation.rX   Nrˆ   r‰   r1   rº   r¯   r°   rŠ   r‹   r»   r¼   rŒ   r�   r_   r`   r±   r²   ra   rb   c	           	   
     s   t ƒ  ||||||||¡ dS )a{  Represents an update_one operation.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param filter: A query that matches the document to update.
        :param update: The modifications to apply.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param array_filters: A list of filters specifying which
            array elements an update should apply.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` or :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.
        :param namespace: The namespace in which to update a document.
        :param sort: Specify which document the operation updates if the query matches
            multiple documents. The first document matched by the sort order will be updated.

        .. versionchanged:: 4.10
            Added ``sort`` option.
        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr—   )	rc   rˆ   r1   r¯   rŠ   r»   rŒ   r_   r±   r™   rX   rY   rd   0  s   /zUpdateOne.__init__re   r   c              
   C  s4   |j | j| jdt| jƒt| jƒ| j| j| j	d� dS )rf   F©rŠ   r»   rŒ   r±   N)
Ú
add_updater…   r\   ru   r«   r   r†   r¸   r‡   r¬   rh   rX   rX   rY   ri   a  s   
øzUpdateOne._add_to_bulkr   c                 C  sB   | j stdƒ‚|j| j | j| jd| jt| jƒ| j| j	| j
d�	 dS )rj   rk   Fr¿   N)r]   r   rÀ   r…   r\   r«   r   r†   r¸   r‡   r¬   rh   rX   rX   rY   rl   n  s   ÿ
÷zUpdateOne._add_to_client_bulk)NNNNNN)rˆ   r‰   r1   rº   r¯   r°   rŠ   r‹   r»   r¼   rŒ   r�   r_   r`   r±   r²   ra   rb   r~   r   r¦   rX   rX   r™   rY   r¾   +  s    ÷
1r¾   c                      sF   e Zd ZdZdZ					dd‡ fdd„Zddd„Zd dd„Z‡  ZS )!Ú
UpdateManyz$Represents an update_many operation.rX   Nrˆ   r‰   r1   rº   r¯   r°   rŠ   r‹   r»   r¼   rŒ   r�   r_   r`   ra   rb   c              
     s   t ƒ  |||||||d¡ dS )aˆ  Create an UpdateMany instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.bulk_write`, :meth:`~pymongo.collection.Collection.bulk_write`,
        :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` and :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.

        :param filter: A query that matches the documents to update.
        :param update: The modifications to apply.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param array_filters: A list of filters specifying which
            array elements an update should apply.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` or :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.
        :param namespace: (optional) The namespace in which to update documents.

        .. versionchanged:: 4.9
           Added the `namespace` option to support `MongoClient.bulk_write`.
        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr—   )rc   rˆ   r1   r¯   rŠ   r»   rŒ   r_   r™   rX   rY   rd   †  s   *zUpdateMany.__init__re   r   c              	   C  s,   |j | j| jd| jt| jƒ| j| jd� dS )rf   T©rŠ   r»   rŒ   N)rÀ   r…   r\   r«   r   r†   r¸   r‡   rh   rX   rX   rY   ri   ²  s   
ùzUpdateMany._add_to_bulkr   c              
   C  s>   | j stdƒ‚|j| j | j| jd| jt| jƒ| j| j	d� dS )rj   rk   TrÂ   N)
r]   r   rÀ   r…   r\   r«   r   r†   r¸   r‡   rh   rX   rX   rY   rl   ¾  s   ÿ
øzUpdateMany._add_to_client_bulkr¶   )rˆ   r‰   r1   rº   r¯   r°   rŠ   r‹   r»   r¼   rŒ   r�   r_   r`   ra   rb   r~   r   r¦   rX   rX   r™   rY   rÁ   �  s    ø
,rÁ   c                   @  s6   e Zd ZdZdZdd	d
„Zeddd„ƒZddd„ZdS )Ú
IndexModelzRepresents an index to create.©Ú
__documentÚkeysÚ_IndexKeyHintÚkwargsr   ra   rb   c                 K  s^   t |ƒ}| d¡du rt|ƒ|d< t|ƒ|d< t| dd¡ƒ}|| _|dur-|| jd< dS dS )aË  Create an Index instance.

        For use with :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_indexes` and :meth:`~pymongo.collection.Collection.create_indexes`.

        Takes either a single key or a list containing (key, direction) pairs
        or keys.  If no direction is given, :data:`~pymongo.ASCENDING` will
        be assumed.
        The key(s) must be an instance of :class:`str`, and the direction(s) must
        be one of (:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`,
        :data:`~pymongo.GEO2D`, :data:`~pymongo.GEOSPHERE`,
        :data:`~pymongo.HASHED`, :data:`~pymongo.TEXT`).

        Valid options include, but are not limited to:

          - `name`: custom name to use for this index - if none is
            given, a name will be generated.
          - `unique`: if ``True``, creates a uniqueness constraint on the index.
          - `background`: if ``True``, this index should be created in the
            background.
          - `sparse`: if ``True``, omit from the index any documents that lack
            the indexed field.
          - `bucketSize`: for use with geoHaystack indexes.
            Number of documents to group together within a certain proximity
            to a given longitude and latitude.
          - `min`: minimum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `max`: maximum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `expireAfterSeconds`: <int> Used to create an expiring (TTL)
            collection. MongoDB will automatically delete documents from
            this collection after <int> seconds. The indexed field must
            be a UTC datetime or the data will not expire.
          - `partialFilterExpression`: A document that specifies a filter for
            a partial index.
          - `collation`: An instance of :class:`~pymongo.collation.Collation`
            that specifies the collation to use.
          - `wildcardProjection`: Allows users to include or exclude specific
            field paths from a `wildcard index`_ using the { "$**" : 1} key
            pattern. Requires MongoDB >= 4.2.
          - `hidden`: if ``True``, this index will be hidden from the query
            planner and will not be evaluated as part of query plan
            selection. Requires MongoDB >= 4.4.

        See the MongoDB documentation for a full list of supported options by
        server version.

        :param keys: a single key or a list containing (key, direction) pairs
             or keys specifying the index to create.
        :param kwargs: any additional index creation
            options (see the above list) should be passed as keyword
            arguments.

        .. versionchanged:: 3.11
           Added the ``hidden`` option.
        .. versionchanged:: 3.2
           Added the ``partialFilterExpression`` option to support partial
           indexes.

        .. _wildcard index: https://dochub.mongodb.org/core/index-wildcard/
        ÚnameNÚkeyrŠ   )r   Úgetr   r   r   ÚpopÚ_IndexModel__document)rc   rÆ   rÈ   rŠ   rX   rX   rY   rd   Õ  s   =ÿzIndexModel.__init__údict[str, Any]c                 C  ó   | j S )zUAn index document suitable for passing to the createIndexes
        command.
        )rÍ   rr   rX   rX   rY   r^     s   zIndexModel.documentrm   c              	   C  s.   d  | jj| jd d dd„ | j ¡ D ƒ¡¡S )Nz{}({}{})rÊ   Ú c                 S  s(   g | ]\}}|d krd|› d|›�‘qS )rÊ   ro   ú=rX   ©Ú.0rÊ   ÚvaluerX   rX   rY   Ú
<listcomp>&  s   ( z'IndexModel.__repr__.<locals>.<listcomp>)r�   rq   r8   r^   ÚjoinÚitemsrr   rX   rX   rY   rs   "  s
   ýzIndexModel.__repr__N)rÆ   rÇ   rÈ   r   ra   rb   )ra   rÎ   r€   ©	r8   r9   r:   r‚   rƒ   rd   Úpropertyr^   rs   rX   rX   rX   rY   rÃ   Ð  s    
FrÃ   c                   @  s<   e Zd ZdZdZ		dddd„Zeddd„ƒZddd„ZdS )ÚSearchIndexModelz$Represents a search index to create.rÄ   NÚ
definitionr‰   rÉ   r`   rw   rÈ   r   ra   rb   c                 K  sD   i | _ |dur|| j d< || j d< |dur|| j d< | j  |¡ dS )a¾  Create a Search Index instance.

        For use with :meth:`~pymongo.collection.AsyncCollection.create_search_index` and :meth:`~pymongo.collection.AsyncCollection.create_search_indexes`.

        :param definition: The definition for this index.
        :param name: The name for this index, if present.
        :param type: The type for this index which defaults to "search". Alternative values include "vectorSearch".
        :param kwargs: Keyword arguments supplying any additional options.

        .. note:: Search indexes require a MongoDB server version 7.0+ Atlas cluster.
        .. versionadded:: 4.5
        .. versionchanged:: 4.7
           Added the type and kwargs arguments.
        NrÉ   rÛ   rw   )Ú_SearchIndexModel__documentr1   )rc   rÛ   rÉ   rw   rÈ   rX   rX   rY   rd   /  s   


zSearchIndexModel.__init__c                 C  rÏ   )zThe document for this index.)rÜ   rr   rX   rX   rY   r^   L  s   zSearchIndexModel.documentrm   c                 C  s&   d  | jjd dd„ | j ¡ D ƒ¡¡S )Nz{}({})ro   c                 S  s   g | ]\}}|› d |›�‘qS )rÑ   rX   rÒ   rX   rX   rY   rÕ   T  s    z-SearchIndexModel.__repr__.<locals>.<listcomp>)r�   rq   r8   rÖ   r^   r×   rr   rX   rX   rY   rs   Q  s   þzSearchIndexModel.__repr__)NN)
rÛ   r‰   rÉ   r`   rw   r`   rÈ   r   ra   rb   )ra   r‰   r€   rØ   rX   rX   rX   rY   rÚ   *  s    ürÚ   )4r‚   Ú
__future__r   ÚenumÚtypingr   r   r   r   r   r   r	   r
   Úbson.raw_bsonr   Úpymongor   Úpymongo.collationr   Úpymongo.commonr   r   Úpymongo.errorsr   Úpymongo.helpers_sharedr   r   r   Úpymongo.typingsr   r   r   Úpymongo.write_concernr   r   r   rm   ÚintÚ
_IndexListrÇ   ÚEnumr   rZ   r„   r•   r©   rª   r·   r¾   rÁ   rÃ   rÚ   rX   rX   rX   rY   Ú<module>   s<   (4ÿ 5:== ^VOZ