
    h                     H    d dl Z d dlmZmZmZmZmZ ddlmZ  G d d      Z	y)    N)ListDictAnyOptionalUnion   )UnauthorizedErrorc            	       z    e Zd Zd	dedee   fdZdeeef   fdZd
dede	e
eeef      ej                  f   fdZy)ModelGroupsManagementClientNbase_urlapi_keyc                 >    |j                  d      | _        || _        y)a"  
        Initialize the ModelGroupsManagementClient.

        Args:
            base_url (str): The base URL of the LiteLLM proxy server (e.g., "http://localhost:8000")
            api_key (Optional[str]): API key for authentication. If provided, it will be sent as a Bearer token.
        /N)rstrip	_base_url_api_key)selfr   r   s      ]/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/proxy/client/model_groups.py__init__z$ModelGroupsManagementClient.__init__   s     "-    returnc                 F    i }| j                   rd| j                    |d<   |S )z
        Get the headers for API requests, including authorization if api_key is set.

        Returns:
            Dict[str, str]: Headers to use for API requests
        zBearer Authorization)r   )r   headerss     r   _get_headersz(ModelGroupsManagementClient._get_headers   s*     ==)0'@GO$r   return_requestc                    | j                    d}t        j                  d|| j                               }|r|S t        j                         }	 |j                  |j                               }|j                          |j                         d   S # t        j                  j                  $ r*}|j                  j                  dk(  rt        |       d}~ww xY w)aG  
        Get detailed information about all model groups from the server.

        Args:
            return_request (bool): If True, returns the prepared request object instead of executing it

        Returns:
            Union[List[Dict[str, Any]], requests.Request]: Either a list of model group information dictionaries
            or a prepared request object if return_request is True

        Raises:
            UnauthorizedError: If the request fails with a 401 status code
            requests.exceptions.RequestException: If the request fails with any other error
        z/model_group/infoGET)r   datai  N)r   requestsRequestr   Sessionsendprepareraise_for_statusjson
exceptions	HTTPErrorresponsestatus_coder	   )r   r   urlrequestsessionr)   es          r   infoz ModelGroupsManagementClient.info   s       12""5#t7H7H7JKN ""$	||GOO$56H%%'==?6**"",, 	zz%%,'**	s   AB C.%CC)N)F)__name__
__module____qualname__strr   r   r   r   boolr   r   r   r    r!   r/    r   r   r   r      s^    	  	 x} 	 
d38n 
4 E$tCH~:NPXP`P`:`4a r   r   )
r    typingr   r   r   r   r   r'   r	   r   r5   r   r   <module>r7      s     3 3 )6 6r   