
    /j.                         S SK r S SKJr  S SKJrJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJrJr  SSKJr  SSKJr  Sr   " S	 S\5      r!g)
    N)uuid4)CreateRoomRequestListRoomsRequestDeleteRoomRequestListRoomsResponseDeleteRoomResponseListParticipantsRequestListParticipantsResponseRoomParticipantIdentityMuteRoomTrackRequestMuteRoomTrackResponseUpdateParticipantRequestUpdateSubscriptionsRequestSendDataRequestSendDataResponseUpdateRoomMetadataRequestRemoveParticipantResponseUpdateSubscriptionsResponseForwardParticipantRequestForwardParticipantResponseMoveParticipantRequestMoveParticipantResponse)RoomParticipantInfo   )Service)VideoGrantsRoomServicec                   >  ^  \ 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	\4S jrS\S	\4S jrS\S	\
4S jrS\S	\4S jrS\S	\4S jrS\S	\4S jrS\S	S4S jrS\S	S4S jrS\ S	\!4S jr"S\#S	\4S jr$S\%S	\&4S jr'S\(S	\)4S jr*S r+U =r,$ )!r   "   a@  Client for LiveKit RoomService API

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

```python
from livekit import api
lkapi = api.LiveKitAPI()
room_service = lkapi.room
```

Also see https://docs.livekit.io/home/server/managing-rooms/ and https://docs.livekit.io/home/server/managing-participants/
sessionurlapi_key
api_secretc                 &   > [         TU ]  XX45        g )N)super__init__)selfr!   r"   r#   r$   	__class__s        I/app/agent/.venv/lib/python3.13/site-packages/livekit/api/room_service.pyr'   RoomService.__init__0   s    w;    createreturnc                    #    U R                   R                  [        SUU R                  [	        SS95      [
        5      I Sh  vN $  N7f)ab  Creates a new room with specified configuration.

Args:
    create (CreateRoomRequest): arg containing:
        - name: str - Unique room name
        - empty_timeout: int - Seconds to keep room open if empty
        - max_participants: int - Max allowed participants
        - metadata: str - Custom room metadata
        - egress: RoomEgress - Egress configuration
        - min_playout_delay: int - Minimum playout delay in ms
        - max_playout_delay: int - Maximum playout delay in ms
        - sync_streams: bool - Enable A/V sync for playout delays >200ms

Returns:
    Room: The created room object

CreateRoomTroom_createN)_clientrequestSVC_auth_headerr   r   )r(   r-   s     r*   create_roomRoomService.create_room3   sG     ( \\))kd;<
 
 	
 
   AA
AA
listc                    #    U R                   R                  [        SUU R                  [	        SS95      [
        5      I Sh  vN $  N7f)zLists active rooms.

Args:
    list (ListRoomsRequest): arg containing:
        - names: list[str] - Optional list of room names to filter by

Returns:
    ListRoomsResponse:
        - rooms: list[Room] - List of active Room objects
	ListRoomsT)	room_listN)r3   r4   r5   r6   r   r   r(   r:   s     r*   
list_roomsRoomService.list_roomsO   sG      \\))kD9:
 
 	
 
r9   deletec                    #    U R                   R                  [        SUU R                  [	        SS95      [
        5      I Sh  vN $  N7f)zDeletes a room and disconnects all participants.

Args:
    delete (DeleteRoomRequest): arg containing:
        - room: str - Name of room to delete

Returns:
    DeleteRoomResponse: Empty response object

DeleteRoomTr1   N)r3   r4   r5   r6   r   r   )r(   rA   s     r*   delete_roomRoomService.delete_roomb   sG      \\))kd;<
 
 	
 
r9   updatec                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Updates a room's [metadata](https://docs.livekit.io/home/client/data/room-metadata/).

Args:
    update (UpdateRoomMetadataRequest): arg containing:
        - room: str - Name of room to update
        - metadata: str - New metadata to set

Returns:
    Room: Updated Room object
UpdateRoomMetadataT
room_adminroomN)r3   r4   r5   r6   r   rK   r   r(   rF   s     r*   update_room_metadata RoomService.update_room_metadatat   sM      \\)) kTLM
 
 	
 
   AAAAc                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Lists all participants in a room.

Args:
    list (ListParticipantsRequest): arg containing:
        - room: str - Name of room to list participants from

Returns:
    ListParticipantsResponse:
        - participants: list[ParticipantInfo] - List of participant details
ListParticipantsTrI   N)r3   r4   r5   r6   r   rK   r
   r>   s     r*   list_participantsRoomService.list_participants   sM      \\))kT		JK$
 
 	
 
rO   getc                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Gets details about a specific participant.

Args:
    get (RoomParticipantIdentity): arg containing:
        - room: str - Room name
        - identity: str - Participant identity to look up

Returns:
    ParticipantInfo:
        - sid: str - Participant session ID
        - identity: str - Participant identity
        - state: int - Connection state
        - tracks: list[TrackInfo] - Published tracks
        - metadata: str - Participant metadata
        - joined_at: int - Join timestamp
        - name: str - Display name
        - version: int - Protocol version
        - permission: ParticipantPermission - Granted permissions
        - region: str - Connected region
GetParticipantTrI   Nr3   r4   r5   r6   r   rK   r   )r(   rT   s     r*   get_participantRoomService.get_participant   sM     * \\))kTIJ
 
 	
 
rO   removec                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)zRemoves a participant from a room.

Args:
    remove (RoomParticipantIdentity): arg containing:
        - room: str - Room name
        - identity: str - Identity of participant to remove

Returns:
    RemoveParticipantResponse: Empty response object
RemoveParticipantTrI   N)r3   r4   r5   r6   r   rK   r   )r(   rZ   s     r*   remove_participantRoomService.remove_participant   sM      \\))kTLM%
 
 	
 
rO   forwardNc                    #    U R                   R                  [        SUU R                  [	        SUR
                  UR                  S95      [        5      I Sh  vN   g N7f)ab  Forwards a participant and their published tracks from one room to another.

This feature is only available for LiveKit Cloud/Private Cloud.

Args:
    forward (ForwardParticipantRequest): arg containing:
        - room: str - Room name
        - identity: str - identity of Participant to forward
        - destination_room: str - Destination room name
ForwardParticipantTrJ   rK   destination_roomN)r3   r4   r5   r6   r   rK   rc   r   )r(   r_   s     r*   forward_participantRoomService.forward_participant   sX      ll"" #',,IaIa
 '

 
	
 
	
   AA!AA!movec                    #    U R                   R                  [        SUU R                  [	        SUR
                  UR                  S95      [        5      I Sh  vN   g N7f)a0  Moves a participant from one room to another.

This feature is only available for LiveKit Cloud/Private Cloud.

Args:
    move (MoveParticipantRequest): arg containing:
        - room: str - Room name
        - identity: str - Participant identity
        - destination_room: str - Destination room name
MoveParticipantTrb   N)r3   r4   r5   r6   r   rK   rc   r   )r(   rg   s     r*   move_participantRoomService.move_participant   sZ      ll""#%)%:%: $
 	
 	
rf   c                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Mutes or unmutes a participant's published track.

Args:
    update (MuteRoomTrackRequest): arg containing:
        - room: str - Room name
        - identity: str - Participant identity
        - track_sid: str - Track session ID to mute
        - muted: bool - True to mute, False to unmute

Returns:
    MuteRoomTrackResponse containing:
        - track: TrackInfo - Updated track information
MutePublishedTrackTrI   N)r3   r4   r5   r6   r   rK   r   rL   s     r*   mute_published_track RoomService.mute_published_track   sM     " \\)) kTLM!
 
 	
 
rO   c                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Updates a participant's metadata or permissions.

Args:
    update (UpdateParticipantRequest): arg containing:
        - room: str - Room name
        - identity: str - Participant identity
        - metadata: str - New metadata
        - permission: ParticipantPermission - New permissions
        - name: str - New display name
        - attributes: dict[str, str] - Key-value attributes

Returns:
    ParticipantInfo: Updated participant information
UpdateParticipantTrI   NrW   rL   s     r*   update_participantRoomService.update_participant  sM      \\))kTLM
 
 	
 
rO   c                    #    U R                   R                  [        SUU R                  [	        SUR
                  S95      [        5      I Sh  vN $  N7f)a  Updates a participant's track subscriptions.

Args:
    update (UpdateSubscriptionsRequest): arg containing:
        - room: str - Room name
        - identity: str - Participant identity
        - track_sids: list[str] - Track session IDs
        - subscribe: bool - True to subscribe, False to unsubscribe
        - participant_tracks: list[ParticipantTracks] - Participant track mappings

Returns:
    UpdateSubscriptionsResponse: Empty response object
UpdateSubscriptionsTrI   N)r3   r4   r5   r6   r   rK   r   rL   s     r*   update_subscriptions RoomService.update_subscriptions.  sM       \\))!kTLM'
 
 	
 
rO   sendc                    #    [        5       R                  Ul        U R                  R	                  [
        SUU R                  [        SUR                  S95      [        5      I Sh  vN $  N7f)a  Sends data to participants in a room.

Args:
    send (SendDataRequest): arg containing:
        - room: str - Room name
        - data: bytes - Data payload to send
        - kind: DataPacket.Kind - RELIABLE or LOSSY delivery
        - destination_identities: list[str] - Target participant identities
        - topic: str - Optional topic for the message

Returns:
    SendDataResponse: Empty response object
SendDataTrI   N)
r   bytesnoncer3   r4   r5   r6   r   rK   r   )r(   rx   s     r*   	send_dataRoomService.send_dataF  sZ      W]]
\\))kT		JK
 
 	
 
s   A%A.'A,(A. )-__name__
__module____qualname____firstlineno____doc__aiohttpClientSessionstrr'   r   r   r7   r   r   r?   r   r   rD   r   rM   r	   r
   rR   r   r   rX   r   r]   r   rd   r   rj   r   r   rn   r   rr   r   r   rv   r   r   r}   __static_attributes____classcell__)r)   s   @r*   r   r   "   sD   < 5 5 <C <# <[^ <
!
 

8
%5 
:K 
&
(9 
>P 
$
1J 
t 
&
,C 
H` 
&
)@ 
_ 
:
-
	"
*
1J 
t 
0
+A 
d 
4
$
 

2
/G 
O 
.
0
	$
0
O 
8H 
 
r,   )"r   uuidr   livekit.protocol.roomr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   livekit.protocol.modelsr   r   _servicer   access_tokenr   r5   r   r   r,   r*   <module>r      sJ          . :  % z
' z
r,   