U
    
ڲge                     @   s   U d Z ddlmZ ddlmZmZ ddlmZ zJddlm	Z	 e
  Ze	j D ]$\ZZedsPeekrPee
 e< qPW n ek
r   edY nX dZeed	< dee	jdddZG dd dZd
S )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.
    )Type)App_utils)Base)	firestore_zrFailed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.Z_firestore_async_FIRESTORE_ASYNC_ATTRIBUTENappreturnc                 C   s   t | ttj}| S )a  Returns an async client that can be used to interact with Google Cloud Firestore.

    Args:
      app: An App instance (optional).

    Returns:
      google.cloud.firestore.Firestore_Async: A `Firestore Async 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 Async Client: https://googleapis.dev/python/firestore/latest/client.html
    )r   Zget_app_servicer   _FirestoreAsyncClientfrom_appget)r
   Z	fs_client r   B/tmp/pip-unpacked-wheel-p0r7i5ii/firebase_admin/firestore_async.pyclient*   s      r   c                   @   sJ   e Zd ZdZee eddddZej	dddZ
eed d	d
dZdS )r   z5Holds a Google Cloud Firestore Async Client instance.N)credentialsprojectr   c                 C   s   t j||d| _d S )N)r   r   )r   AsyncClient_client)selfr   r   r   r   r   __init__A   s    z_FirestoreAsyncClient.__init__)r   c                 C   s   | j S )N)r   )r   r   r   r   r   D   s    z_FirestoreAsyncClient.getr	   c                 C   s&   |j  }|j}|stdt||S )z:Creates a new _FirestoreAsyncClient 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   G   s    
z_FirestoreAsyncClient.from_app)__name__
__module____qualname____doc__r   r   strr   r   r   r   classmethodr   r   r   r   r   r   r   >   s
   r   )N)r   typingr   Zfirebase_adminr   r   Zfirebase_admin.credentialsr   Zgoogle.cloudr   globalskeysexisting__dict__itemskeyvalue
startswithImportErrorr   r   __annotations__r   r   r   r   r   r   r   <module>   s   
