
    R-j]                       d dl mZ d dlZd dlmZmZmZ d dlmZm	Z	 d dl
Z
ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddl m!Z!m"Z" ddlm#Z# ddl$m%Z%m&Z&m'Z' ddl(m)Z)m*Z* er"ddl+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7 g dZ8 G d de&      Z9 G d de'      Z: G d d      Z; G d d      Z< G d d      Z= G d  d!      Z>e9Z?e:Z@y)"    )annotationsN)TYPE_CHECKINGAnyMapping)Selfoverride   )_exceptionsQuerystring)OmitHeadersTimeoutNotGiven	TransportProxiesTypesRequestOptions	not_given)is_given)cached_property)FinalRequestOptions)__version__)StreamAsyncStream)APIStatusError)DEFAULT_MAX_RETRIESSyncAPIClientAsyncAPIClient)GeminiNextGenAPIClientAdapter"AsyncGeminiNextGenAPIClientAdapter)agentswebhooksinteractions)AgentsResourceAsyncAgentsResource)WebhooksResourceAsyncWebhooksResource)InteractionsResourceAsyncInteractionsResource)r   r   r   r   GeminiNextGenAPIClientAsyncGeminiNextGenAPIClientClientAsyncClientc                      e Zd ZU ded<   ded<   ded<   dddeeddddd	d

	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Zedd       Z	edd       Z
edd       Zedd       Zeed d              Zeed!d              Zeed" fd              Zed#d       Zed$d       Zdddededddddi d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZeZd&dZe	 	 	 	 	 	 	 	 d'd       Z xZS )(r*   
str | Noneapi_keystrapi_version$GeminiNextGenAPIClientAdapter | Noneclient_adapterNv1betaF
r0   r2   base_urltimeoutmax_retriesdefault_headersdefault_queryhttp_clientr4   _strict_response_validationc       
   
        |t         j                  j                  d      }|| _        |d}|| _        |t         j                  j                  d      }|d}|	| _        t        |   t        |||||||
       t        | _
        y)zConstruct a new synchronous GeminiNextGenAPIClient client instance.

        This automatically infers the `api_key` argument from the `GEMINI_API_KEY` environment variable if it is not provided.
        NGEMINI_API_KEYr5   GEMINI_NEXT_GEN_API_BASE_URL)https://generativelanguage.googleapis.comversionr7   r9   r8   r<   custom_headerscustom_queryr=   )osenvirongetr0   r2   r4   super__init__r   r   _default_stream_clsselfr0   r2   r7   r8   r9   r:   r;   r<   r4   r=   	__class__s              p/Users/jameslopez/projects/TradingBot25/.venv/lib/python3.12/site-packages/google/genai/_interactions/_client.pyrJ   zGeminiNextGenAPIClient.__init__K   s    : ?jjnn%56G"K&zz~~&DEHBH,##*&(C 	 		
 $*     c                    ddl m}  ||       S )Nr	   )r(   )resources.interactionsr(   )rM   r(   s     rO   r#   z#GeminiNextGenAPIClient.interactions   s    @#D))rP   c                    ddl m}  ||       S )Nr	   )r&   )resources.webhooksr&   )rM   r&   s     rO   r"   zGeminiNextGenAPIClient.webhooks   s    8%%rP   c                    ddl m}  ||       S )Nr	   )r$   )resources.agentsr$   )rM   r$   s     rO   r!   zGeminiNextGenAPIClient.agents   s    4d##rP   c                    t        |       S N)%GeminiNextGenAPIClientWithRawResponserM   s    rO   with_raw_responsez(GeminiNextGenAPIClient.with_raw_response   s    4T::rP   c                    t        |       S rX   )*GeminiNextGenAPIClientWithStreamedResponserZ   s    rO   with_streaming_responsez.GeminiNextGenAPIClient.with_streaming_response       9$??rP   c                    t        d      S Ncomma)array_formatr   rZ   s    rO   qszGeminiNextGenAPIClient.qs        00rP   c                *    | j                   }|i S d|iS Nx-goog-api-keyr0   rM   r0   s     rO   auth_headersz#GeminiNextGenAPIClient.auth_headers   "     ,,?I '**rP   c                <    i t         |   ddi| j                  S NzApi-Revisionz
2026-05-20rI   r:   _custom_headersrM   rN   s    rO   r:   z&GeminiNextGenAPIClient.default_headers   4    
g%
L
 ""
 	
rP   c                :   |j                  d      s0|j                  d      st        |j                  d      t              ry | j                  r|j                  d      ry |j                  d      st        |j                  d      t              ry t	        d      NAuthorizationrh   z"Could not resolve authentication method. Expected the api_key to be set. Or for the `x-goog-api-key` headers to be explicitly omitted"rH   
isinstancer   r0   	TypeErrorrM   headersrD   s      rO   _validate_headersz(GeminiNextGenAPIClient._validate_headers       ;;'>+=+=o+NR\]k]o]op  ^A  CG  SH<<GKK(89./:n>P>PQa>bdh3i V
 	
rP   c                   | j                   r| j                   j                         s|S |j                  xs i }|j                  d      xs |j                  d      }|r|S | j                   j	                         }|ri |||_        |S Nru   rh   )r4   is_vertex_airz   rH   get_auth_headersrM   optionsrz   has_authadapted_headerss        rO   _prepare_optionsz'GeminiNextGenAPIClient._prepare_options   s    ""$*=*=*J*J*LN//'R;;/P7;;?O3PN-->>@!GO rP   r0   r2   r7   r8   r<   r9   r:   set_default_headersr;   set_default_queryr4   _extra_kwargsc                  ||t        d      |	|
t        d      | j                  }|i ||}n||}| j                  }|	i ||	}n|
|
}|xs | j                  } | j                  d|xs | j
                  |xs | j                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||| j                  xs |d	|S z~
        Create a new client instance re-using the same options given to the current client with optional overriding.
        zPThe `default_headers` and `set_default_headers` arguments are mutually exclusivezLThe `default_query` and `set_default_query` arguments are mutually exclusive)	r0   r2   r7   r8   r<   r9   r:   r;   r4    
ValueErrorrp   _custom_query_clientrN   r0   r2   r7   rw   r   r8   r   r9   r4   rM   r0   r2   r7   r8   r<   r9   r:   r   r;   r   r4   r   rz   paramss                  rO   copyzGeminiNextGenAPIClient.copy      & &+>+Jopp$):)Fkll&&&44O4G ,)G##$00-0F*&F!1T\\t~~ 
+t||#7t'7'7.$.w$ADLLw#'/'<$BRBR# ..@.
 
 	
rP   c                    | j                   S rX   r2   rZ   s    rO   _get_api_version_path_paramz2GeminiNextGenAPIClient._get_api_version_path_param
      rP   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S 
Ni  )responsebodyi  i  i  i  i  i  i  status_coder
   BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorr   rM   err_msgr   r   s       rO   _make_status_errorz)GeminiNextGenAPIClient._make_status_error  0    3&..wPTUU3&227XTXYY3&44WxVZ[[3&,,WxdSS3&,,WxdSS3&77(Y]^^3&--gtTT3&227XTXYYgtDDrP   )r0   r/   r2   r/   r7   str | httpx.URL | Noner8   !float | Timeout | None | NotGivenr9   intr:   Mapping[str, str] | Noner;   Mapping[str, object] | Noner<   httpx.Client | Noner4   r3   r=   boolreturnNone)r   r(   )r   r&   )r   r$   )r   rY   )r   r]   r   r   r   zdict[str, str]r   zdict[str, str | Omit]rz   r   rD   r   r   r   r   r   r   r   )r0   r/   r2   r/   r7   r   r8   r   r<   r   r9   int | NotGivenr:   r   r   r   r;   r   r   r   r4   r3   r   Mapping[str, Any]r   r   r   r1   r   r1   r   objectr   zhttpx.Responser   r   __name__
__module____qualname____annotations__r   r   rJ   r   r#   r"   r!   r[   r^   propertyr   rd   rk   r:   r{   r   r   with_optionsr   r   __classcell__rN   s   @rO   r*   r*   E   s   88
 #"*+/5>.4859 ,0?C -2/7* 7*  	7*
 )7* 37* 7* 27* 37* )7* =7*. &*/7*0 
17*r * *
 & &
 $ $
 ; ; @ @ 1  1 +  + 
  
 

 

  ( #"&+/5>+/&/488<599=?C+-1
 1
  	1

 )1
 31
 )1
 $1
 21
 61
 31
 71
 =1
 )1
 
1
j L  EE 	E
 !E 
E ErP   r*   c                      e Zd ZU ded<   ded<   ded<   dddeeddddd	d

	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Zedd       Z	edd       Z
edd       Zedd       Zeed d              Zeed!d              Zeed" fd              Zed#d       Zed$d       Zdddededddddi d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZeZd&dZe	 	 	 	 	 	 	 	 d'd       Z xZS )(r+   r/   r0   r1   r2   )AsyncGeminiNextGenAPIClientAdapter | Noner4   Nr5   Fr6   c       
   
        |t         j                  j                  d      }|| _        |d}|| _        |t         j                  j                  d      }|d}|	| _        t        |   t        |||||||
       t        | _
        y)zConstruct a new async AsyncGeminiNextGenAPIClient client instance.

        This automatically infers the `api_key` argument from the `GEMINI_API_KEY` environment variable if it is not provided.
        Nr?   r5   r@   rA   rB   )rF   rG   rH   r0   r2   r4   rI   rJ   r   r   rK   rL   s              rO   rJ   z$AsyncGeminiNextGenAPIClient.__init__5  s    : ?jjnn%56G"K&zz~~&DEHBH,##*&(C 	 		
 $/ rP   c                    ddl m}  ||       S )Nr	   )r)   )rR   r)   )rM   r)   s     rO   r#   z(AsyncGeminiNextGenAPIClient.interactionsn  s    E(..rP   c                    ddl m}  ||       S )Nr	   )r'   )rT   r'   )rM   r'   s     rO   r"   z$AsyncGeminiNextGenAPIClient.webhookst  s    =$T**rP   c                    ddl m}  ||       S )Nr	   )r%   )rV   r%   )rM   r%   s     rO   r!   z"AsyncGeminiNextGenAPIClient.agentsz  s    9"4((rP   c                    t        |       S rX   )*AsyncGeminiNextGenAPIClientWithRawResponserZ   s    rO   r[   z-AsyncGeminiNextGenAPIClient.with_raw_response  r_   rP   c                    t        |       S rX   )/AsyncGeminiNextGenAPIClientWithStreamedResponserZ   s    rO   r^   z3AsyncGeminiNextGenAPIClient.with_streaming_response  s    >tDDrP   c                    t        d      S ra   r   rZ   s    rO   rd   zAsyncGeminiNextGenAPIClient.qs  re   rP   c                *    | j                   }|i S d|iS rg   ri   rj   s     rO   rk   z(AsyncGeminiNextGenAPIClient.auth_headers  rl   rP   c                <    i t         |   ddi| j                  S rn   ro   rq   s    rO   r:   z+AsyncGeminiNextGenAPIClient.default_headers  rr   rP   c                :   |j                  d      s0|j                  d      st        |j                  d      t              ry | j                  r|j                  d      ry |j                  d      st        |j                  d      t              ry t	        d      rt   rv   ry   s      rO   r{   z-AsyncGeminiNextGenAPIClient._validate_headers  r|   rP   c                0  K   | j                   r| j                   j                         s|S |j                  xs i }|j                  d      xs |j                  d      }|r|S | j                   j	                          d {   }|ri |||_        |S 7 wr~   )r4   r   rz   rH   async_get_auth_headersr   s        rO   r   z,AsyncGeminiNextGenAPIClient._prepare_options  s     ""$*=*=*J*J*LN//'R;;/P7;;?O3PN $ 3 3 J J LL!GO  Ms   A>B BBr   c                  ||t        d      |	|
t        d      | j                  }|i ||}n||}| j                  }|	i ||	}n|
|
}|xs | j                  } | j                  d|xs | j
                  |xs | j                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||| j                  xs |d	|S r   r   r   s                  rO   r   z AsyncGeminiNextGenAPIClient.copy  r   rP   c                    | j                   S rX   r   rZ   s    rO   r   z7AsyncGeminiNextGenAPIClient._get_api_version_path_param  r   rP   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S r   r   r   s       rO   r   z.AsyncGeminiNextGenAPIClient._make_status_error  r   rP   )r0   r/   r2   r/   r7   r   r8   r   r9   r   r:   r   r;   r   r<   httpx.AsyncClient | Noner4   r   r=   r   r   r   )r   r)   )r   r'   )r   r%   )r   r   )r   r   r   r   r   r   r   )r0   r/   r2   r/   r7   r   r8   r   r<   r   r9   r   r:   r   r   r   r;   r   r   r   r4   r   r   r   r   r   r   r   r   r   s   @rO   r+   r+   /  s   ==
 #"*+/5>.4859 15DH -2/7/ 7/  	7/
 )7/ 37/ 7/ 27/ 37/ .7/ B7/. &*/7/0 
17/r / /
 + +
 ) )
 @ @ E E 1  1 +  + 
  
 

 

  ( #"&+/5>04&/488<599=DH+-1
 1
  	1

 )1
 31
 .1
 $1
 21
 61
 31
 71
 B1
 )1
 
1
j L  EE 	E
 !E 
E ErP   r+   c                  V    e Zd ZU ded<   ddZed	d       Zed
d       Zedd       Zy)rY   r*   r   c                    || _         y rX   r   rM   clients     rO   rJ   z.GeminiNextGenAPIClientWithRawResponse.__init__  	    rP   c                F    ddl m}  || j                  j                        S )Nr	   )#InteractionsResourceWithRawResponse)rR   r   r   r#   )rM   r   s     rO   r#   z2GeminiNextGenAPIClientWithRawResponse.interactions  s    O24<<3L3LMMrP   c                F    ddl m}  || j                  j                        S )Nr	   )WebhooksResourceWithRawResponse)rT   r   r   r"   )rM   r   s     rO   r"   z.GeminiNextGenAPIClientWithRawResponse.webhooks%  s    G.t||/D/DEErP   c                F    ddl m}  || j                  j                        S )Nr	   )AgentsResourceWithRawResponse)rV   r   r   r!   )rM   r   s     rO   r!   z,GeminiNextGenAPIClientWithRawResponse.agents+  s    C,T\\-@-@AArP   Nr   r*   r   r   )r   z0interactions.InteractionsResourceWithRawResponse)r   z(webhooks.WebhooksResourceWithRawResponse)r   z$agents.AgentsResourceWithRawResponse	r   r   r   r   rJ   r   r#   r"   r!   r   rP   rO   rY   rY     sO    ## N N
 F F
 B BrP   rY   c                  V    e Zd ZU ded<   ddZed	d       Zed
d       Zedd       Zy)r   r+   r   c                    || _         y rX   r   r   s     rO   rJ   z3AsyncGeminiNextGenAPIClientWithRawResponse.__init__5  r   rP   c                F    ddl m}  || j                  j                        S )Nr	   )(AsyncInteractionsResourceWithRawResponse)rR   r   r   r#   )rM   r   s     rO   r#   z7AsyncGeminiNextGenAPIClientWithRawResponse.interactions8  s    T78Q8QRRrP   c                F    ddl m}  || j                  j                        S )Nr	   )$AsyncWebhooksResourceWithRawResponse)rT   r   r   r"   )rM   r   s     rO   r"   z3AsyncGeminiNextGenAPIClientWithRawResponse.webhooks>  s    L3DLL4I4IJJrP   c                F    ddl m}  || j                  j                        S )Nr	   )"AsyncAgentsResourceWithRawResponse)rV   r   r   r!   )rM   r   s     rO   r!   z1AsyncGeminiNextGenAPIClientWithRawResponse.agentsD  s    H1$,,2E2EFFrP   Nr   r+   r   r   )r   z5interactions.AsyncInteractionsResourceWithRawResponse)r   z-webhooks.AsyncWebhooksResourceWithRawResponse)r   z)agents.AsyncAgentsResourceWithRawResponser   r   rP   rO   r   r   2  sO    (( S S
 K K
 G GrP   r   c                  V    e Zd ZU ded<   ddZed	d       Zed
d       Zedd       Zy)r]   r*   r   c                    || _         y rX   r   r   s     rO   rJ   z3GeminiNextGenAPIClientWithStreamedResponse.__init__N  r   rP   c                F    ddl m}  || j                  j                        S )Nr	   ))InteractionsResourceWithStreamingResponse)rR   r   r   r#   )rM   r   s     rO   r#   z7GeminiNextGenAPIClientWithStreamedResponse.interactionsQ  s    U89R9RSSrP   c                F    ddl m}  || j                  j                        S )Nr	   )%WebhooksResourceWithStreamingResponse)rT   r   r   r"   )rM   r   s     rO   r"   z3GeminiNextGenAPIClientWithStreamedResponse.webhooksW  s    M4T\\5J5JKKrP   c                F    ddl m}  || j                  j                        S )Nr	   )#AgentsResourceWithStreamingResponse)rV   r   r   r!   )rM   r   s     rO   r!   z1GeminiNextGenAPIClientWithStreamedResponse.agents]  s    I24<<3F3FGGrP   Nr   )r   z6interactions.InteractionsResourceWithStreamingResponse)r   z.webhooks.WebhooksResourceWithStreamingResponse)r   z*agents.AgentsResourceWithStreamingResponser   r   rP   rO   r]   r]   K  sO    ## T T
 L L
 H HrP   r]   c                  V    e Zd ZU ded<   ddZed	d       Zed
d       Zedd       Zy)r   r+   r   c                    || _         y rX   r   r   s     rO   rJ   z8AsyncGeminiNextGenAPIClientWithStreamedResponse.__init__g  r   rP   c                F    ddl m}  || j                  j                        S )Nr	   ).AsyncInteractionsResourceWithStreamingResponse)rR   r   r   r#   )rM   r   s     rO   r#   z<AsyncGeminiNextGenAPIClientWithStreamedResponse.interactionsj  s    Z=dll>W>WXXrP   c                F    ddl m}  || j                  j                        S )Nr	   )*AsyncWebhooksResourceWithStreamingResponse)rT   r   r   r"   )rM   r   s     rO   r"   z8AsyncGeminiNextGenAPIClientWithStreamedResponse.webhooksp  s    R9$,,:O:OPPrP   c                F    ddl m}  || j                  j                        S )Nr	   )(AsyncAgentsResourceWithStreamingResponse)rV   r  r   r!   )rM   r  s     rO   r!   z6AsyncGeminiNextGenAPIClientWithStreamedResponse.agentsv  s    N78K8KLLrP   Nr   )r   z;interactions.AsyncInteractionsResourceWithStreamingResponse)r   z3webhooks.AsyncWebhooksResourceWithStreamingResponse)r   z/agents.AsyncAgentsResourceWithStreamingResponser   r   rP   rO   r   r   d  sO    (( Y Y
 Q Q
 M MrP   r   )A
__future__r   rF   typingr   r   r   typing_extensionsr   r   httpx r
   _qsr   _typesr   r   r   r   r   r   r   r   _utilsr   _compatr   _modelsr   _versionr   
_streamingr   r   r   _base_clientr   r   r   _client_adapterr   r    	resourcesr!   r"   r#   rV   r$   r%   rT   r&   r'   rR   r(   r)   __all__r*   r+   rY   r   r]   r   r,   r-   r   rP   rO   <module>r     s   $ # 	 . . ,   	 	 	  $ ( ! D ' 
 _99EKW	gE] gETgE. gETB B2G G2H H2M M2 
 )rP   