
    h                    v   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                                            Ze
j                                        D ]+\  ZZe                    d          seevre e            e<   ,n# e$ rZ ed	          ed
Z[ww xY wdZdddZ G d d          Zd
S )zCloud Firestore module.

This module contains utilities for 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appOptional[App]database_idOptional[str]returnfirestore.Clientc                    |(t          |t                    st          d| d          t          j        | t
          t                    }|                    |          S )a,  Returns a 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: A `Firestore 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 Client: https://cloud.google.com/python/docs/reference/firestore/latest/        google.cloud.firestore_v1.client.Client
    Nzdatabase_id "z" must be a string or None.)
isinstancestr
ValueErrorr   get_app_service_FIRESTORE_ATTRIBUTE_FirestoreService
get_client)r   r   
fs_services      \/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/firebase_admin/firestore.pyclientr   )   s]    * z+s'C'CQQQQRRR'-ACTUUJ  ---    c                  "    e Zd ZdZddZdd
ZdS )r   z9Service that maintains a collection of firestore clients.r   r   r   Nonec                "    || _         i | _        d S )N)_app_clients)selfr   s     r   __init__z_FirestoreService.__init__G   s    	57r   r   r   r   c                    |pt           }|| j        vr\| j        j                                        }| j        j        }|st          d          t          j        |||          }|| j        |<   | j        |         S )zDCreates a 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   Client)r#   r   r&   r'   	fs_clients        r   r   z_FirestoreService.get_clientK   s    !5%5dm++).==??Ki*G B AB B B
 "(';P P PI)2DM+&}[))r   N)r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r$   r    r   r   r   r   D   sB        CC8 8 8 8* * * * * *r   r   )NN)r   r   r   r   r   r   )r1   
__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   r   r   r2   r   r   <module>rB      s    # " " " " " ! ! ! ! ! ! ! !       ! ! ! ! ! !	T&&&&&&FFFFFFwyy~~H(..00 # #
U~~c"" 	#s(':':"GGIIcN#  T T T
+ H I INSTT
 $ . . . . .6* * * * * * * * * *s   A-B B"BB"