
    Ѯh9                    N    d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d de      Z	y)	z=Helpers for batch requests to the Google Cloud Firestore API.    )annotations)gapic_v1)retry_async)BaseWriteBatchc                  p     e Zd ZdZd fdZej                  j                  df	 	 	 	 	 ddZd Z	d Z
 xZS )	AsyncWriteBatcha  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.async_document.AsyncDocumentReference` does,
    e.g. :meth:`~google.cloud.firestore_v1.async_document.AsyncDocumentReference.create`.

    Args:
        client (:class:`~google.cloud.firestore_v1.async_client.AsyncClient`):
            The client that created this batch.
    c                .    t         t        |   |       y )N)client)superr   __init__)selfr
   	__class__s     w/home/www/academy-backend.kofcorporation.com/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/async_batch.pyr   zAsyncWriteBatch.__init__$   s    ot-V-<    Nc                .  K   | j                  ||      \  }} | j                  j                  j                  d|| j                  j                  d| d{   }g | _        t        |j                        x| _        }|j                  | _        |S 7 :w)a  Commit the changes accumulated in this batch.

        Args:
            retry (google.api_core.retry.Retry): Designation of what errors, if any,
                should be retried.  Defaults to a system-specified policy.
            timeout (float): The timeout for this request.  Defaults to a
                system-specified value.

        Returns:
            List[:class:`google.cloud.firestore_v1.write.WriteResult`, ...]:
            The write results corresponding to the changes committed, returned
            in the same order as the changes were applied to this batch. A
            write result contains an ``update_time`` field.
        )requestmetadataN )	_prep_commit_client_firestore_apicommit_rpc_metadata
_write_pbslistwrite_resultscommit_time)r   retrytimeoutr   kwargscommit_responseresultss          r   r   zAsyncWriteBatch.commit'   s     & ++E7; B ; ; B B !
\\//!
 !
 
 '+O,I,I'JJW*66
s   ABB;Bc                   K   | S wNr   )r   s    r   
__aenter__zAsyncWriteBatch.__aenter__H   s     s   c                F   K   || j                          d {    y y 7 wr$   )r   )r   exc_type	exc_value	tracebacks       r   	__aexit__zAsyncWriteBatch.__aexit__K   s#     ++- s   !!)returnNone)r   z"retries.AsyncRetry | object | Noner   zfloat | Noner+   r   )__name__
__module____qualname____doc__r   r   methodDEFAULTr   r%   r*   __classcell__)r   s   @r   r   r      sK    	=
 5=OO4K4K $1  
	B r   r   N)
r0   
__future__r   google.api_corer   r   retries$google.cloud.firestore_v1.base_batchr   r   r   r   r   <module>r8      s#    D " $ 2 ?5 n 5 r   