
                            S r SSKrSSKJrJrJr  SSKrSSKJr  Sr	 " S S\
5      r " S S	\5      r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S  S!\5      r " S" S#\5      r  S+S$\\\4   S%\\\4   S&\\\\4      S'\\   S(\\   S)\4S* jjrg),z0Utility functions and classes for BQ CLI errors.    N)DictListOptional)
bq_logginga  BQ CLI no longer supports the deprecated P12 format by default. To migrate to the new JSON service account key format, follow the steps in https://cloud.google.com/iam/docs/keys-create-delete#creating. To force BQ CLI to recognize P12 keys, re-run the command with --nouse_google_auth.c                       \ rS rSrSrSrg)BigqueryError   z$Class to represent a BigQuery error. N__name__
__module____qualname____firstlineno____doc____static_attributes__r
       platform/bq/utils/bq_error.pyr   r          ,r   r   c                       \ rS rSrSrSrg)BigqueryTypeError   z7A BQ CLI type error that should not show a stack trace.r
   Nr   r
   r   r   r   r      s    ?r   r   c                       \ rS rSrSrSrg)BigqueryCommunicationError   z$Error communicating with the server.r
   Nr   r
   r   r   r   r      r   r   r   c                       \ rS rSrSrSrg)BigqueryInterfaceError    z-Response from server missing required fields.r
   Nr   r
   r   r   r   r       s    5r   r   c            
       l   ^  \ rS rSrSr S
S\S\\\4   S\\\\4      S\\   4U 4S jjjr	S r
S	rU =r$ )BigqueryServiceError$   znBase class of Bigquery-specific error responses.

The BigQuery server received request and returned an error.
messageerror
error_listjob_refc                 R   > [         TU ]  " U/UQ70 UD6  X l        X0l        X@l        g)a  Initializes a BigqueryServiceError.

Args:
  message: A user-facing error message.
  error: The error dictionary, code may inspect the 'reason' key.
  error_list: A list of additional entries, for example a load job may
    contain multiple errors here for each error encountered during
    processing.
  job_ref: Optional JobReference string, if this error was encountered while
    processing a job.
N)super__init__r"   r#   r$   )selfr!   r"   r#   r$   argskwds	__class__s          r   r'   BigqueryServiceError.__init__*   s+    , 
GW,t,t,J OLr   c                     U R                   R                  < SU R                  < SU R                  < SU R                  < 3$ )Nz: error=z, error_list=z
, job_ref=)r+   r   r"   r#   r$   )r(   s    r   __repr__BigqueryServiceError.__repr__E   s.    

	 r   )r"   r#   r$   )N)r   r   r   r   r   strr   r   r   r'   r.   r   __classcell__)r+   s   @r   r   r   $   s`      $ #s(^ tCH~&	
 } 6 r   r   c                       \ rS rSrSrSrg)BigqueryNotFoundErrorN   z3The requested resource or identifier was not found.r
   Nr   r
   r   r   r3   r3   N       ;r   r3   c                       \ rS rSrSrSrg)BigqueryDuplicateErrorR   z4The requested resource or identifier already exists.r
   Nr   r
   r   r   r7   r7   R   s    <r   r7   c                       \ rS rSrSrSrg)BigqueryAccessDeniedErrorV   z8The user does not have access to the requested resource.r
   Nr   r
   r   r   r:   r:   V   s    @r   r:   c                       \ rS rSrSrSrg)BigqueryInvalidQueryErrorZ   zThe SQL statement is invalid.r
   Nr   r
   r   r   r=   r=   Z   s    %r   r=   c                       \ rS rSrSrSrg)BigqueryTermsOfServiceError^   zUser has not ACK'd ToS.r
   Nr   r
   r   r   r@   r@   ^   s    r   r@   c                       \ rS rSrSrSrg)BigqueryBackendErrorb   zGA backend error typically corresponding to retriable HTTP 5xx failures.r
   Nr   r
   r   r   rC   rC   b   s    Or   rC   c                       \ rS rSrSrSrg)BigqueryClientErrorf   zInvalid use of BigqueryClient.r
   Nr   r
   r   r   rF   rF   f   s    &r   rF   c                       \ rS rSrSrSrg) BigqueryClientConfigurationErrorj   z(Invalid configuration of BigqueryClient.r
   Nr   r
   r   r   rI   rI   j       0r   rI   c                       \ rS rSrSrSrg)BigquerySchemaErrorn   z(Error in locating or parsing the schema.r
   Nr   r
   r   r   rM   rM   n   rK   r   rM   c                       \ rS rSrSrSrg)BigqueryTableConstraintsErrorr   z3Error in locating or parsing the table constraints.r
   Nr   r
   r   r   rP   rP   r   r5   r   rP   r"   server_errorerror_lsr$   
session_idreturnc                 n   U R                  S5      nU(       a  SU SU R                  S5       3nOU R                  SS5      nU Vs/ s H  owU :w  d  M
  UPM     nnU(       a  US-  nSn	U Vs/ s H>  nSR                  [        S	UR                  S
5      UR                  S5      /5      5      PM@     n
nU	(       a  USR                  S U
 5       5      -  nO SR                  U
5      nU(       a  USU-   -  nU(       a  USU-  -  n[        R                  " U5      nU(       a  U(       d  [        S[        U5      < 35      $ US:X  a
  [        X`X#S9$ US:X  a
  [        X`X#S9$ US:X  a
  [        X`X#S9$ US:X  a
  [        X`X#S9$ US:X  a
  [        X`X#S9$ US:X  a
  [        X`X#S9$ [        X`X#S9$ s  snf s  snf )aR  Returns a BigqueryError for json error embedded in server_error.

If error_ls contains any errors other than the given one, those
are also included in the returned message.

Args:
  error: The primary error to convert.
  server_error: The error returned by the server. (This is only used in the
    case that error is malformed.)
  error_ls: Additional errors to include in the error message.
  job_ref: String representation a JobReference, if this is an error
    associated with a job.
  session_id: Id of the session if the job is part of one.

Returns:
  BigqueryError representing error.
reasonzError processing job 'z': r!    z
Failure details:
Tz: Nlocation
c              3   N   #    U  H  n[         R                  " US SS9v   M     g7f)z - z   )initial_indentsubsequent_indentN)textwrapfill).0msgs     r   	<genexpr>&CreateBigqueryError.<locals>.<genexpr>   s$      %C 	c%5I%s   #%z- z
In session: %szEError reported by server with missing error fields. Server returned: notFound)r$   	duplicateaccessDeniedinvalidQuerytermsOfServiceNotAcceptedbackendError)getjoinfilterr   EncodeForPrintingr   r0   r3   r7   r:   r=   r@   rC   r   )r"   rR   rS   r$   rT   rW   r!   err
new_errorswrap_error_messagenew_error_messageserror_messages               r   CreateBigqueryErrorrs   v   s   0 99X&&wis599Y3G2HIGii	2&G'8x%<x*8%%G # iitcggj137793EFGH   tyy %  G
 II01M%%g!J..G ((1'	w!!$\!2	5  z KK{!'(LL~$WXOO~$WXOO**&  ~JJ	gh	HH_ 9s   	F-F-.AF2)NN)r   r^   typingr   r   r   bq_flagsutilsr   P12_DEPRECATION_MESSAGE	Exceptionr   r   r   r   r   r3   r7   r:   r=   r@   rC   rF   rI   rM   rP   r0   rs   r
   r   r   <module>ry      s]   6  ' '   -I -@ @- -6] 6'= 'T<0 <=1 =A 4 A& 4 & ";  P/ P'- '1': 11- 1<$7 < " $MIS>MIsCx.MI 4S>"MI c]	MI
 MI MIr   