
    tni                         d Z ddlZddlZddlmZmZmZmZ ddlm	Z	 ddl
mZ  G d de          Zd	 Zd
 Z G d dej                  ZdS )z
HTTP Client abstractions
    N)ClientSessionClientTimeoutTCPConnectorClientResponseError   )get_credentials)
USER_AGENTc                       e Zd ZdS )TooManyRequestsN)__name__
__module____qualname__     O/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/runpod/http_client.pyr   r      s        Dr   r   c                      t                      x} r|                     dd          }nt          j        dd          }d|t          dS )z
    Produce a header dict with the `Authorization` key derived from
    credentials.get("api_key") OR os.getenv('RUNPOD_AI_API_KEY')
    api_key RUNPOD_AI_API_KEYzapplication/json)zContent-TypeAuthorizationz
User-Agent)r   getosgetenvr	   )credentialsauths     r   get_auth_headerr      sX    
 &'''{ 2y"--y,b11 +   r   c            	      t    t          | t          d          t                      t          dd          d|S )zf
    Deprecation from aiohttp.ClientSession forbids inheritance.
    This is now a factory method
    r   )limitiX  i  )ceil_threshold)	connectorheaderstimeout)r   r   r   r   )argskwargss     r   AsyncClientSessionr%   #   sS    
  
 Q'''!!c#666 
   r   c                       e Zd ZdZdS )SyncClientSessionzN
    Inherits requests.Session to override `request()` method for tracing
    N)r   r   r   __doc__r   r   r   r'   r'   1   s          	Dr   r'   )r(   r   requestsaiohttpr   r   r   r   cli.groups.config.functionsr   
user_agentr	   r   r   r%   Sessionr'   r   r   r   <module>r.      s     
			  S S S S S S S S S S S S 8 8 8 8 8 8 " " " " " "	 	 	 	 	) 	 	 	  "  	 	 	 	 	( 	 	 	 	 	r   