
    j%                     b   U d dl Z d dlZd dlmZmZmZmZmZ g Zeeej                  gej                  f      e
d<   g aed   e
d<    e j                  e      Z G d d      Zdeddfd	Zd
eeef   deeef   fdZdej                  ddfdZdeej                  gej                  f   ddfdZy)    N)AnyCallableListOptionalDict_deprecated_httpx_client_hooksHttpxClientHook_httpx_client_hooksc                       e Zd Zdeeej                  gdf      deeee	f      ddfdZ
deee	f   deee	f   fdZdej                  ddfd	Zy)
r	   client_modifierNclient_init_argumentsreturnc                      || _         || _        y)a  Provides a means to customize an `httpx.Client` instance used by Opik.

        This class allows users to attach a callable hook to modify or interact
        with an `httpx.Client` instance and pass initialization arguments to
        create customized client configurations. The primary usage is to allow
        pre-processing or setup of HTTP clients used in a broader application.

        Args:
            client_modifier: Optional callable that accepts an `httpx.Client` instance and
                returns a modified httpx.Client instance.
            client_init_arguments: Dictionary containing additional `httpx.Client`
                initialization arguments to be passed to the default `httpx.Client`.
        N)_hook_httpx_client_arguments)selfr   r   s      u/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/hooks/httpx_client_hook.py__init__zHttpxClientHook.__init__   s    $ %
'<$    kwargsc                 T    | j                   |j                  | j                          |S N)r   update)r   r   s     r   update_init_argumentsz%HttpxClientHook.update_init_arguments&   s%    ''3MM$667r   clientc                 @    | j                   | j                  |       y y r   )r   )r   r   s     r   __call__zHttpxClientHook.__call__,   s    ::!JJv "r   )__name__
__module____qualname__r   r   httpxClientr   strr   r   r   r    r   r   r	   r	      s    =!(ELL>4+?"@A=  (S#X7= 
	=*DcN tCH~ u||  r   hookr   c                 .    t         j                  |        y)aa  
    Adds an HttpxClientHook to the list of hooks to be used with HTTPX clients.

    Injects a new hook into the global list of HTTPX client hooks, allowing for
    custom behavior or additional functionality when making requests with
    an HTTPX client.

    Args:
        hook (HttpxClientHook): A callable to be added as an HTTPX client hook.

    N)r
   appendr%   s    r   add_httpx_client_hookr)   1   s     t$r   default_kwargsc                 >    t         D ]  }|j                  |       }  | S )a  
    Modifies and returns initialization arguments by applying pre-defined hooks.

    This function iterates through a collection of hooks and applies their logic to
    update the initialization arguments provided.

    Args:
        default_kwargs: A dictionary containing default initialization
            arguments.

    Returns:
        Dict[str, Any]: The modified dictionary of initialization arguments.
    )r
   r   )r*   r%   s     r   build_init_argumentsr,   A   s&     $33NC $ r   r   c                 P    t         D ]
  } ||         t        D ]
  } ||         y)z&Applies registered httpx client hooks.N)r
   r   )r   r%   deprecated_hooks      r   apply_httpx_client_hooksr/   U   s'    #V $ : :r   c                 X    t         j                  |        t        j                  d       y)a  
    Deprecated: This method is deprecated and will be removed in a future release. Please use `add_httpx_client_hook` instead.

    Registers a hook for the customization of `httpx.Client` instances. The provided
    hook function will be invoked with an `httpx.Client` instance and is expected
    to return a customized `httpx.Client`.


    Args:
        hook: A callable that takes an `httpx.Client` instance and returns a
              customized `httpx.Client`.
    z{register_httpx_client_hook is deprecated and will be removed in a future release. Please use add_httpx_client_hook instead.N)r   r'   LOGGERwarningr(   s    r   register_httpx_client_hookr3   _   s$     #))$/
NN 	Fr   )loggingr!   typingr   r   r   r   r   r   r"   __annotations__r
   	getLoggerr   r1   r	   r)   r#   r,   r/   r3   r$   r   r   <module>r8      s      6 6 PR Xu||nell.J%K L Q 02 T+, 1 
		8	$ B% %D % c3h DcN ( U\\  d  Xu||nell.J%K PT r   