
    Ѯhz                    f    d Z ddlmZ ddlm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)_helpers)	BaseBatch)BatchWriteResponsec                  l     e Zd ZdZd fdZej                  j                  df	 	 	 	 	 ddZddZ	 xZ
S )	BulkWriteBatcha  Accumulate write operations to be sent in a batch. Use this over
    `WriteBatch` for higher volumes (e.g., via `BulkWriter`) and when the order
    of operations within a given batch is unimportant.

    Because the order in which individual write operations are applied to the database
    is not guaranteed, `batch_write` RPCs can never contain multiple operations
    to the same document. If calling code detects a second write operation to a
    known document reference, it should first cut off the previous batch and
    send it, then create a new batch starting with the latest write operation.
    In practice, the [Async]BulkWriter classes handle this.

    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.
    c                .    t         t        |   |       y )N)client)superr
   __init__)selfr   	__class__s     v/home/www/academy-backend.kofcorporation.com/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/bulk_batch.pyr   zBulkWriteBatch.__init__.   s    nd,F,;    Nc                    | j                  ||      \  }}| j                  j                  } |j                  d|| j                  j                  d|}g | _        t        |j                        | _        |S )a  Writes the changes accumulated in this batch.

        Write operations are not guaranteed to be applied in order and must not
        contain multiple writes to any given document. Preferred over `commit`
        for performance reasons if these conditions are acceptable.

        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:
            :class:`google.cloud.firestore_v1.write.BatchWriteResponse`:
            Container holding the write results corresponding to the changes
            committed, returned in the same order as the changes were applied to
            this batch. An individual write result contains an ``update_time``
            field.
        )requestmetadata )_prep_commit_client_firestore_apibatch_write_rpc_metadata
_write_pbslistwrite_results)r   r   timeoutr   kwargs_apisave_responses          r   commitzBulkWriteBatch.commit1   s|    0 ++E7;||**,<D,<,< -
\\//-
 -
 !-"="=>r   c                ~    | j                   j                  | j                  d d}t        j                  ||      }||fS )N)databasewriteslabels)r   _database_stringr   r   make_retry_timeout_kwargs)r   r   r   r   r    s        r   r   zBulkWriteBatch._prep_commitW   s>    55oo

 33E7Cr   )returnNone)r   retries.Retry | object | Noner   float | Noner*   r   )r   r,   r   r-   )__name__
__module____qualname____doc__r   r   methodDEFAULTr#   r   __classcell__)r   s   @r   r
   r
      sF    (<
 08/F/F $$,$ $ 
	$Lr   r
   N)r1   
__future__r   google.api_corer   r   retriesgoogle.cloud.firestore_v1r   $google.cloud.firestore_v1.base_batchr   )google.cloud.firestore_v1.types.firestorer   r
   r   r   r   <module>r;      s+    D " $ , . : HEY Er   