fU dZddlmZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZddlmZddlmZddlmZmZdd lmZmZmZdd lmZmZmZdd lmZerdd l m!Z!e e e e"e e"e e#e"ee"effffee"effZ$e e"e$fZ%Gd de"ejLZ'GddeeZ(GddZ)GddZ*GddeeZ+GddZ,Gdde,Z-Gdde,Z.GddZ/Gdd Z0y)!zOperation class definitions.) annotationsN) TYPE_CHECKINGAnyGenericMappingOptionalSequenceTupleUnion)RawBSONDocument)helpers)validate_collation_or_none)validate_is_mapping validate_list)_gen_index_name_index_document _index_list) _CollationIn _DocumentType _Pipeline)validate_boolean)_Bulkc|eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy)_OpabortTransaction aggregatecommitTransactioncountcreate createIndexescreateSearchIndexesdeletedistinctdrop dropDatabase dropIndexesdropSearchIndexes endSessions findAndModifyfindinsertlistCollections listIndexeslistSearchIndexes listDatabasesupdate updateIndexupdateSearchIndexrenamegetMore killCursors testOperationN)__name__ __module__ __qualname__ABORT AGGREGATECOMMITCOUNTCREATECREATE_INDEXESCREATE_SEARCH_INDEXESDELETEDISTINCTDROP DROP_DATABASE DROP_INDEXESDROP_SEARCH_INDEXES END_SESSIONSFIND_AND_MODIFYFINDINSERTLIST_COLLECTIONS LIST_INDEXESLIST_SEARCH_INDEXLIST_DATABASESUPDATE UPDATE_INDEXUPDATE_SEARCH_INDEXRENAMEGETMORE KILL_CURSORSTEST[/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pymongo/operations.pyrr0s EI F E F$N1 FH D"M L- L%O D F( L+$N F L- FG L DrWrc<eZdZdZdZd dZd dZd dZd dZd dZ y) InsertOnez#Represents an insert_one operation._docc||_y)zCreate an InsertOne instance. For use with :meth:`~pymongo.collection.Collection.bulk_write`. :param document: The document to insert. If the document is missing an _id field one will be added. Nr[)selfdocuments rX__init__zInsertOne.__init__Ts  rWc:|j|jy)3Add this operation to the _Bulk instance `bulkobj`.N) add_insertr\r^bulkobjs rX _add_to_bulkzInsertOne._add_to_bulk^s499%rWc"d|jdS)Nz InsertOne()r[r^s rX__repr__zInsertOne.__repr__bsDII=**rWcnt|t|k(r|j|jk(StSN)typer\NotImplementedr^others rX__eq__zInsertOne.__eq__es+ ;$t* $::* *rWc||k( SrlrVros rX__ne__zInsertOne.__ne__j5=  rWN)r_rreturnNonererrurvrustrrprrubool r7r8r9__doc__ __slots__r`rfrjrqrsrVrWrXrZrZOs#-I&+ !rWrZcPeZdZdZdZ d d dZd dZd dZd dZd dZ y) DeleteOnez"Represents a delete_one operation._filter _collation_hintNc| td||+t|tstj||_n||_||_||_y)aCreate a DeleteOne instance. For use with :meth:`~pymongo.collection.Collection.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.collection.Collection.create_index` (e.g. ``[('field', ASCENDING)]``). This option is only supported on MongoDB 4.4 and above. .. versionchanged:: 3.11 Added the ``hint`` option. .. versionchanged:: 3.5 Added the `collation` option. Nfilterr isinstanceryr rrrrr^r collationhints rXr`zDeleteOne.__init__sK2   & 1  JtS$9;B;R;RSW;XDJDJ #rWc||j|jdt|j|jy)rbrrN add_deleterrrrrds rXrfzDeleteOne._add_to_bulk2 LL 0A  rWcVd|jd|jd|jdS)Nz DeleteOne(, rhrris rXrjzDeleteOne.__repr__s,DLL+2doo-@4::.PQRRrWct|t|k(rG|j|j|jf|j|j|jfk(StSrlrmrrrrnros rXrqzDeleteOne.__eq__W ;$t* $MM5#3#3U[[A  F  rWc||k( SrlrVros rXrszDeleteOne.__ne__rtrWNNrMapping[str, Any]rOptional[_CollationIn]rOptional[_IndexKeyHint]rurvrwrxrzr|rVrWrXrrnsS,2I -1(, $! $* $& $  $D S!rWrcPeZdZdZdZ d d dZd dZd dZd dZd dZ y) DeleteManyz#Represents a delete_many operation.rNc| td||+t|tstj||_n||_||_||_y)aCreate a DeleteMany instance. For use with :meth:`~pymongo.collection.Collection.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.collection.Collection.create_index` (e.g. ``[('field', ASCENDING)]``). This option is only supported on MongoDB 4.4 and above. .. versionchanged:: 3.11 Added the ``hint`` option. .. versionchanged:: 3.5 Added the `collation` option. Nrrrs rXr`zDeleteMany.__init__rrWc||j|jdt|j|jy)rbrrNrrds rXrfzDeleteMany._add_to_bulkrrWcVd|jd|jd|jdS)Nz DeleteMany(rrhrris rXrjzDeleteMany.__repr__s,T\\,Bt.ADJJ>QRSSrWct|t|k(rG|j|j|jf|j|j|jfk(StSrlrros rXrqzDeleteMany.__eq__rrWc||k( SrlrVros rXrszDeleteMany.__ne__rtrWrrrwrxrzr|rVrWrXrrsS-2I -1(, $! $* $& $  $D T!rWrcZeZdZdZdZ d d dZd dZd dZd dZd dZ y) ReplaceOnez#Represents a replace_one operation.)rr\_upsertrrNc| td|| td||+t|tst j ||_n||_||_||_||_ ||_ y)aCreate a ReplaceOne instance. For use with :meth:`~pymongo.collection.Collection.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.collection.Collection.create_index` (e.g. ``[('field', ASCENDING)]``). This option is only supported on MongoDB 4.2 and above. .. versionchanged:: 3.11 Added the ``hint`` option. .. versionchanged:: 3.5 Added the ``collation`` option. Nrupsert) rrrryr rrrr\rr)r^r replacementrrrs rXr`zReplaceOne.__init__si<   & 1   Xv .  JtS$9;B;R;RSW;XDJDJ   #rWc|j|j|j|jt |j |j y)rbrN) add_replacerr\rrrrrds rXrfzReplaceOne._add_to_bulks= LL II LL0A  rWc"t|t|k(rs|j|j|j|j|j f|j|j|j|j|j fk(St Srl)rmrr\rrrrnros rXrqzReplaceOne.__eq__(sx ;$t* $            rWc||k( SrlrVros rXrszReplaceOne.__ne__9rtrWcdj|jj|j|j|j |j |jS)Nz {}({!r}, {!r}, {!r}, {!r}, {!r}))format __class__r7rr\rrrris rXrjzReplaceOne.__repr__<sE188 NN # # LL II LL OO JJ   rW)FNN) rrrz%Union[_DocumentType, RawBSONDocument]rr{rrrrrurvrwrzrx) r7r8r9r}r~r`rfrqrsrjrVrWrXrrsi-EI ,0(, )$!)$;)$ )$ * )$ & )$ )$V "! rWrcDeZdZdZdZ ddZddZd dZy) _UpdateOpz)Private base class for update operations.)rr\rr_array_filtersrc| td|| td|| td||+t|tst j ||_n||_||_||_ ||_ ||_ ||_ y)Nrr array_filters) rrrrryr rrrr\rrr)r^rdocrrrrs rXr`z_UpdateOp.__init__Ls   & 1   Xv .  $ /= 9  JtS$9;B;R;RSW;XDJDJ   #+rWcJt|t|r|j|j|j|j |j |jf|j|j|j|j |j |jfk(StSrl) rrmrr\rrrrrnros rXrqz_UpdateOp.__eq__fs eT$Z (     $$    ##  rWc dj|jj|j|j|j |j |j|jS)Nz&{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r})) rrr7rr\rrrrris rXrjz_UpdateOp.__repr__ysN7>> NN # # LL II LL OO    JJ  rWN) rrr#Union[Mapping[str, Any], _Pipeline]rr{rrr!Optional[list[Mapping[str, Any]]]rr)rpobjectrur{rx)r7r8r9r}r~r`rqrjrVrWrXrrGsS3WI,!,1, , * , 9 ,&,4&  rWrcTeZdZdZdZ d dfd ZddZxZS) UpdateOnez#Represents an update_one operation.rVc.t|||||||y)aRepresents an update_one operation. For use with :meth:`~pymongo.collection.Collection.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.collection.Collection.create_index` (e.g. ``[('field', ASCENDING)]``). This option is only supported on MongoDB 4.2 and above. .. 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. Nsuperr`r^rr0rrrrrs rXr`zUpdateOne.__init__J M4PrWc |j|j|jd|jt |j |j |jy)rbFrrrN add_updaterr\rrrrrrds rXrfzUpdateOne._add_to_bulksI LL II  LL0A--  rWFNNNrrr0rrr{rrrrrrrurvrwr7r8r9r}r~r`rf __classcell__rs@rXrrsp-I ,0;?(,%Q!%Q4%Q %Q * %Q 9 %Q&%Q %QN  rWrcTeZdZdZdZ d dfd ZddZxZS) UpdateManyz$Represents an update_many operation.rVc.t|||||||y)aCreate an UpdateMany instance. For use with :meth:`~pymongo.collection.Collection.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.collection.Collection.create_index` (e.g. ``[('field', ASCENDING)]``). This option is only supported on MongoDB 4.2 and above. .. 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. Nrrs rXr`zUpdateMany.__init__rrWc |j|j|jd|jt |j |j |jy)rbTrNrrds rXrfzUpdateMany._add_to_bulksI LL II  LL0A--  rWrrrwrrs@rXrrsp.I ,0;?(,%Q!%Q4%Q %Q * %Q 9 %Q&%Q %QN  rWrc.eZdZdZdZddZeddZy) IndexModelzRepresents an index to create. __documentc t|}|jdt||d<t||d<t |j dd}||_|||j d<yy)a Create an Index instance. For use with :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`: Used to create an expiring (TTL) collection. MongoDB will automatically delete documents from this collection after 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://mongodb.com/docs/master/core/index-wildcard/ nameNkeyr)rgetrrrpop_IndexModel__document)r^keyskwargsrs rXr`zIndexModel.__init__soz4  ::f  %,T2F6N'-u .vzz+t/LM    +4DOOK ( !rWc|jS)zUAn index document suitable for passing to the createIndexes command. )rris rXr_zIndexModel.documentBs rWN)r _IndexKeyHintrrrurv)ruzdict[str, Any]r7r8r9r}r~r`propertyr_rVrWrXrrs%(ID5LrWrcFeZdZdZdZ d ddZeddZy) SearchIndexModelz$Represents a search index to create.rNc i|_|||jd<||jd<|||jd<|jj|y)aCreate a Search Index instance. For use with :meth:`~pymongo.collection.Collection.create_search_index` and :meth:`~pymongo.collection.Collection.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 definitionrm)_SearchIndexModel__documentr0)r^rrrmrs rXr`zSearchIndexModel.__init__OsS*+-  &*DOOF #(2 %  &*DOOF # v&rWc|jS)zThe document for this index.)rris rXr_zSearchIndexModel.documentlsrWr) rrr Optional[str]rmrrrrurv)rurrrVrWrXrrJs[.I #" '%'' '  '  ':rWr)1r} __future__renumtypingrrrrrr r r bson.raw_bsonr pymongor pymongo.collationrpymongo.commonrrpymongo.helpersrrrpymongo.typingsrrrpymongo.write_concernr pymongo.bulkrryint _IndexListrEnumrrZrrrrrrrrrVrWrXrs)#"    *8=IIBB2" U3c5c7383D)D#EEFF GH'RUWZRZJ[[ c:o& #tyy>! &!>=!=!@=!=!@V 'V r; ; |6 6 r6 6 rPPf%%rW