
    Bf~K                        U d Z ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	Z	ddl
mZ 	 ddlZ	 ddlmZ n# e$ r  e	j        d	e           dZY nw xY wn# e$ r dZY nw xY wi Zeeef         ed
<   i Zeeef         ed<   i Zeej        D ]Zeeej        d         <    G d de          Z G d de          Z G d de          Z G d de          Z G d dee          Z  G d de           Z! G d de!          Z" G d de!          Z# G d de!          Z$ G d d e!          Z% G d! d"e           Z& G d# d$e&          Z' G d% d&e'          Z( G d' d(e'          Z) G d) d*e'          Z* G d+ d,e&          Z+ G d- d.e+          Z, G d/ d0e&          Z- G d1 d2e-          Z. G d3 d4e&          Z/ G d5 d6e&          Z0 G d7 d8e&          Z1 G d9 d:e1          Z2 G d; d<e1          Z3 G d= d>e&          Z4 G d? d@e&          Z5 G dA dBe&          Z6 G dC dDe&          Z7 G dE dFe7          Z8 G dG dHe&          Z9 G dI dJe           Z: G dK dLe:          Z; G dM dNe:          Z< G dO dPe:          Z= G dQ dRe:          Z> G dS dTe:          Z? G dU dVe:          Z@ G dW dXe:          ZA G dY dZeA          ZBd[ ZCd\ ZDd] ZEd^ ZFd_ ZGd` ZHda ZIdb ZJdS )czExceptions raised by Google API core & clients.

This module provides base classes for all errors raised by libraries based
on :mod:`google.api_core`, including both HTTP and gRPC clients.
    )absolute_import)unicode_literalsN)Dict)Union)error_details_pb2)
rpc_statuszCPlease install grpcio-status to obtain helpful grpc error messages._HTTP_CODE_TO_EXCEPTION_GRPC_CODE_TO_EXCEPTIONc                       e Zd ZdZdS )GoogleAPIErrorz;Base class for all exceptions raised by Google API Clients.N__name__
__module____qualname____doc__     i/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/google/api_core/exceptions.pyr   r   ;   s        EEDr   r   c                       e Zd ZdZdS )DuplicateCredentialArgsz,Raised when multiple credentials are passed.Nr   r   r   r   r   r   A   s        66Dr   r   c                   >     e Zd ZdZ fdZed             Zd Z xZS )
RetryErrorzRaised when a function has exhausted all of its available retries.

    Args:
        message (str): The exception message.
        cause (Exception): The last exception raised when retrying the
            function.
    c                 t    t          t          |                               |           || _        || _        d S N)superr   __init__message_cause)selfr   cause	__class__s      r   r   zRetryError.__init__P   s3    j$((111r   c                     | j         S )z5The last exception raised when retrying the function.)r   r   s    r   r    zRetryError.causeU   s     {r   c                 B    d                     | j        | j                  S )Nz{}, last exception: {})formatr   r    r#   s    r   __str__zRetryError.__str__Z   s    '..t|TZHHHr   )	r   r   r   r   r   propertyr    r&   __classcell__r!   s   @r   r   r   G   ss             
   XI I I I I I Ir   r   c                       e Zd ZdZd ZdS )_GoogleAPICallErrorMetaz8Metaclass for registering GoogleAPICallError subclasses.c                     t                               | |||          }|j         t                              |j        |           |j         t                              |j        |           |S r   )type__new__coder	   
setdefaultgrpc_status_coder
   )mcsnamebases
class_dictclss        r   r.   z_GoogleAPICallErrorMeta.__new__a   s`    ll3eZ888#..sx===+#..s/CSIII
r   N)r   r   r   r   r.   r   r   r   r+   r+   ^   s)        BB    r   r+   c                        e Zd ZU dZdZeedf         ed<   	 dZ	 d fd	Z	d Z
ed             Zed             Zed	             Zed
             Zed             Zed             Z xZS )GoogleAPICallErrora  Base class for exceptions raised by calling API methods.

    Args:
        message (str): The exception message.
        errors (Sequence[Any]): An optional list of error details.
        details (Sequence[Any]): An optional list of objects defined in google.rpc.error_details.
        response (Union[requests.Request, grpc.Call]): The response or
            gRPC call metadata.
        error_info (Union[error_details_pb2.ErrorInfo, None]): An optional object containing error info
            (google.rpc.error_details.ErrorInfo).
    Nr/   r   c                     t          t          |                               |           || _        	 || _        || _        || _        || _        d S r   )r   r8   r   r   _errors_details	_response_error_info)r   r   errorsdetailsresponse
error_infor!   s         r   r   zGoogleAPICallError.__init__   sO     $''00999)!%r   c                    d                     | j        | j                  }| j        rd                     || j                  }nC| j        r<d | j        D             }|r)d                     |d                    |                    }|S )Nz{} {}c                 p    g | ]3}t          |d           t          |d          "|j         d|j         4S )r/   r   z: )hasattrr/   r   ).0errors     r   
<listcomp>z.GoogleAPICallError.__str__.<locals>.<listcomp>   s^       uf-- 3:%2K2Kz44U]44  r   
)r%   r/   r   r?   r>   join)r   	error_msgr>   s      r   r&   zGoogleAPICallError.__str__   s    NN49dl;;	< 	My$,??II { M !%  
  M 'y$))F:K:K L LIr   c                 ,    | j         r| j         j        ndS )zThe reason of the error.

        Reference:
            https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto#L112

        Returns:
            Union[str, None]: An optional string containing reason of the error.
        N)r=   reasonr#   s    r   rL   zGoogleAPICallError.reason        +/*:Dt&&Dr   c                 ,    | j         r| j         j        ndS )a5  The logical grouping to which the "reason" belongs.

        Reference:
            https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto#L112

        Returns:
            Union[str, None]: An optional string containing a logical grouping to which the "reason" belongs.
        N)r=   domainr#   s    r   rO   zGoogleAPICallError.domain   rM   r   c                 ,    | j         r| j         j        ndS )a.  Additional structured details about this error.

        Reference:
            https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto#L112

        Returns:
            Union[Dict[str, str], None]: An optional object containing structured details about the error.
        N)r=   metadatar#   s    r   rQ   zGoogleAPICallError.metadata   s     -1,<Ft(($Fr   c                 *    t          | j                  S )zuDetailed error information.

        Returns:
            Sequence[Any]: A list of additional error details.
        )listr:   r#   s    r   r>   zGoogleAPICallError.errors   s     DL!!!r   c                 *    t          | j                  S )al  Information contained in google.rpc.status.details.

        Reference:
            https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto
            https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto

        Returns:
            Sequence[Any]: A list of structured objects from error_details.proto
        )rS   r;   r#   s    r   r?   zGoogleAPICallError.details   s     DM"""r   c                     | j         S )zYOptional[Union[requests.Request, grpc.Call]]: The response or
        gRPC call metadata.)r<   r#   s    r   r@   zGoogleAPICallError.response   s     ~r   )r   r   NN)r   r   r   r   r/   r   int__annotations__r1   r   r&   r'   rL   rO   rQ   r>   r?   r@   r(   r)   s   @r   r8   r8   j   s0        
 
 "D%T	
!!! & & & & & &  " 	E 	E X	E 	E 	E X	E 	G 	G X	G " " X" 
# 
# X
#   X    r   r8   )	metaclassc                       e Zd ZdZdS )Redirectionz8Base class for for all redirection (HTTP 3xx) responses.Nr   r   r   r   rZ   rZ      s        BBBBr   rZ   c                   *    e Zd ZdZej        j        ZdS )MovedPermanentlyz7Exception mapping a ``301 Moved Permanently`` response.N)r   r   r   r   httpclientMOVED_PERMANENTLYr/   r   r   r   r\   r\              AA;(DDDr   r\   c                   *    e Zd ZdZej        j        ZdS )NotModifiedz2Exception mapping a ``304 Not Modified`` response.N)r   r   r   r   r]   r^   NOT_MODIFIEDr/   r   r   r   rb   rb              <<;#DDDr   rb   c                   *    e Zd ZdZej        j        ZdS )TemporaryRedirectz8Exception mapping a ``307 Temporary Redirect`` response.N)r   r   r   r   r]   r^   TEMPORARY_REDIRECTr/   r   r   r   rf   rf              BB;)DDDr   rf   c                       e Zd ZdZdZdS )ResumeIncompletezException mapping a ``308 Resume Incomplete`` response.

    .. note:: :attr:`http.client.PERMANENT_REDIRECT` is ``308``, but Google
        APIs differ in their use of this status code.
    i4  N)r   r   r   r   r/   r   r   r   rj   rj      s          DDDr   rj   c                       e Zd ZdZdS )ClientErrorz5Base class for all client error (HTTP 4xx) responses.Nr   r   r   r   rl   rl     s        ????r   rl   c                   *    e Zd ZdZej        j        ZdS )
BadRequestz1Exception mapping a ``400 Bad Request`` response.N)r   r   r   r   r]   r^   BAD_REQUESTr/   r   r   r   rn   rn             ;;;"DDDr   rn   c                   2    e Zd ZdZeej        j        ndZdS )InvalidArgumentzCException mapping a :attr:`grpc.StatusCode.INVALID_ARGUMENT` error.N)r   r   r   r   grpc
StatusCodeINVALID_ARGUMENTr1   r   r   r   rr   rr     s,        MM;?;Kt77QUr   rr   c                   2    e Zd ZdZeej        j        ndZdS )FailedPreconditionzJException mapping a :attr:`grpc.StatusCode.FAILED_PRECONDITION`
    error.N)r   r   r   r   rs   rt   FAILED_PRECONDITIONr1   r   r   r   rw   rw     s3          ?C>Nt::TXr   rw   c                   2    e Zd ZdZeej        j        ndZdS )
OutOfRangez?Exception mapping a :attr:`grpc.StatusCode.OUT_OF_RANGE` error.N)r   r   r   r   rs   rt   OUT_OF_RANGEr1   r   r   r   rz   rz     s+        II7;7Gt33Tr   rz   c                   *    e Zd ZdZej        j        ZdS )Unauthorizedz2Exception mapping a ``401 Unauthorized`` response.N)r   r   r   r   r]   r^   UNAUTHORIZEDr/   r   r   r   r}   r}     rd   r   r}   c                   2    e Zd ZdZeej        j        ndZdS )UnauthenticatedzBException mapping a :attr:`grpc.StatusCode.UNAUTHENTICATED` error.N)r   r   r   r   rs   rt   UNAUTHENTICATEDr1   r   r   r   r   r   %  s,        LL:>:Jt66PTr   r   c                   *    e Zd ZdZej        j        ZdS )	Forbiddenz/Exception mapping a ``403 Forbidden`` response.N)r   r   r   r   r]   r^   	FORBIDDENr/   r   r   r   r   r   +  s        99; DDDr   r   c                   2    e Zd ZdZeej        j        ndZdS )PermissionDeniedzDException mapping a :attr:`grpc.StatusCode.PERMISSION_DENIED` error.N)r   r   r   r   rs   rt   PERMISSION_DENIEDr1   r   r   r   r   r   1  ,        NN<@<Lt88RVr   r   c                   J    e Zd ZdZej        j        Zeej	        j        ndZ
dS )NotFoundz`Exception mapping a ``404 Not Found`` response or a
    :attr:`grpc.StatusCode.NOT_FOUND` error.N)r   r   r   r   r]   r^   	NOT_FOUNDr/   rs   rt   r1   r   r   r   r   r   7  s;        0 0 ; D484Dt00$r   r   c                   *    e Zd ZdZej        j        ZdS )MethodNotAllowedz8Exception mapping a ``405 Method Not Allowed`` response.N)r   r   r   r   r]   r^   METHOD_NOT_ALLOWEDr/   r   r   r   r   r   ?  rh   r   r   c                   *    e Zd ZdZej        j        ZdS )Conflictz.Exception mapping a ``409 Conflict`` response.N)r   r   r   r   r]   r^   CONFLICTr/   r   r   r   r   r   E  s        88;DDDr   r   c                   2    e Zd ZdZeej        j        ndZdS )AlreadyExistszAException mapping a :attr:`grpc.StatusCode.ALREADY_EXISTS` error.N)r   r   r   r   rs   rt   ALREADY_EXISTSr1   r   r   r   r   r   K  s+        KK9=9It55tr   r   c                   2    e Zd ZdZeej        j        ndZdS )Abortedz:Exception mapping a :attr:`grpc.StatusCode.ABORTED` error.N)r   r   r   r   rs   rt   ABORTEDr1   r   r   r   r   r   Q  +        DD262Bt..r   r   c                   *    e Zd ZdZej        j        ZdS )LengthRequiredz5Exception mapping a ``411 Length Required`` response.N)r   r   r   r   r]   r^   LENGTH_REQUIREDr/   r   r   r   r   r   W          ??;&DDDr   r   c                   *    e Zd ZdZej        j        ZdS )PreconditionFailedz9Exception mapping a ``412 Precondition Failed`` response.N)r   r   r   r   r]   r^   PRECONDITION_FAILEDr/   r   r   r   r   r   ]  s        CC;*DDDr   r   c                   *    e Zd ZdZej        j        ZdS )RequestRangeNotSatisfiablezCException mapping a ``416 Request Range Not Satisfiable`` response.N)r   r   r   r   r]   r^   REQUESTED_RANGE_NOT_SATISFIABLEr/   r   r   r   r   r   c  s        MM;6DDDr   r   c                   *    e Zd ZdZej        j        ZdS )TooManyRequestsz7Exception mapping a ``429 Too Many Requests`` response.N)r   r   r   r   r]   r^   TOO_MANY_REQUESTSr/   r   r   r   r   r   i  r`   r   r   c                   2    e Zd ZdZeej        j        ndZdS )ResourceExhaustedzEException mapping a :attr:`grpc.StatusCode.RESOURCE_EXHAUSTED` error.N)r   r   r   r   rs   rt   RESOURCE_EXHAUSTEDr1   r   r   r   r   r   o  s,        OO=A=Mt99SWr   r   c                   6    e Zd ZdZdZeej        j        ndZdS )	Cancelledz<Exception mapping a :attr:`grpc.StatusCode.CANCELLED` error.i  N)	r   r   r   r   r/   rs   rt   	CANCELLEDr1   r   r   r   r   r   u  s2        FF D484Dt00$r   r   c                       e Zd ZdZdS )ServerErrorzBase for 5xx responses.Nr   r   r   r   r   r   ~  s        !!!!r   r   c                   J    e Zd ZdZej        j        Zeej	        j
        ndZdS )InternalServerErrorzlException mapping a ``500 Internal Server Error`` response. or a
    :attr:`grpc.StatusCode.INTERNAL` error.N)r   r   r   r   r]   r^   INTERNAL_SERVER_ERRORr/   rs   rt   INTERNALr1   r   r   r   r   r     s;        / / ;,D373Ct//r   r   c                   2    e Zd ZdZeej        j        ndZdS )Unknownz:Exception mapping a :attr:`grpc.StatusCode.UNKNOWN` error.N)r   r   r   r   rs   rt   UNKNOWNr1   r   r   r   r   r     r   r   r   c                   2    e Zd ZdZeej        j        ndZdS )DataLossz<Exception mapping a :attr:`grpc.StatusCode.DATA_LOSS` error.N)r   r   r   r   rs   rt   	DATA_LOSSr1   r   r   r   r   r     s+        FF484Dt00$r   r   c                   J    e Zd ZdZej        j        Zeej	        j
        ndZdS )MethodNotImplementedzjException mapping a ``501 Not Implemented`` response or a
    :attr:`grpc.StatusCode.UNIMPLEMENTED` error.N)r   r   r   r   r]   r^   NOT_IMPLEMENTEDr/   rs   rt   UNIMPLEMENTEDr1   r   r   r   r   r     s;        4 4 ;&D8<8Ht44dr   r   c                   *    e Zd ZdZej        j        ZdS )
BadGatewayz1Exception mapping a ``502 Bad Gateway`` response.N)r   r   r   r   r]   r^   BAD_GATEWAYr/   r   r   r   r   r     rp   r   r   c                   J    e Zd ZdZej        j        Zeej	        j
        ndZdS )ServiceUnavailablezlException mapping a ``503 Service Unavailable`` response or a
    :attr:`grpc.StatusCode.UNAVAILABLE` error.N)r   r   r   r   r]   r^   SERVICE_UNAVAILABLEr/   rs   rt   UNAVAILABLEr1   r   r   r   r   r     s;        2 2 ;*D6:6Ft22Dr   r   c                   *    e Zd ZdZej        j        ZdS )GatewayTimeoutz5Exception mapping a ``504 Gateway Timeout`` response.N)r   r   r   r   r]   r^   GATEWAY_TIMEOUTr/   r   r   r   r   r     r   r   r   c                   2    e Zd ZdZeej        j        ndZdS )DeadlineExceededzDException mapping a :attr:`grpc.StatusCode.DEADLINE_EXCEEDED` error.N)r   r   r   r   rs   rt   DEADLINE_EXCEEDEDr1   r   r   r   r   r     r   r   r   c                 B    t                               | t                    S )zReturn the exception class for a specific HTTP status code.

    Args:
        status_code (int): The HTTP status code.

    Returns:
        :func:`type`: the appropriate subclass of :class:`GoogleAPICallError`.
    )r	   getr8   status_codes    r   exception_class_for_http_statusr          #&&{4FGGGr   c                 R    t          |           } ||fi |}|j        | |_        |S )a  Create a :class:`GoogleAPICallError` from an HTTP status code.

    Args:
        status_code (int): The HTTP status code.
        message (str): The exception message.
        kwargs: Additional arguments passed to the :class:`GoogleAPICallError`
            constructor.

    Returns:
        GoogleAPICallError: An instance of the appropriate subclass of
            :class:`GoogleAPICallError`.
    )r   r/   r   r   kwargserror_classrF   s        r   from_http_statusr     s<     2+>>KK**6**Ez 
Lr   c                 H   	 |                                  }n# t          $ r dd| j        pdii}Y nw xY w|                    di                               dd          }|                    di                               dd          }|                    di                               dd          }t	          t          d |                    }|r|d         nd	}d
                    | j        j        | j        j	        |          }t          | j        |||| |          }|S )aS  Create a :class:`GoogleAPICallError` from a :class:`requests.Response`.

    Args:
        response (requests.Response): The HTTP response.

    Returns:
        GoogleAPICallError: An instance of the appropriate subclass of
            :class:`GoogleAPICallError`, with the message and errors populated
            from the response.
    rF   r   zunknown errorr>   r   r?   c                 6    |                      dd          dk    S )Nz@type z(type.googleapis.com/google.rpc.ErrorInfo)r   )details    r   <lambda>z$from_http_response.<locals>.<lambda>  s    6::gr229: r   r   Nz{method} {url}: {error})methodurlrF   r>   r?   r@   rA   )json
ValueErrortextr   rS   filterr%   requestr   r   r   r   )r@   payloaderror_messager>   r?   rA   r   	exceptions           r   from_http_responser     sZ   K--// K K KY(HIJK KK,,00OLLM[["%%))(B77Fkk'2&&**9b99G: :	
 	
 J #-6A$J'..&  /  G !  I s    11c                 B    t                               | t                    S )zReturn the exception class for a specific :class:`grpc.StatusCode`.

    Args:
        status_code (grpc.StatusCode): The gRPC status code.

    Returns:
        :func:`type`: the appropriate subclass of :class:`GoogleAPICallError`.
    )r
   r   r8   r   s    r   exception_class_for_grpc_statusr     r   r   c                     t          | t                    rt                              | |           } t	          |           } ||fi |}|j        | |_        |S )a  Create a :class:`GoogleAPICallError` from a :class:`grpc.StatusCode`.

    Args:
        status_code (Union[grpc.StatusCode, int]): The gRPC status code.
        message (str): The exception message.
        kwargs: Additional arguments passed to the :class:`GoogleAPICallError`
            constructor.

    Returns:
        GoogleAPICallError: An instance of the appropriate subclass of
            :class:`GoogleAPICallError`.
    )
isinstancerV   _INT_TO_GRPC_CODEr   r   r1   r   s        r   from_grpc_statusr     sf     +s## F'++KEE1+>>KK**6**E%!,Lr   c                 B    t          | d          ot          | d          S )Nr/   r?   )rD   )rpc_excs    r   _is_informative_grpc_errorr   .  s!    7F##C(C(CCr   c           
         	 t          j        |           }n# t          $ r g d fcY S w xY w|sg d fS t          j        t          j        t          j        t          j        t          j        t          j	        t          j
        t          j        t          j        t          j        g
}d }g }|j        D ]t          t!          fd|                    }t#          |          dk    r}n% |d                     }                    |           |                    |           t)          |t          j                  r|}||fS )Nc                 8                         | j                  S r   )Is
DESCRIPTOR)xr   s    r   r   z+_parse_grpc_error_details.<locals>.<lambda>K  s    VYYq|44 r   r   )r   	from_callNotImplementedErrorr   rn   PreconditionFailureQuotaFailure	ErrorInfo	RetryInfoResourceInfoRequestInfo	DebugInfoHelpLocalizedMessager?   rS   r   lenUnpackappendr   )r   statuspossible_errorsrA   error_detailsmatched_detail_clsinfor   s          @r   _parse_grpc_error_detailsr  2  s[   %g..   4x  4x 	$-&##&%#*O JM.  !4444oFF
 
 !""a''DD(%a(**DMM$T"""d-788 	J*$$s    ))c                 :   t           t          | t           j                  st          |           rLt	          |           \  }}t          |                                 |                                 | f|| |          S t          t          |           | f|           S )a  Create a :class:`GoogleAPICallError` from a :class:`grpc.RpcError`.

    Args:
        rpc_exc (grpc.RpcError): The gRPC error.

    Returns:
        GoogleAPICallError: An instance of the appropriate subclass of
            :class:`GoogleAPICallError`.
    Nr   )r>   r@   )
rs   r   Callr   r  r   r/   r?   r8   str)r   r?   err_infos      r   from_grpc_errorr  Y  s     	Z;;	#G	,	, 	5g>>LLNNOO:
 
 
 	
 "#g,,zGTTTTr   )Kr   
__future__r   r   http.clientr]   typingr   r   warnings
google.rpcr   rs   grpc_statusr   ImportErrorwarnImportWarningr	   rV   	ExceptionrW   r
   r   rt   r   valuer   r   r   r-   r+   r8   rZ   r\   rb   rf   rj   rl   rn   rr   rw   rz   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   r   r   r   r  r  r   r   r   <module>r     s$	     ' & & & & & ' ' ' ' ' '                  ( ( ( ( ( (KKK*******   Q	
 	
 	
 


    DDD
 13 c9n- 2 2 202 c9n- 2 2 2
  _ * *()!'!*%%	 	 	 	 	Y 	 	 		 	 	 	 	n 	 	 	I I I I I I I I.	 	 	 	 	d 	 	 	u u u u u3J u u u upC C C C C$ C C C) ) ) ) ){ ) ) )$ $ $ $ $+ $ $ $* * * * * * * *    {   @ @ @ @ @$ @ @ @# # # # # # # #V V V V Vj V V VY Y Y Y Y Y Y YR R R R R R R R$ $ $ $ $; $ $ $U U U U Ul U U U! ! ! ! ! ! ! !W W W W Wy W W WO O O O O{ O O O* * * * *{ * * *         {      T T T T TH T T TM M M M Mh M M M' ' ' ' '[ ' ' '+ + + + + + + +7 7 7 7 7 7 7 7) ) ) ) )k ) ) )X X X X X X X XO O O O O O O O" " " " "$ " " "N N N N N+ N N NM M M M Mk M M MO O O O O{ O O OS S S S S; S S S# # # # # # # #Q Q Q Q Q Q Q Q' ' ' ' '[ ' ' 'W W W W W~ W W W	H 	H 	H  ,+ + +\	H 	H 	H  4D D D$% $% $%NU U U U Us1   A 7 A AA AA A A 