o
    ưi                     @   sB   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 dZ	dS )    N)ListDictAnyOptionalUnion   )UnauthorizedErrorc                	   @   sd   e Zd Zddedee fddZdeeef fddZdd
ede	e
eeef  ejf fddZdS )ModelGroupsManagementClientNbase_urlapi_keyc                 C   s   | d| _|| _dS )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    r   X/home/app/Keep/.python/lib/python3.10/site-packages/litellm/proxy/client/model_groups.py__init__   s   
z$ModelGroupsManagementClient.__init__returnc                 C   s   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   headersr   r   r   _get_headers   s   z(ModelGroupsManagementClient._get_headersFreturn_requestc              
   C   s   | j  d}tjd||  d}|r|S t }z|| }|  | d W S  tj	j
yC } z|jjdkr>t| d}~w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$   er   r   r   info   s   z ModelGroupsManagementClient.info)N)F)__name__
__module____qualname__strr   r   r   r   boolr   r   r   r   r   r*   r   r   r   r   r	      s    .r	   )
r   typingr   r   r   r   r   r"   r   r	   r   r   r   r   <module>   s    