Ë
    V¼Sf0  ã                   ó†   — d Z ddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZ  G d„ dej                  ¬	«      Z G d
„ de«      Zy)z=Helpers for batch requests to the Google Cloud Firestore API.é    N)ÚDictÚUnion)Úretry)Ú_helpers)ÚBaseDocumentReferencec            	       óô   — e Zd ZdZdd„Zd„ Zdefd„Zdeddfd	„Z	e
j                  d
„ «       Zdededdfd„Z	 ddededeeef   ddfd„Z	 ddededej&                  ddfd„Z	 ddedej&                  ddfd„Zy)Ú	BaseBatchaŽ  Accumulate write operations to be sent in a batch.

    This has the same set of methods for write operations that
    :class:`~google.cloud.firestore_v1.document.DocumentReference` does,
    e.g. :meth:`~google.cloud.firestore_v1.document.DocumentReference.create`.

    Args:
        client (:class:`~google.cloud.firestore_v1.client.Client`):
            The client that created this batch.
    ÚreturnNc                 óJ   — || _         g | _        i | _        d | _        d | _        y ©N)Ú_clientÚ
_write_pbsÚ_document_referencesÚwrite_resultsÚcommit_time)ÚselfÚclients     úcC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/cloud/firestore_v1/base_batch.pyÚ__init__zBaseBatch.__init__&   s(   € ØˆŒØˆŒØFHˆÔ!Ø!ˆÔØˆÕó    c                 ó,   — t        | j                  «      S r   )Úlenr   ©r   s    r   Ú__len__zBaseBatch.__len__-   s   € Ü�4×,Ñ,Ó-Ð-r   Ú	referencec                 ó2   — |j                   | j                  v S r   )Ú_document_pathr   )r   r   s     r   Ú__contains__zBaseBatch.__contains__0   s   € Ø×'Ñ'¨4×+DÑ+DÐDÐDr   Ú	write_pbsc                 ó:   — | j                   j                  |«       y)a  Add `Write`` protobufs to this transaction.

        This method intended to be over-ridden by subclasses.

        Args:
            write_pbs (List[google.cloud.proto.firestore.v1.                write_pb2.Write]): A list of write protobufs to be added.
        N)r   Úextend)r   r   s     r   Ú_add_write_pbszBaseBatch._add_write_pbs3   s   € ð 	�‰×Ñ˜yÕ)r   c                 ó   — t        «       ‚)zySends all accumulated write operations to the server. The details of this
        write depend on the implementing class.)ÚNotImplementedErrorr   s    r   ÚcommitzBaseBatch.commit>   s   € ô "Ó#Ð#r   Údocument_datac                 ó˜   — t        j                  |j                  |«      }|| j                  |j                  <   | j	                  |«       y)aÊ  Add a "change" to this batch to create a document.

        If the document given by ``reference`` already exists, then this
        batch will fail when :meth:`commit`-ed.

        Args:
            reference (:class:`~google.cloud.firestore_v1.document.DocumentReference`):
                A document reference to be created in this batch.
            document_data (dict): Property names and values to use for
                creating a document.
        N)r   Úpbs_for_creater   r   r"   )r   r   r&   r   s       r   ÚcreatezBaseBatch.createD   s@   € ô ×+Ñ+¨I×,DÑ,DÀmÓTˆ	Ø>Gˆ×!Ñ! )×":Ñ":Ñ;Ø×Ñ˜IÕ&r   Úmergec                 óä   — |dur"t        j                  |j                  ||«      }n t        j                  |j                  |«      }|| j                  |j                  <   | j                  |«       y)a«  Add a "change" to replace a document.

        See
        :meth:`google.cloud.firestore_v1.document.DocumentReference.set` for
        more information on how ``option`` determines how the change is
        applied.

        Args:
            reference (:class:`~google.cloud.firestore_v1.document.DocumentReference`):
                A document reference that will have values set in this batch.
            document_data (dict):
                Property names and values to use for replacing a document.
            merge (Optional[bool] or Optional[List<apispec>]):
                If True, apply merging instead of overwriting the state
                of the document.
        FN)r   Úpbs_for_set_with_merger   Úpbs_for_set_no_merger   r"   )r   r   r&   r*   r   s        r   ÚsetzBaseBatch.setT   sm   € ð, ˜ÑÜ ×7Ñ7Ø×(Ñ(¨-¸ó‰Iô !×5Ñ5Ø×(Ñ(¨-óˆIð ?Hˆ×!Ñ! )×":Ñ":Ñ;Ø×Ñ˜IÕ&r   Úfield_updatesÚoptionc                 óâ   — |j                   j                  dk(  rt        d«      ‚t        j                  |j
                  ||«      }|| j                  |j
                  <   | j                  |«       y)aÊ  Add a "change" to update a document.

        See
        :meth:`google.cloud.firestore_v1.document.DocumentReference.update`
        for more information on ``field_updates`` and ``option``.

        Args:
            reference (:class:`~google.cloud.firestore_v1.document.DocumentReference`):
                A document reference that will be updated in this batch.
            field_updates (dict):
                Field names or paths to update and values to update with.
            option (Optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
                A write option to make assertions / preconditions on the server
                state of the document before applying changes.
        ÚExistsOptionz5you must not pass an explicit write option to update.N)Ú	__class__Ú__name__Ú
ValueErrorr   Úpbs_for_updater   r   r"   )r   r   r/   r0   r   s        r   ÚupdatezBaseBatch.updatev   sh   € ð* ×Ñ×$Ñ$¨Ò6ÜÐWÓXÐXÜ×+Ñ+Ø×$Ñ$ m°Vó
ˆ	ð ?Hˆ×!Ñ! )×":Ñ":Ñ;Ø×Ñ˜IÕ&r   c                 óš   — t        j                  |j                  |«      }|| j                  |j                  <   | j	                  |g«       y)ay  Add a "change" to delete a document.

        See
        :meth:`google.cloud.firestore_v1.document.DocumentReference.delete`
        for more information on how ``option`` determines how the change is
        applied.

        Args:
            reference (:class:`~google.cloud.firestore_v1.document.DocumentReference`):
                A document reference that will be deleted in this batch.
            option (Optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
                A write option to make assertions / preconditions on the server
                state of the document before applying changes.
        N)r   Úpb_for_deleter   r   r"   )r   r   r0   Úwrite_pbs       r   ÚdeletezBaseBatch.delete“   sB   € ô" ×)Ñ)¨)×*BÑ*BÀFÓKˆØ>Gˆ×!Ñ! )×":Ñ":Ñ;Ø×Ñ˜X˜JÕ'r   )r
   N)Fr   )r4   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Úlistr"   ÚabcÚabstractmethodr%   Údictr)   r   Úboolr.   r   ÚWriteOptionr7   r;   © r   r   r	   r	      s  „ ñ	ó ò.ðEÐ&;ó Eð	*¨ð 	*°ó 	*ð 	×Ññ$ó ð$ð
'Ð 5ð 'Àdð 'Ètó 'ð( $)ñ	 'à(ð 'ð ð 'ð �T˜4�ZÑ ð	 'ð
 
ó 'ðL (,ñ	'à(ð'ð ð'ð ×$Ñ$ð	'ð
 
ó'ð< PTñ(Ø.ð(Ø8@×8LÑ8Lð(à	ô(r   r	   )Ú	metaclassc                   ó4   — e Zd ZdZdej
                  defd„Zy)ÚBaseWriteBatchz—Base class for a/sync implementations of the `commit` RPC. `commit` is useful
    for lower volumes or when the order of write operations is important.r   Útimeoutc                 ó~   — | j                   j                  | j                  ddœ}t        j                  ||«      }||fS )z+Shared setup for async/sync :meth:`commit`.N)ÚdatabaseÚwritesÚtransaction)r   Ú_database_stringr   r   Úmake_retry_timeout_kwargs)r   r   rI   ÚrequestÚkwargss        r   Ú_prep_commitzBaseWriteBatch._prep_commit­   s@   € ð Ÿ™×5Ñ5Ø—o‘oØñ
ˆô
 ×3Ñ3°E¸7ÓCˆØ˜ˆÐr   N)r4   r<   r=   r>   ÚretriesÚRetryÚfloatrR   rE   r   r   rH   rH   ©   s   „ ñMð '§-¡-ð ¸%ô r   rH   )r>   r@   Útypingr   r   Úgoogle.api_corer   rS   Úgoogle.cloud.firestore_v1r   Ú'google.cloud.firestore_v1.base_documentr   ÚABCMetar	   rH   rE   r   r   ú<module>r[      s;   ðñ Dã 
ß õ -Ý .Ý IôL(˜#Ÿ+™+õ L(ô^�Yõ r   