Skip to content

Commit cf41e9e

Browse files
authored
Update python docstrings (#209)
1 parent 79f3307 commit cf41e9e

2 files changed

Lines changed: 201 additions & 58 deletions

File tree

versioned_docs/version-0.23.0/api/server-python/fishjam.md

Lines changed: 131 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ custom_edit_url: null
1818
```python
1919
class FishjamClient(Client):
2020
```
21-
Allows for managing rooms
21+
Allows for managing rooms.
2222

2323
### __init__
2424
```python
2525
def __init__(fishjam_id: str, management_token: str)
2626
```
27-
Create a FishjamClient instance, providing the fishjam id and management token.
27+
Create a FishjamClient instance.
28+
29+
Args:
30+
- fishjam_id: The unique identifier for the Fishjam instance.
31+
- management_token: The token used for authenticating management operations.
2832

2933
### create_peer
3034
```python
@@ -34,12 +38,16 @@ def create_peer(
3438
options: PeerOptions | None = None
3539
) -> tuple[Peer, str]
3640
```
37-
Creates peer in the room
41+
Creates a peer in the room.
3842

39-
Returns a tuple (`Peer`, `PeerToken`) - the token is needed by Peer
40-
to authenticate to Fishjam.
43+
Args:
44+
- room_id: The ID of the room where the peer will be created.
45+
- options: Configuration options for the peer. Defaults to None.
4146

42-
The possible options to pass for peer are `PeerOptions`.
47+
Returns:
48+
- A tuple containing:
49+
- Peer: The created peer object.
50+
- str: The peer token needed to authenticate to Fishjam.
4351

4452
### create_agent
4553
```python
@@ -49,7 +57,15 @@ def create_agent(
4957
options: AgentOptions | None = None
5058
)
5159
```
60+
Creates an agent in the room.
61+
62+
Args:
63+
- room_id: The ID of the room where the agent will be created.
64+
- options: Configuration options for the agent. Defaults to None.
5265

66+
Returns:
67+
- Agent: The created agent instance initialized with peer ID, room ID, token,
68+
and Fishjam URL.
5369

5470
### create_room
5571
```python
@@ -58,62 +74,112 @@ def create_room(
5874
options: RoomOptions | None = None
5975
) -> Room
6076
```
61-
Creates a new room
62-
Returns the created `Room`
77+
Creates a new room.
78+
79+
Args:
80+
- options: Configuration options for the room. Defaults to None.
81+
82+
Returns:
83+
- Room: The created Room object.
6384

6485
### get_all_rooms
6586
```python
6687
def get_all_rooms(self) -> list[Room]
6788
```
68-
Returns list of all rooms
89+
Returns list of all rooms.
90+
91+
Returns:
92+
- list[Room]: A list of all available Room objects.
6993

7094
### get_room
7195
```python
7296
def get_room(self, room_id: str) -> Room
7397
```
74-
Returns room with the given id
98+
Returns room with the given id.
99+
100+
Args:
101+
- room_id: The ID of the room to retrieve.
102+
103+
Returns:
104+
- Room: The Room object corresponding to the given ID.
75105

76106
### delete_peer
77107
```python
78108
def delete_peer(self, room_id: str, peer_id: str) -> None
79109
```
80-
Deletes peer
110+
Deletes a peer from a room.
111+
112+
Args:
113+
- room_id: The ID of the room the peer belongs to.
114+
- peer_id: The ID of the peer to delete.
81115

82116
### delete_room
83117
```python
84118
def delete_room(self, room_id: str) -> None
85119
```
86-
Deletes a room
120+
Deletes a room.
121+
122+
Args:
123+
- room_id: The ID of the room to delete.
87124

88125
### refresh_peer_token
89126
```python
90127
def refresh_peer_token(self, room_id: str, peer_id: str) -> str
91128
```
92-
Refreshes peer token
129+
Refreshes a peer token.
130+
131+
Args:
132+
- room_id: The ID of the room.
133+
- peer_id: The ID of the peer whose token needs refreshing.
134+
135+
Returns:
136+
- str: The new peer token.
93137

94138
### create_livestream_viewer_token
95139
```python
96140
def create_livestream_viewer_token(self, room_id: str) -> str
97141
```
98-
Generates viewer token for livestream rooms
142+
Generates a viewer token for livestream rooms.
143+
144+
Args:
145+
- room_id: The ID of the livestream room.
146+
147+
Returns:
148+
- str: The generated viewer token.
99149

100150
### create_livestream_streamer_token
101151
```python
102152
def create_livestream_streamer_token(self, room_id: str) -> str
103153
```
104-
Generates streamer token for livestream rooms
154+
Generates a streamer token for livestream rooms.
155+
156+
Args:
157+
- room_id: The ID of the livestream room.
158+
159+
Returns:
160+
- str: The generated streamer token.
105161

106162
### subscribe_peer
107163
```python
108164
def subscribe_peer(self, room_id: str, peer_id: str, target_peer_id: str)
109165
```
110-
Subscribe a peer to all tracks of another peer.
166+
Subscribes a peer to all tracks of another peer.
167+
168+
Args:
169+
- room_id: The ID of the room.
170+
- peer_id: The ID of the subscribing peer.
171+
- target_peer_id: The ID of the peer to subscribe to.
111172

112173
### subscribe_tracks
113174
```python
114175
def subscribe_tracks(self, room_id: str, peer_id: str, track_ids: list[str])
115176
```
116-
Subscribe a peer to specific tracks of another peer.
177+
Subscribes a peer to specific tracks of another peer.
178+
179+
Args:
180+
- room_id: The ID of the room.
181+
- peer_id: The ID of the subscribing peer.
182+
- track_ids: A list of track IDs to subscribe to.
117183

118184
#### Inherited Members
119185
* **Client**:
@@ -129,7 +195,7 @@ Allows for receiving WebSocket messages from Fishjam.
129195
```python
130196
def __init__(fishjam_id: str, management_token: str)
131197
```
132-
Create FishjamNotifier instance, providing the fishjam id and management token.
198+
Create a FishjamNotifier instance with an ID and management token.
133199

134200
### on_server_notification
135201
```python
@@ -138,14 +204,19 @@ def on_server_notification(
138204
handler: Union[Callable[[Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated]], NoneType], Callable[[Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated]], Coroutine[Any, Any, None]]]
139205
)
140206
```
141-
Decorator used for defining handler for Fishjam Notifications
207+
Decorator for defining a handler for Fishjam notifications.
208+
209+
Args:
210+
- handler: The function to be registered as the notification handler.
211+
212+
Returns:
213+
- NotificationHandler: The original handler function (unmodified).
142214

143215
### connect
144216
```python
145217
def connect(self)
146218
```
147-
A coroutine which connects FishjamNotifier to Fishjam and listens for
148-
all incoming messages from the Fishjam.
219+
Connects to Fishjam and listens for all incoming messages.
149220

150221
It runs until the connection isn't closed.
151222

@@ -170,9 +241,17 @@ def receive_binary(
170241
binary: bytes
171242
) -> Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated, NoneType]
172243
```
173-
Transform received protobuf notification to adequate notification instance.
244+
Transforms a received protobuf notification into a notification instance.
245+
174246
The available notifications are listed in `fishjam.events` module.
175247

248+
Args:
249+
- binary: The raw binary data received from the webhook.
250+
251+
Returns:
252+
- AllowedNotification | None: The parsed notification object, or None if
253+
the message type is not supported.
254+
176255
---
177256
## PeerMetadata
178257
```python
@@ -218,7 +297,12 @@ additional_keys: list[str]
218297
```python
219298
class PeerOptions:
220299
```
221-
Options specific to a WebRTC Peer
300+
Options specific to a WebRTC Peer.
301+
302+
Attributes:
303+
- enable_simulcast: Enables the peer to use simulcast.
304+
- metadata: Peer metadata.
305+
- subscribe_mode: Configuration of peer's subscribing policy.
222306

223307
### __init__
224308
```python
@@ -256,7 +340,15 @@ Configuration of peer's subscribing policy
256340
```python
257341
class RoomOptions:
258342
```
259-
Description of a room options
343+
Description of a room options.
344+
345+
Attributes:
346+
- max_peers: Maximum amount of peers allowed into the room.
347+
- video_codec: Enforces video codec for each peer in the room.
348+
- webhook_url: URL where Fishjam notifications will be sent.
349+
- room_type: The use-case of the room. If not provided, this defaults
350+
to conference.
351+
- public: True if livestream viewers can omit specifying a token.
260352

261353
### __init__
262354
```python
@@ -310,7 +402,11 @@ True if livestream viewers can omit specifying a token.
310402
```python
311403
class AgentOptions:
312404
```
313-
Options specific to a WebRTC Peer
405+
Options specific to a WebRTC Peer.
406+
407+
Attributes:
408+
- output: Configuration for the agent's output options.
409+
- subscribe_mode: Configuration of peer's subscribing policy.
314410

315411
### __init__
316412
```python
@@ -341,6 +437,10 @@ class AgentOutputOptions:
341437
```
342438
Options of the desired format of audio tracks going from Fishjam to the agent.
343439

440+
Attributes:
441+
- audio_format: The format of the audio stream (e.g., 'pcm16').
442+
- audio_sample_rate: The sample rate of the audio stream.
443+
344444
### __init__
345445
```python
346446
def __init__(
@@ -369,7 +469,12 @@ audio_sample_rate: Literal[16000, 24000] = 16000
369469
```python
370470
class Room:
371471
```
372-
Description of the room state
472+
Description of the room state.
473+
474+
Attributes:
475+
- config: Room configuration.
476+
- id: Room ID.
477+
- peers: List of all peers.
373478

374479
### __init__
375480
```python

0 commit comments

Comments
 (0)