Ë
    V¼Sf  ã                   óZ   — 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
  G d„ de«      Zy	)
z=Helpers for batch requests to the Google Cloud Firestore API.é    )Úgapic_v1)Úretry)Ú_helpers)Ú	BaseBatch)ÚBatchWriteResponsec                   óž   ‡ — e Zd ZdZd	ˆ fd„Zej                  j                  dfdej                  de
defd„Zdej                  de
f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.
    ÚreturnNc                 ó.   •— t         t        | �  |¬«       y )N)Úclient)Úsuperr	   Ú__init__)Úselfr   Ú	__class__s     €úcC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/cloud/firestore_v1/bulk_batch.pyr   zBulkWriteBatch.__init__-   s   ø€ ÜŒn˜dÑ,°FÐ,Õ;ó    r   Útimeoutc                 óð   — | 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.proto.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   r   r   ÚkwargsÚ_apiÚsave_responses          r   ÚcommitzBulkWriteBatch.commit0   s|   € ð, ×+Ñ+¨E°7Ó;‰ˆ�à�|‰|×*Ñ*ˆØ,<¨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_commitT   s>   € àŸ™×5Ñ5Ø—o‘oØñ
ˆô
 ×3Ñ3°E¸7ÓCˆØ˜ˆÐr   )r
   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚmethodÚDEFAULTÚretriesÚRetryÚfloatr   r#   r   Ú__classcell__)r   s   @r   r	   r	      sW   ø„ ñõ(<ð &.§_¡_×%<Ñ%<Ètñ"Ø—]‘]ð"ØGLð"à	ó"ðH '§-¡-ð ¸%÷ r   r	   N)r-   Úgoogle.api_corer   r   r0   Úgoogle.cloud.firestore_v1r   Ú$google.cloud.firestore_v1.base_batchr   Ú)google.cloud.firestore_v1.types.firestorer   r	   r   r   r   ú<module>r8      s(   ðñ DÝ $Ý ,å .Ý :Ý HôC�Yõ Cr   