
    i                     ^    S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
  \ " S S5      5       rg)	z$Proxy related classes and functions.    )	dataclass)OptionalDictAny)urlparse)HttpNtlmAuthc                       \ rS rSr% SrSr\\\\4      \	S'   Sr
\\   \	S'   Sr\\   \	S'   SS jrS\4S	 jrS\4S
 jrS\S\4S jrSrg)ProxyConfiguration   az  Class for representing a proxy configuration.

Args
    urls: a dictionary mapping protocol or protocol and host to the URL of the proxy. Refer to
        https://requests.readthedocs.io/en/latest/api/#requests.Session.proxies for details.
    username_ntlm: username used to enable NTLM user authentication.
    password_ntlm: password used to enable NTLM user authentication.
Nurlsusername_ntlmpassword_ntlmreturnc                    [        [        U R                  [        5      =(       a    [        U R                  [        5      U R                  SL =(       a    U R                  SL /5      (       d&  [        SU R                   SU R                   S35      eU R                  b8  [        U R                  [        5      (       d  [        SU R                   35      egg)zNValidate configuration.

Raises:
    ValueError: If configuration is invalid.
NzInvalid proxy configuration for NTLM authentication. None or both of username and password must be provided. Got username_ntlm=z, password_ntlm=.zInvalid proxy configuration. Expected `urls` to contain a dictionary mapping protocol or protocol and host to the URL of the proxy. Got )any
isinstancer   strr   
ValueErrorr   dict)selfs    b/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/proxies/configuration.pyvalidateProxyConfiguration.validate&   s     4--s3[
4CUCUWZ8[""d*It/A/AT/I
 
 @@D@R@R?S T!!%!3!3 4A7  99 DIIt)D)DEEIYYKQ  *E     c                 v    U R                   R                  5        VVs0 s H  u  pUc  M
  X_M     snn$ s  snnf )z&Transform configuration to dictionary.)__dict__items)r   kvs      r   to_dictProxyConfiguration.to_dict>   s3     "&!4!4!6H!6!!6HHHs   	55c                     0 nU R                   (       a  U R                   US'   U R                  (       a4  U R                  (       a#  [        U R                  U R                  5      US'   U$ )zTransform configuration to request parameters.

Returns:
    A dictionary with proxy configuration parameters in the format
    expected by ``requests``. The following keys can be present:
    ``proxies``and ``auth``.
proxiesauth)r   r   r   r   )r   request_kwargss     r   to_request_params$ProxyConfiguration.to_request_paramsC   sR     99(,		N9%$"4"4%1$2D2DdFXFX%YN6"r   ws_urlc                 h   0 nU R                   (       a  U R                   n[        U5      nUSSUR                  -   SSUR                  -   S/nU H  nXc;   d  M
  [        X6   SS9nUR                  US'   UR                  US	'   UR                  R                  S5      (       a  SOUR                  US
'   UR                  (       a,  UR                  (       a  UR                  UR                  4US'     O   U R                  (       a,  U R                  (       a  U R                  U R                  4US'   U$ )a+  Extract proxy information for websocket.

Args:
    ws_url: Websocket URL.

Returns:
    A dictionary with proxy configuration parameters in the format expected by websocket.
    The following keys can be present: ``http_proxy_host``and ``http_proxy_port``,
    ``proxy_type``, ``http_proxy_auth``.
wsszhttps://httpszall://allhttp)schemehttp_proxy_hosthttp_proxy_port
proxy_typehttp_proxy_auth)
r   r   hostnameportr/   
startswithusernamepasswordr   r   )r   r)   outr$   	url_parts
proxy_keyskeyproxy_partss           r   to_ws_paramsProxyConfiguration.to_ws_paramsU   s)    99iiG (IY///9---J ">"*7<"GK-8-A-AC)*-8-=-=C)*"-"4"4"?"?"G"G[M_M_ % #++0D0D'00'002-.  " $"4"4&*&8&8$:L:L%MC!"
r    )r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   __annotations__r   r   r   r   r!   r'   r>   __static_attributes__r@   r   r   r
   r
      sn     &*D(4S>
")#'M8C='#'M8C='0I I
4 $*3 *4 *r   r
   N)rE   dataclassesr   typingr   r   r   urllib.parser   requests_ntlmr   r
   r@   r   r   <module>rL      s7    + " & & ! & g g gr   