Skip to content

Commit

Permalink
Data classes and type hints (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel authored Oct 2, 2023
1 parent 615e209 commit 9b17b84
Show file tree
Hide file tree
Showing 173 changed files with 4,728 additions and 955 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
env:
VIDEO_API_KEY: ${{ secrets.VIDEO_API_KEY }}
VIDEO_API_SECRET: ${{ secrets.VIDEO_API_SECRET }}
run: poetry run pytest tests/test_integration.py
run: poetry run pytest tests/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
*/cli/__pycache__
.env
.vscode/settings.json
*.pyc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ poetry run create-token --api-key API_KEY --api-secret API_SECRET --user-id USER
```

Or you can use docker
First, build the image
First, build the image:

```sh
docker build -t stream-py .
Expand Down
2 changes: 1 addition & 1 deletion getstream/chat/sync/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .chat import ChatClient # noqa F401
# from getstream.chat.sync.chat import ChatClient # noqa: F401
8 changes: 4 additions & 4 deletions getstream/chat/sync/chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from getstream.sync.base import BaseClient
# from getstream.sync.base import BaseClient


class ChatClient(BaseClient):
def __init__(self, api_key: str, base_url, token):
super().__init__(api_key=api_key, base_url=base_url, token=token)
# class ChatClient(BaseClient):
# def __init__(self, api_key: str, base_url, token):
# super().__init__(api_key=api_key, base_url=base_url, token=token)
4 changes: 4 additions & 0 deletions getstream/generic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import TypeVar


T = TypeVar("T")
Empty file added getstream/models/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions getstream/models/accept_call_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class AcceptCallResponse:
duration: str = field(metadata=config(field_name="duration"))
18 changes: 18 additions & 0 deletions getstream/models/api_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import List, Dict, Optional


@dataclass_json
@dataclass
class Apierror:
code: int = field(metadata=config(field_name="code"))
details: List[int] = field(metadata=config(field_name="details"))
duration: str = field(metadata=config(field_name="duration"))
message: str = field(metadata=config(field_name="message"))
more_info: str = field(metadata=config(field_name="more_info"))
status_code: int = field(metadata=config(field_name="StatusCode"))
exception_fields: Optional[Dict[str, str]] = field(
metadata=config(field_name="exception_fields"), default=None
)
9 changes: 9 additions & 0 deletions getstream/models/apns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class Apns:
body: str = field(metadata=config(field_name="body"))
title: str = field(metadata=config(field_name="title"))
11 changes: 11 additions & 0 deletions getstream/models/apns_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional


@dataclass_json
@dataclass
class Apnsrequest:
body: Optional[str] = field(metadata=config(field_name="body"), default=None)
title: Optional[str] = field(metadata=config(field_name="title"), default=None)
17 changes: 17 additions & 0 deletions getstream/models/audio_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class AudioSettings:
access_request_enabled: bool = field(
metadata=config(field_name="access_request_enabled")
)
default_device: str = field(metadata=config(field_name="default_device"))
mic_default_on: bool = field(metadata=config(field_name="mic_default_on"))
opus_dtx_enabled: bool = field(metadata=config(field_name="opus_dtx_enabled"))
redundant_coding_enabled: bool = field(
metadata=config(field_name="redundant_coding_enabled")
)
speaker_default_on: bool = field(metadata=config(field_name="speaker_default_on"))
25 changes: 25 additions & 0 deletions getstream/models/audio_settings_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional


@dataclass_json
@dataclass
class AudioSettingsRequest:
default_device: str = field(metadata=config(field_name="default_device"))
speaker_default_on: Optional[bool] = field(
metadata=config(field_name="speaker_default_on"), default=None
)
access_request_enabled: Optional[bool] = field(
metadata=config(field_name="access_request_enabled"), default=None
)
mic_default_on: Optional[bool] = field(
metadata=config(field_name="mic_default_on"), default=None
)
opus_dtx_enabled: Optional[bool] = field(
metadata=config(field_name="opus_dtx_enabled"), default=None
)
redundant_coding_enabled: Optional[bool] = field(
metadata=config(field_name="redundant_coding_enabled"), default=None
)
8 changes: 8 additions & 0 deletions getstream/models/backstage_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class BackstageSettings:
enabled: bool = field(metadata=config(field_name="enabled"))
10 changes: 10 additions & 0 deletions getstream/models/backstage_settings_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional


@dataclass_json
@dataclass
class BackstageSettingsRequest:
enabled: Optional[bool] = field(metadata=config(field_name="enabled"), default=None)
8 changes: 8 additions & 0 deletions getstream/models/block_user_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class BlockUserRequest:
user_id: str = field(metadata=config(field_name="user_id"))
8 changes: 8 additions & 0 deletions getstream/models/block_user_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json


@dataclass_json
@dataclass
class BlockUserResponse:
duration: str = field(metadata=config(field_name="duration"))
27 changes: 27 additions & 0 deletions getstream/models/blocked_user_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional
from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields
from getstream.models.user_response import UserResponse


@dataclass_json
@dataclass
class BlockedUserEvent:
type: str = field(metadata=config(field_name="type"))
user: UserResponse = field(metadata=config(field_name="user"))
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
blocked_by_user: Optional[UserResponse] = field(
metadata=config(field_name="blocked_by_user"), default=None
)
14 changes: 14 additions & 0 deletions getstream/models/broadcast_settings_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional
from getstream.models.hls_settings_request import HlssettingsRequest


@dataclass_json
@dataclass
class BroadcastSettingsRequest:
enabled: Optional[bool] = field(metadata=config(field_name="enabled"), default=None)
hls: Optional[HlssettingsRequest] = field(
metadata=config(field_name="hls"), default=None
)
11 changes: 11 additions & 0 deletions getstream/models/broadcast_settings_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from getstream.models.hls_settings_response import HlssettingsResponse


@dataclass_json
@dataclass
class BroadcastSettingsResponse:
enabled: bool = field(metadata=config(field_name="enabled"))
hls: HlssettingsResponse = field(metadata=config(field_name="hls"))
25 changes: 25 additions & 0 deletions getstream/models/call_accepted_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields
from getstream.models.user_response import UserResponse
from getstream.models.call_response import CallResponse


@dataclass_json
@dataclass
class CallAcceptedEvent:
user: UserResponse = field(metadata=config(field_name="user"))
call: CallResponse = field(metadata=config(field_name="call"))
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
type: str = field(metadata=config(field_name="type"))
26 changes: 26 additions & 0 deletions getstream/models/call_created_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import List
from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields
from getstream.models.call_response import CallResponse
from getstream.models.member_response import MemberResponse


@dataclass_json
@dataclass
class CallCreatedEvent:
call: CallResponse = field(metadata=config(field_name="call"))
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
members: List[MemberResponse] = field(metadata=config(field_name="members"))
type: str = field(metadata=config(field_name="type"))
28 changes: 28 additions & 0 deletions getstream/models/call_ended_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from typing import Optional
from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields
from getstream.models.user_response import UserResponse
from getstream.models.call_response import CallResponse


@dataclass_json
@dataclass
class CallEndedEvent:
call: CallResponse = field(metadata=config(field_name="call"))
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
type: str = field(metadata=config(field_name="type"))
user: Optional[UserResponse] = field(
metadata=config(field_name="user"), default=None
)
22 changes: 22 additions & 0 deletions getstream/models/call_hls_broadcasting_started_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields


@dataclass_json
@dataclass
class CallHlsbroadcastingStartedEvent:
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
hls_playlist_url: str = field(metadata=config(field_name="hls_playlist_url"))
type: str = field(metadata=config(field_name="type"))
21 changes: 21 additions & 0 deletions getstream/models/call_hls_broadcasting_stopped_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields


@dataclass_json
@dataclass
class CallHlsbroadcastingStoppedEvent:
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
type: str = field(metadata=config(field_name="type"))
10 changes: 10 additions & 0 deletions getstream/models/call_ingress_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from getstream.models.rtmp_ingress import Rtmpingress


@dataclass_json
@dataclass
class CallIngressResponse:
rtmp: Rtmpingress = field(metadata=config(field_name="rtmp"))
23 changes: 23 additions & 0 deletions getstream/models/call_live_started_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json

from datetime import datetime
from dateutil.parser import parse
from marshmallow import fields
from getstream.models.call_response import CallResponse


@dataclass_json
@dataclass
class CallLiveStartedEvent:
type: str = field(metadata=config(field_name="type"))
call: CallResponse = field(metadata=config(field_name="call"))
call_cid: str = field(metadata=config(field_name="call_cid"))
created_at: datetime = field(
metadata=config(
field_name="created_at",
encoder=lambda d: d.isoformat(),
decoder=parse,
mm_field=fields.DateTime(format="iso"),
)
)
Loading

0 comments on commit 9b17b84

Please sign in to comment.