artemis-model 0.1.90__py3-none-any.whl → 0.1.92__py3-none-any.whl

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.
@@ -1,9 +1,8 @@
1
1
  """Zone state schema."""
2
2
 
3
- from dataclasses import Field
4
3
  from typing import Annotated, Literal
5
4
 
6
- from pydantic import BaseModel, field_validator
5
+ from pydantic import BaseModel, Field, field_validator
7
6
 
8
7
 
9
8
  class NowPlaying(BaseModel):
artemis_model/schedule.py CHANGED
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: artemis-model
3
- Version: 0.1.90
3
+ Version: 0.1.92
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -14,12 +14,14 @@ artemis_model/permission.py,sha256=Bn1Bg1aCS4Z4_3tqEqvtrzqAYDCImsvmGyIEMoVycEk,1
14
14
  artemis_model/playlist.py,sha256=L22KSJgTZmNEc9CqM3TFD4Wnx3TW77GQJ5EFLJCxZ20,6393
15
15
  artemis_model/redis/__init__.py,sha256=tLPIfZSrHCYBuldoQbFVTb5PYffo0l76TBj-cemggzg,201
16
16
  artemis_model/redis/device.py,sha256=ZUiIyVmtWiEwayFIg9mktiFaVuHQ7Fg0rvSjjWyryCI,484
17
- artemis_model/redis/zone_state.py,sha256=rRoyK-VTj-1SxLlORopO5RiXuRxUgAeSFbVG3_t7bQM,1735
18
- artemis_model/schedule.py,sha256=pnoKDMlUh28o61I7kZddNYn6z-uqOt_ml1nbWxKVeRM,1722
17
+ artemis_model/redis/zone_state.py,sha256=PgHiGUZ2WI3bqO-8CW2cwzLEQu3l4wJAzIABSWErfBM,1712
18
+ artemis_model/schedule.py,sha256=BbiRqpsRReMQtx0KnCUWwSTAwdEPMqQggxpNR12mKmY,2323
19
19
  artemis_model/setting.py,sha256=EWzOmE31mLNWwmV_wmqttHPMycvQZW7SJUIozF2b8bo,1190
20
+ artemis_model/sqs/__init__.py,sha256=nHpXQns64qQ5Cqjyo6w9fDGO_wWhprqn1bhKf3eWnio,17
21
+ artemis_model/sqs/messages.py,sha256=98cWxrj48T1AcEnltqVGTts6rcmTYimeN8fC6wkdNQk,2452
20
22
  artemis_model/track.py,sha256=QwUF0QKVn1I64648B-NI75-IzGQvnLt9B0emD4GnS6E,3757
21
23
  artemis_model/user.py,sha256=eqIdCiBJRNLjCwPPCn-gQ6si0O5JUBGfp9oWJL5zVW4,2131
22
24
  artemis_model/zone.py,sha256=iGRUtzUwKh9LHT3MOfzzg1DnkPBts_ZBzZVTi2EmIgs,2282
23
- artemis_model-0.1.90.dist-info/METADATA,sha256=iw4LR2vVj3BmgFn84Wx2FehKux9C1IgZI0eW2KRPz_s,3444
24
- artemis_model-0.1.90.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
25
- artemis_model-0.1.90.dist-info/RECORD,,
25
+ artemis_model-0.1.92.dist-info/METADATA,sha256=2t9bSqu2hdefShf6kvgDTnNCk6D-f0lrxUs_6kzrHts,3444
26
+ artemis_model-0.1.92.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
27
+ artemis_model-0.1.92.dist-info/RECORD,,