o
     i9                     @  sH   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 deZ	dS )	z=Helpers for batch requests to the Google Cloud Firestore API.    )annotations)gapic_v1)retry_async)BaseWriteBatchc                      sF   e Zd ZdZd fddZejjdfdddZdd Z	dd Z
  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.
    returnNonec                   s   t t| j|d d S )N)client)superr   __init__)selfr	   	__class__ /var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/google/cloud/firestore_v1/async_batch.pyr   $   s   zAsyncWriteBatch.__init__Nretry"retries.AsyncRetry | object | Nonetimeoutfloat | Nonelistc                   sX   |  ||\}}| jjjd|| jjd|I dH }g | _t|j | _}|j| _|S )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metadataNr   )	_prep_commit_client_firestore_apicommit_rpc_metadata
_write_pbsr   write_resultscommit_time)r   r   r   r   kwargscommit_responseresultsr   r   r   r   '   s   
zAsyncWriteBatch.commitc                   s   | S Nr   )r   r   r   r   
__aenter__H   s   zAsyncWriteBatch.__aenter__c                   s    |d u r|   I d H  d S d S r#   )r   )r   exc_type	exc_value	tracebackr   r   r   	__aexit__K   s   zAsyncWriteBatch.__aexit__)r   r   )r   r   r   r   r   r   )__name__
__module____qualname____doc__r   r   methodDEFAULTr   r$   r(   __classcell__r   r   r   r   r      s    !r   N)
r,   
__future__r   google.api_corer   r   retries$google.cloud.firestore_v1.base_batchr   r   r   r   r   r   <module>   s   