
    (phj.                       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  SSKJr  SSKJrJr  SS	KJrJr  SS
KJr  SSKJr  \(       a  SSKJr  SSKJ r   SSK!J"r"   " S S\\RF                     5      r$g)zHClasses for representing collections for the Google Cloud Firestore API.    )annotations)TYPE_CHECKINGAnyCallable	GeneratorOptionalTupleUnion)gapic_v1)retry)aggregationdocument)query)transactionvector_query)BaseCollectionReference_item_to_document_ref)QueryResultsList)Watch)DocumentSnapshot)ExplainOptions)StreamGeneratorc                    ^  \ rS rSrSrSU 4S jjrSS jrSS jrSS jrS\	R                  R                  S4         SS jjrS\	R                  R                  S4       SS	 jjrSS
 jrS\	R                  R                  S4SS.         SS jjjrS\	R                  R                  S4SS.         SS jjjrSS jrSrU =r$ )CollectionReference'   a  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                .   > [         [        U ]
  " U0 UD6  g N)superr   __init__)selfpathkwargs	__class__s      W/var/www/html/venv/lib/python3.13/site-packages/google/cloud/firestore_v1/collection.pyr   CollectionReference.__init__A   s    !414B6B    c                .    [         R                  " U 5      $ )zMQuery factory.

Returns:
    :class:`~google.cloud.firestore_v1.query.Query`
)	query_modQueryr    s    r$   _queryCollectionReference._queryD   s     t$$r&   c                J    [         R                  " U R                  5       5      $ )zoAggregationQuery factory.

Returns:
    :class:`~google.cloud.firestore_v1.aggregation_query.AggregationQuery`
)r   AggregationQueryr+   r*   s    r$   _aggregation_query&CollectionReference._aggregation_queryL   s     ++DKKM::r&   c                J    [         R                  " U R                  5       5      $ )z`VectorQuery factory.

Returns:
    :class:`~google.cloud.firestore_v1.vector_query.VectorQuery`
)r   VectorQueryr+   r*   s    r$   _vector_query!CollectionReference._vector_queryT   s     ''66r&   Nc                p    U R                  UUUU5      u  pVUR                  " U40 UD6nUR                  U4$ )am  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$   addCollectionReference.add\   sJ    D  $~~	 
 $**=CFC''55r&   c                   ^  T R                  XU5      u  pET R                  R                  R                  " SUT R                  R                  S.UD6nU 4S jU 5       $ )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metadatac              3  <   >#    U  H  n[        TU5      v   M     g 7fr   )r   ).0ir    s     r$   	<genexpr>5CollectionReference.list_documents.<locals>.<genexpr>   s     A1%dA..s    )_prep_list_documents_client_firestore_apilist_documents_rpc_metadata)r    	page_sizer   r;   rA   r"   iterators   `      r$   rL   "CollectionReference.list_documents   s`    . 33IgN<<..== 
\\//
 

 BAAr&   c                @    U R                  5       R                  U5      $ r   )r+   	_chunkify)r    
chunk_sizes     r$   rR   CollectionReference._chunkify   s    {{}&&z22r&   )explain_optionsc               ^    U R                  X#5      u  pVUb  XFS'   UR                  " SSU0UD6$ )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.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.

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.
rU   r   rH   )_prep_get_or_streamgetr    r   r   r;   rU   r   r"   s          r$   rX   CollectionReference.get   s=    D 00@&(7$%yy;[;F;;r&   c               f    U R                  X#5      u  pVU(       a  XFS'   UR                  " SSU0UD6$ )aP  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.

Returns:
    `StreamGenerator[DocumentSnapshot]`: A generator of the query results.
rU   r   rH   )rW   streamrY   s          r$   r\   CollectionReference.stream   s:    T 00@(7$%||>>v>>r&   c                l    U R                  5       n[        R                  " X![        R                  5      $ )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_snapshotCollectionReference.on_snapshot  s&    4 u0I0IJJr&   rH   )returnNone)rc   zquery_mod.Query)rc   zaggregation.AggregationQuery)rc   zvector_query.VectorQuery)
r9   dictr:   zUnion[str, None]r   retries.Retry | object | Noner;   Union[float, None]rc   zTuple[Any, Any])rN   zUnion[int, None]r   rf   r;   rg   rc   zGenerator[Any, Any, None])rS   int)
r   z$Union[transaction.Transaction, None]r   rf   r;   rg   rU   Optional[ExplainOptions]rc   z"QueryResultsList[DocumentSnapshot])
r   z!Optional[transaction.Transaction]r   rf   r;   zOptional[float]rU   ri   rc   z!StreamGenerator[DocumentSnapshot])r`   r   rc   r   )__name__
__module____qualname____firstlineno____doc__r   r+   r/   r3   r   methodDEFAULTr>   rL   rR   rX   r\   ra   __static_attributes____classcell__)r#   s   @r$   r   r   '   sj   2C%;7 )-/7/F/F&*)6)6 &)6 -	)6
 $)6 
)6Z '+/7/F/F&*	B#B -B $	B
 
#B@3
 =A/7/F/F&*	&< 59&<9&< -&< $	&< 2&< 
,&<T :>/7/F/F#'	.? 59.?6.? -.? !	.? 2.? 
+.?`K Kr&   r   N)%rn   
__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   'google.cloud.firestore_v1.base_documentr   'google.cloud.firestore_v1.query_profiler   *google.cloud.firestore_v1.stream_generatorr   r)   r   rH   r&   r$   <module>r~      sZ    O " R R R $ , ; 8 ? E 1HFJvK1)//B vKr&   