U
    
ڲg7!                     @   sX  d Z dZdZdZdZdZdZdZdZd	Z	d
Z
dZdZdZdZdZdZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZG d%d& d&eZG d'd( d(eZG d)d* d*eZG d+d, d,eZG d-d. d.eZ G d/d0 d0eZ!G d1d2 d2eZ"d3S )4a9  Firebase Exceptions module.

This module defines the base types for exceptions and the platform-wide error codes as outlined in
https://cloud.google.com/apis/design/errors.

:class:`FirebaseError` is the parent class of all exceptions raised by the Admin SDK. It contains
the ``code``, ``http_response`` and ``cause`` properties common to all Firebase exception types.
Each exception also carries a message that outlines what went wrong. This can be logged for
audit or debugging purposes.

When calling an Admin SDK API, developers can catch the parent ``FirebaseError`` and
inspect its ``code`` to implement fine-grained error handling. Alternatively, developers can
catch one or more subtypes of ``FirebaseError``. Under normal conditions, any given API can raise
only a small subset of the available exception subtypes. However, the SDK also exposes rare error
conditions like connection timeouts and other I/O errors as instances of ``FirebaseError``.
Therefore it is always a good idea to have a handler specified for ``FirebaseError``, after all the
subtype error handlers.
INVALID_ARGUMENTFAILED_PRECONDITIONOUT_OF_RANGEUNAUTHENTICATEDPERMISSION_DENIED	NOT_FOUNDCONFLICTABORTEDALREADY_EXISTSRESOURCE_EXHAUSTED	CANCELLED	DATA_LOSSUNKNOWNINTERNALUNAVAILABLEDEADLINE_EXCEEDEDc                   @   s>   e Zd ZdZdddZedd Zedd Zed	d
 ZdS )FirebaseErrora  Base class for all errors raised by the Admin SDK.

    Args:
        code: A string error code that represents the type of the exception. Possible error
            codes are defined in https://cloud.google.com/apis/design/errors#handling_errors.
        message: A human-readable error message string.
        cause: The exception that caused this error (optional).
        http_response: If this error was caused by an HTTP error response, this property is
            set to the ``requests.Response`` object that represents the HTTP response (optional).
            See https://2.python-requests.org/en/master/api/#requests.Response for details of
            this object.
    Nc                 C   s"   t | | || _|| _|| _d S N)	Exception__init___code_cause_http_response)selfcodemessagecausehttp_response r   =/tmp/pip-unpacked-wheel-p0r7i5ii/firebase_admin/exceptions.pyr   b   s    zFirebaseError.__init__c                 C   s   | j S r   )r   r   r   r   r   r   h   s    zFirebaseError.codec                 C   s   | j S r   )r   r   r   r   r   r   l   s    zFirebaseError.causec                 C   s   | j S r   )r   r   r   r   r   r   p   s    zFirebaseError.http_response)NN)	__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r   T   s   


r   c                   @   s   e Zd ZdZdddZdS )InvalidArgumentErrorz%Client specified an invalid argument.Nc                 C   s   t | t||| d S r   )r   r   r   r   r   r   r   r   r   r   r   x   s    zInvalidArgumentError.__init__)NNr    r!   r"   r#   r   r   r   r   r   r%   u   s   r%   c                   @   s   e Zd ZdZdddZdS )FailedPreconditionErrorzdRequest can not be executed in the current system state, such as deleting a non-empty
    directory.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    z FailedPreconditionError.__init__)NNr'   r   r   r   r   r(   |   s   r(   c                   @   s   e Zd ZdZdddZdS )OutOfRangeErrorz"Client specified an invalid range.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zOutOfRangeError.__init__)NNr'   r   r   r   r   r)      s   r)   c                   @   s   e Zd ZdZdddZdS )UnauthenticatedErrorzJRequest not authenticated due to missing, invalid, or expired OAuth token.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zUnauthenticatedError.__init__)NNr'   r   r   r   r   r*      s   r*   c                   @   s   e Zd ZdZdddZdS )PermissionDeniedErrorzClient does not have sufficient permission.

    This can happen because the OAuth token does not have the right scopes, the client doesn't
    have permission, or the API has not been enabled for the client project.
    Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zPermissionDeniedError.__init__)NNr'   r   r   r   r   r+      s   r+   c                   @   s   e Zd ZdZdddZdS )NotFoundErrorzoA specified resource is not found, or the request is rejected by undisclosed reasons, such
    as whitelisting.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zNotFoundError.__init__)NNr'   r   r   r   r   r,      s   r,   c                   @   s   e Zd ZdZdddZdS )ConflictError9Concurrency conflict, such as read-modify-write conflict.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zConflictError.__init__)NNr'   r   r   r   r   r-      s   r-   c                   @   s   e Zd ZdZdddZdS )AbortedErrorr.   Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zAbortedError.__init__)NNr'   r   r   r   r   r/      s   r/   c                   @   s   e Zd ZdZdddZdS )AlreadyExistsErrorz:The resource that a client tried to create already exists.Nc                 C   s   t | t||| d S r   )r   r   r	   r&   r   r   r   r      s    zAlreadyExistsError.__init__)NNr'   r   r   r   r   r0      s   r0   c                   @   s   e Zd ZdZdddZdS )ResourceExhaustedErrorz7Either out of resource quota or reaching rate limiting.Nc                 C   s   t | t||| d S r   )r   r   r
   r&   r   r   r   r      s    zResourceExhaustedError.__init__)NNr'   r   r   r   r   r1      s   r1   c                   @   s   e Zd ZdZdddZdS )CancelledErrorz Request cancelled by the client.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zCancelledError.__init__)NNr'   r   r   r   r   r2      s   r2   c                   @   s   e Zd ZdZdddZdS )DataLossErrorz+Unrecoverable data loss or data corruption.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zDataLossError.__init__)NNr'   r   r   r   r   r3      s   r3   c                   @   s   e Zd ZdZdddZdS )UnknownErrorzUnknown server error.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zUnknownError.__init__)NNr'   r   r   r   r   r4      s   r4   c                   @   s   e Zd ZdZdddZdS )InternalErrorzInternal server error.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zInternalError.__init__)NNr'   r   r   r   r   r5      s   r5   c                   @   s   e Zd ZdZdddZdS )UnavailableErrorz2Service unavailable. Typically the server is down.Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zUnavailableError.__init__)NNr'   r   r   r   r   r6      s   r6   c                   @   s   e Zd ZdZdddZdS )DeadlineExceededErrora  Request deadline exceeded.

    This will happen only if the caller sets a deadline that is shorter than the method's
    default deadline (i.e. requested deadline is not enough for the server to process the
    request) and the request did not finish within the deadline.
    Nc                 C   s   t | t||| d S r   )r   r   r   r&   r   r   r   r      s    zDeadlineExceededError.__init__)NNr'   r   r   r   r   r7      s   r7   N)#r#   r   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r%   r(   r)   r*   r+   r,   r-   r/   r0   r1   r2   r3   r4   r5   r6   r7   r   r   r   r   <module>   sB   !