
    h5                     h    S SK r S SKJr  S SKJrJrJrJrJr  SSK	J
r
  SSKJr  Sr  " S S\
5      rg)	    N)Optional)CreateAgentDispatchRequestAgentDispatchDeleteAgentDispatchRequestListAgentDispatchRequestListAgentDispatchResponse   )Service)VideoGrantsAgentDispatchServicec                      ^  \ rS rSrSrS\R                  S\S\S\4U 4S jjrS\	S	\
4S
 jrS\S\S	\
4S jrS\S	\\
   4S jrS\S\S	\\
   4S jrSrU =r$ )r      zManage agent dispatches. Service APIs require roomAdmin permissions.

Recommended way to use this service is via `livekit.api.LiveKitAPI`:

```python
from livekit import api
lkapi = api.LiveKitAPI()
agent_dispatch = lkapi.agent_dispatch
```
sessionurlapi_key
api_secretc                 &   > [         TU ]  XX45        g )N)super__init__)selfr   r   r   r   	__class__s        T/var/www/html/env/lib/python3.13/site-packages/livekit/api/agent_dispatch_service.pyr   AgentDispatchService.__init__   s    w;    reqreturnc                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a#  Create an explicit dispatch for an agent to join a room.

To use explicit dispatch, your agent must be registered with an `agentName`.

Args:
    req (CreateAgentDispatchRequest): Request containing dispatch creation parameters

Returns:
    AgentDispatch: The created agent dispatch object
CreateDispatchT
room_adminroomN)_clientrequestSVC_auth_headerr   r!   r   )r   r   s     r   create_dispatch$AgentDispatchService.create_dispatch    sM      \\))kTIJ
 
 	
 
s   AAAAdispatch_id	room_namec                    #    U R                   R                  [        S[        UUS9U R	                  [        SUS95      [        5      I Sh  vN $  N7f)zDelete an explicit dispatch for an agent in a room.

Args:
    dispatch_id (str): ID of the dispatch to delete
    room_name (str): Name of the room containing the dispatch

Returns:
    AgentDispatch: The deleted agent dispatch object
DeleteDispatchr(   r!   Tr   N)r"   r#   r$   r   r%   r   r   )r   r(   r)   s      r   delete_dispatch$AgentDispatchService.delete_dispatch3   sV      \\))&' kT	JK	
 	
 		
 	
s   A
AAAc                    #    U R                   R                  [        S[        US9U R	                  [        SUS95      [        5      I Sh  vN n[        UR                  5      $  N7f)zList all agent dispatches in a room.

Args:
    room_name (str): Name of the room to list dispatches from

Returns:
    list[AgentDispatch]: List of agent dispatch objects in the room
ListDispatch)r!   Tr   N)	r"   r#   r$   r   r%   r   r   listagent_dispatches)r   r)   ress      r   list_dispatch"AgentDispatchService.list_dispatchH   s^      LL(($)4kT	JK%
 
 C(())
s   A	A'A%A'c                    #    U R                   R                  [        S[        XS9U R	                  [        SUS95      [        5      I Sh  vN n[        UR                  5      S:  a  UR                  S   $ g N-7f)zGet an Agent dispatch by ID

Args:
    dispatch_id (str): ID of the dispatch to retrieve
    room_name (str): Name of the room containing the dispatch

Returns:
    Optional[AgentDispatch]: The requested agent dispatch object if found, None otherwise
r0   r,   Tr   Nr   )	r"   r#   r$   r   r%   r   r   lenr2   )r   r(   r)   r3   s       r   get_dispatch!AgentDispatchService.get_dispatchZ   st      LL(($MkT	JK%
 
 s##$q(''**
s   A	A;A9.A; )__name__
__module____qualname____firstlineno____doc__aiohttpClientSessionstrr   r   r   r&   r-   r1   r4   r   r8   __static_attributes____classcell__)r   s   @r   r   r      s    	< 5 5 <C <# <[^ <
)C 
 
&
 
 
 
**S *T-5H *$c c h}F]  r   )r@   typingr   livekit.protocol.agent_dispatchr   r   r   r   r   _servicer
   access_tokenr   r$   r   r:   r   r   <module>rI      s3        % \7 \r   