Skip to content

Commit f2f6e28

Browse files
authored
[RTC-409] Switch openapi generator (#21)
* Migrate to python-generator * Fix ruff * Ruff * Add enum template * Fix ServerMessage docs * Add custom http errors * Update comment * Fix docs warning
1 parent 57716b3 commit f2f6e28

95 files changed

Lines changed: 5291 additions & 7384 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ jobs:
2020
- run:
2121
name: Lint
2222
command: poetry run lint
23-
- run:
24-
name: Check code formatting
25-
command: poetry run check_format
2623
- persist_to_workspace:
2724
root: ~/project
2825
paths:

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,31 @@ Create a `RoomApi` instance, providing the jellyfish server address and api toke
2626
```python
2727
from jellyfish import RoomApi
2828

29-
room_api = RoomApi(server_address='localhost:5002', server_api_token='development')
29+
room_api = RoomApi(server_address="localhost:5002", server_api_token="development")
3030
```
3131

3232
You can use it to interact with Jellyfish, manage rooms, peers and components
3333

3434
```python
3535
# Create a room
36-
jellyfish_address, room = room_api.create_room(video_codec='h264')
37-
# 'localhost:5002', Room(components=[], config=RoomConfig(max_peers=None, video_codec='h264'), id='5a099a31-0eb2-4c28-84af-a1ec55c228af', peers=[]))
36+
jellyfish_address, room = room_api.create_room(video_codec="h264", webhook_url="http://localhost:5000/webhook")
37+
# '127.0.0.1:5002', Room(components=[], config=RoomConfig(max_peers=None, video_codec=<RoomConfigVideoCodec.H264: 'h264'>, webhook_url='http://localhost:5000/webhook'), id='1d905478-ccfc-44d6-a6e7-8ccb1b38d955', peers=[])
3838

3939
# Add peer to the room
4040
from jellyfish import PeerOptionsWebRTC
4141

4242
peer_token, peer_webrtc = room_api.add_peer(room.id, options=PeerOptionsWebRTC())
43-
# 'AgDYfrCSigFiAA', Peer(id='2869fb5', status=<PeerStatus.DISCONNECTED: 'disconnected'>, type='webrtc')
43+
# 'M8TUGhj-L11KpyG-2zBPIo', Peer(id='b1232c7e-c969-4450-acdf-ea24f3cdd7f6', status=<PeerStatus.DISCONNECTED: 'disconnected'>, type='webrtc')
4444

4545
# Add component to the room
4646
from jellyfish import ComponentOptionsHLS
4747

4848
component_hls = room_api.add_component(room.id, options=ComponentOptionsHLS())
49-
# Component(actual_instance=ComponentHLS(id='c0dfab50-cafd-438d-985e-7b8f97ae55e3', metadata=ComponentMetadataHLS(low_latency=False, playable=False), type='hls'))
49+
# ComponentHLS(id='5f062447-a9f7-45ed-8d1b-511f77dc78ae', properties=ComponentPropertiesHLS(low_latency=False, persistent=False, playable=False, subscribe_mode=<ComponentPropertiesHLSSubscribeMode.AUTO: 'auto'>, target_window_duration=None), type='hls')
5050
```
5151

52+
All methods in `RoomApi` may raise one of the exceptions deriving from `jellyfish.errors.HTTPError`. They are defined in `jellyfish.errors`.
53+
5254
#### Notifier
5355

5456
Create `Notifier` instance
@@ -96,14 +98,14 @@ You can test the SDK by running
9698
poetry run ci_test
9799
```
98100

99-
## Format&Lint
101+
## Format & Lint
100102
You can format code by running
101103
```console
102104
poetry run format
103105
```
104106

105107
You can check linter by running
106-
```
108+
```console
107109
poetry run lint
108110
```
109111

generate_client.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

jellyfish/__init__.py

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,53 @@
44

55
# pylint: disable=locally-disabled, no-name-in-module, import-error
66

7-
from pydantic.error_wrappers import ValidationError
8-
9-
# API
10-
from jellyfish._room_api import RoomApi
11-
from jellyfish._recording_api import RecordingApi
12-
from jellyfish._ws_notifier import Notifier
13-
from jellyfish._webhook_notifier import receive_json
7+
# Exceptions and Server Messages
8+
from jellyfish import errors, events
149

1510
# Models
16-
from jellyfish._openapi_client import (
17-
Room,
18-
RoomConfig,
19-
Peer,
20-
Component,
11+
from jellyfish._openapi_client.models import (
2112
ComponentHLS,
22-
ComponentRTSP,
23-
ComponentOptions,
24-
ComponentOptionsRTSP,
2513
ComponentOptionsHLS,
14+
ComponentOptionsHLSSubscribeMode,
15+
ComponentOptionsRTSP,
16+
ComponentPropertiesHLS,
17+
ComponentPropertiesHLSSubscribeMode,
18+
ComponentPropertiesRTSP,
19+
ComponentRTSP,
20+
Peer,
2621
PeerOptionsWebRTC,
22+
PeerStatus,
23+
Room,
24+
RoomConfig,
25+
RoomConfigVideoCodec,
2726
)
2827

29-
# Server Messages
30-
from jellyfish import events
31-
32-
# Exceptions
33-
from jellyfish._openapi_client.exceptions import (
34-
UnauthorizedException,
35-
NotFoundException,
36-
BadRequestException,
37-
)
38-
28+
# API
29+
from jellyfish._webhook_notifier import receive_json
30+
from jellyfish._ws_notifier import Notifier
31+
from jellyfish.api._recording_api import RecordingApi
32+
from jellyfish.api._room_api import RoomApi
3933

4034
__all__ = [
4135
"RoomApi",
4236
"RecordingApi",
4337
"Notifier",
4438
"receive_json",
4539
"Room",
40+
"RoomConfig",
41+
"RoomConfigVideoCodec",
4642
"Peer",
47-
"Component",
43+
"PeerOptionsWebRTC",
44+
"PeerStatus",
4845
"ComponentHLS",
49-
"ComponentRTSP",
5046
"ComponentOptionsHLS",
51-
"RoomConfig",
52-
"ComponentOptions",
47+
"ComponentOptionsHLSSubscribeMode",
48+
"ComponentPropertiesHLS",
49+
"ComponentPropertiesHLSSubscribeMode",
50+
"ComponentRTSP",
5351
"ComponentOptionsRTSP",
54-
"PeerOptionsWebRTC",
52+
"ComponentPropertiesRTSP",
5553
"events",
56-
"UnauthorizedException",
57-
"NotFoundException",
58-
"BadRequestException",
54+
"errors",
5955
]
60-
6156
__docformat__ = "restructuredtext"
Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,7 @@
1-
# coding: utf-8
1+
""" A client library for accessing Jellyfish Media Server """
2+
from .client import AuthenticatedClient, Client
23

3-
# flake8: noqa
4-
5-
"""
6-
Python API wrapper for Jellyfish Media Server
7-
8-
The version of the OpenAPI document: 0.2.0
9-
Generated by OpenAPI Generator (https://openapi-generator.tech)
10-
11-
Do not edit the class manually.
12-
""" # noqa: E501
13-
14-
15-
__version__ = "1.0.0"
16-
17-
# import apis into sdk package
18-
from jellyfish._openapi_client.api.hls_api import HlsApi
19-
from jellyfish._openapi_client.api.recording_api import RecordingApi
20-
from jellyfish._openapi_client.api.room_api import RoomApi
21-
22-
# import ApiClient
23-
from jellyfish._openapi_client.api_response import ApiResponse
24-
from jellyfish._openapi_client.api_client import ApiClient
25-
from jellyfish._openapi_client.configuration import Configuration
26-
from jellyfish._openapi_client.exceptions import OpenApiException
27-
from jellyfish._openapi_client.exceptions import ApiTypeError
28-
from jellyfish._openapi_client.exceptions import ApiValueError
29-
from jellyfish._openapi_client.exceptions import ApiKeyError
30-
from jellyfish._openapi_client.exceptions import ApiAttributeError
31-
from jellyfish._openapi_client.exceptions import ApiException
32-
33-
# import models into sdk package
34-
from jellyfish._openapi_client.models.add_component_request import AddComponentRequest
35-
from jellyfish._openapi_client.models.add_peer_request import AddPeerRequest
36-
from jellyfish._openapi_client.models.component import Component
37-
from jellyfish._openapi_client.models.component_details_response import (
38-
ComponentDetailsResponse,
39-
)
40-
from jellyfish._openapi_client.models.component_hls import ComponentHLS
41-
from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS
42-
from jellyfish._openapi_client.models.component_options import ComponentOptions
43-
from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS
44-
from jellyfish._openapi_client.models.component_options_hlss3 import (
45-
ComponentOptionsHLSS3,
46-
)
47-
from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP
48-
from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP
49-
from jellyfish._openapi_client.models.error import Error
50-
from jellyfish._openapi_client.models.hls_skip import HlsSkip
51-
from jellyfish._openapi_client.models.peer import Peer
52-
from jellyfish._openapi_client.models.peer_details_response import PeerDetailsResponse
53-
from jellyfish._openapi_client.models.peer_details_response_data import (
54-
PeerDetailsResponseData,
55-
)
56-
from jellyfish._openapi_client.models.peer_options import PeerOptions
57-
from jellyfish._openapi_client.models.peer_options_web_rtc import PeerOptionsWebRTC
58-
from jellyfish._openapi_client.models.peer_status import PeerStatus
59-
from jellyfish._openapi_client.models.recording_list_response import (
60-
RecordingListResponse,
61-
)
62-
from jellyfish._openapi_client.models.room import Room
63-
from jellyfish._openapi_client.models.room_config import RoomConfig
64-
from jellyfish._openapi_client.models.room_create_details_response import (
65-
RoomCreateDetailsResponse,
66-
)
67-
from jellyfish._openapi_client.models.room_create_details_response_data import (
68-
RoomCreateDetailsResponseData,
4+
__all__ = (
5+
"AuthenticatedClient",
6+
"Client",
697
)
70-
from jellyfish._openapi_client.models.room_details_response import RoomDetailsResponse
71-
from jellyfish._openapi_client.models.rooms_listing_response import RoomsListingResponse
72-
from jellyfish._openapi_client.models.s3_credentials import S3Credentials
73-
from jellyfish._openapi_client.models.subscription_config import SubscriptionConfig
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
# flake8: noqa
2-
3-
# import apis into api package
4-
from jellyfish._openapi_client.api.hls_api import HlsApi
5-
from jellyfish._openapi_client.api.recording_api import RecordingApi
6-
from jellyfish._openapi_client.api.room_api import RoomApi
1+
""" Contains methods for accessing the API """

jellyfish/_openapi_client/api/hls/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)