Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data classes and type hints #5

Merged
merged 70 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b6fe5f8
models wip
sachaarbonel Aug 22, 2023
25a68fb
lint
sachaarbonel Aug 23, 2023
6df05d6
wip
sachaarbonel Aug 24, 2023
7794551
lint
sachaarbonel Aug 24, 2023
74c7242
wip
sachaarbonel Aug 25, 2023
15eae8a
lint
sachaarbonel Aug 25, 2023
9f6bc4c
lint
sachaarbonel Aug 25, 2023
154c4df
lint fix?
sachaarbonel Aug 25, 2023
34e9f98
lint
sachaarbonel Aug 25, 2023
27ee2ce
lint
sachaarbonel Aug 25, 2023
7b823cb
lint
sachaarbonel Aug 25, 2023
cc97b91
lint
sachaarbonel Aug 25, 2023
83d894b
more lints
sachaarbonel Aug 25, 2023
aac51bf
lint
sachaarbonel Aug 25, 2023
e254ece
lint?
sachaarbonel Aug 25, 2023
06b25a4
lint
sachaarbonel Aug 25, 2023
a2ff15b
lint
sachaarbonel Aug 25, 2023
2a6646a
lint
sachaarbonel Aug 25, 2023
ca3dcd2
lint
sachaarbonel Aug 25, 2023
4fcf94d
lint
sachaarbonel Aug 25, 2023
aaca008
lint
sachaarbonel Aug 25, 2023
8570c9e
lint
sachaarbonel Aug 25, 2023
1b6f2bf
test + _parse_response
sachaarbonel Aug 25, 2023
f84b767
lint
sachaarbonel Aug 25, 2023
60e9fc2
debug
sachaarbonel Aug 25, 2023
e05b47d
fix deserialization?
sachaarbonel Aug 25, 2023
4863a17
fix?
sachaarbonel Aug 25, 2023
b3e3c9d
fix?
sachaarbonel Aug 25, 2023
4c75a4c
more deserialization
sachaarbonel Aug 27, 2023
e5d690d
wip
sachaarbonel Aug 27, 2023
b99930a
wip
sachaarbonel Aug 27, 2023
2a442ce
handle none
sachaarbonel Aug 27, 2023
3f592b3
wip
sachaarbonel Aug 27, 2023
c4bd0ec
fix ?
sachaarbonel Aug 27, 2023
f533edb
cleanup
sachaarbonel Aug 27, 2023
e4bcd93
debug
sachaarbonel Aug 27, 2023
d2053b5
debug
sachaarbonel Aug 27, 2023
941343f
fix?
sachaarbonel Aug 27, 2023
02cb39a
Optional None
sachaarbonel Aug 27, 2023
a781ff9
wip
sachaarbonel Aug 27, 2023
9be1b39
fix?
sachaarbonel Aug 27, 2023
3a67ddd
wip
sachaarbonel Aug 27, 2023
fb9a0e4
wip
sachaarbonel Aug 27, 2023
d632ec7
fix
sachaarbonel Aug 28, 2023
669cdcf
fix
sachaarbonel Aug 28, 2023
f3b8c58
debug
sachaarbonel Aug 28, 2023
92b47ff
fix error handling
sachaarbonel Aug 28, 2023
dec9b6a
error handling
sachaarbonel Aug 28, 2023
17fdccc
handle StreamResponse for delete
sachaarbonel Aug 28, 2023
c345905
missing from_dict
sachaarbonel Aug 30, 2023
1e65790
fix wrong imports
sachaarbonel Aug 30, 2023
1586af5
fix fromisoformat error
sachaarbonel Aug 30, 2023
d933839
handle api error better
sachaarbonel Sep 4, 2023
4ebdffb
lint
sachaarbonel Sep 4, 2023
66e59ce
fix rate limit refactor
sachaarbonel Sep 4, 2023
8424f96
deal with optional
sachaarbonel Sep 4, 2023
e0a756f
none
sachaarbonel Sep 4, 2023
faec3c3
non-default argument error
sachaarbonel Sep 4, 2023
bb09888
update ci
sachaarbonel Sep 4, 2023
d931fbc
Generated (#6)
sachaarbonel Sep 19, 2023
579adb4
fixes
sachaarbonel Sep 22, 2023
e599215
fix lints
sachaarbonel Sep 22, 2023
3ad056c
lints
sachaarbonel Sep 22, 2023
e6e6d89
lint
sachaarbonel Sep 22, 2023
72ecca1
add back convenient call method
sachaarbonel Sep 25, 2023
1892b92
format
sachaarbonel Sep 25, 2023
1c9388c
improvements to convenient Call class
sachaarbonel Sep 27, 2023
c9c2420
format
sachaarbonel Sep 27, 2023
6890199
lint
sachaarbonel Sep 27, 2023
25723c8
thumbnail settings
sachaarbonel Sep 28, 2023
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
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