Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
Karolk99 committed Sep 25, 2024
1 parent 3e65be4 commit 3b714dd
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 680 deletions.
76 changes: 5 additions & 71 deletions fishjam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,13 @@
# Exceptions and Server Messages
from fishjam import errors, events

# Models
from fishjam._openapi_client.models import (
ComponentFile,
ComponentHLS,
ComponentOptionsFile,
ComponentOptionsHLS,
ComponentOptionsHLSSubscribeMode,
ComponentOptionsRecording,
ComponentOptionsRecordingSubscribeMode,
ComponentOptionsRTSP,
ComponentOptionsSIP,
ComponentPropertiesFile,
ComponentPropertiesHLS,
ComponentPropertiesHLSSubscribeMode,
ComponentPropertiesRecording,
ComponentPropertiesRecordingSubscribeMode,
ComponentPropertiesRTSP,
ComponentPropertiesSIP,
ComponentPropertiesSIPSIPCredentials,
ComponentRecording,
ComponentRTSP,
ComponentSIP,
Peer,
PeerOptionsWebRTC,
PeerStatus,
Room,
RoomConfig,
RoomConfigVideoCodec,
S3Credentials,
SIPCredentials,
)

# API
from fishjam._webhook_notifier import receive_binary
from fishjam._ws_notifier import Notifier
from fishjam.api._recording_api import RecordingApi
from fishjam.api._room_api import RoomApi
from fishjam.api._room_api import (
RoomApi,
RoomOptions,
PeerOptions,
)

__all__ = [
"RoomApi",
"RecordingApi",
"Notifier",
"receive_binary",
"Room",
"RoomConfig",
"RoomConfigVideoCodec",
"Peer",
"PeerOptionsWebRTC",
"PeerStatus",
"ComponentHLS",
"ComponentOptionsHLS",
"ComponentOptionsHLSSubscribeMode",
"ComponentPropertiesHLS",
"ComponentPropertiesHLSSubscribeMode",
"ComponentSIP",
"ComponentOptionsSIP",
"ComponentPropertiesSIP",
"ComponentPropertiesSIPSIPCredentials",
"ComponentFile",
"ComponentRTSP",
"ComponentOptionsRTSP",
"ComponentPropertiesRTSP",
"ComponentFile",
"ComponentOptionsFile",
"ComponentPropertiesFile",
"events",
"errors",
"SIPCredentials",
"ComponentRecording",
"ComponentOptionsRecording",
"ComponentOptionsRecordingSubscribeMode",
"ComponentPropertiesRecording",
"ComponentPropertiesRecordingSubscribeMode",
"S3Credentials",
]
__docformat__ = "restructuredtext"
14 changes: 5 additions & 9 deletions fishjam/_ws_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ class Notifier:
Allows for receiving WebSocket messages from Fishjam.
"""

def __init__(
self,
server_address: str = "localhost:5002",
server_api_token: str = "development",
secure: bool = False,
):
def __init__(self, fishjam_url: str, management_token: str):
"""
Create Notifier instance, providing the fishjam address and api token.
Set secure to `True` for `wss` and `False` for `ws` connection (default).
"""

protocol = "wss" if secure else "ws"
self._server_address = f"{protocol}://{server_address}/socket/server/websocket"
self._server_api_token = server_api_token
self._server_address = (
f"{fishjam_url.replace('http', 'ws')}/socket/server/websocket"
)
self._server_api_token = management_token
self._websocket = None
self._ready = False

Expand Down
13 changes: 2 additions & 11 deletions fishjam/api/_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@


class BaseApi:
def __init__(
self,
server_address: str = "localhost:5002",
server_api_token: str = "development",
secure: bool = False,
):
protocol = "https" if secure else "http"

self.client = AuthenticatedClient(
f"{protocol}://{server_address}", token=server_api_token
)
def __init__(self, fishjam_url: str, management_token: str):
self.client = AuthenticatedClient(f"{fishjam_url}", token=management_token)

def _request(self, method, **kwargs):
response: Response = method.sync_detailed(client=self.client, **kwargs)
Expand Down
37 changes: 0 additions & 37 deletions fishjam/api/_recording_api.py

This file was deleted.

Loading

0 comments on commit 3b714dd

Please sign in to comment.