Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fishjam/_fishjam_openapi_client/api/mo_q/create_moq_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 503:
response_503 = Error.from_dict(response.json())

Expand Down
6 changes: 6 additions & 0 deletions fishjam/_fishjam_openapi_client/api/rooms/refresh_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def _get_kwargs(
room_id: str,
id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/room/{room_id}/peer/{id}/refresh_token".format(
Expand Down Expand Up @@ -44,6 +45,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 404:
response_404 = Error.from_dict(response.json())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def _get_kwargs(
stream_id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/livestream/{stream_id}/streamer".format(
Expand All @@ -37,6 +38,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 404:
response_404 = Error.from_dict(response.json())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def _get_kwargs(
room_id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/room/{room_id}/streamer".format(
Expand Down Expand Up @@ -42,6 +43,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 404:
response_404 = Error.from_dict(response.json())

Expand Down
6 changes: 6 additions & 0 deletions fishjam/_fishjam_openapi_client/api/viewers/create_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def _get_kwargs(
stream_id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/livestream/{stream_id}/viewer".format(
Expand All @@ -37,6 +38,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 404:
response_404 = Error.from_dict(response.json())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def _get_kwargs(
room_id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/room/{room_id}/viewer".format(
Expand Down Expand Up @@ -42,6 +43,11 @@ def _parse_response(

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 404:
response_404 = Error.from_dict(response.json())

Expand Down
2 changes: 2 additions & 0 deletions fishjam/_fishjam_openapi_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .recording_config_metadata_type_0 import RecordingConfigMetadataType0
from .recording_details_response import RecordingDetailsResponse
from .recording_file import RecordingFile
from .recording_hls_type_0 import RecordingHlsType0
from .recording_list_response import RecordingListResponse
from .recording_metadata_type_0 import RecordingMetadataType0
from .recording_status import RecordingStatus
Expand Down Expand Up @@ -99,6 +100,7 @@
"RecordingConfigMetadataType0",
"RecordingDetailsResponse",
"RecordingFile",
"RecordingHlsType0",
"RecordingListResponse",
"RecordingMetadataType0",
"RecordingStatus",
Expand Down
5 changes: 3 additions & 2 deletions fishjam/_fishjam_openapi_client/models/moq_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class MoqAccess:
"""Connection details for a MoQ relay client

Attributes:
connection_url (str): Relay connection URL with the JWT embedded as a `?jwt=` query parameter. Pass directly to
a MoQ client SDK. Example: https://relay.fishjam.io/abc123?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....
connection_url (str): Relay connection URL scoped to the tenant UUID, with the JWT embedded as a `?jwt=` query
parameter. Pass directly to a MoQ client SDK. Example:
https://relay.fishjam.io/abc123?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....
token (str): JWT authorizing the MoQ relay connection, also embedded in `connection_url` Example: eyJhbGciOiJIUz
I1NiIsInR5cCI6IkpXVCJ9.eyJyb290IjoiZmlzaGphbSIsInB1dCI6WyJteS1zdHJlYW0iXSwiZ2V0IjpbXSwiaWF0IjoxNzEzMzYwMDAwLCJle
HAiOjE3MTMzNjM2MDB9.abc123.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MoqAccessConfig:
subscribe_path (None | str | Unset): Path under the root the token grants subscribe access to Example: my-
stream.
ttl (int | None | Unset): Token time to live in seconds. Defaults to 3600 (1 hour), maximum is 604800 (7 days).
Example: 3600.
On the free tier the maximum is 3600 (1 hour). Example: 3600.
"""

publish_path: None | str | Unset = UNSET
Expand Down
29 changes: 29 additions & 0 deletions fishjam/_fishjam_openapi_client/models/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
if TYPE_CHECKING:
from ..models.composition_source import CompositionSource
from ..models.recording_file import RecordingFile
from ..models.recording_hls_type_0 import RecordingHlsType0
from ..models.recording_metadata_type_0 import RecordingMetadataType0
from ..models.template_source import TemplateSource

Expand All @@ -26,6 +27,8 @@ class Recording:
Attributes:
files (list[RecordingFile]): Media files of the recording, in playback order. Empty until the recording is
`available`.
hls (None | RecordingHlsType0): HLS playlist of the recording, playable while it is still `active`. Null until
the playlist reaches the delivery bucket.
id (str): Assigned recording id
source (CompositionSource | TemplateSource): The source for the recording
status (RecordingStatus): Lifecycle status of a recording
Expand All @@ -34,6 +37,7 @@ class Recording:
"""

files: list[RecordingFile]
hls: None | RecordingHlsType0
id: str
source: CompositionSource | TemplateSource
status: RecordingStatus
Expand All @@ -42,13 +46,20 @@ class Recording:

def to_dict(self) -> dict[str, Any]:
from ..models.composition_source import CompositionSource
from ..models.recording_hls_type_0 import RecordingHlsType0
from ..models.recording_metadata_type_0 import RecordingMetadataType0

files = []
for files_item_data in self.files:
files_item = files_item_data.to_dict()
files.append(files_item)

hls: dict[str, Any] | None
if isinstance(self.hls, RecordingHlsType0):
hls = self.hls.to_dict()
else:
hls = self.hls

id = self.id

source: dict[str, Any]
Expand All @@ -71,6 +82,7 @@ def to_dict(self) -> dict[str, Any]:
field_dict.update(self.additional_properties)
field_dict.update({
"files": files,
"hls": hls,
"id": id,
"source": source,
"status": status,
Expand All @@ -84,6 +96,7 @@ def to_dict(self) -> dict[str, Any]:
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.composition_source import CompositionSource
from ..models.recording_file import RecordingFile
from ..models.recording_hls_type_0 import RecordingHlsType0
from ..models.recording_metadata_type_0 import RecordingMetadataType0
from ..models.template_source import TemplateSource

Expand All @@ -95,6 +108,21 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:

files.append(files_item)

def _parse_hls(data: object) -> None | RecordingHlsType0:
if data is None:
return data
try:
if not isinstance(data, dict):
raise TypeError()
hls_type_0 = RecordingHlsType0.from_dict(data)

return hls_type_0
except (TypeError, ValueError, AttributeError, KeyError):
pass
return cast(None | RecordingHlsType0, data)

hls = _parse_hls(d.pop("hls"))

id = d.pop("id")

def _parse_source(data: object) -> CompositionSource | TemplateSource:
Expand Down Expand Up @@ -137,6 +165,7 @@ def _parse_metadata(data: object) -> None | RecordingMetadataType0 | Unset:

recording = cls(
files=files,
hls=hls,
id=id,
source=source,
status=status,
Expand Down
61 changes: 61 additions & 0 deletions fishjam/_fishjam_openapi_client/models/recording_hls_type_0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

T = TypeVar("T", bound="RecordingHlsType0")


@_attrs_define
class RecordingHlsType0:
"""HLS playlist of the recording, playable while it is still `active`. Null until the playlist reaches the delivery
bucket.

Attributes:
url (str): Public URL the playlist is served at
"""

url: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
url = self.url

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({
"url": url,
})

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
url = d.pop("url")

recording_hls_type_0 = cls(
url=url,
)

recording_hls_type_0.additional_properties = d
return recording_hls_type_0

@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())

def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]

def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value

def __delitem__(self, key: str) -> None:
del self.additional_properties[key]

def __contains__(self, key: str) -> bool:
return key in self.additional_properties
26 changes: 26 additions & 0 deletions tests/test_recording_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def make_recording_json(source: RecordingSource, status: str):
return {
"id": RECORDING_ID,
"files": [],
"hls": None,
"source": source.to_dict(),
"status": status,
}
Expand Down Expand Up @@ -243,6 +244,31 @@ def test_returns_recording(self, recording_api: FishjamClient):
assert request.method == "GET"
assert request.url.path.endswith(f"/recordings/{RECORDING_ID}")

def test_exposes_the_hls_link_of_an_active_recording(
self, recording_api: FishjamClient
):
hls_url = "https://media.example.com/tenant/composition/recording/index.m3u8"
recording_json = make_recording_json(make_composition_source(), "active")
recording_json["hls"] = {"url": hls_url}
_, request_patch = mock_request(200, {"data": recording_json})

with request_patch:
recording = recording_api.get_recording(RECORDING_ID)

assert recording.hls is not None
assert recording.hls.url == hls_url

def test_hls_is_none_until_the_playlist_is_uploaded(
self, recording_api: FishjamClient
):
recording_json = make_recording_json(make_composition_source(), "active")
_, request_patch = mock_request(200, {"data": recording_json})

with request_patch:
recording = recording_api.get_recording(RECORDING_ID)

assert recording.hls is None

def test_id_not_found(self, recording_api: FishjamClient):
with pytest.raises(NotFoundError):
recording_api.get_recording(NONEXISTENT_RECORDING_ID)
Expand Down
Loading