Skip to content

Commit 1169e90

Browse files
Rados13Karolk99
andauthored
RTC-510 Update subscribe method in room_api (#34)
* Update subscribe method in room_api * Update jellyfish/api/_room_api.py Co-authored-by: Karol Konkol <[email protected]> * Update client * Update example --------- Co-authored-by: Karol Konkol <[email protected]>
1 parent 98df769 commit 1169e90

File tree

11 files changed

+142
-30
lines changed

11 files changed

+142
-30
lines changed

examples/mini_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def test_notifier():
6161
room_api = RoomApi(server_address=address)
6262

6363
# Add HLS component with manual subscribe mode
64-
_hls_component = room_api.add_component(
64+
hls_component = room_api.add_component(
6565
room.id,
6666
ComponentOptionsHLS(subscribe_mode=ComponentOptionsHLSSubscribeMode.MANUAL),
6767
)
@@ -70,7 +70,7 @@ async def test_notifier():
7070
file_component = room_api.add_component(room.id, ComponentOptionsFile("video.h264"))
7171

7272
# Subscribe on specific component
73-
room_api.hls_subscribe(room.id, [file_component.id])
73+
room_api.subscribe(room.id, hls_component.id, [file_component.id])
7474

7575
try:
7676
await notifier_task

jellyfish/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
ComponentOptionsHLS,
1616
ComponentOptionsHLSSubscribeMode,
1717
ComponentOptionsRecording,
18+
ComponentOptionsRecordingSubscribeMode,
1819
ComponentOptionsRTSP,
1920
ComponentOptionsSIP,
2021
ComponentPropertiesFile,
2122
ComponentPropertiesHLS,
2223
ComponentPropertiesHLSSubscribeMode,
2324
ComponentPropertiesRecording,
25+
ComponentPropertiesRecordingSubscribeMode,
2426
ComponentPropertiesRTSP,
2527
ComponentPropertiesSIP,
2628
ComponentPropertiesSIPSIPCredentials,
@@ -75,7 +77,9 @@
7577
"SIPCredentials",
7678
"ComponentRecording",
7779
"ComponentOptionsRecording",
80+
"ComponentOptionsRecordingSubscribeMode",
7881
"ComponentPropertiesRecording",
82+
"ComponentPropertiesRecordingSubscribeMode",
7983
"S3Credentials",
8084
]
8185
__docformat__ = "restructuredtext"

jellyfish/_openapi_client/api/hls/subscribe_hls_to.py renamed to jellyfish/_openapi_client/api/room/subscribe_to.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212

1313
def _get_kwargs(
1414
room_id: str,
15+
component_id: str,
1516
*,
1617
json_body: SubscriptionConfig,
1718
) -> Dict[str, Any]:
1819
json_json_body = json_body.to_dict()
1920

2021
return {
2122
"method": "post",
22-
"url": "/hls/{room_id}/subscribe".format(
23+
"url": "/room/{room_id}/component/{component_id}/subscribe".format(
2324
room_id=room_id,
25+
component_id=component_id,
2426
),
2527
"json": json_json_body,
2628
}
@@ -63,14 +65,16 @@ def _build_response(
6365

6466
def sync_detailed(
6567
room_id: str,
68+
component_id: str,
6669
*,
6770
client: AuthenticatedClient,
6871
json_body: SubscriptionConfig,
6972
) -> Response[Union[Any, Error]]:
70-
"""Subscribe the HLS component to the tracks of peers or components
73+
"""Subscribe component to the tracks of peers or components
7174
7275
Args:
7376
room_id (str):
77+
component_id (str):
7478
json_body (SubscriptionConfig): Subscription config
7579
7680
Raises:
@@ -83,6 +87,7 @@ def sync_detailed(
8387

8488
kwargs = _get_kwargs(
8589
room_id=room_id,
90+
component_id=component_id,
8691
json_body=json_body,
8792
)
8893

@@ -95,14 +100,16 @@ def sync_detailed(
95100

96101
def sync(
97102
room_id: str,
103+
component_id: str,
98104
*,
99105
client: AuthenticatedClient,
100106
json_body: SubscriptionConfig,
101107
) -> Optional[Union[Any, Error]]:
102-
"""Subscribe the HLS component to the tracks of peers or components
108+
"""Subscribe component to the tracks of peers or components
103109
104110
Args:
105111
room_id (str):
112+
component_id (str):
106113
json_body (SubscriptionConfig): Subscription config
107114
108115
Raises:
@@ -115,21 +122,24 @@ def sync(
115122

116123
return sync_detailed(
117124
room_id=room_id,
125+
component_id=component_id,
118126
client=client,
119127
json_body=json_body,
120128
).parsed
121129

122130

123131
async def asyncio_detailed(
124132
room_id: str,
133+
component_id: str,
125134
*,
126135
client: AuthenticatedClient,
127136
json_body: SubscriptionConfig,
128137
) -> Response[Union[Any, Error]]:
129-
"""Subscribe the HLS component to the tracks of peers or components
138+
"""Subscribe component to the tracks of peers or components
130139
131140
Args:
132141
room_id (str):
142+
component_id (str):
133143
json_body (SubscriptionConfig): Subscription config
134144
135145
Raises:
@@ -142,6 +152,7 @@ async def asyncio_detailed(
142152

143153
kwargs = _get_kwargs(
144154
room_id=room_id,
155+
component_id=component_id,
145156
json_body=json_body,
146157
)
147158

@@ -152,14 +163,16 @@ async def asyncio_detailed(
152163

153164
async def asyncio(
154165
room_id: str,
166+
component_id: str,
155167
*,
156168
client: AuthenticatedClient,
157169
json_body: SubscriptionConfig,
158170
) -> Optional[Union[Any, Error]]:
159-
"""Subscribe the HLS component to the tracks of peers or components
171+
"""Subscribe component to the tracks of peers or components
160172
161173
Args:
162174
room_id (str):
175+
component_id (str):
163176
json_body (SubscriptionConfig): Subscription config
164177
165178
Raises:
@@ -173,6 +186,7 @@ async def asyncio(
173186
return (
174187
await asyncio_detailed(
175188
room_id=room_id,
189+
component_id=component_id,
176190
client=client,
177191
json_body=json_body,
178192
)

jellyfish/_openapi_client/models/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
from .component_options_hls import ComponentOptionsHLS
1010
from .component_options_hls_subscribe_mode import ComponentOptionsHLSSubscribeMode
1111
from .component_options_recording import ComponentOptionsRecording
12+
from .component_options_recording_subscribe_mode import (
13+
ComponentOptionsRecordingSubscribeMode,
14+
)
1215
from .component_options_rtsp import ComponentOptionsRTSP
1316
from .component_options_sip import ComponentOptionsSIP
1417
from .component_options_sipsip_credentials import ComponentOptionsSIPSIPCredentials
1518
from .component_properties_file import ComponentPropertiesFile
1619
from .component_properties_hls import ComponentPropertiesHLS
1720
from .component_properties_hls_subscribe_mode import ComponentPropertiesHLSSubscribeMode
1821
from .component_properties_recording import ComponentPropertiesRecording
22+
from .component_properties_recording_subscribe_mode import (
23+
ComponentPropertiesRecordingSubscribeMode,
24+
)
1925
from .component_properties_rtsp import ComponentPropertiesRTSP
2026
from .component_properties_sip import ComponentPropertiesSIP
2127
from .component_properties_sipsip_credentials import (
@@ -59,13 +65,15 @@
5965
"ComponentOptionsHLS",
6066
"ComponentOptionsHLSSubscribeMode",
6167
"ComponentOptionsRecording",
68+
"ComponentOptionsRecordingSubscribeMode",
6269
"ComponentOptionsRTSP",
6370
"ComponentOptionsSIP",
6471
"ComponentOptionsSIPSIPCredentials",
6572
"ComponentPropertiesFile",
6673
"ComponentPropertiesHLS",
6774
"ComponentPropertiesHLSSubscribeMode",
6875
"ComponentPropertiesRecording",
76+
"ComponentPropertiesRecordingSubscribeMode",
6977
"ComponentPropertiesRTSP",
7078
"ComponentPropertiesSIP",
7179
"ComponentPropertiesSIPSIPCredentials",

jellyfish/_openapi_client/models/component_options_recording.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from attrs import define as _attrs_define
44
from attrs import field as _attrs_field
55

6+
from ..models.component_options_recording_subscribe_mode import (
7+
ComponentOptionsRecordingSubscribeMode,
8+
)
69
from ..types import UNSET, Unset
710

811
if TYPE_CHECKING:
@@ -18,8 +21,12 @@ class ComponentOptionsRecording:
1821

1922
credentials: Union[Unset, None, "S3Credentials"] = UNSET
2023
"""An AWS S3 credential that will be used to send HLS stream. The stream will only be uploaded if credentials are provided"""
21-
path_prefix: Union[Unset, str] = ""
24+
path_prefix: Union[Unset, None, str] = UNSET
2225
"""Path prefix under which all recording are stored"""
26+
subscribe_mode: Union[
27+
Unset, ComponentOptionsRecordingSubscribeMode
28+
] = ComponentOptionsRecordingSubscribeMode.AUTO
29+
"""Whether the Recording component should subscribe to tracks automatically or manually."""
2330
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
2431
"""@private"""
2532

@@ -30,6 +37,9 @@ def to_dict(self) -> Dict[str, Any]:
3037
credentials = self.credentials.to_dict() if self.credentials else None
3138

3239
path_prefix = self.path_prefix
40+
subscribe_mode: Union[Unset, str] = UNSET
41+
if not isinstance(self.subscribe_mode, Unset):
42+
subscribe_mode = self.subscribe_mode.value
3343

3444
field_dict: Dict[str, Any] = {}
3545
field_dict.update(self.additional_properties)
@@ -38,6 +48,8 @@ def to_dict(self) -> Dict[str, Any]:
3848
field_dict["credentials"] = credentials
3949
if path_prefix is not UNSET:
4050
field_dict["pathPrefix"] = path_prefix
51+
if subscribe_mode is not UNSET:
52+
field_dict["subscribeMode"] = subscribe_mode
4153

4254
return field_dict
4355

@@ -58,9 +70,17 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
5870

5971
path_prefix = d.pop("pathPrefix", UNSET)
6072

73+
_subscribe_mode = d.pop("subscribeMode", UNSET)
74+
subscribe_mode: Union[Unset, ComponentOptionsRecordingSubscribeMode]
75+
if isinstance(_subscribe_mode, Unset):
76+
subscribe_mode = UNSET
77+
else:
78+
subscribe_mode = ComponentOptionsRecordingSubscribeMode(_subscribe_mode)
79+
6180
component_options_recording = cls(
6281
credentials=credentials,
6382
path_prefix=path_prefix,
83+
subscribe_mode=subscribe_mode,
6484
)
6585

6686
component_options_recording.additional_properties = d
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from enum import Enum
2+
3+
4+
class ComponentOptionsRecordingSubscribeMode(str, Enum):
5+
"""Whether the Recording component should subscribe to tracks automatically or manually."""
6+
7+
AUTO = "auto"
8+
MANUAL = "manual"
9+
10+
def __str__(self) -> str:
11+
return str(self.value)

jellyfish/_openapi_client/models/component_properties_recording.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@
33
from attrs import define as _attrs_define
44
from attrs import field as _attrs_field
55

6+
from ..models.component_properties_recording_subscribe_mode import (
7+
ComponentPropertiesRecordingSubscribeMode,
8+
)
9+
610
T = TypeVar("T", bound="ComponentPropertiesRecording")
711

812

913
@_attrs_define
1014
class ComponentPropertiesRecording:
1115
"""Properties specific to the Recording component"""
1216

13-
path_prefix: str
14-
"""Path prefix under which all recording are stored"""
17+
subscribe_mode: ComponentPropertiesRecordingSubscribeMode
18+
"""Whether the Recording component should subscribe to tracks automatically or manually"""
1519
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
1620
"""@private"""
1721

1822
def to_dict(self) -> Dict[str, Any]:
1923
"""@private"""
20-
path_prefix = self.path_prefix
24+
subscribe_mode = self.subscribe_mode.value
2125

2226
field_dict: Dict[str, Any] = {}
2327
field_dict.update(self.additional_properties)
2428
field_dict.update(
2529
{
26-
"pathPrefix": path_prefix,
30+
"subscribeMode": subscribe_mode,
2731
}
2832
)
2933

@@ -33,10 +37,12 @@ def to_dict(self) -> Dict[str, Any]:
3337
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
3438
"""@private"""
3539
d = src_dict.copy()
36-
path_prefix = d.pop("pathPrefix")
40+
subscribe_mode = ComponentPropertiesRecordingSubscribeMode(
41+
d.pop("subscribeMode")
42+
)
3743

3844
component_properties_recording = cls(
39-
path_prefix=path_prefix,
45+
subscribe_mode=subscribe_mode,
4046
)
4147

4248
component_properties_recording.additional_properties = d
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from enum import Enum
2+
3+
4+
class ComponentPropertiesRecordingSubscribeMode(str, Enum):
5+
"""Whether the Recording component should subscribe to tracks automatically or manually"""
6+
7+
AUTO = "auto"
8+
MANUAL = "manual"
9+
10+
def __str__(self) -> str:
11+
return str(self.value)

jellyfish/_openapi_client/models/health_report.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,36 @@ class HealthReport:
1818

1919
distribution: "HealthReportDistribution"
2020
"""Informs about the status of Jellyfish distribution"""
21+
git_commit: str
22+
"""Commit hash of the build"""
2123
status: HealthReportStatus
2224
"""Informs about the status of Jellyfish or a specific service"""
2325
uptime: int
2426
"""Uptime of Jellyfish (in seconds)"""
27+
version: str
28+
"""Version of Jellyfish"""
2529
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
2630
"""@private"""
2731

2832
def to_dict(self) -> Dict[str, Any]:
2933
"""@private"""
3034
distribution = self.distribution.to_dict()
3135

36+
git_commit = self.git_commit
3237
status = self.status.value
3338

3439
uptime = self.uptime
40+
version = self.version
3541

3642
field_dict: Dict[str, Any] = {}
3743
field_dict.update(self.additional_properties)
3844
field_dict.update(
3945
{
4046
"distribution": distribution,
47+
"gitCommit": git_commit,
4148
"status": status,
4249
"uptime": uptime,
50+
"version": version,
4351
}
4452
)
4553

@@ -53,14 +61,20 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
5361
d = src_dict.copy()
5462
distribution = HealthReportDistribution.from_dict(d.pop("distribution"))
5563

64+
git_commit = d.pop("gitCommit")
65+
5666
status = HealthReportStatus(d.pop("status"))
5767

5868
uptime = d.pop("uptime")
5969

70+
version = d.pop("version")
71+
6072
health_report = cls(
6173
distribution=distribution,
74+
git_commit=git_commit,
6275
status=status,
6376
uptime=uptime,
77+
version=version,
6478
)
6579

6680
health_report.additional_properties = d

0 commit comments

Comments
 (0)