
    hjAO                         d Z ddlmZmZmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZ ddlZddlmZmZmZmZmZmZ dd	lmZmZ  G d
 d          Z G d d          ZdS )zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )errorstypesutils)AfterErrorContextAfterSuccessContextBeforeRequestContextHookContext)SDKConfiguration)RetryConfigSerializedRequestBodyget_body_content    N)AnyCallableListMappingOptionalTuple)parse_qsurlparsec                      e Zd ZU eed<   dZee         ed<   	 	 ddedee         ddfdZd Z	dee
         dee         fd	Z	 	 	 	 	 	 	 	 	 dd
ee         deeg ee         f                  dee         deeeef                  deeee
f                  deee                  deee                  dej        fdZ	 	 	 	 	 	 	 	 	 dd
ee         deeg ee         f                  dee         deeeef                  deeee
f                  deee                  deee                  dej        fdZ	 	 ddedej        deegef         dedeeeee         f                  dej        fdZdS )BaseSDKsdk_configurationN
parent_ref
sdk_configreturnc                 "    || _         || _        d S Nr   r   selfr   r   s      ^/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/google/genai/_gaos/basesdk.py__init__zBaseSDK.__init__)       
 ",$    c                 t    | j                                         \  }}||}||}t          j        ||          S r   r   get_server_detailsr   template_urlr!   base_urlurl_variablessdk_urlsdk_variabless        r"   _get_urlzBaseSDK._get_url1   D    !%!7!J!J!L!LH )M!(M:::r%   timeoutc                 J   |d S t          |t          t          f          rt          |dz            S t          |t          j                  rI|j        |j        |j        |j        g}d |D             }|sd S t          t          |          dz            S t          d          )N  c                     g | ]}||S r    .0values     r"   
<listcomp>z.BaseSDK._coerce_timeout_ms.<locals>.<listcomp>C       LLLu%:KU:K:K:Kr%   4timeout must be a float, int, httpx.Timeout, or None
isinstanceintfloathttpxTimeoutconnectreadwritepoolmax	TypeErrorr!   r1   valuesfinite_valuess       r"   _coerce_timeout_mszBaseSDK._coerce_timeout_ms<       ?4gU|,, 	'w~&&&gu}-- 	2ow|W]GLQFLLLLLM  ts=))D0111NOOOr%   
timeout_msget_serialized_bodyurl_overridehttp_headersextra_query_paramsallow_empty_valueallowed_fieldsc                 j    | j         j        }|                     ||||||||||	|
|||||||||          S r   )r   client_build_request_with_clientr!   methodpathr+   r,   requestrequest_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_value_globalssecurityrM   rN   rO   rP   rQ   rR   rS   rU   s                        r"   _build_requestzBaseSDK._build_requestI   sc    0 '...!#$)
 
 	
r%   c           
      B   i }|}|Rt          j        |                     ||          ||r|nd |r|nd           }t          j        |	r|nd |	r|nd |          }n2t	          t          |                    }t          |j        d          }t          j        ||          }||d<   | j	        j
        ||
<   |t          |          r
 |            }t          j        |t          j                  }|$t          j        ||          \  }}i ||}i ||}|\|                                D ]G\  }}|t#          |t$          t&          f          rd |D             ||<   4t          |          g||<   Ht)                      }|! |            }|r|t+          d          ||}|j        |j        dvr
|j        |d<   ||                                D ]
\  }}|||<   ||dz  nd } |                    ||||j        |j        |j        || | nt6          j        	          S )
NTkeep_blank_valuesAcceptc                 ,    g | ]}t          |          S r5   strr7   vs     r"   r9   z6BaseSDK._build_request_with_client.<locals>.<listcomp>       )@)@)@Q#a&&)@)@)@r%   request body is requiredzmultipart/form-datazmultipart/mixedcontent-typer3   paramscontentdatafilesheadersr1   r   generate_urlr/   get_query_paramsr   ri   r   queryget_headersr   
user_agentcallableget_security_from_envr   Securityget_securityitemsr=   listtupler   
ValueError
media_typebuild_requestrr   rs   rt   r@   USE_CLIENT_DEFAULT!r!   rU   rX   rY   r+   r,   rZ   r[   r\   r]   r^   r_   r`   ra   rM   rN   rO   rP   rQ   rR   rS   query_paramsurlparsed_overrideru   security_headerssecurity_query_paramsnamer8   serialized_request_bodyrbheaderr1   s!                                    r"   rV   z"BaseSDK._build_request_with_clienty      2 ;$h662<3=	 C !13=4>$! LL 's<'8'899O#O$9TRRRL#GX66/%)%;%F!"!! &#8::.xHH6;6H.7 733 65$45GDlD.CDL)17799 6 6e=edE]33 6)@)@%)@)@)@L&&*-e**L&&"7"9"9*$$&&B$ = !;<<<~*,' $.:'2  '>&HGN##!-!3!3!5!5 ( ("''1'=*t##4##+3(-)/&2GG8P $ 	
 	
 		
r%   Fhook_ctxrZ   is_error_status_codestreamretry_configc                 V  
 | j         j        
| j         j        | j         j        d         ddt          f
fd}|5t          j        |t          j        |d         |d                             }n
 |            } ||j                  rq	                    t                    |d           \  }}	|	                    dd           |	||}nM                    d	           t          j        d
|                              t                    |          }|S )N_hooksr   _attemptc           	         d }	                      t                    	          }d	j        v rd|j        vr	j        d         |j        d<                       d|j        |j        |j        t          |                     t          d          	                    |
          }nY# t          $ rL}                    t                    d |          \  }}|                    dd           |Y d }~nd }~ww xY w|)                    d           t          j        d	                              d
|j        |j        |j        
rdn|j                   |S Nr1   z0Request:
Method: %s
URL: %s
Headers: %s
Body: %szclient is required)r   Request ExceptionTexc_infozRaising no response SDK errorzNo response receivedz6Response:
Status Code: %s
URL: %s
Headers: %s
Body: %sz<streaming response>before_requestr   
extensionsdebugrX   r   ru   r   r   send	Exceptionafter_errorr   r   NoResponseErrorstatus_codetext)r   http_resreqe_rU   r   hooksloggerrZ   r   s        r"   dozBaseSDK.do_request.<locals>.do   s   H**+?+I+I7SS 222y7V7V070B90MCN9-JJGK$S))   >$%9:::!;;s6;::   (():8)D)DdANN1=LL!4tLDDDG !==== <===,-CDDDLLL$ *0C&&hm   Os   B'B- -
D7AC>>Dr   r   Tr   Raising unexpected SDK errorUnexpected error occurredr   )r   rU   debug_logger__dict__r>   r   retryRetriesr   r   r   r   r   GenAiDefaultErrorafter_successr   )r!   r   rZ   r   r   r   r   r   resulterrrU   r   r   s    `` `     @@@r"   
do_requestzBaseSDK.do_request   sc    '.'4&/9$	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	L #{2u}\!_lSTo'V'VWWHHrttH 455 	T++,=h,G,GSWXXKFC04@@@	!!;<<<./JHUUU**+>x+H+H(SSHr%   r   	NNNNNNNNNFN)__name__
__module____qualname__r
   __annotations__r   r   objectr#   r/   r   r>   rK   r   r   ri   r   r   r@   Requestrb   rV   r	   boolr   r   Responser   r5   r%   r"   r   r   !   s        ''''#'J ''' (,% %$% V$% 
	% % % %	; 	; 	;P(3- PHSM P P P P2 $( &*48:>15.2-.
 .
 SM.
 &R"7889
.
$ sm%.
& wsCx01'.
( %WS#X%67).
* $DI.+.
, !c+-.
. 
/.
 .
 .
 .
z $( &*48:>15.2/i
 i
 SMi
  &R"7889
!i
& sm'i
( wsCx01)i
* %WS#X%67+i
, $DI.-i
. !c+/i
0 
1i
 i
 i
 i
` @DE EE E 'ud{3	E
 E u[$s)%;<=E 
E E E E E Er%   r   c                      e Zd ZU eed<   dZee         ed<   	 	 ddedee         ddfdZd Z	dee
         dee         fd	Z	 	 	 	 	 	 	 	 	 dd
ee         deeg ee         f                  dee         deeeef                  deeee
f                  deee                  deee                  dej        fdZ	 	 	 	 	 	 	 	 	 dd
ee         deeg ee         f                  dee         deeeef                  deeee
f                  deee                  deee                  dej        fdZ	 	 ddedej        deegef         dedeeeee         f                  dej        fdZdS )AsyncBaseSDKr   Nr   r   r   c                 "    || _         || _        d S r   r   r    s      r"   r#   zAsyncBaseSDK.__init__4  r$   r%   c                 t    | j                                         \  }}||}||}t          j        ||          S r   r'   r*   s        r"   r/   zAsyncBaseSDK._get_url<  r0   r%   r1   c                 J   |d S t          |t          t          f          rt          |dz            S t          |t          j                  rI|j        |j        |j        |j        g}d |D             }|sd S t          t          |          dz            S t          d          )Nr3   c                     g | ]}||S r   r5   r6   s     r"   r9   z3AsyncBaseSDK._coerce_timeout_ms.<locals>.<listcomp>N  r:   r%   r;   r<   rH   s       r"   rK   zAsyncBaseSDK._coerce_timeout_msG  rL   r%   rM   rN   rO   rP   rQ   rR   rS   c                 j    | j         j        }|                     ||||||||||	|
|||||||||          S r   )r   async_clientrV   rW   s                        r"   _build_request_asyncz!AsyncBaseSDK._build_request_asyncT  sc    0 '4..!#$)
 
 	
r%   c           
      B   i }|}|Rt          j        |                     ||          ||r|nd |r|nd           }t          j        |	r|nd |	r|nd |          }n2t	          t          |                    }t          |j        d          }t          j        ||          }||d<   | j	        j
        ||
<   |t          |          r
 |            }t          j        |t          j                  }|$t          j        ||          \  }}i ||}i ||}|\|                                D ]G\  }}|t#          |t$          t&          f          rd |D             ||<   4t          |          g||<   Ht)                      }|! |            }|r|t+          d          ||}|j        |j        dvr
|j        |d<   ||                                D ]
\  }}|||<   ||dz  nd } |                    ||||j        |j        |j        || | nt6          j        	          S )
NTrd   rf   c                 ,    g | ]}t          |          S r5   rh   rj   s     r"   r9   z;AsyncBaseSDK._build_request_with_client.<locals>.<listcomp>  rl   r%   rm   rn   ro   r3   rp   rv   r   s!                                    r"   rV   z'AsyncBaseSDK._build_request_with_client  r   r%   Fr   rZ   r   r   r   c                   
K   | j         j        | j         j        | j         j        d         
ddt          f
fd}|;t          j        |t          j        |d         |d                              d {V }n |             d {V } ||j                  rw
	                    t                    |d            d {V \  }}	|	                    dd           |	||}nS                    d	           t          j        d
|          
                    t                    |           d {V }|S )N_async_hooksr   r   c           	        K   d }	                      t                    	           d {V }d	j        v rd|j        vr	j        d         |j        d<                       d|j        |j        |j        t          |                     t          d          	                    |
           d {V }n_# t          $ rR}                    t                    d |           d {V \  }}|                    dd           |Y d }~nd }~ww xY w|)                    d           t          j        d	                              d
|j        |j        |j        
rdn|j                   |S r   r   )r   r   r   r   r   async_hooksrU   r   r   rZ   r   s        r"   r   z)AsyncBaseSDK.do_request_async.<locals>.do  s     H'66(22G         222y7V7V070B90MCN9-JJGK$S))   >$%9:::!'S!@!@@@@@@@   (44%h//q       1 =LL!4tLDDDG !==== <===,-CDDDLLL$ *0C&&hm   Os   B3B; ;
DADDr   r   Tr   r   r   r   )r   r   r   r   r>   r   retry_asyncr   r   r   r   r   r   r   r   r   )r!   r   rZ   r   r   r   r   r   r   r   r   rU   r   s    `` `     @@@r"   do_request_asynczAsyncBaseSDK.do_request_async  s      '4'4,5nE*	 *	s *	 *	 *	 *	 *	 *	 *	 *	 *	 *	 *	X #".EM,q/<?CC       HH  RTTzzzzzzH 455 	 + 7 7!(++Xt! !      KFC 04@@@	!!;<<<./JHUUU(66#H--x       H r%   r   r   r   )r   r   r   r
   r   r   r   r   r#   r/   r   r>   rK   r   r   ri   r   r   r@   r   r   rV   r	   r   r   r   r   r   r5   r%   r"   r   r   ,  s        ''''#'J ''' (,% %$% V$% 
	% % % %	; 	; 	;P(3- PHSM P P P P2 $( &*48:>15.2-.
 .
 SM.
 &R"7889
.
$ sm%.
& wsCx01'.
( %WS#X%67).
* $DI.+.
, !c+-.
. 
/.
 .
 .
 .
z $( &*48:>15.2/i
 i
 SMi
  &R"7889
!i
& sm'i
( wsCx01)i
* %WS#X%67+i
, $DI.-i
. !c+/i
0 
1i
 i
 i
 i
` @DR RR R 'ud{3	R
 R u[$s)%;<=R 
R R R R R Rr%   r   )__doc__ r   r   r   r   r   r   r   r	   sdkconfigurationr
   r   r   r   r@   typingr   r   r   r   r   r   urllib.parser   r   r   r   r5   r%   r"   <module>r      sX  " H G " " " " " " " " " "            / . . . . . G G G G G G G G G G  @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ + + + + + + + +H H H H H H H HVU U U U U U U U U Ur%   