Ë
    ö%9jŸ4  ã                  óü   — d Z ddlmZ ddlmZmZmZmZ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mZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ erddlZddlmZ ddl m!Z! ddl"m#Z#  G d„ deejH                     «      Z%y)zHClasses for representing collections for the Google Cloud Firestore API.é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚCallableÚ	GeneratorÚOptionalÚTupleÚUnion)Úgapic_v1)Úretry)ÚaggregationÚdocumentÚtransactionÚvector_query)Úquery)ÚBaseCollectionReferenceÚ_item_to_document_ref)ÚQueryResultsList)ÚWatchN)ÚDocumentSnapshot)ÚExplainOptions)ÚStreamGeneratorc                  ó’  ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zdd„Zdej                  j                  df	 	 	 	 	 	 	 	 	 dd„Zdej                  j                  dfddœ	 	 	 	 	 	 	 	 	 dd	„Zdd
„Zdej                  j                  dfdddœ	 	 	 	 	 	 	 	 	 	 	 dd„Zdej                  j                  dfdddœ	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zˆ xZS )ÚCollectionReferencea  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.
    c                ó,   •— t        t        | �
  |i |¤Ž y ©N)Úsuperr   Ú__init__)ÚselfÚpathÚkwargsÚ	__class__s      €ú`/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/collection.pyr   zCollectionReference.__init__C   s   ø€ ÜÔ! 4Ñ1°4ÐB¸6ÓBó    c                ó,   — t        j                  | «      S )zeQuery factory.

        Returns:
            :class:`~google.cloud.firestore_v1.query.Query`
        )Ú	query_modÚQuery©r   s    r#   Ú_queryzCollectionReference._queryF   s   € ô �‰˜tÓ$Ð$r$   c                óH   — t        j                  | j                  «       «      S )z‡AggregationQuery factory.

        Returns:
            :class:`~google.cloud.firestore_v1.aggregation_query.AggregationQuery`
        )r   ÚAggregationQueryr)   r(   s    r#   Ú_aggregation_queryz&CollectionReference._aggregation_queryN   s   € ô ×+Ñ+¨D¯K©K«MÓ:Ð:r$   c                óH   — t        j                  | j                  «       «      S )zxVectorQuery factory.

        Returns:
            :class:`~google.cloud.firestore_v1.vector_query.VectorQuery`
        )r   ÚVectorQueryr)   r(   s    r#   Ú_vector_queryz!CollectionReference._vector_queryV   s   € ô ×'Ñ'¨¯©«Ó6Ð6r$   Nc                ór   — | j                  ||||«      \  }} |j                  |fi |¤Ž}|j                  |fS )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.document.DocumentReference`]:
                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.
        )Ú	_prep_addÚcreateÚupdate_time)r   Údocument_dataÚdocument_idr   ÚtimeoutÚdocument_refr!   Úwrite_results           r#   ÚaddzCollectionReference.add^   sN   € ðD  $Ÿ~™~ØØØØó	 
Ñˆ�fð +�|×*Ñ*¨=ÑC¸FÑCˆØ×'Ñ'¨Ð5Ð5r$   )Ú	read_timec               óÂ   ‡ — ‰ j                  ||||«      \  }} ‰ j                  j                  j                  d|‰ j                  j                  dœ|¤Ž}ˆ fd„|D «       S )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.
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
                is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
                timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.

        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Úmetadatac              3  ó6   •K  — | ]  }t        ‰|«      –— Œ y ­wr   )r   )Ú.0Úir   s     €r#   ú	<genexpr>z5CollectionReference.list_documents.<locals>.<genexpr>¯   s   øè ø€ ÒA°1Ô% d¨A×.ÑAùs   ƒ© )Ú_prep_list_documentsÚ_clientÚ_firestore_apiÚlist_documentsÚ_rpc_metadata)r   Ú	page_sizer   r6   r:   r<   r!   Úiterators   `       r#   rF   z"CollectionReference.list_documents‰   sm   ø€ ð: ×3Ñ3Ø�u˜g yó
‰ˆ�ð >�4—<‘<×.Ñ.×=Ñ=ð 
ØØ—\‘\×/Ñ/ñ
ð ñ
ˆó
 B¸ÔAÐAr$   c                ó@   — | j                  «       j                  |«      S r   )r)   Ú	_chunkify)r   Ú
chunk_sizes     r#   rK   zCollectionReference._chunkify±   s   € Ø�{‰{‹}×&Ñ& zÓ2Ð2r$   )Úexplain_optionsr:   c               óp   — | j                  ||«      \  }}|�||d<   |�||d<    |j                  dd|i|¤ŽS )as  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.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.
            explain_options
                (Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned generator.
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
                is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
                timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.

        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:
            QueryResultsList[DocumentSnapshot]: The documents in this collection
            that match the query.
        rM   r:   r   rB   )Ú_prep_get_or_streamÚget©r   r   r   r6   rM   r:   r   r!   s           r#   rP   zCollectionReference.get´   sU   € ðN ×0Ñ0°¸Ó@‰ˆˆvØÐ&Ø(7ˆFÐ$Ñ%ØÐ Ø"+ˆF�;Ñàˆu�y‰yÑ; [Ð;°FÑ;Ð;r$   c               óp   — | j                  ||«      \  }}|r||d<   |�||d<    |j                  dd|i|¤ŽS )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.Transaction`]):
                An existing transaction that the query will run in.
            retry (Optional[google.api_core.retry.Retry]): Designation of what
                errors, if any, should be retried.  Defaults to a
                system-specified policy.
            timeout (Optional[float]): The timeout for this request. Defaults
                to a system-specified value.
            explain_options
                (Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned generator.
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
                is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
                timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.

        Returns:
            `StreamGenerator[DocumentSnapshot]`: A generator of the query results.
        rM   r:   r   rB   )rO   ÚstreamrQ   s           r#   rS   zCollectionReference.streamã   sR   € ð^ ×0Ñ0°¸Ó@‰ˆˆvÙØ(7ˆFÐ$Ñ%ØÐ Ø"+ˆF�;Ñàˆu�|‰|Ñ>¨Ð>°vÑ>Ð>r$   c                ól   — | j                  «       }t        j                  ||t        j                  «      S )aš  Monitor the documents in this collection.

        This starts a watch on this collection using a background thread. The
        provided callback is run on the snapshot of the documents.

        Args:
            callback (Callable[[:class:`~google.cloud.firestore.collection.CollectionSnapshot`], NoneType]):
                a callback to run when a change occurs.

        Example:
            from google.cloud import firestore_v1

            db = firestore_v1.Client()
            collection_ref = db.collection(u'users')

            def on_snapshot(collection_snapshot, changes, read_time):
                for doc in collection_snapshot.documents:
                    print(u'{} => {}'.format(doc.id, doc.to_dict()))

            # Watch this collection
            collection_watch = collection_ref.on_snapshot(on_snapshot)

            # Terminate this watch
            collection_watch.unsubscribe()
        )r)   r   Ú	for_queryr   r   )r   Úcallbackr   s      r#   Úon_snapshotzCollectionReference.on_snapshot  s(   € ð4 —‘“ˆÜ�‰˜u h´×0IÑ0IÓJÐJr$   )ÚreturnÚNone)rX   zquery_mod.Query)rX   zaggregation.AggregationQuery)rX   zvector_query.VectorQuery)
r4   Údictr5   zUnion[str, None]r   úretries.Retry | object | Noner6   úUnion[float, None]rX   zTuple[Any, Any])
rH   zUnion[int, None]r   r[   r6   r\   r:   úOptional[datetime.datetime]rX   zGenerator[Any, Any, None])rL   Úint)r   z$Union[transaction.Transaction, None]r   r[   r6   r\   rM   úOptional[ExplainOptions]r:   r]   rX   z"QueryResultsList[DocumentSnapshot])r   z!Optional[transaction.Transaction]r   r[   r6   zOptional[float]rM   r_   r:   r]   rX   z!StreamGenerator[DocumentSnapshot])rV   r   rX   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r)   r,   r/   r   ÚmethodÚDEFAULTr9   rF   rK   rP   rS   rW   Ú__classcell__)r"   s   @r#   r   r   )   s”  ø„ ñõ2Có%ó;ó7ð )-Ø/7¯©×/FÑ/FØ&*ð)6àð)6ð &ð)6ð -ð	)6ð
 $ð)6ð 
ó)6ðZ '+Ø/7¯©×/FÑ/FØ&*ð	&Bð 26ñ&Bà#ð&Bð -ð&Bð $ð	&Bð /ð&Bð 
#ó&BóP3ð
 =AØ/7¯©×/FÑ/FØ&*ð	-<ð 59Ø15ñ-<à9ð-<ð -ð-<ð $ð	-<ð 2ð-<ð /ð-<ð 
,ó-<ðb :>Ø/7¯©×/FÑ/FØ#'ð	5?ð 59Ø15ñ5?à6ð5?ð -ð5?ð !ð	5?ð 2ð5?ð /ð5?ð 
+ó5?÷nKr$   r   )&rc   Ú
__future__r   Útypingr   r   r   r   r   r	   r
   Úgoogle.api_corer   r   ÚretriesÚgoogle.cloud.firestore_v1r   r   r   r   r   r&   Ú)google.cloud.firestore_v1.base_collectionr   r   Ú'google.cloud.firestore_v1.query_resultsr   Úgoogle.cloud.firestore_v1.watchr   ÚdatetimeÚ'google.cloud.firestore_v1.base_documentr   Ú'google.cloud.firestore_v1.query_profiler   Ú*google.cloud.firestore_v1.stream_generatorr   r'   r   rB   r$   r#   ú<module>rs      s]   ðñ Oå "ç R× RÑ Rå $Ý ,ç VÓ VÝ 8÷õ EÝ 1áÛåHÝFÝJôLKÐ1°)·/±/ÑBõ LKr$   