
    (phN8                       S r SSKJr  SSKJrJrJrJrJrJ	r	J
r
  SSKJr  SSKJr  SSKJrJrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSK J!r"  SSK#J$r%  SSK&J'r'  \(       a  SSK(J)r)   " S S\5      r*g)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
WriteBatch)CollectionReference)DocumentReference)	FieldPath)CollectionGroup)client)grpcTransaction)
BulkWriterc                  b  ^  \ rS rSrSrSSS\S4 SU 4S jjjr\S 5       rSS jr	SS jr
SS jrSS\R                  R                  S4           SS	 jjr\R                  R                  S4     SS
 jjrSSS.       SS jjrSSS.         SS jjrSS jrSS jrSrU =r$ )Client9   a  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                0   > [         [        U ]  UUUUUS9  g )N)projectcredentialsdatabaseclient_infoclient_options)superr   __init__)selfr!   r"   r#   r$   r%   	__class__s         S/var/www/html/venv/lib/python3.13/site-packages/google/cloud/firestore_v1/client.pyr'   Client.__init__T   s(     	fd$##) 	% 	
    c                h    U R                  [        R                  [        R                  [        5      $ )zLazy-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_apiClient._firestore_apid   s,     ))$;;,,
 	
r,   c                *    [        [        U5      SU 06$ )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*   
collectionClient.collectionq   s    : #L$AO$OOr,   c                6    [        U R                  U5      5      $ )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_groupClient.collection_group   s    ( t==mLMMr,   c                2    [        U R                  " U6 SU 06$ )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*   documentClient.document   s'    > !''7
@D
 	
r,   c              #     #    U R                  XX4U5      u  pgnU R                  R                  " SUU R                  S.UD6n	U	 H  n
[	        XU 5      v   M     g7f)a  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.

Yields:
    .DocumentSnapshot: The next document snapshot that fulfills the
    query, or :data:`None` if the document does not exist.
requestmetadataN )_prep_get_allr4   batch_get_documents_rpc_metadatar   )r(   
referencesfield_pathstransactionr   timeoutrF   reference_mapkwargsresponse_iteratorget_doc_responses              r*   get_allClient.get_all   ss     \ *.););[*
& !//CC 
''
 
 !2"#3DII !2s   AAc              #     #    U R                  X5      u  p4U R                  R                  " SUU R                  S.UD6nU H  nU R	                  U5      v   M     g7f)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.

Returns:
    Sequence[:class:`~google.cloud.firestore_v1.collection.CollectionReference`]:
        iterator of subcollections of the current document.
rE   NrH   )_prep_collectionsr4   list_collection_idsrK   r8   )r(   r   rO   rF   rQ   iteratorr<   s          r*   collectionsClient.collections  se     " 00@&&:: 
''
 
 &M//-00 &s   AAi  )bulk_writer
chunk_sizec               J    Uc  U R                  5       nU R                  UUUS9$ )a  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_deleteClient.recursive_delete   s9    8 **,K%%! & 
 	
r,   r   r]   depthc          	     >   Sn[        U[        5      (       as  UR                  5       R                  [        R
                  " 5       /5      R                  U5       H,  nU H#  nUS-  nUR                  UR                  5        M%     M.     O|[        U[        5      (       aE  UR                  5        H  nXPR                  UUUUS-   S9-  nM     US-  nUR                  U5        O"[        SUR                  R                   35      eUS:X  a  UR                  5         U$ )z'Recursion helper for `recursive_delete.r      rc   zUnexpected type for reference: )
isinstancer   	recursiveselectr   document_id	_chunkifydeleter`   r   rZ   r_   	TypeErrorr)   __name__close)	r(   r`   r\   r]   rd   num_deletedchunkdoc_snapcol_refs	            r*   r_   Client._recursive_deleteE  s&    i!455 ##%..012:&'  !&H1$K&&x'9'9: !&' 	#455$00255)!)	  6    3 1Ky) 1)2E2E2N2N1OP  A:r,   c                    [        U 5      $ )zGet 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   r3   s    r*   batchClient.batchs  s     $r,   c                    [        U 40 UD6$ )a  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.
r   )r(   rQ   s     r*   rN   Client.transaction}  s      4*6**r,   rH   )returnNone)r7   strrz   r   )r<   r|   rz   r   )rA   r|   rz   r   )rL   listrM   zIterable[str] | NonerN   zTransaction | Noner   retries.Retry | object | NonerO   float | Nonerz   z&Generator[DocumentSnapshot, Any, None])r   r~   rO   r   rz   zGenerator[Any, Any, None])r`   -Union[CollectionReference, DocumentReference]r\   zOptional['BulkWriter']r]   intrz   r   )
r`   r   r\   z'BulkWriter'r]   r   rd   r   rz   r   )rz   r   )rz   r   )rn   
__module____qualname____firstlineno____doc__r   r'   propertyr4   r8   r=   rB   r   methodDEFAULTrT   rZ   ra   r_   rv   rN   __static_attributes____classcell__)r)   s   @r*   r   r   9   sg   8  
 

 
  

 

P>N,!
L -1*./7/F/F $9J9J *9J (	9J
 -9J 9J 
09Jz 08/F/F $1,1 1 
#	1@ /3#
@#
 ,	#

 #
 
#
T ,@, ",
 , , 
,\ + +r,   r   N)+r   
__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.batchr   $google.cloud.firestore_v1.collectionr   "google.cloud.firestore_v1.documentr   $google.cloud.firestore_v1.field_pathr   google.cloud.firestore_v1.queryr   ,google.cloud.firestore_v1.services.firestorer   r1   7google.cloud.firestore_v1.services.firestore.transportsr   r/   %google.cloud.firestore_v1.transactionr   %google.cloud.firestore_v1.bulk_writerr   r   rH   r,   r*   <module>r      s^   
 # Q Q Q $ ,  E 6 D @ : ; S >@T+Z T+r,   