11"""
22Data models for the SignalRGB API client.
33
4- This module contains Pydantic models that represent various data structures
4+ This module contains Mashumaro-based models that represent various data structures
55used in the SignalRGB API, including effects, responses, and error information.
66These models are used to validate and structure the data received from and sent to the API.
77"""
88
99from typing import Any , Dict , List , Optional
10+ from dataclasses import dataclass , field
11+ from mashumaro import DataClassDictMixin
12+ from mashumaro .config import BaseConfig
1013
11- from pydantic import BaseModel , Field
1214
13-
14- class Attributes (BaseModel ):
15+ @ dataclass
16+ class Attributes (DataClassDictMixin ):
1517 """
1618 Attributes of an effect in SignalRGB.
1719
@@ -32,31 +34,20 @@ class Attributes(BaseModel):
3234 uses_video (bool): Indicates whether the effect uses video input.
3335 """
3436
35- description : Optional [str ] = Field (
36- default = None , description = "Description of the effect"
37- )
38- developer_effect : bool = Field (
39- default = False , description = "Whether this is a developer effect"
40- )
41- image : Optional [str ] = Field (
42- default = None , description = "URL or path to the effect image"
43- )
44- name : str = Field (..., description = "Name of the effect" )
45- parameters : Dict [str , Any ] = Field (
46- default_factory = dict , description = "Effect parameters"
47- )
48- publisher : Optional [str ] = Field (
49- default = None , description = "Publisher of the effect"
50- )
51- uses_audio : bool = Field (default = False , description = "Whether the effect uses audio" )
52- uses_input : bool = Field (default = False , description = "Whether the effect uses input" )
53- uses_meters : bool = Field (
54- default = False , description = "Whether the effect uses meters"
55- )
56- uses_video : bool = Field (default = False , description = "Whether the effect uses video" )
57-
58-
59- class Links (BaseModel ):
37+ name : str
38+ description : Optional [str ] = None
39+ developer_effect : bool = False
40+ image : Optional [str ] = None
41+ parameters : Dict [str , Any ] = field (default_factory = dict )
42+ publisher : Optional [str ] = None
43+ uses_audio : bool = False
44+ uses_input : bool = False
45+ uses_meters : bool = False
46+ uses_video : bool = False
47+
48+
49+ @dataclass
50+ class Links (DataClassDictMixin ):
6051 """
6152 Links associated with an effect in SignalRGB.
6253
@@ -65,14 +56,18 @@ class Links(BaseModel):
6556
6657 Attributes:
6758 apply (Optional[str]): URL to apply the effect, if available.
68- self (Optional[str]): URL of the effect itself, typically for retrieving its details.
59+ self_link (Optional[str]): URL of the effect itself, typically for retrieving its details.
6960 """
7061
71- apply : Optional [str ] = Field (default = None , description = "URL to apply the effect" )
72- self : Optional [str ] = Field (default = None , description = "URL of the effect itself" )
62+ apply : Optional [str ] = None
63+ self_link : Optional [str ] = None
64+
65+ class Config (BaseConfig ):
66+ aliases = {"self_link" : "self" }
7367
7468
75- class Effect (BaseModel ):
69+ @dataclass
70+ class Effect (DataClassDictMixin ):
7671 """
7772 Represents a single effect in SignalRGB.
7873
@@ -86,13 +81,14 @@ class Effect(BaseModel):
8681 type (str): Type of the object, typically 'lighting'.
8782 """
8883
89- attributes : Attributes = Field (..., description = "Attributes of the effect" )
90- id : str = Field (..., description = "Unique identifier of the effect" )
91- links : Links = Field (..., description = "Links associated with the effect" )
92- type : str = Field (..., description = "Type of the object, typically 'lighting'" )
84+ attributes : Attributes
85+ id : str
86+ links : Links
87+ type : str
9388
9489
95- class EffectList (BaseModel ):
90+ @dataclass
91+ class EffectList (DataClassDictMixin ):
9692 """
9793 A list of effects in SignalRGB.
9894
@@ -103,10 +99,11 @@ class EffectList(BaseModel):
10399 items (List[Effect]): A list of Effect objects.
104100 """
105101
106- items : List [Effect ] = Field (default_factory = list , description = "List of effects" )
102+ items : List [Effect ] = field (default_factory = list )
107103
108104
109- class Error (BaseModel ):
105+ @dataclass
106+ class Error (DataClassDictMixin ):
110107 """
111108 Represents an error returned by the SignalRGB API.
112109
@@ -119,12 +116,13 @@ class Error(BaseModel):
119116 title (str): A brief title or summary of the error.
120117 """
121118
122- code : Optional [ str ] = Field ( default = None , description = "Error code" )
123- detail : Optional [str ] = Field ( default = None , description = "Detailed error message" )
124- title : str = Field (..., description = "Error title" )
119+ title : str
120+ code : Optional [str ] = None
121+ detail : Optional [ str ] = None
125122
126123
127- class SignalRGBResponse (BaseModel ):
124+ @dataclass
125+ class SignalRGBResponse (DataClassDictMixin ):
128126 """
129127 Base class for responses from the SignalRGB API.
130128
@@ -141,18 +139,15 @@ class SignalRGBResponse(BaseModel):
141139 errors (List[Error]): A list of Error objects if any errors occurred.
142140 """
143141
144- api_version : str = Field (..., description = "API version" )
145- id : int = Field (..., description = "Response ID" )
146- method : str = Field (..., description = "HTTP method used" )
147- params : Dict [str , Any ] = Field (
148- default_factory = dict , description = "Request parameters"
149- )
150- status : str = Field (..., description = "Response status" )
151- errors : List [Error ] = Field (
152- default_factory = list , description = "List of errors if any"
153- )
142+ api_version : str
143+ id : int
144+ method : str
145+ status : str
146+ params : Dict [str , Any ] = field (default_factory = dict )
147+ errors : List [Error ] = field (default_factory = list )
154148
155149
150+ @dataclass
156151class EffectDetailsResponse (SignalRGBResponse ):
157152 """
158153 Response model for requests that return details of a single effect.
@@ -164,9 +159,10 @@ class EffectDetailsResponse(SignalRGBResponse):
164159 data (Optional[Effect]): The details of the requested effect, if available.
165160 """
166161
167- data : Optional [Effect ] = Field ( default = None , description = "Effect details" )
162+ data : Optional [Effect ] = None
168163
169164
165+ @dataclass
170166class EffectListResponse (SignalRGBResponse ):
171167 """
172168 Response model for requests that return a list of effects.
@@ -178,4 +174,4 @@ class EffectListResponse(SignalRGBResponse):
178174 data (Optional[EffectList]): The list of effects returned by the API, if available.
179175 """
180176
181- data : Optional [EffectList ] = Field ( default = None , description = "List of effects" )
177+ data : Optional [EffectList ] = None
0 commit comments