Skip to content

Commit fdd5570

Browse files
authored
Update moq api (#85)
1 parent ef11da8 commit fdd5570

9 files changed

Lines changed: 89 additions & 68 deletions

File tree

fishjam/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
AgentOptions,
1919
AgentOutputOptions,
2020
FishjamClient,
21+
MoqAccess,
2122
Peer,
2223
PeerOptions,
2324
PeerOptionsVapi,
@@ -41,6 +42,7 @@
4142
"AgentOutputOptions",
4243
"Room",
4344
"Peer",
45+
"MoqAccess",
4446
"MissingFishjamIdError",
4547
"InvalidFishjamCredentialsError",
4648
"events",

fishjam/_openapi_client/api/mo_q/create_moq_token.py renamed to fishjam/_openapi_client/api/mo_q/create_moq_access.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
from ... import errors
77
from ...client import AuthenticatedClient, Client
88
from ...models.error import Error
9-
from ...models.moq_token import MoqToken
10-
from ...models.moq_token_config import MoqTokenConfig
9+
from ...models.moq_access import MoqAccess
10+
from ...models.moq_access_config import MoqAccessConfig
1111
from ...types import UNSET, Response, Unset
1212

1313

1414
def _get_kwargs(
1515
*,
16-
body: MoqTokenConfig | Unset = UNSET,
16+
body: MoqAccessConfig | Unset = UNSET,
1717
) -> dict[str, Any]:
1818
headers: dict[str, Any] = {}
1919

2020
_kwargs: dict[str, Any] = {
2121
"method": "post",
22-
"url": "/moq/token",
22+
"url": "/moq/access",
2323
}
2424

2525
if not isinstance(body, Unset):
@@ -33,9 +33,9 @@ def _get_kwargs(
3333

3434
def _parse_response(
3535
*, client: AuthenticatedClient | Client, response: httpx.Response
36-
) -> Error | MoqToken | None:
36+
) -> Error | MoqAccess | None:
3737
if response.status_code == 200:
38-
response_200 = MoqToken.from_dict(response.json())
38+
response_200 = MoqAccess.from_dict(response.json())
3939

4040
return response_200
4141

@@ -62,7 +62,7 @@ def _parse_response(
6262

6363
def _build_response(
6464
*, client: AuthenticatedClient | Client, response: httpx.Response
65-
) -> Response[Error | MoqToken]:
65+
) -> Response[Error | MoqAccess]:
6666
return Response(
6767
status_code=HTTPStatus(response.status_code),
6868
content=response.content,
@@ -74,21 +74,21 @@ def _build_response(
7474
def sync_detailed(
7575
*,
7676
client: AuthenticatedClient,
77-
body: MoqTokenConfig | Unset = UNSET,
78-
) -> Response[Error | MoqToken]:
79-
"""Create a MoQ token
77+
body: MoqAccessConfig | Unset = UNSET,
78+
) -> Response[Error | MoqAccess]:
79+
"""Create MoQ access
8080
8181
Issue a short-lived JWT for a Media over QUIC client.
8282
8383
Args:
84-
body (MoqTokenConfig | Unset): MoQ token configuration
84+
body (MoqAccessConfig | Unset): MoQ access configuration
8585
8686
Raises:
8787
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[Error | MoqToken]
91+
Response[Error | MoqAccess]
9292
"""
9393

9494
kwargs = _get_kwargs(
@@ -105,21 +105,21 @@ def sync_detailed(
105105
def sync(
106106
*,
107107
client: AuthenticatedClient,
108-
body: MoqTokenConfig | Unset = UNSET,
109-
) -> Error | MoqToken | None:
110-
"""Create a MoQ token
108+
body: MoqAccessConfig | Unset = UNSET,
109+
) -> Error | MoqAccess | None:
110+
"""Create MoQ access
111111
112112
Issue a short-lived JWT for a Media over QUIC client.
113113
114114
Args:
115-
body (MoqTokenConfig | Unset): MoQ token configuration
115+
body (MoqAccessConfig | Unset): MoQ access configuration
116116
117117
Raises:
118118
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
119119
httpx.TimeoutException: If the request takes longer than Client.timeout.
120120
121121
Returns:
122-
Error | MoqToken
122+
Error | MoqAccess
123123
"""
124124

125125
return sync_detailed(
@@ -131,21 +131,21 @@ def sync(
131131
async def asyncio_detailed(
132132
*,
133133
client: AuthenticatedClient,
134-
body: MoqTokenConfig | Unset = UNSET,
135-
) -> Response[Error | MoqToken]:
136-
"""Create a MoQ token
134+
body: MoqAccessConfig | Unset = UNSET,
135+
) -> Response[Error | MoqAccess]:
136+
"""Create MoQ access
137137
138138
Issue a short-lived JWT for a Media over QUIC client.
139139
140140
Args:
141-
body (MoqTokenConfig | Unset): MoQ token configuration
141+
body (MoqAccessConfig | Unset): MoQ access configuration
142142
143143
Raises:
144144
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
145145
httpx.TimeoutException: If the request takes longer than Client.timeout.
146146
147147
Returns:
148-
Response[Error | MoqToken]
148+
Response[Error | MoqAccess]
149149
"""
150150

151151
kwargs = _get_kwargs(
@@ -160,21 +160,21 @@ async def asyncio_detailed(
160160
async def asyncio(
161161
*,
162162
client: AuthenticatedClient,
163-
body: MoqTokenConfig | Unset = UNSET,
164-
) -> Error | MoqToken | None:
165-
"""Create a MoQ token
163+
body: MoqAccessConfig | Unset = UNSET,
164+
) -> Error | MoqAccess | None:
165+
"""Create MoQ access
166166
167167
Issue a short-lived JWT for a Media over QUIC client.
168168
169169
Args:
170-
body (MoqTokenConfig | Unset): MoQ token configuration
170+
body (MoqAccessConfig | Unset): MoQ access configuration
171171
172172
Raises:
173173
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
174174
httpx.TimeoutException: If the request takes longer than Client.timeout.
175175
176176
Returns:
177-
Error | MoqToken
177+
Error | MoqAccess
178178
"""
179179

180180
return (

fishjam/_openapi_client/models/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from .audio_sample_rate import AudioSampleRate
66
from .composition_info import CompositionInfo
77
from .error import Error
8-
from .moq_token import MoqToken
9-
from .moq_token_config import MoqTokenConfig
8+
from .moq_access import MoqAccess
9+
from .moq_access_config import MoqAccessConfig
1010
from .peer import Peer
1111
from .peer_config import PeerConfig
1212
from .peer_details_response import PeerDetailsResponse
@@ -54,8 +54,8 @@
5454
"AudioSampleRate",
5555
"CompositionInfo",
5656
"Error",
57-
"MoqToken",
58-
"MoqTokenConfig",
57+
"MoqAccess",
58+
"MoqAccessConfig",
5959
"Peer",
6060
"PeerConfig",
6161
"PeerDetailsResponse",

fishjam/_openapi_client/models/moq_token.py renamed to fishjam/_openapi_client/models/moq_access.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66
from attrs import define as _attrs_define
77
from attrs import field as _attrs_field
88

9-
T = TypeVar("T", bound="MoqToken")
9+
T = TypeVar("T", bound="MoqAccess")
1010

1111

1212
@_attrs_define
13-
class MoqToken:
14-
"""Token for authorizing a MoQ relay connection
13+
class MoqAccess:
14+
"""Connection details for a MoQ relay client
1515
1616
Attributes:
17-
token (str): JWT token for MoQ relay Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb290IjoiZmlzaGphbSIsInB1d
18-
CI6WyJteS1zdHJlYW0iXSwiZ2V0IjpbXSwiaWF0IjoxNzEzMzYwMDAwLCJleHAiOjE3MTMzNjM2MDB9.abc123.
17+
connection_url (str): Relay connection URL with the JWT embedded as a `?jwt=` query parameter. Pass directly to
18+
a MoQ client SDK. Example: https://relay.fishjam.io/abc123?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....
19+
token (str): JWT authorizing the MoQ relay connection, also embedded in `connection_url` Example: eyJhbGciOiJIUz
20+
I1NiIsInR5cCI6IkpXVCJ9.eyJyb290IjoiZmlzaGphbSIsInB1dCI6WyJteS1zdHJlYW0iXSwiZ2V0IjpbXSwiaWF0IjoxNzEzMzYwMDAwLCJle
21+
HAiOjE3MTMzNjM2MDB9.abc123.
1922
"""
2023

24+
connection_url: str
2125
token: str
2226
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
2327

2428
def to_dict(self) -> dict[str, Any]:
29+
connection_url = self.connection_url
30+
2531
token = self.token
2632

2733
field_dict: dict[str, Any] = {}
2834
field_dict.update(self.additional_properties)
2935
field_dict.update({
36+
"connection_url": connection_url,
3037
"token": token,
3138
})
3239

@@ -35,14 +42,17 @@ def to_dict(self) -> dict[str, Any]:
3542
@classmethod
3643
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
3744
d = dict(src_dict)
45+
connection_url = d.pop("connection_url")
46+
3847
token = d.pop("token")
3948

40-
moq_token = cls(
49+
moq_access = cls(
50+
connection_url=connection_url,
4151
token=token,
4252
)
4353

44-
moq_token.additional_properties = d
45-
return moq_token
54+
moq_access.additional_properties = d
55+
return moq_access
4656

4757
@property
4858
def additional_keys(self) -> list[str]:

fishjam/_openapi_client/models/moq_token_config.py renamed to fishjam/_openapi_client/models/moq_access_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
from ..types import UNSET, Unset
99

10-
T = TypeVar("T", bound="MoqTokenConfig")
10+
T = TypeVar("T", bound="MoqAccessConfig")
1111

1212

1313
@_attrs_define
14-
class MoqTokenConfig:
15-
"""MoQ token configuration
14+
class MoqAccessConfig:
15+
"""MoQ access configuration
1616
1717
Attributes:
1818
publish_path (None | str | Unset): Path under the root the token grants publish access to Example: my-stream.
@@ -68,9 +68,9 @@ def _parse_subscribe_path(data: object) -> None | str | Unset:
6868

6969
subscribe_path = _parse_subscribe_path(d.pop("subscribePath", UNSET))
7070

71-
moq_token_config = cls(
71+
moq_access_config = cls(
7272
publish_path=publish_path,
7373
subscribe_path=subscribe_path,
7474
)
7575

76-
return moq_token_config
76+
return moq_access_config

fishjam/api/_fishjam_client.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
validate_credentials as credentials_validate_credentials,
99
)
1010
from fishjam._openapi_client.api.mo_q import (
11-
create_moq_token as moq_create_token,
11+
create_moq_access as moq_create_access,
1212
)
1313
from fishjam._openapi_client.api.rooms import add_peer as room_add_peer
1414
from fishjam._openapi_client.api.rooms import create_room as room_create_room
@@ -29,8 +29,8 @@
2929
AgentOutput,
3030
AudioFormat,
3131
AudioSampleRate,
32-
MoqToken,
33-
MoqTokenConfig,
32+
MoqAccess,
33+
MoqAccessConfig,
3434
Peer,
3535
PeerConfig,
3636
PeerDetailsResponse,
@@ -415,29 +415,31 @@ def create_livestream_streamer_token(self, room_id: str) -> str:
415415

416416
return response.token
417417

418-
def create_moq_token(
418+
def create_moq_access(
419419
self,
420420
publish_path: str | None = None,
421421
subscribe_path: str | None = None,
422-
) -> str:
423-
"""Generates a MoQ token.
422+
) -> MoqAccess:
423+
"""Generates MoQ relay connection details.
424424
425425
Args:
426-
publish_path: Path the token grants publish access to.
427-
subscribe_path: Path the token grants subscribe access to.
426+
publish_path: Path the access grants publish access to.
427+
subscribe_path: Path the access grants subscribe access to.
428428
429429
Returns:
430-
str: The generated token.
430+
MoqAccess: The relay connection details, containing the
431+
``connection_url`` (with the JWT embedded as a ``?jwt=`` query
432+
parameter) and the ``token`` itself.
431433
"""
432-
config = MoqTokenConfig(
434+
config = MoqAccessConfig(
433435
publish_path=publish_path, subscribe_path=subscribe_path
434436
)
435437
response = cast(
436-
MoqToken,
437-
self._request(moq_create_token, body=config),
438+
MoqAccess,
439+
self._request(moq_create_access, body=config),
438440
)
439441

440-
return response.token
442+
return response
441443

442444
def subscribe_peer(self, room_id: str, peer_id: str, target_peer_id: str):
443445
"""Subscribes a peer to all tracks of another peer.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fishjam-server-sdk"
3-
version = "0.28.0"
3+
version = "0.28.1"
44
description = "Python server SDK for the Fishjam"
55
authors = [{ name = "Fishjam Team", email = "contact@fishjam.io" }]
66
requires-python = ">=3.10"

0 commit comments

Comments
 (0)