Skip to content

Commit 08a2c0b

Browse files
committed
doc rs
1 parent ec3eab4 commit 08a2c0b

File tree

1 file changed

+142
-1
lines changed

1 file changed

+142
-1
lines changed

livekit-api/livekit/api/room_service.py

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,26 @@ def __init__(
2525
):
2626
super().__init__(session, url, api_key, api_secret)
2727

28-
async def create_room(self, create: CreateRoomRequest) -> Room:
28+
async def create_room(
29+
self,
30+
create: CreateRoomRequest,
31+
) -> Room:
32+
"""Creates a new room with specified configuration.
33+
34+
Args:
35+
create (CreateRoomRequest): arg containing:
36+
- name: str - Unique room name
37+
- empty_timeout: int - Seconds to keep room open if empty
38+
- max_participants: int - Max allowed participants
39+
- metadata: str - Custom room metadata
40+
- egress: RoomEgress - Egress configuration
41+
- min_playout_delay: int - Minimum playout delay in ms
42+
- max_playout_delay: int - Maximum playout delay in ms
43+
- sync_streams: bool - Enable A/V sync for playout delays >200ms
44+
45+
Returns:
46+
Room: The created room object
47+
"""
2948
return await self._client.request(
3049
SVC,
3150
"CreateRoom",
@@ -35,6 +54,16 @@ async def create_room(self, create: CreateRoomRequest) -> Room:
3554
)
3655

3756
async def list_rooms(self, list: ListRoomsRequest) -> ListRoomsResponse:
57+
"""Lists active rooms.
58+
59+
Args:
60+
list (ListRoomsRequest): arg containing:
61+
- names: list[str] - Optional list of room names to filter by
62+
63+
Returns:
64+
ListRoomsResponse:
65+
- rooms: list[Room] - List of active Room objects
66+
"""
3867
return await self._client.request(
3968
SVC,
4069
"ListRooms",
@@ -44,6 +73,15 @@ async def list_rooms(self, list: ListRoomsRequest) -> ListRoomsResponse:
4473
)
4574

4675
async def delete_room(self, delete: DeleteRoomRequest) -> DeleteRoomResponse:
76+
"""Deletes a room and disconnects all participants.
77+
78+
Args:
79+
delete (DeleteRoomRequest): arg containing:
80+
- room: str - Name of room to delete
81+
82+
Returns:
83+
DeleteRoomResponse: Empty response object
84+
"""
4785
return await self._client.request(
4886
SVC,
4987
"DeleteRoom",
@@ -53,6 +91,16 @@ async def delete_room(self, delete: DeleteRoomRequest) -> DeleteRoomResponse:
5391
)
5492

5593
async def update_room_metadata(self, update: UpdateRoomMetadataRequest) -> Room:
94+
"""Updates a room's [metadata](https://docs.livekit.io/home/client/data/room-metadata/).
95+
96+
Args:
97+
update (UpdateRoomMetadataRequest): arg containing:
98+
- room: str - Name of room to update
99+
- metadata: str - New metadata to set
100+
101+
Returns:
102+
Room: Updated Room object
103+
"""
56104
return await self._client.request(
57105
SVC,
58106
"UpdateRoomMetadata",
@@ -64,6 +112,16 @@ async def update_room_metadata(self, update: UpdateRoomMetadataRequest) -> Room:
64112
async def list_participants(
65113
self, list: ListParticipantsRequest
66114
) -> ListParticipantsResponse:
115+
"""Lists all participants in a room.
116+
117+
Args:
118+
list (ListParticipantsRequest): arg containing:
119+
- room: str - Name of room to list participants from
120+
121+
Returns:
122+
ListParticipantsResponse:
123+
- participants: list[ParticipantInfo] - List of participant details
124+
"""
67125
return await self._client.request(
68126
SVC,
69127
"ListParticipants",
@@ -73,6 +131,26 @@ async def list_participants(
73131
)
74132

75133
async def get_participant(self, get: RoomParticipantIdentity) -> ParticipantInfo:
134+
"""Gets details about a specific participant.
135+
136+
Args:
137+
get (RoomParticipantIdentity): arg containing:
138+
- room: str - Room name
139+
- identity: str - Participant identity to look up
140+
141+
Returns:
142+
ParticipantInfo:
143+
- sid: str - Participant session ID
144+
- identity: str - Participant identity
145+
- state: int - Connection state
146+
- tracks: list[TrackInfo] - Published tracks
147+
- metadata: str - Participant metadata
148+
- joined_at: int - Join timestamp
149+
- name: str - Display name
150+
- version: int - Protocol version
151+
- permission: ParticipantPermission - Granted permissions
152+
- region: str - Connected region
153+
"""
76154
return await self._client.request(
77155
SVC,
78156
"GetParticipant",
@@ -84,6 +162,16 @@ async def get_participant(self, get: RoomParticipantIdentity) -> ParticipantInfo
84162
async def remove_participant(
85163
self, remove: RoomParticipantIdentity
86164
) -> RemoveParticipantResponse:
165+
"""Removes a participant from a room.
166+
167+
Args:
168+
remove (RoomParticipantIdentity): arg containing:
169+
- room: str - Room name
170+
- identity: str - Identity of participant to remove
171+
172+
Returns:
173+
RemoveParticipantResponse: Empty response object
174+
"""
87175
return await self._client.request(
88176
SVC,
89177
"RemoveParticipant",
@@ -96,6 +184,19 @@ async def mute_published_track(
96184
self,
97185
update: MuteRoomTrackRequest,
98186
) -> MuteRoomTrackResponse:
187+
"""Mutes or unmutes a participant's published track.
188+
189+
Args:
190+
update (MuteRoomTrackRequest): arg containing:
191+
- room: str - Room name
192+
- identity: str - Participant identity
193+
- track_sid: str - Track session ID to mute
194+
- muted: bool - True to mute, False to unmute
195+
196+
Returns:
197+
MuteRoomTrackResponse containing:
198+
- track: TrackInfo - Updated track information
199+
"""
99200
return await self._client.request(
100201
SVC,
101202
"MutePublishedTrack",
@@ -107,6 +208,20 @@ async def mute_published_track(
107208
async def update_participant(
108209
self, update: UpdateParticipantRequest
109210
) -> ParticipantInfo:
211+
"""Updates a participant's metadata or permissions.
212+
213+
Args:
214+
update (UpdateParticipantRequest): arg containing:
215+
- room: str - Room name
216+
- identity: str - Participant identity
217+
- metadata: str - New metadata
218+
- permission: ParticipantPermission - New permissions
219+
- name: str - New display name
220+
- attributes: dict[str, str] - Key-value attributes
221+
222+
Returns:
223+
ParticipantInfo: Updated participant information
224+
"""
110225
return await self._client.request(
111226
SVC,
112227
"UpdateParticipant",
@@ -118,6 +233,19 @@ async def update_participant(
118233
async def update_subscriptions(
119234
self, update: UpdateSubscriptionsRequest
120235
) -> UpdateSubscriptionsResponse:
236+
"""Updates a participant's track subscriptions.
237+
238+
Args:
239+
update (UpdateSubscriptionsRequest): arg containing:
240+
- room: str - Room name
241+
- identity: str - Participant identity
242+
- track_sids: list[str] - Track session IDs
243+
- subscribe: bool - True to subscribe, False to unsubscribe
244+
- participant_tracks: list[ParticipantTracks] - Participant track mappings
245+
246+
Returns:
247+
UpdateSubscriptionsResponse: Empty response object
248+
"""
121249
return await self._client.request(
122250
SVC,
123251
"UpdateSubscriptions",
@@ -127,6 +255,19 @@ async def update_subscriptions(
127255
)
128256

129257
async def send_data(self, send: SendDataRequest) -> SendDataResponse:
258+
"""Sends data to participants in a room.
259+
260+
Args:
261+
send (SendDataRequest): arg containing:
262+
- room: str - Room name
263+
- data: bytes - Data payload to send
264+
- kind: DataPacket.Kind - RELIABLE or LOSSY delivery
265+
- destination_identities: list[str] - Target participant identities
266+
- topic: str - Optional topic for the message
267+
268+
Returns:
269+
SendDataResponse: Empty response object
270+
"""
130271
return await self._client.request(
131272
SVC,
132273
"SendData",

0 commit comments

Comments
 (0)