Ë
    V¼Sf '  ã                   ó¬   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZ dd	lmZ  G d
„ dee	j*                     «      Zy)zHClasses for representing collections for the Google Cloud Firestore API.é    )Úgapic_v1)Úretry_async)ÚBaseCollectionReferenceÚ_item_to_document_ref)Úasync_queryÚasync_documentÚasync_aggregation)ÚDocumentReference)ÚAsyncIterator)ÚAnyÚAsyncGeneratorÚTuple)ÚTransactionc                   ó>  ‡ — e Zd ZdZdˆ fd„Zdej                  fd„Zdej                  fd„Z
defd„Zdej                  j                  dfd	ed
edej&                  dedeeef   f
d„Z	 dd
edej2                  fˆ fd„Zdej                  j                  dfdedej&                  dedeedf   fd„Zdej                  j                  dfdedej&                  dedefd„Z dej                  j                  dfdedej&                  dede!ejD                     fd„Z#ˆ xZ$S )ÚAsyncCollectionReferencea  A reference to a collection in a Firestore database.

    The collection may already exist or this class can facilitate creation
    of documents within the collection.

    Args:
        path (Tuple[str, ...]): The components in the collection path.
            This is a series of strings representing each collection and
            sub-collection ID, as well as the document IDs for any documents
            that contain a sub-collection.
        kwargs (dict): The keyword arguments for the constructor. The only
            supported keyword is ``client`` and it must be a
            :class:`~google.cloud.firestore_v1.client.Client` if provided. It
            represents the client that created this collection reference.

    Raises:
        ValueError: if

            * the ``path`` is empty
            * there are an even number of elements
            * a collection ID in ``path`` is not a string
            * a document ID in ``path`` is not a string
        TypeError: If a keyword other than ``client`` is used.
    ÚreturnNc                 ó,   •— t        t        | �
  |i |¤Ž y ©N)Úsuperr   Ú__init__)ÚselfÚpathÚkwargsÚ	__class__s      €úiC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/cloud/firestore_v1/async_collection.pyr   z!AsyncCollectionReference.__init__=   s   ø€ ÜÔ&¨Ñ6¸ÐGÀÓGó    c                 ó,   — t        j                  | «      S )zeQuery factory.

        Returns:
            :class:`~google.cloud.firestore_v1.query.Query`
        )r   Ú
AsyncQuery©r   s    r   Ú_queryzAsyncCollectionReference._query@   s   € ô ×%Ñ% dÓ+Ð+r   c                 óH   — t        j                  | j                  «       «      S )z�AsyncAggregationQuery factory.

        Returns:
            :class:`~google.cloud.firestore_v1.async_aggregation.AsyncAggregationQuery
        )r	   ÚAsyncAggregationQueryr    r   s    r   Ú_aggregation_queryz+AsyncCollectionReference._aggregation_queryH   s   € ô !×6Ñ6°t·{±{³}ÓEÐEr   Ú
chunk_sizec                ón   K  — | j                  «       j                  |«      2 3 d {  –—† }|­–— Œ7 Œ
6 y ­wr   )r    Ú	_chunkify)r   r$   Úpages      r   r&   z"AsyncCollectionReference._chunkifyP   s4   è ø€ ØŸ+™+›-×1Ñ1°*Ó=÷ 	ð 	�$ØŒJð	øÑ=ùs   ‚ 5¢3¦1§3ª5±3³5Údocument_dataÚdocument_idÚretryÚtimeoutc              ƒ   óŽ   K  — | j                  ||||«      \  }} |j                  |fi |¤Žƒ d{  –—† }|j                  |fS 7 Œ­w)a   Create a document in the Firestore database with the provided data.

        Args:
            document_data (dict): Property names and values to use for
                creating the document.
            document_id (Optional[str]): The document identifier within the
                current collection. If not provided, an ID will be
                automatically assigned by the server (the assigned ID will be
                a random 20 character string composed of digits,
                uppercase and lowercase letters).
            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:
            Tuple[:class:`google.protobuf.timestamp_pb2.Timestamp`,                 :class:`~google.cloud.firestore_v1.async_document.AsyncDocumentReference`]:
                Pair of

                * The ``update_time`` when the document was created/overwritten.
                * A document reference for the created document.

        Raises:
            :class:`google.cloud.exceptions.Conflict`:
                If ``document_id`` is provided and the document already exists.
        N)Ú	_prep_addÚcreateÚupdate_time)r   r(   r)   r*   r+   Údocument_refr   Úwrite_results           r   ÚaddzAsyncCollectionReference.addT   s[   è ø€ ðD  $Ÿ~™~ØØØØó	 
Ñˆ�fð 1˜\×0Ñ0°ÑIÀ&ÑI×IˆØ×'Ñ'¨Ð5Ð5ð Jús   ‚.A°A±Ac                 ó*   •— t         t        | �  |«      S )aé  Create a sub-document underneath the current collection.

        Args:
            document_id (Optional[str]): The document identifier
                within the current collection. If not provided, will default
                to a random 20 character string composed of digits,
                uppercase and lowercase and letters.

        Returns:
            :class:`~google.cloud.firestore_v1.document.async_document.AsyncDocumentReference`:
            The child document.
        )r   r   Údocument)r   r)   r   s     €r   r4   z!AsyncCollectionReference.document   s   ø€ ô Ô-¨tÑ=¸kÓJÐJr   Ú	page_sizec                ó  K  — | j                  |||«      \  }} | j                  j                  j                  d|| j                  j                  dœ|¤Žƒ d{  –—† }|2 3 d{  –—† }t        | |«      ­–— Œ7 Œ7 Œ6 y­w)a`  List all subdocuments of the current collection.

        Args:
            page_size (Optional[int]]): The maximum number of documents
                in each page of results from this request. Non-positive values
                are ignored. Defaults to a sensible value set by the API.
            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:
            Sequence[:class:`~google.cloud.firestore_v1.collection.DocumentReference`]:
                iterator of subdocuments of the current collection. If the
                collection does not exist at the time of `snapshot`, the
                iterator will be empty
        )ÚrequestÚmetadataN© )Ú_prep_list_documentsÚ_clientÚ_firestore_apiÚlist_documentsÚ_rpc_metadatar   )r   r5   r*   r+   r7   r   ÚiteratorÚis           r   r=   z'AsyncCollectionReference.list_documents�   sŒ   è ø€ ð. ×3Ñ3°I¸uÀgÓN‰ˆ�àC˜Ÿ™×4Ñ4×CÑCð 
ØØ—\‘\×/Ñ/ñ
ð ñ
÷ 
ˆð
  ÷ 	1ð 	1�!Ü'¨¨aÓ0Ô0ð
øð
	1ø‘xùs6   ‚AA?ÁA9ÁA?Á A=Á$A;Á%A=Á(A?Á;A=Á=A?Útransactionc              ƒ   óp   K  — | j                  ||«      \  }} |j                  dd|i|¤Žƒ d{  –—† S 7 Œ­w)a�  Read the documents in this collection.

        This sends a ``RunQuery`` RPC and returns a list of documents
        returned in the stream of ``RunQueryResponse`` messages.

        Args:
            transaction
                (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that this query will run in.
            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.

        If a ``transaction`` is used and it already has write operations
        added, this method cannot be used (i.e. read-after-write is not
        allowed).

        Returns:
            list: The documents in this collection that match the query.
        rA   Nr9   )Ú_prep_get_or_streamÚget)r   rA   r*   r+   Úqueryr   s         r   rD   zAsyncCollectionReference.get±   s=   è ø€ ð6 ×0Ñ0°¸Ó@‰ˆˆvà�U—Y‘YÑA¨;ÐA¸&ÑA×AÐAÐAús   ‚-6¯4°6c                ó‚   K  — | j                  ||«      \  }} |j                  dd|i|¤Ž2 3 d{  –—† }|­–— Œ7 Œ
6 y­w)a  Read the documents in this collection.

        This sends a ``RunQuery`` RPC and then returns an iterator which
        consumes each document returned in the stream of ``RunQueryResponse``
        messages.

        .. note::

           The underlying stream of responses will time out after
           the ``max_rpc_timeout_millis`` value set in the GAPIC
           client configuration for the ``RunQuery`` API.  Snapshots
           not consumed from the iterator before that point will be lost.

        If a ``transaction`` is used and it already has write operations
        added, this method cannot be used (i.e. read-after-write is not
        allowed).

        Args:
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.                Transaction`]):
                An existing transaction that the query will run in.
            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.

        Yields:
            :class:`~google.cloud.firestore_v1.document.DocumentSnapshot`:
            The next document that fulfills the query.
        rA   Nr9   )rC   Ústream)r   rA   r*   r+   rE   r   Úds          r   rG   zAsyncCollectionReference.streamÐ   sO   è ø€ ðH ×0Ñ0°¸Ó@‰ˆˆvà#�u—|‘|ÑF°ÐF¸vÑF÷ 	ð 	�!ØŒGð	øÑFùs   ‚*?¬=°;±=´?»=½?)r   Nr   )%Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r    r	   r"   r#   Úintr&   r   ÚmethodÚDEFAULTÚdictÚstrÚretriesÚ
AsyncRetryÚfloatr   r   r2   r   ÚAsyncDocumentReferencer4   r   r
   r=   r   ÚlistrD   r   ÚDocumentSnapshotrG   Ú__classcell__)r   s   @r   r   r   #   s¬  ø„ ñõ2Hð,˜×.Ñ.ó ,ðFÐ$5×$KÑ$Kó Fð¨#ó ð  Ø$,§O¡O×$;Ñ$;Øñ)6àð)6ð ð)6ð ×!Ñ!ð	)6ð
 ð)6ð 
ˆs�Cˆx‰ó)6ðX "&ñKØðKà	×	.Ñ	.õKð& Ø$,§O¡O×$;Ñ$;Øñ	1àð1ð ×!Ñ!ð1ð ð	1ð
 
Ð)¨4Ð/Ñ	0ó1ðF $(Ø$,§O¡O×$;Ñ$;Øñ	Bà ðBð ×!Ñ!ðBð ð	Bð
 
óBðB $(Ø$,§O¡O×$;Ñ$;Øñ	'à ð'ð ×!Ñ!ð'ð ð	'ð
 
�~×6Ñ6Ñ	7÷'r   r   N)rL   Úgoogle.api_corer   r   rR   Ú)google.cloud.firestore_v1.base_collectionr   r   Úgoogle.cloud.firestore_v1r   r   r	   Ú"google.cloud.firestore_v1.documentr
   Útypingr   r   r   r   Ú%google.cloud.firestore_v1.transactionr   r   r   r9   r   r   ú<module>r_      sJ   ðñ Oå $Ý 2÷÷ UÑ Tå @å  ß -Ñ -õ >ôTÐ6°{×7MÑ7MÑNõ Tr   