Ë
    ö%9jë=  ã                  ó&  — 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 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# ddl$m%Z% ddl&m'Z( ddl)m*Z+ ddl,m-Z- er
ddl.Z.ddl/m0Z0  G d„ de«      Z1y)a¡  Client for interacting with the Google Cloud Firestore API.

This is the base from which all interactions with the API occur.

In the hierarchy of API concepts

* a :class:`~google.cloud.firestore_v1.client.Client` owns a
  :class:`~google.cloud.firestore_v1.collection.CollectionReference`
* a :class:`~google.cloud.firestore_v1.client.Client` owns a
  :class:`~google.cloud.firestore_v1.document.DocumentReference`
é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚ	GeneratorÚIterableÚListÚOptionalÚUnion)Úgapic_v1)Úretry)Ú_CLIENT_INFOÚ
BaseClientÚ_parse_batch_getÚ_path_helper)ÚDocumentSnapshot)ÚMAX_ATTEMPTS©Ú
WriteBatch)ÚCollectionReference)ÚDocumentReference)Ú	FieldPath©ÚPipeline©ÚPipelineSource)ÚCollectionGroup)Úclient)Úgrpc©ÚTransactionN)Ú
BulkWriterc                  óv  ‡ — e Zd ZdZdddedf	 dˆ fd„Zed„ «       Zdd„Zdd„Z	dd„Z
ddej                  j                  dfddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd	„Zej                  j                  dfddœ	 	 	 	 	 	 	 dd
„Zdddœ	 	 	 	 	 	 	 dd„Zdddœ	 	 	 	 	 	 	 	 	 dd„Zdd„Zedf	 	 	 	 	 dd„Zed„ «       Zd d„Zˆ xZS )!ÚClienta  Client for interacting with Google Cloud Firestore API.

    .. note::

        Since the Cloud Firestore API requires the gRPC transport, no
        ``_http`` argument is accepted by this class.

    Args:
        project (Optional[str]): The project which the client acts on behalf
            of. If not passed, falls back to the default inferred
            from the environment.
        credentials (Optional[~google.auth.credentials.Credentials]): The
            OAuth2 Credentials to use for this client. If not passed, falls
            back to the default inferred from the environment.
        database (Optional[str]): The database name that the client targets.
            If not passed, falls back to :attr:`DEFAULT_DATABASE`.
        client_info (Optional[google.api_core.gapic_v1.client_info.ClientInfo]):
            The client info used to send a user-agent string along with API
            requests. If ``None``, then default info will be used. Generally,
            you only need to set this if you're developing your own library
            or partner tool.
        client_options (Union[dict, google.api_core.client_options.ClientOptions]):
            Client options used to set user options on the client. API Endpoint
            should be set through client_options.
    Nc                ó6   •— t         t        | �  |||||¬«       y )N)ÚprojectÚcredentialsÚdatabaseÚclient_infoÚclient_options)Úsuperr#   Ú__init__)Úselfr%   r&   r'   r(   r)   Ú	__class__s         €ú\/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/client.pyr+   zClient.__init__Z   s(   ø€ ô 	Œf�dÑ$ØØ#ØØ#Ø)ð 	%õ 	
ó    c                óh   — | j                  t        j                  t        j                  t        «      S )zãLazy-loading getter GAPIC Firestore API.
        Returns:
            :class:`~google.cloud.gapic.firestore.v1`.firestore_client.FirestoreClient:
            The GAPIC client with the credentials of the current client.
        )Ú_firestore_api_helperÚfirestore_grpc_transportÚFirestoreGrpcTransportÚfirestore_clientÚFirestoreClient©r,   s    r.   Ú_firestore_apizClient._firestore_apij   s,   € ð ×)Ñ)Ü$×;Ñ;Ü×,Ñ,Üó
ð 	
r/   c                ó*   — t        t        |«      d| iŽS )a  Get a reference to a collection.

        For a top-level collection:

        .. code-block:: python

            >>> client.collection('top')

        For a sub-collection:

        .. code-block:: python

            >>> client.collection('mydocs/doc/subcol')
            >>> # is the same as
            >>> client.collection('mydocs', 'doc', 'subcol')

        Sub-collections can be nested deeper in a similar fashion.

        Args:
            collection_path: Can either be

                * A single ``/``-delimited path to a collection
                * A tuple of collection path segments

        Returns:
            :class:`~google.cloud.firestore_v1.collection.CollectionReference`:
            A reference to a collection in the Firestore database.
        r   )r   r   )r,   Úcollection_paths     r.   Ú
collectionzClient.collectionw   s   € ô: #¤L°Ó$AÐOÈ$ÑOÐOr/   c                ó6   — t        | j                  |«      «      S )a†  
        Creates and returns a new Query that includes all documents in the
        database that are contained in a collection or subcollection with the
        given collection_id.

        .. code-block:: python

            >>> query = client.collection_group('mygroup')

        Args:
            collection_id (str) Identifies the collections to query over.

                Every collection or subcollection with this ID as the last segment of its
                path will be included. Cannot contain a slash.

        Returns:
            :class:`~google.cloud.firestore_v1.query.CollectionGroup`:
            The created Query.
        )r   Ú_get_collection_reference)r,   Úcollection_ids     r.   Úcollection_groupzClient.collection_group–   s   € ô( ˜t×=Ñ=¸mÓLÓMÐMr/   c                ó2   — t         | j                  |Ž d| iŽS )a}  Get a reference to a document in a collection.

        For a top-level document:

        .. code-block:: python

            >>> client.document('collek/shun')
            >>> # is the same as
            >>> client.document('collek', 'shun')

        For a document in a sub-collection:

        .. code-block:: python

            >>> client.document('mydocs/doc/subcol/child')
            >>> # is the same as
            >>> client.document('mydocs', 'doc', 'subcol', 'child')

        Documents in sub-collections can be nested deeper in a similar fashion.

        Args:
            document_path): Can either be

                * A single ``/``-delimited path to a document
                * A tuple of document path segments

        Returns:
            :class:`~google.cloud.firestore_v1.document.DocumentReference`:
            A reference to a document in a collection.
        r   )r   Ú_document_path_helper)r,   Údocument_paths     r.   ÚdocumentzClient.document¬   s)   € ô> !Ø'ˆT×'Ñ'¨Ð7ð
Ø@Dñ
ð 	
r/   )Ú	read_timec             #  ó¾   K  — | j                  ||||||«      \  }}}	 | j                  j                  d|| j                  dœ|	¤Ž}
|
D ]  }t	        ||| «      –— Œ y­w)a7  Retrieve a batch of documents.

        .. note::

           Documents returned by this method are not guaranteed to be
           returned in the same order that they are given in ``references``.

        .. note::

           If multiple ``references`` refer to the same document, the server
           will only return one result.

        See :meth:`~google.cloud.firestore_v1.client.Client.field_path` for
        more information on **field paths**.

        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:
            references (List[.DocumentReference, ...]): Iterable of document
                references to be retrieved.
            field_paths (Optional[Iterable[str, ...]]): An iterable of field
                paths (``.``-delimited list of field names) to use as a
                projection of document fields in the returned results. If
                no value is provided, all fields will be returned.
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that these ``references`` will be
                retrieved 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.
            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.

        Yields:
            .DocumentSnapshot: The next document snapshot that fulfills the
            query, or :data:`None` if the document does not exist.
        ©ÚrequestÚmetadataN© )Ú_prep_get_allr7   Úbatch_get_documentsÚ_rpc_metadatar   )r,   Ú
referencesÚfield_pathsÚtransactionr   ÚtimeoutrC   rF   Úreference_mapÚkwargsÚresponse_iteratorÚget_doc_responses               r.   Úget_allzClient.get_allÏ   sˆ   è ø€ ðh *.×);Ñ);Ø˜ [°%¸À)ó*
Ñ&ˆ� ð D˜D×/Ñ/×CÑCð 
ØØ×'Ñ'ñ
ð ñ
Ðð !2ò 	JÐÜ"Ð#3°]ÀDÓIÓIñ	Jùó   ‚AAc             #  ó¾   K  — | j                  |||«      \  }} | j                  j                  d|| j                  dœ|¤Ž}|D ]  }| j	                  |«      –— Œ y­w)a«  List top-level collections of the client's database.

        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.
            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.CollectionReference`]:
                iterator of subcollections of the current document.
        rE   NrH   )Ú_prep_collectionsr7   Úlist_collection_idsrK   r:   )r,   r   rO   rC   rF   rQ   Úiteratorr=   s           r.   ÚcollectionszClient.collections  ss   è ø€ ð. ×0Ñ0°¸ÀÓK‰ˆ�à:�4×&Ñ&×:Ñ:ð 
ØØ×'Ñ'ñ
ð ñ
ˆð &ò 	1ˆMØ—/‘/ -Ó0Ó0ñ	1ùrU   iˆ  )Úbulk_writerÚ
chunk_sizec               óN   — |€| j                  «       }| j                  |||¬«      S )aU  Deletes documents and their subcollections, regardless of collection
        name.

        Passing a CollectionReference leads to each document in the collection
        getting deleted, as well as all of their descendents.

        Passing a DocumentReference deletes that one document and all of its
        descendents.

        Args:
            reference (Union[
                :class:`@google.cloud.firestore_v1.collection.CollectionReference`,
                :class:`@google.cloud.firestore_v1.document.DocumentReference`,
            ])
                The reference to be deleted.

            bulk_writer (Optional[:class:`@google.cloud.firestore_v1.bulk_writer.BulkWriter`])
                The BulkWriter used to delete all matching documents. Supply this
                if you want to override the default throttling behavior.

        )r\   )r[   Ú_recursive_delete)r,   Ú	referencer[   r\   s       r.   Úrecursive_deletezClient.recursive_delete2  s9   € ð8 ÐØ×*Ñ*Ó,ˆKà×%Ñ%ØØØ!ð &ó 
ð 	
r/   r   ©r\   Údepthc          	     ó"  — d}t        |t        «      rn|j                  «       j                  t	        j
                  «       g«      j                  |«      D ])  }|D ]"  }|dz  }|j                  |j                  «       Œ$ Œ+ nyt        |t        «      rG|j                  «       D ]  }|| j                  ||||dz   ¬«      z  }Œ |dz  }|j                  |«       n"t        d|j                  j                  › �«      ‚|dk(  r|j                  «        |S )z'Recursion helper for `recursive_delete.r   é   ra   zUnexpected type for reference: )Ú
isinstancer   Ú	recursiveÚselectr   Údocument_idÚ	_chunkifyÚdeleter_   r   rZ   r^   Ú	TypeErrorr-   Ú__name__Úclose)	r,   r_   r[   r\   rb   Únum_deletedÚchunkÚdoc_snapÚcol_refs	            r.   r^   zClient._recursive_deleteW  s)  € ð ˆä�iÔ!4Ô5ð ×#Ñ#Ó%ß‘œ×.Ñ.Ó0Ð1Ó2ß‘˜:Ó&ò;�ð !&ò ;�HØ 1Ñ$�KØ×&Ñ& x×'9Ñ'9Õ:ñ;ñ;ô ˜	Ô#4Ô5à$×0Ñ0Ó2ò �Ø˜t×5Ñ5ØØØ)Ø !™)ð	  6ó  ñ ‘ðð ˜1ÑˆKØ×Ñ˜yÕ)ô Ø1°)×2EÑ2E×2NÑ2NÐ1OÐPóð ð �AŠ:Ø×ÑÔàÐr/   c                ó   — t        | «      S )zýGet a batch instance from this client.

        Returns:
            :class:`~google.cloud.firestore_v1.batch.WriteBatch`:
            A "write" batch to be used for accumulating document changes and
            sending the changes all at once.
        r   r6   s    r.   ÚbatchzClient.batch…  s   € ô ˜$ÓÐr/   Fc                ó   — t        | ||¬«      S )aD  Get a transaction that uses this client.

        See :class:`~google.cloud.firestore_v1.transaction.Transaction` for
        more information on transactions and the constructor arguments.

        Args:
            kwargs (Dict[str, Any]): The keyword arguments (other than
                ``client``) to pass along to the
                :class:`~google.cloud.firestore_v1.transaction.Transaction`
                constructor.

        Returns:
            :class:`~google.cloud.firestore_v1.transaction.Transaction`:
            A transaction attached to this client.
        )Úmax_attemptsÚ	read_onlyr   )r,   ru   rv   s      r.   rN   zClient.transaction�  s   € ô$ ˜4¨lÀiÔPÐPr/   c                ó   — t         S ©Nr   r6   s    r.   Ú_pipeline_clszClient._pipeline_cls£  s   € äˆr/   c                ó   — t        | «      S rx   r   r6   s    r.   ÚpipelinezClient.pipeline§  s   € Ü˜dÓ#Ð#r/   )ÚreturnÚNone)r9   Ústrr|   r   )r=   r~   r|   r   )rA   r~   r|   r   )rL   ÚlistrM   zIterable[str] | NonerN   zTransaction | Noner   úretries.Retry | object | NonerO   úfloat | NonerC   údatetime.datetime | Noner|   z&Generator[DocumentSnapshot, Any, None])r   r€   rO   r�   rC   r‚   r|   zGenerator[Any, Any, None])r_   ú-Union[CollectionReference, DocumentReference]r[   zOptional['BulkWriter']r\   Úintr|   r„   )
r_   rƒ   r[   z'BulkWriter'r\   r„   rb   r„   r|   r„   )r|   r   )ru   r„   rv   Úboolr|   r    )r|   r   )rl   Ú
__module__Ú__qualname__Ú__doc__r   r+   Úpropertyr7   r:   r>   rB   r   ÚmethodÚDEFAULTrT   rZ   r`   r^   rs   r   rN   ry   r{   Ú__classcell__)r-   s   @r.   r#   r#   ?   sÃ  ø„ ñð8 ØØØ Øð
ð 
õ
ð  ñ

ó ð

óPó>Nó,!
ðL -1Ø*.Ø/7¯©×/FÑ/FØ $ð?Jð /3ñ?Jàð?Jð *ð?Jð (ð	?Jð
 -ð?Jð ð?Jð ,ð?Jð 
0ó?JðF 08¯©×/FÑ/FØ $ð 1ð
 /3ñ 1à,ð 1ð ð 1ð
 ,ð 1ð 
#ó 1ðL /3Øñ#
à@ð#
ð ,ð	#
ð
 ð#
ð 
ó#
ðT Øñ,à@ð,ð "ð,ð
 ð,ð ð,ð 
ó,ó\ ð #/À%ðQØðQØ;?ðQà	óQð( ñó ð÷$r/   r#   )2rˆ   Ú
__future__r   Útypingr   r   r   r   r   r	   r
   Úgoogle.api_corer   r   ÚretriesÚ%google.cloud.firestore_v1.base_clientr   r   r   r   Ú'google.cloud.firestore_v1.base_documentr   Ú*google.cloud.firestore_v1.base_transactionr   Úgoogle.cloud.firestore_v1.batchr   Ú$google.cloud.firestore_v1.collectionr   Ú"google.cloud.firestore_v1.documentr   Ú$google.cloud.firestore_v1.field_pathr   Ú"google.cloud.firestore_v1.pipeliner   Ú)google.cloud.firestore_v1.pipeline_sourcer   Úgoogle.cloud.firestore_v1.queryr   Ú,google.cloud.firestore_v1.services.firestorer   r4   Ú7google.cloud.firestore_v1.services.firestore.transportsr   r2   Ú%google.cloud.firestore_v1.transactionr    ÚdatetimeÚ%google.cloud.firestore_v1.bulk_writerr!   r#   rH   r/   r.   ú<module>r       sj   ðñ
õ #ç Q× QÑ Qå $Ý ,÷ó õ EÝ CÝ 6Ý DÝ @Ý :Ý 7Ý DÝ ;Ý Sõõ >áÛå@ôi$ˆZõ i$r/   