o
    iS                     @   sv   d dl Z d dlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ d d	lmZ G d
d dZdS )    N   )RoomService)EgressService)IngressService)
SipService)AgentDispatchService)ConnectorService)Optionalc                   @   s   e Zd ZdZ			dddddee dee dee deej deej f
d	d
Z	e
defddZe
defddZe
defddZe
defddZe
defddZe
defddZdd Zdd Zdd ZdS )
LiveKitAPIa  LiveKit Server API Client

    This class is the main entrypoint, which exposes all services.

    Usage:

    ```python
    from livekit import api
    lkapi = api.LiveKitAPI()
    rooms = await lkapi.room.list_rooms(api.proto_room.ListRoomsRequest(names=['test-room']))
    ```
    N)timeoutsessionurlapi_key
api_secretr   r   c                C   s   |pt d}|pt d}|pt d}|std|r|s#tdd| _|| _| js>d| _|s7tjdd	}tj|d
| _t| j|||| _	t
| j|||| _t| j|||| _t| j|||| _t| j|||| _t| j|||| _dS )a  Create a new LiveKitAPI instance.

        Args:
            url: LiveKit server URL (read from `LIVEKIT_URL` environment variable if not provided)
            api_key: API key (read from `LIVEKIT_API_KEY` environment variable if not provided)
            api_secret: API secret (read from `LIVEKIT_API_SECRET` environment variable if not provided)
            timeout: Request timeout (default: 60 seconds)
            session: aiohttp.ClientSession instance to use for requests, if not provided, a new one will be created
        LIVEKIT_URLLIVEKIT_API_KEYLIVEKIT_API_SECRETzurl must be setz"api_key and api_secret must be setTF<   )total)r   N)osgetenv
ValueError_custom_session_sessionaiohttpClientTimeoutClientSessionr   _roomr   _ingressr   _egressr   _sipr   _agent_dispatchr   
_connector)selfr   r   r   r   r    r$   Y/var/www/html/livekit_bhavya/venv/lib/python3.10/site-packages/livekit/api/livekit_api.py__init__   s(   zLiveKitAPI.__init__returnc                 C      | j S )z$Instance of the AgentDispatchService)r!   r#   r$   r$   r%   agent_dispatchE      zLiveKitAPI.agent_dispatchc                 C   r(   )zInstance of the RoomService)r   r)   r$   r$   r%   roomJ   r+   zLiveKitAPI.roomc                 C   r(   )zInstance of the IngressService)r   r)   r$   r$   r%   ingressO   r+   zLiveKitAPI.ingressc                 C   r(   )zInstance of the EgressService)r   r)   r$   r$   r%   egressT   r+   zLiveKitAPI.egressc                 C   r(   )zInstance of the SipService)r    r)   r$   r$   r%   sipY   r+   zLiveKitAPI.sipc                 C   r(   )z Instance of the ConnectorService)r"   r)   r$   r$   r%   	connector^   r+   zLiveKitAPI.connectorc                    s    | j s| j I dH  dS dS )zqClose the API client

        Call this before your application exits or when the API client is no longer needed.N)r   r   closer)   r$   r$   r%   aclosec   s   zLiveKitAPI.aclosec                    s   | S )*@private

        Support for `async with`r$   r)   r$   r$   r%   
__aenter__k   s   zLiveKitAPI.__aenter__c                    s   |   I dH  dS )r3   N)r2   )r#   exc_typeexc_valexc_tbr$   r$   r%   	__aexit__q   s   zLiveKitAPI.__aexit__)NNN)__name__
__module____qualname____doc__r	   strr   r   r   r&   propertyr   r*   r   r,   r   r-   r   r.   r   r/   r   r0   r2   r4   r8   r$   r$   r$   r%   r
      sD    
+r
   )r   r   room_servicer   egress_servicer   ingress_servicer   sip_servicer   agent_dispatch_servicer   connector_servicer   typingr	   r
   r$   r$   r$   r%   <module>   s    