a
    |f
                     @   s   d Z zJddlmZ e  Zej D ]$\ZZ	e
ds&eevr&e	e e< q&W n eyh   edY n0 ddlmZ dZddd	ZG d
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.
    )	firestore_zrFailed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.)_utilsZ
_firestoreNc                 C   s   t | ttj}| S )a  Returns a client that can be used to interact with Google Cloud Firestore.

    Args:
      app: An App instance (optional).

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

    Raises:
      ValueError: 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://googlecloudplatform.github.io/google-cloud-python/latest          /firestore/client.html
    )r   Zget_app_service_FIRESTORE_ATTRIBUTE_FirestoreClientfrom_appget)appZ	fs_client r
   RD:\Projects\storyit_web\backend\venv\Lib\site-packages\firebase_admin/firestore.pyclient%   s    r   c                   @   s,   e Zd ZdZdd Zdd Zedd ZdS )	r   z/Holds a Google Cloud Firestore client instance.c                 C   s   t j||d| _d S )N)credentialsproject)r   ZClient_client)selfr   r   r
   r
   r   __init__<   s    z_FirestoreClient.__init__c                 C   s   | j S )N)r   )r   r
   r
   r   r   ?   s    z_FirestoreClient.getc                 C   s&   |j  }|j}|stdt||S )z5Creates a new _FirestoreClient for the specified app.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.)Z
credentialget_credentialZ
project_id
ValueErrorr   )clsr	   r   r   r
   r
   r   r   B   s    
z_FirestoreClient.from_appN)__name__
__module____qualname____doc__r   r   classmethodr   r
   r
   r
   r   r   9   s
   r   )N)r   Zgoogle.cloudr   globalskeysexisting__dict__itemskeyvalue
startswithImportErrorZfirebase_adminr   r   r   r   r
   r
   r
   r   <module>   s   

