Ë
    ö%9ji  ã                  ó¦   — 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
mZmZ er"d dl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)é    )Úannotations)ÚTYPE_CHECKING)Úpipeline_stages)Ú_BasePipeline)ÚPipelineResultÚPipelineSnapshotÚPipelineStreamN)ÚClient)ÚConstant)ÚPipelineExplainOptions)ÚTransaction)ÚValuec                  ó|   ‡ — e Zd ZU dZded<   d	ˆ fd„Zdddi dœ	 	 	 	 	 	 	 	 	 d
d„Zdddi dœ	 	 	 	 	 	 	 	 	 dd„Zˆ xZS )ÚPipelineaÏ  
    Pipelines allow for complex data transformations and queries involving
    multiple stages like filtering, projection, aggregation, and vector search.

    Usage Example:
        >>> from google.cloud.firestore_v1.pipeline_expressions import Field
        >>>
        >>> def run_pipeline():
        ...     client = Client(...)
        ...     pipeline = client.pipeline()
        ...                      .collection("books")
        ...                      .where(Field.of("published").gt(1980))
        ...                      .select("title", "author")
        ...     for result in pipeline.execute():
        ...         print(result)

    Use `client.pipeline()` to create instances of this class.


    r
   Ú_clientc                ó&   •— t        ‰| �  |g|¢­Ž  y)z®
        Initializes a Pipeline.

        Args:
            client: The `Client` instance to use for execution.
            *stages: Initial stages for the pipeline.
        N)ÚsuperÚ__init__)ÚselfÚclientÚstagesÚ	__class__s      €ú^/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/pipeline.pyr   zPipeline.__init__=   s   ø€ ô 	‰Ñ˜Ð) &Ô)ó    N)ÚtransactionÚ	read_timeÚexplain_optionsÚadditional_optionsc               óÒ   — t        «       j                  «       D ��ci c]  \  }}|dk7  sŒ||“Œ }}}t        t        | fi |¤Ž}|D �	cg c]  }	|	‘Œ }
}	t	        |
|«      S c c}}w c c}	w )a�  
        Executes this pipeline and returns results as a list

        Args:
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that this query will run in.
                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).
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a microsecond precision 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. For the most accurate results, use UTC timezone.
            explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned list.
            additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
                These options will take precedence over method argument if there is a conflict (e.g. explain_options)

        Raises:
            google.api_core.exceptions.GoogleAPIError: If there is a backend error.
        r   )ÚlocalsÚitemsr	   r   r   )r   r   r   r   r   ÚkÚvÚkwargsÚstreamÚresultÚresultss              r   ÚexecutezPipeline.executeG   sh   € ô< $*£8§>¡>Ó#3×C™4˜1˜a°q¸F³{�!�Q‘$ÐCˆÑCÜ¤°Ñ?¸Ñ?ˆØ(.Ö/˜f’6Ð/ˆÐ/Ü ¨Ó0Ð0ùó Dùâ/s   œAªAÁ	A$c               ó’   — t        «       j                  «       D ��ci c]  \  }}|dk7  sŒ||“Œ }}}t        t        | fi |¤ŽS c c}}w )a¦  
        Process this pipeline as a stream, providing results through an Iterable

        Args:
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that this query will run in.
                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).
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a microsecond precision 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. For the most accurate results, use UTC timezone.
            explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned generator.
            additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
                These options will take precedence over method argument if there is a conflict (e.g. explain_options)

        Raises:
            google.api_core.exceptions.GoogleAPIError: If there is a backend error.
        r   )r    r!   r	   r   )r   r   r   r   r   r"   r#   r$   s           r   r%   zPipeline.streamj   sF   € ô< $*£8§>¡>Ó#3×C™4˜1˜a°q¸F³{�!�Q‘$ÐCˆÑCÜœn¨dÑ=°fÑ=Ð=ùó Ds
   œAªA)r   r
   r   zstages.Stage)
r   ú'Transaction' | Noner   údatetime.datetime | Noner   úPipelineExplainOptions | Noner   údict[str, Value | Constant]Úreturnz PipelineSnapshot[PipelineResult])
r   r*   r   r+   r   r,   r   r-   r.   zPipelineStream[PipelineResult])	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r(   r%   Ú__classcell__)r   s   @r   r   r   %   sŸ   ø… ñð* ƒOõ*ð -1Ø.2Ø9=Ø:<ñ!1ð *ð!1ð ,ð	!1ð
 7ð!1ð 8ð!1ð 
*ó!1ðL -1Ø.2Ø9=Ø:<ñ>ð *ð>ð ,ð	>ð
 7ð>ð 8ð>ð 
(÷>r   r   )Ú
__future__r   Útypingr   Úgoogle.cloud.firestore_v1r   r   Ú'google.cloud.firestore_v1.base_pipeliner   Ú)google.cloud.firestore_v1.pipeline_resultr   r   r	   ÚdatetimeÚ google.cloud.firestore_v1.clientr
   Ú.google.cloud.firestore_v1.pipeline_expressionsr   Ú'google.cloud.firestore_v1.query_profiler   Ú%google.cloud.firestore_v1.transactionr   Ú(google.cloud.firestore_v1.types.documentr   r   © r   r   ú<module>rA      sB   ðõ #å  å ?Ý A÷ñ ñ Ûå7ÝGÝNÝAÝ>ôd>ˆ}õ d>r   