
    Ѯh                    b   U d Z ddlmZ ddlmZmZ ddlmZ ddlmZ 	 ddl	m
Z
 ddlmZ  e       j                         Ze
j                   j#                         D ]&  \  ZZej)                  d      reevse e       e<   ( 	 dZded<   dddZ G d d      Zy
# e$ rZ ed	      ed
Z[ww xY w)zCloud Firestore Async module.

This module contains utilities for asynchronusly accessing the Google Cloud Firestore databases
associated with Firebase apps. This requires the ``google-cloud-firestore`` Python module.
    )annotations)OptionalDict)App)_utils)	firestore)DEFAULT_DATABASE_zrFailed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.N_firestore_asyncstr_FIRESTORE_ASYNC_ATTRIBUTEc                    |t        |t              st        d| d      t        j                  | t
        t              }|j                  |      S )aP  Returns an async client that can be used to interact with Google Cloud Firestore.

    Args:
        app: An App instance (optional).
        database_id: The database ID of the Google Cloud Firestore database to be used.
            Defaults to the default Firestore database ID if not specified or an empty string
            (optional).

    Returns:
        google.cloud.firestore.Firestore_Async: A `Firestore Async Client`_.

    Raises:
        ValueError: If the specified database ID is not a valid string, or if a project ID is not
            specified either via options, credentials or environment variables, or if the specified
            project ID is not a valid string.

    .. _Firestore Async Client: https://cloud.google.com/python/docs/reference/firestore/latest/        google.cloud.firestore_v1.async_client.AsyncClient
    zdatabase_id "z" must be a string or None.)
isinstancer   
ValueErrorr   get_app_servicer   _FirestoreAsyncService
get_client)appdatabase_id
fs_services      p/home/www/academy-backend.kofcorporation.com/venv/lib/python3.12/site-packages/firebase_admin/firestore_async.pyclientr   )   sO    * z+s'C=5PQRR''-GI_`J  --    c                       e Zd ZdZddZddZy)r   z?Service that maintains a collection of firestore async clients.c                     || _         i | _        y )N)_app_clients)selfr   s     r   __init__z_FirestoreAsyncService.__init__G   s    	:<r   c                ,   |xs t         }|| j                  vrn| j                  j                  j	                         }| j                  j
                  }|st        d      t        j                  |||      }|| j                  |<   | j                  |   S )zKCreates an async client based on the database_id. These clients are cached.zProject ID is required to access Firestore. Either set the projectId option, or use service account credentials. Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable.)credentialsprojectdatabase)	r	   r   r   
credentialget_credential
project_idr   r   AsyncClient)r   r   r!   r"   	fs_clients        r   r   z!_FirestoreAsyncService.get_clientK   s    !5%5dmm+))..==?Kii**G AB B
 "--';PI)2DMM+&}}[))r   N)r   r   returnNone)r   Optional[str]r)   firestore.AsyncClient)__name__
__module____qualname____doc__r   r    r   r   r   r   D   s    I=*r   r   )NN)r   zOptional[App]r   r+   r)   r,   )r0   
__future__r   typingr   r   firebase_adminr   r   google.cloudr   %google.cloud.firestore_v1.base_clientr	   globalskeysexisting__dict__itemskeyvalue
startswithImportErrorerrorr   __annotations__r   r   r1   r   r   <module>rB      s    # !  !	T&Fy~~H((..0 #
U~~c"s(':"GIcN# #5 C 4.6* *G  T
 H INSTTs$   AB 2B 7B B. 	B))B.