
    'wf~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 i Zeeef   ed
<   i Zeeef   ed<   i Ze#ej0                  D ]  Zeeej4                  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 ZJy# e$ r  e	j                   d	e       dZY $w xY w# e$ r dZY 2w xY w)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y)GoogleAPIErrorz;Base class for all exceptions raised by Google API Clients.N__name__
__module____qualname____doc__     n/home/panchajanya/Development/work/volatility3/venv/lib/python3.12/site-packages/google/api_core/exceptions.pyr   r   ;   s    Er   r   c                       e Zd ZdZy)DuplicateCredentialArgsz,Raised when multiple credentials are passed.Nr   r   r   r   r   r   A   s    6r   r   c                   8     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                 H    t         t        |   |       || _        || _        y N)superr   __init__message_cause)selfr   cause	__class__s      r   r   zRetryError.__init__P   s     j$(1r   c                     | j                   S )z5The last exception raised when retrying the function.)r   r   s    r   r    zRetryError.causeU   s     {{r   c                 N    dj                  | j                  | j                        S )Nz{}, last exception: {})formatr   r    r#   s    r   __str__zRetryError.__str__Z   s    '..t||TZZHHr   )	r   r   r   r   r   propertyr    r&   __classcell__r!   s   @r   r   r   G   s'    
  Ir   r   c                       e Zd ZdZd Zy)_GoogleAPICallErrorMetaz8Metaclass for registering GoogleAPICallError subclasses.c                     t         j                  | |||      }|j                   t        j	                  |j                  |       |j
                   t        j	                  |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88#..sxx=+#..s/C/CSI
r   N)r   r   r   r   r.   r   r   r   r+   r+   ^   s
    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/   c                 t    t         t        |   |       || _        	 || _        || _        || _        || _        y r   )r   r8   r   r   _errors_details	_response_error_info)r   r   errorsdetailsresponse
error_infor!   s         r   r   zGoogleAPICallError.__init__   s:     $09)!%r   c                    dj                  | j                  | j                        }| j                  rdj                  || j                        }|S | j                  rm| j                  D cg c]5  }t        |d      r't        |d      r|j                   d|j                   7 }}|r!dj                  |dj                  |            }|S c c}w )Nz{} {}r/   r   z: 
)r%   r/   r   r?   r>   hasattrjoin)r   	error_msgerrorr>   s       r   r&   zGoogleAPICallError.__str__   s    NN499dll;	<<y$,,?I  {{ "&uf-'%2K zzl"U]]O4 
  'y$))F:K LIs   +:Cc                 J    | j                   r| j                   j                  S 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   rI   zGoogleAPICallError.reason   #     +/*:*:t&&DDr   c                 J    | j                   r| j                   j                  S 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   rL   zGoogleAPICallError.domain   rJ   r   c                 J    | j                   r| j                   j                  S 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   rN   zGoogleAPICallError.metadata   s#     -1,<,<t((F$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     DLL!!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
        )rP   r;   r#   s    r   r?   zGoogleAPICallError.details   s     DMM""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'   rI   rL   rN   r>   r?   r@   r(   r)   s   @r   r8   r8   j   s    
 "D%T	
! &" 	E 	E 	E 	E 	G 	G " " 
# 
#  r   r8   )	metaclassc                       e Zd ZdZy)Redirectionz8Base class for for all redirection (HTTP 3xx) responses.Nr   r   r   r   rW   rW      s    Br   rW   c                   <    e Zd ZdZej
                  j                  Zy)MovedPermanentlyz7Exception mapping a ``301 Moved Permanently`` response.N)r   r   r   r   httpclientMOVED_PERMANENTLYr/   r   r   r   rY   rY          A;;((Dr   rY   c                   <    e Zd ZdZej
                  j                  Zy)NotModifiedz2Exception mapping a ``304 Not Modified`` response.N)r   r   r   r   rZ   r[   NOT_MODIFIEDr/   r   r   r   r_   r_          <;;##Dr   r_   c                   <    e Zd ZdZej
                  j                  Zy)TemporaryRedirectz8Exception mapping a ``307 Temporary Redirect`` response.N)r   r   r   r   rZ   r[   TEMPORARY_REDIRECTr/   r   r   r   rc   rc          B;;))Dr   rc   c                       e Zd ZdZdZy)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   rg   rg      s     Dr   rg   c                       e Zd ZdZy)ClientErrorz5Base class for all client error (HTTP 4xx) responses.Nr   r   r   r   ri   ri     s    ?r   ri   c                   <    e Zd ZdZej
                  j                  Zy)
BadRequestz1Exception mapping a ``400 Bad Request`` response.N)r   r   r   r   rZ   r[   BAD_REQUESTr/   r   r   r   rk   rk         ;;;""Dr   rk   c                   F    e Zd ZdZeej
                  j                  ZydZy)InvalidArgumentzCException mapping a :attr:`grpc.StatusCode.INVALID_ARGUMENT` error.N)r   r   r   r   grpc
StatusCodeINVALID_ARGUMENTr1   r   r   r   ro   ro     s     M;?;Kt77QUr   ro   c                   F    e Zd ZdZeej
                  j                  ZydZy)FailedPreconditionzJException mapping a :attr:`grpc.StatusCode.FAILED_PRECONDITION`
    error.N)r   r   r   r   rp   rq   FAILED_PRECONDITIONr1   r   r   r   rt   rt     s%     ?C>Nt::TXr   rt   c                   F    e Zd ZdZeej
                  j                  ZydZy)
OutOfRangez?Exception mapping a :attr:`grpc.StatusCode.OUT_OF_RANGE` error.N)r   r   r   r   rp   rq   OUT_OF_RANGEr1   r   r   r   rw   rw     s    I7;7Gt33Tr   rw   c                   <    e Zd ZdZej
                  j                  Zy)Unauthorizedz2Exception mapping a ``401 Unauthorized`` response.N)r   r   r   r   rZ   r[   UNAUTHORIZEDr/   r   r   r   rz   rz     ra   r   rz   c                   F    e Zd ZdZeej
                  j                  ZydZy)UnauthenticatedzBException mapping a :attr:`grpc.StatusCode.UNAUTHENTICATED` error.N)r   r   r   r   rp   rq   UNAUTHENTICATEDr1   r   r   r   r}   r}   %  s     L:>:Jt66PTr   r}   c                   <    e Zd ZdZej
                  j                  Zy)	Forbiddenz/Exception mapping a ``403 Forbidden`` response.N)r   r   r   r   rZ   r[   	FORBIDDENr/   r   r   r   r   r   +  s    9;;  Dr   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)PermissionDeniedzDException mapping a :attr:`grpc.StatusCode.PERMISSION_DENIED` error.N)r   r   r   r   rp   rq   PERMISSION_DENIEDr1   r   r   r   r   r   1       N<@<Lt88RVr   r   c                   r    e Zd ZdZej
                  j                  Zeej                  j                  Z
ydZ
y)NotFoundz`Exception mapping a ``404 Not Found`` response or a
    :attr:`grpc.StatusCode.NOT_FOUND` error.N)r   r   r   r   rZ   r[   	NOT_FOUNDr/   rp   rq   r1   r   r   r   r   r   7  s2    0 ;;  D484Dt00$r   r   c                   <    e Zd ZdZej
                  j                  Zy)MethodNotAllowedz8Exception mapping a ``405 Method Not Allowed`` response.N)r   r   r   r   rZ   r[   METHOD_NOT_ALLOWEDr/   r   r   r   r   r   ?  re   r   r   c                   <    e Zd ZdZej
                  j                  Zy)Conflictz.Exception mapping a ``409 Conflict`` response.N)r   r   r   r   rZ   r[   CONFLICTr/   r   r   r   r   r   E  s    8;;Dr   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)AlreadyExistszAException mapping a :attr:`grpc.StatusCode.ALREADY_EXISTS` error.N)r   r   r   r   rp   rq   ALREADY_EXISTSr1   r   r   r   r   r   K  s    K9=9It55tr   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)Abortedz:Exception mapping a :attr:`grpc.StatusCode.ABORTED` error.N)r   r   r   r   rp   rq   ABORTEDr1   r   r   r   r   r   Q      D262Bt..r   r   c                   <    e Zd ZdZej
                  j                  Zy)LengthRequiredz5Exception mapping a ``411 Length Required`` response.N)r   r   r   r   rZ   r[   LENGTH_REQUIREDr/   r   r   r   r   r   W      ?;;&&Dr   r   c                   <    e Zd ZdZej
                  j                  Zy)PreconditionFailedz9Exception mapping a ``412 Precondition Failed`` response.N)r   r   r   r   rZ   r[   PRECONDITION_FAILEDr/   r   r   r   r   r   ]  s    C;;**Dr   r   c                   <    e Zd ZdZej
                  j                  Zy)RequestRangeNotSatisfiablezCException mapping a ``416 Request Range Not Satisfiable`` response.N)r   r   r   r   rZ   r[   REQUESTED_RANGE_NOT_SATISFIABLEr/   r   r   r   r   r   c  s    M;;66Dr   r   c                   <    e Zd ZdZej
                  j                  Zy)TooManyRequestsz7Exception mapping a ``429 Too Many Requests`` response.N)r   r   r   r   rZ   r[   TOO_MANY_REQUESTSr/   r   r   r   r   r   i  r]   r   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)ResourceExhaustedzEException mapping a :attr:`grpc.StatusCode.RESOURCE_EXHAUSTED` error.N)r   r   r   r   rp   rq   RESOURCE_EXHAUSTEDr1   r   r   r   r   r   o  s     O=A=Mt99SWr   r   c                   J    e Zd ZdZdZeej                  j                  ZydZy)	Cancelledz<Exception mapping a :attr:`grpc.StatusCode.CANCELLED` error.i  N)	r   r   r   r   r/   rp   rq   	CANCELLEDr1   r   r   r   r   r   u  s&    F D484Dt00$r   r   c                       e Zd ZdZy)ServerErrorzBase for 5xx responses.Nr   r   r   r   r   r   ~  s    !r   r   c                   r    e Zd ZdZej
                  j                  Zeej                  j                  ZydZy)InternalServerErrorzlException mapping a ``500 Internal Server Error`` response. or a
    :attr:`grpc.StatusCode.INTERNAL` error.N)r   r   r   r   rZ   r[   INTERNAL_SERVER_ERRORr/   rp   rq   INTERNALr1   r   r   r   r   r     s2    / ;;,,D373Ct//r   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)Unknownz:Exception mapping a :attr:`grpc.StatusCode.UNKNOWN` error.N)r   r   r   r   rp   rq   UNKNOWNr1   r   r   r   r   r     r   r   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)DataLossz<Exception mapping a :attr:`grpc.StatusCode.DATA_LOSS` error.N)r   r   r   r   rp   rq   	DATA_LOSSr1   r   r   r   r   r     s    F484Dt00$r   r   c                   r    e Zd ZdZej
                  j                  Zeej                  j                  ZydZy)MethodNotImplementedzjException mapping a ``501 Not Implemented`` response or a
    :attr:`grpc.StatusCode.UNIMPLEMENTED` error.N)r   r   r   r   rZ   r[   NOT_IMPLEMENTEDr/   rp   rq   UNIMPLEMENTEDr1   r   r   r   r   r     s2    4 ;;&&D8<8Ht44dr   r   c                   <    e Zd ZdZej
                  j                  Zy)
BadGatewayz1Exception mapping a ``502 Bad Gateway`` response.N)r   r   r   r   rZ   r[   BAD_GATEWAYr/   r   r   r   r   r     rm   r   r   c                   r    e Zd ZdZej
                  j                  Zeej                  j                  ZydZy)ServiceUnavailablezlException mapping a ``503 Service Unavailable`` response or a
    :attr:`grpc.StatusCode.UNAVAILABLE` error.N)r   r   r   r   rZ   r[   SERVICE_UNAVAILABLEr/   rp   rq   UNAVAILABLEr1   r   r   r   r   r     s2    2 ;;**D6:6Ft22Dr   r   c                   <    e Zd ZdZej
                  j                  Zy)GatewayTimeoutz5Exception mapping a ``504 Gateway Timeout`` response.N)r   r   r   r   rZ   r[   GATEWAY_TIMEOUTr/   r   r   r   r   r     r   r   r   c                   F    e Zd ZdZeej
                  j                  ZydZy)DeadlineExceededzDException mapping a :attr:`grpc.StatusCode.DEADLINE_EXCEEDED` error.N)r   r   r   r   rp   rq   DEADLINE_EXCEEDEDr1   r   r   r   r   r     r   r   r   c                 6    t         j                  | 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Gr   c                 T    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_classrG   s        r   from_http_statusr     s3     2+>K*6*Ezz 
Lr   c                 &   	 | j                         }|j                  di       j                  dd      }|j                  di       j                  dd      }|j                  di       j                  dd      }t	        t        d |            }|r|d   nd	}d
j                  | j                  j                  | j                  j                  |      }t        | j                  |||| |      }|S # t        $ r dd| j                  xs dii}Y w xY w)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.
    rG   r   zunknown errorr>   r   r?   c                 ,    | j                  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9: r   r   Nz{method} {url}: {error})methodurlrG   r>   r?   r@   rA   )json
ValueErrortextr   rP   filterr%   requestr   r   r   r   )r@   payloaderror_messager>   r?   rA   r   	exceptions           r   from_http_responser     s"   K--/ KK,00OLM[["%))(B7Fkk'2&**9b9G:	
J #-A$J'..&&   / G !I =  KY(HIJKs   C0 0DDc                 6    t         j                  | 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        j                  | |       } 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`.
    )
isinstancerS   _INT_TO_GRPC_CODEr   r   r1   r   s        r   from_grpc_statusr     sR     +s#'++KE1+>K*6*E%!,Lr   c                 6    t        | d      xr t        | d      S )Nr/   r?   )rD   )rpc_excs    r   _is_informative_grpc_errorr   .  s    7F#C(CCr   c           
         	 t        j                  |       }|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        t!        fd|            }t#        |      dk(  r}n |d          }j%                  |       |j'                  |       t)        |t        j                        ss|}v ||fS # t        $ r g d fcY S w xY w)Nc                 :    j                  | j                        S r   )Is
DESCRIPTOR)xr   s    r   r   z+_parse_grpc_error_details.<locals>.<lambda>K  s    VYYq||4 r   r   )r   	from_callNotImplementedErrorr   rk   PreconditionFailureQuotaFailure	ErrorInfo	RetryInfoResourceInfoRequestInfo	DebugInfoHelpLocalizedMessager?   rP   r   lenUnpackappendr   )r   statuspossible_errorsrA   error_detailsmatched_detail_clsinfor   s          @r   _parse_grpc_error_detailsr  2  s;   %%g. 4x 	$$--&&####&&%%##**O JM.. !4oF
 !"a'D(%a(*DMM$T"d-778J *$$C  4xs   E EEc                     t         t        | t         j                        st        |       r<t	        |       \  }}t        | j                         | j                         | 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`.
    r   )r>   r@   )
rp   r   Callr   r  r   r/   r?   r8   str)r   r?   err_infos      r   from_grpc_errorr  Y  ss     	Z;	#G	,5g>LLNOO:
 	
 "#g,zGTTr   )Kr   
__future__r   r   http.clientrZ   typingr   r   warnings
google.rpcr   rp   grpc_statusr   ImportErrorwarnImportWarningr	   rS   	ExceptionrT   r
   r   rq   r   valuer   r   r   r-   r+   r8   rW   rY   r_   rc   rg   ri   rk   ro   rt   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   <module>r     s   ' '     (* 13 c9n- 202 c9n- 2
  __ *()!''!*%*	Y 		n 	I I.	d 	u3J upC$ C){ )$+ $* *{ @$ @# #Vj VY YR R$; $Ul U! !Wy WO{ O*{ * {  TH TMh M'[ '+ +7 7)k )X XO O"$ "N+ NMk MO{ OS; S# #Q Q'[ 'W~ W	H,+\	H4D$%NUk  Q	
 
  Ds.   I H= =II II I)(I)