artemis-model 0.1.91__tar.gz → 0.1.92__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {artemis_model-0.1.91 → artemis_model-0.1.92}/PKG-INFO +1 -1
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/schedule.py +28 -0
- artemis_model-0.1.92/artemis_model/sqs/__init__.py +1 -0
- artemis_model-0.1.92/artemis_model/sqs/messages.py +91 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/pyproject.toml +1 -1
- {artemis_model-0.1.91 → artemis_model-0.1.92}/README.md +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/__init__.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/album.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/artist.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/auth.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/base.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/category.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/dj_set.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/genre.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/location.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/message.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/organization.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/otp.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/permission.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/playlist.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/redis/__init__.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/redis/device.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/redis/zone_state.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/setting.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/track.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/user.py +0 -0
- {artemis_model-0.1.91 → artemis_model-0.1.92}/artemis_model/zone.py +0 -0
@@ -1,8 +1,12 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Annotated, NotRequired
|
3
|
+
from typing_extensions import TypedDict
|
1
4
|
import uuid
|
2
5
|
|
3
6
|
from sqlalchemy import ForeignKey
|
4
7
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
5
8
|
from sqlalchemy.types import JSON, UUID
|
9
|
+
from pydantic import Field, RootModel, BaseModel
|
6
10
|
|
7
11
|
from artemis_model.base import CustomBase, TimeStampMixin, AuditMixin, CustomSyncBase
|
8
12
|
|
@@ -52,3 +56,27 @@ class SchedulePresetSync(CustomSyncBase, SchedulePresetMixin):
|
|
52
56
|
|
53
57
|
class SchedulePreset(CustomBase, SchedulePresetMixin):
|
54
58
|
pass
|
59
|
+
|
60
|
+
|
61
|
+
class TimeslotData(TypedDict):
|
62
|
+
"""Timeslot data schema."""
|
63
|
+
|
64
|
+
p: NotRequired[list[int]]
|
65
|
+
d: NotRequired[list[int]]
|
66
|
+
scheduled_at: NotRequired[datetime]
|
67
|
+
|
68
|
+
|
69
|
+
class Timesheet(RootModel):
|
70
|
+
"""Timesheet schema."""
|
71
|
+
|
72
|
+
root: dict[Annotated[str, Field(pattern=r"^\d{2}:\d{2}$")], TimeslotData]
|
73
|
+
|
74
|
+
|
75
|
+
class ScheduleItem(BaseModel):
|
76
|
+
"""Schedule item schema."""
|
77
|
+
|
78
|
+
zone_id: int
|
79
|
+
timesheet: Timesheet
|
80
|
+
|
81
|
+
|
82
|
+
__all__ = ["ScheduleItem"]
|
@@ -0,0 +1 @@
|
|
1
|
+
"""SQS model."""
|
@@ -0,0 +1,91 @@
|
|
1
|
+
"""SQS messages."""
|
2
|
+
|
3
|
+
from datetime import datetime, timezone
|
4
|
+
from enum import Enum
|
5
|
+
from typing import Literal
|
6
|
+
|
7
|
+
from artemis_model.redis.zone_state import SessionId
|
8
|
+
from artemis_model.schedule import ScheduleItem
|
9
|
+
from pydantic import BaseModel, Field
|
10
|
+
|
11
|
+
|
12
|
+
class Action(str, Enum):
|
13
|
+
"""Message type enum."""
|
14
|
+
|
15
|
+
CALCULATE_ALL_SCHEDULES = "calculate-all-schedules"
|
16
|
+
TRIAGE_SCHEDULE = "triage-schedule"
|
17
|
+
TRIGGER_DATABASE_MIGRATION = "trigger-database-migration"
|
18
|
+
MOVE_TIME_SLOT = "move-time-slot"
|
19
|
+
PUSH_PLAYLIST = "push-playlist"
|
20
|
+
EXPIRE_PUSHED_PLAYLIST = "expire-pushed-playlist"
|
21
|
+
REFRESH_TRACK_BUCKET = "refresh-track-bucket"
|
22
|
+
RECALCULATE_SCHEDULE = "recalculate-schedule"
|
23
|
+
PLAYER_MODE_CHANGE = "player-mode-change"
|
24
|
+
|
25
|
+
|
26
|
+
class BaseMessage(BaseModel):
|
27
|
+
"""Base message for incoming messages schema."""
|
28
|
+
|
29
|
+
ts: str = Field(
|
30
|
+
default_factory=lambda: datetime.now(timezone.utc).isoformat(),
|
31
|
+
description="Timestamp value of the message",
|
32
|
+
)
|
33
|
+
action: Action
|
34
|
+
|
35
|
+
|
36
|
+
class MoveTimeSlotIn(BaseMessage):
|
37
|
+
"""Move to time slot message schema."""
|
38
|
+
|
39
|
+
action: Action = Action.MOVE_TIME_SLOT
|
40
|
+
zone_id: int
|
41
|
+
timeslot: str
|
42
|
+
|
43
|
+
|
44
|
+
class TriageScheduleIn(BaseMessage):
|
45
|
+
"""Triage schedule message schema."""
|
46
|
+
|
47
|
+
action: Action = Action.TRIAGE_SCHEDULE
|
48
|
+
schedule: list[ScheduleItem]
|
49
|
+
|
50
|
+
|
51
|
+
class CalculateAllSchedulesIn(BaseMessage):
|
52
|
+
"""Calculate all schedules message schema."""
|
53
|
+
|
54
|
+
action: Action = Action.CALCULATE_ALL_SCHEDULES
|
55
|
+
|
56
|
+
|
57
|
+
class PushPlaylistIn(BaseMessage):
|
58
|
+
"""Push playlist message schema."""
|
59
|
+
|
60
|
+
action: Action = Action.PUSH_PLAYLIST
|
61
|
+
zone_id: int
|
62
|
+
playlist_ids: list[int]
|
63
|
+
expire_at: datetime | None = Field(
|
64
|
+
default=None, description="The datetime that the playlist will expire"
|
65
|
+
)
|
66
|
+
session_id: SessionId = Field(
|
67
|
+
default_factory=lambda: int(datetime.now(timezone.utc).timestamp()),
|
68
|
+
)
|
69
|
+
|
70
|
+
|
71
|
+
class PushPlaylistExpireIn(BaseMessage):
|
72
|
+
"""Push playlist expire message schema."""
|
73
|
+
|
74
|
+
action: Action = Action.EXPIRE_PUSHED_PLAYLIST
|
75
|
+
zone_id: int
|
76
|
+
new_mode: Literal["pushplaylist", "scheduled"] = "scheduled"
|
77
|
+
session_id: SessionId | None = None
|
78
|
+
|
79
|
+
|
80
|
+
class RefreshTrackBucketIn(BaseMessage):
|
81
|
+
"""Refresh track bucket message schema."""
|
82
|
+
|
83
|
+
action: Action = Action.REFRESH_TRACK_BUCKET
|
84
|
+
zone_id: int
|
85
|
+
|
86
|
+
|
87
|
+
class RecalculateScheduleIn(BaseMessage):
|
88
|
+
"""Recalculate schedule message schema."""
|
89
|
+
|
90
|
+
action: Action = Action.RECALCULATE_SCHEDULE
|
91
|
+
zone_id: int
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|