layrz-sdk 4.0.36__py3-none-any.whl → 4.1.0__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.

Potentially problematic release.


This version of layrz-sdk might be problematic. Click here for more details.

Files changed (97) hide show
  1. layrz_sdk/decorators/func_timing.py +14 -7
  2. layrz_sdk/entities/action.py +28 -16
  3. layrz_sdk/entities/action_geofence_ownership.py +0 -2
  4. layrz_sdk/entities/action_kind.py +0 -2
  5. layrz_sdk/entities/action_subkind.py +0 -2
  6. layrz_sdk/entities/asset.py +15 -9
  7. layrz_sdk/entities/asset_constants.py +10 -9
  8. layrz_sdk/entities/asset_contact.py +7 -3
  9. layrz_sdk/entities/asset_operation_mode.py +0 -2
  10. layrz_sdk/entities/ats_entry.py +11 -4
  11. layrz_sdk/entities/ats_exit_history.py +21 -19
  12. layrz_sdk/entities/ats_operation.py +57 -17
  13. layrz_sdk/entities/ats_possible_entry.py +9 -4
  14. layrz_sdk/entities/ats_possible_exit.py +19 -9
  15. layrz_sdk/entities/ats_purchaseorder.py +45 -12
  16. layrz_sdk/entities/ats_reception.py +16 -4
  17. layrz_sdk/entities/broadcast/result.py +21 -2
  18. layrz_sdk/entities/broadcast/service.py +12 -2
  19. layrz_sdk/entities/case.py +34 -7
  20. layrz_sdk/entities/charts/axis_config.py +13 -5
  21. layrz_sdk/entities/charts/bar_chart.py +12 -1
  22. layrz_sdk/entities/charts/chart_data_serie.py +17 -1
  23. layrz_sdk/entities/charts/column_chart.py +12 -1
  24. layrz_sdk/entities/charts/html_chart.py +8 -4
  25. layrz_sdk/entities/charts/line_chart.py +12 -3
  26. layrz_sdk/entities/charts/map_chart.py +14 -5
  27. layrz_sdk/entities/charts/map_point.py +7 -1
  28. layrz_sdk/entities/charts/number_chart.py +8 -4
  29. layrz_sdk/entities/charts/pie_chart.py +11 -3
  30. layrz_sdk/entities/charts/radar_chart.py +11 -3
  31. layrz_sdk/entities/charts/radial_bar_chart.py +11 -3
  32. layrz_sdk/entities/charts/scatter_chart.py +12 -3
  33. layrz_sdk/entities/charts/scatter_serie.py +11 -1
  34. layrz_sdk/entities/charts/scatter_serie_item.py +7 -1
  35. layrz_sdk/entities/charts/table_chart.py +7 -3
  36. layrz_sdk/entities/charts/table_header.py +7 -1
  37. layrz_sdk/entities/charts/table_row.py +7 -1
  38. layrz_sdk/entities/charts/timeline_chart.py +11 -3
  39. layrz_sdk/entities/charts/timeline_serie.py +7 -1
  40. layrz_sdk/entities/charts/timeline_serie_item.py +7 -1
  41. layrz_sdk/entities/checkpoint.py +20 -13
  42. layrz_sdk/entities/command_series_ticket.py +29 -4
  43. layrz_sdk/entities/comment.py +15 -4
  44. layrz_sdk/entities/custom_field.py +12 -4
  45. layrz_sdk/entities/custom_report_page.py +3 -0
  46. layrz_sdk/entities/destination_phone.py +7 -1
  47. layrz_sdk/entities/device.py +11 -4
  48. layrz_sdk/entities/event.py +20 -4
  49. layrz_sdk/entities/exchange_service.py +12 -4
  50. layrz_sdk/entities/function.py +11 -4
  51. layrz_sdk/entities/geofence.py +12 -4
  52. layrz_sdk/entities/geofence_category.py +0 -2
  53. layrz_sdk/entities/last_message.py +7 -3
  54. layrz_sdk/entities/locator.py +16 -2
  55. layrz_sdk/entities/message.py +16 -9
  56. layrz_sdk/entities/modbus/config.py +7 -1
  57. layrz_sdk/entities/modbus/parameter.py +7 -1
  58. layrz_sdk/entities/modbus/wait.py +11 -1
  59. layrz_sdk/entities/notification_type.py +0 -2
  60. layrz_sdk/entities/operation.py +37 -16
  61. layrz_sdk/entities/operation_case_payload.py +39 -13
  62. layrz_sdk/entities/operation_payload.py +13 -51
  63. layrz_sdk/entities/operation_type.py +0 -2
  64. layrz_sdk/entities/outbound_service.py +11 -4
  65. layrz_sdk/entities/platform.py +0 -2
  66. layrz_sdk/entities/position.py +7 -3
  67. layrz_sdk/entities/preset.py +15 -9
  68. layrz_sdk/entities/report.py +7 -3
  69. layrz_sdk/entities/report_col.py +17 -3
  70. layrz_sdk/entities/report_configuration.py +7 -1
  71. layrz_sdk/entities/report_data_type.py +1 -3
  72. layrz_sdk/entities/report_format.py +1 -5
  73. layrz_sdk/entities/report_header.py +12 -29
  74. layrz_sdk/entities/report_page.py +7 -3
  75. layrz_sdk/entities/report_row.py +7 -19
  76. layrz_sdk/entities/request_type.py +0 -2
  77. layrz_sdk/entities/sensor.py +11 -4
  78. layrz_sdk/entities/sensor_mask.py +7 -3
  79. layrz_sdk/entities/sound_effect.py +0 -2
  80. layrz_sdk/entities/static_position.py +6 -1
  81. layrz_sdk/entities/telemetry/assetmessage.py +14 -15
  82. layrz_sdk/entities/telemetry/devicemessage.py +17 -8
  83. layrz_sdk/entities/text_alignment.py +0 -2
  84. layrz_sdk/entities/timezone.py +12 -4
  85. layrz_sdk/entities/trigger.py +12 -14
  86. layrz_sdk/entities/trigger_kind.py +1 -5
  87. layrz_sdk/entities/user.py +11 -4
  88. layrz_sdk/entities/waypoint.py +38 -16
  89. layrz_sdk/entities/weekday.py +1 -3
  90. layrz_sdk/helpers/color.py +1 -6
  91. layrz_sdk/lcl/core.py +0 -1
  92. {layrz_sdk-4.0.36.dist-info → layrz_sdk-4.1.0.dist-info}/METADATA +2 -2
  93. layrz_sdk-4.1.0.dist-info/RECORD +122 -0
  94. layrz_sdk-4.0.36.dist-info/RECORD +0 -122
  95. {layrz_sdk-4.0.36.dist-info → layrz_sdk-4.1.0.dist-info}/WHEEL +0 -0
  96. {layrz_sdk-4.0.36.dist-info → layrz_sdk-4.1.0.dist-info}/licenses/LICENSE +0 -0
  97. {layrz_sdk-4.0.36.dist-info → layrz_sdk-4.1.0.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@
3
3
  from datetime import datetime
4
4
  from typing import Any
5
5
 
6
- from pydantic import BaseModel, Field
6
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
7
7
 
8
8
  from .request import BroadcastRequest
9
9
  from .response import BroadcastResponse
@@ -24,13 +24,28 @@ class BroadcastResult(BaseModel):
24
24
  class RawBroadcastResult(BaseModel):
25
25
  """Broadcast result data"""
26
26
 
27
- pk: int | None = Field(default=None, description='Broadcast result ID', alias='id')
27
+ model_config = ConfigDict(
28
+ validate_by_name=False,
29
+ validate_by_alias=True,
30
+ serialize_by_alias=True,
31
+ )
32
+
33
+ pk: int | None = Field(
34
+ default=None,
35
+ description='Broadcast result ID',
36
+ alias='id',
37
+ )
38
+
28
39
  trigger_id: int | None = Field(default=None, description='Trigger ID')
29
40
  service_id: int | None = Field(description='Service ID')
30
41
  asset_id: int | None = Field(description='Asset ID')
31
42
 
32
43
  status: BroadcastStatus = Field(description='Broadcast status')
33
44
 
45
+ @field_serializer('status', when_used='always')
46
+ def serialize_status(self, status: BroadcastStatus) -> str:
47
+ return status.value
48
+
34
49
  algorithm: str | None = Field(
35
50
  default=None,
36
51
  description='Algorithm used for the broadcast, if any',
@@ -70,3 +85,7 @@ class RawBroadcastResult(BaseModel):
70
85
  description='Broadcast submission date',
71
86
  alias='at',
72
87
  )
88
+
89
+ @field_serializer('submitted_at', when_used='always')
90
+ def serialize_submitted_at(self, v: datetime) -> float:
91
+ return v.timestamp()
@@ -2,12 +2,22 @@
2
2
 
3
3
  from typing import Any
4
4
 
5
- from pydantic import BaseModel, Field
5
+ from pydantic import BaseModel, ConfigDict, Field
6
6
 
7
7
 
8
8
  class BroadcastService(BaseModel):
9
9
  """Broadcast Service object"""
10
10
 
11
- pk: int = Field(..., description='Service ID', alias='id')
11
+ model_config = ConfigDict(
12
+ validate_by_name=False,
13
+ validate_by_alias=True,
14
+ serialize_by_alias=True,
15
+ )
16
+
17
+ pk: int = Field(
18
+ ...,
19
+ description='Service ID',
20
+ alias='id',
21
+ )
12
22
  name: str = Field(..., description='Service name')
13
23
  credentials: dict[str, Any] = Field(default_factory=dict, description='Service credentials')
@@ -1,9 +1,7 @@
1
- """Events entities"""
2
-
3
1
  from datetime import datetime
4
- from typing import Any, Optional, Self
2
+ from typing import Any, Self
5
3
 
6
- from pydantic import BaseModel, Field, model_validator
4
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer, model_validator
7
5
 
8
6
  from .case_ignored_status import CaseIgnoredStatus
9
7
  from .case_status import CaseStatus
@@ -14,18 +12,47 @@ from .trigger import Trigger
14
12
  class Case(BaseModel):
15
13
  """Case entity"""
16
14
 
17
- pk: int = Field(description='Defines the primary key of the case', alias='id')
15
+ model_config = ConfigDict(
16
+ validate_by_name=False,
17
+ validate_by_alias=True,
18
+ serialize_by_alias=True,
19
+ )
20
+
21
+ pk: int = Field(
22
+ description='Defines the primary key of the case',
23
+ alias='id',
24
+ )
18
25
  trigger: Trigger = Field(description='Defines the trigger of the case')
19
26
  asset_id: int = Field(description='Defines the asset ID of the case')
20
27
  comments: list[Comment] = Field(default_factory=list, description='Defines the comments of the case')
21
28
  opened_at: datetime = Field(description='Defines the date when the case was opened')
22
- closed_at: Optional[datetime] = Field(default=None, description='Defines the date when the case was closed')
29
+
30
+ @field_serializer('opened_at', when_used='always')
31
+ def serialize_opened_at(self, opened_at: datetime) -> float:
32
+ return opened_at.timestamp()
33
+
34
+ closed_at: datetime | None = Field(default=None, description='Defines the date when the case was closed')
35
+
36
+ @field_serializer('closed_at', when_used='always')
37
+ def serialize_closed_at(self, closed_at: datetime | None) -> float | None:
38
+ return closed_at.timestamp() if closed_at else None
39
+
23
40
  status: CaseStatus = Field(description='Defines the status of the case', default=CaseStatus.CLOSED)
41
+
42
+ @field_serializer('status', when_used='always')
43
+ def serialize_status(self, status: CaseStatus) -> str:
44
+ return status.value
45
+
24
46
  ignored_status: CaseIgnoredStatus = Field(
25
47
  description='Defines the ignored status of the case',
26
48
  default=CaseIgnoredStatus.NORMAL,
27
49
  )
28
- sequence: Optional[int | str] = Field(
50
+
51
+ @field_serializer('ignored_status', when_used='always')
52
+ def serialize_ignored_status(self, ignored_status: CaseIgnoredStatus) -> str:
53
+ return ignored_status.value
54
+
55
+ sequence: int | str | None = Field(
29
56
  default=None,
30
57
  description='Defines the sequence of the case. This is a unique identifier for the case',
31
58
  )
@@ -1,6 +1,4 @@
1
- from typing import Optional
2
-
3
- from pydantic import BaseModel, Field
1
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
4
2
 
5
3
  from .chart_data_type import ChartDataType
6
4
 
@@ -8,8 +6,18 @@ from .chart_data_type import ChartDataType
8
6
  class AxisConfig(BaseModel):
9
7
  """Axis configuration"""
10
8
 
9
+ model_config = ConfigDict(
10
+ validate_by_name=False,
11
+ validate_by_alias=True,
12
+ serialize_by_alias=True,
13
+ )
14
+
11
15
  label: str = Field(default='', description='Label of the axis')
12
16
  measure_unit: str = Field(default='', description='Measure unit of the axis')
13
- min_value: Optional[float] = Field(default=None, description='Minimum value of the axis')
14
- max_value: Optional[float] = Field(default=None, description='Maximum value of the axis')
17
+ min_value: float | None = Field(default=None, description='Minimum value of the axis')
18
+ max_value: float | None = Field(default=None, description='Maximum value of the axis')
15
19
  data_type: ChartDataType = Field(default=ChartDataType.DATETIME, description='Data type of the axis')
20
+
21
+ @field_serializer('data_type', when_used='always')
22
+ def serialize_data_type(self, data_type: ChartDataType) -> str:
23
+ return data_type.value
@@ -2,7 +2,7 @@
2
2
 
3
3
  from typing import Any, Self
4
4
 
5
- from pydantic import BaseModel, Field
5
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
6
 
7
7
  from .axis_config import AxisConfig
8
8
  from .chart_alignment import ChartAlignment
@@ -14,10 +14,21 @@ from .chart_render_technology import ChartRenderTechnology
14
14
  class BarChart(BaseModel):
15
15
  """Bar chart configuration"""
16
16
 
17
+ model_config = ConfigDict(
18
+ validate_by_name=False,
19
+ validate_by_alias=True,
20
+ serialize_by_alias=True,
21
+ )
22
+
17
23
  x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
18
24
  y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
19
25
  title: str = Field(default='Chart', description='Title of the chart')
20
26
  align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
27
+
28
+ @field_serializer('align', when_used='always')
29
+ def serialize_align(self, align: ChartAlignment) -> str:
30
+ return align.value
31
+
21
32
  x_axis_config: AxisConfig = Field(
22
33
  default_factory=lambda: AxisConfig(),
23
34
  description='Configuration of the X Axis',
@@ -2,7 +2,7 @@
2
2
 
3
3
  from typing import Any
4
4
 
5
- from pydantic import BaseModel, Field
5
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
6
 
7
7
  from .chart_data_serie_type import ChartDataSerieType
8
8
  from .chart_data_type import ChartDataType
@@ -11,9 +11,25 @@ from .chart_data_type import ChartDataType
11
11
  class ChartDataSerie(BaseModel):
12
12
  """Chart Serie"""
13
13
 
14
+ model_config = ConfigDict(
15
+ validate_by_name=False,
16
+ validate_by_alias=True,
17
+ serialize_by_alias=True,
18
+ )
19
+
14
20
  data: Any = Field(description='Data of the serie')
15
21
  color: str = Field(description='Color of the serie', default='#000000')
16
22
  label: str = Field(description='Label of the serie', default='')
17
23
  serie_type: ChartDataSerieType = Field(description='Type of the serie', default=ChartDataSerieType.LINE)
24
+
25
+ @field_serializer('serie_type', when_used='always')
26
+ def serialize_serie_type(self, serie_type: ChartDataSerieType) -> str:
27
+ return serie_type.value
28
+
18
29
  data_type: ChartDataType = Field(description='Type of the data', default=ChartDataType.NUMBER)
30
+
31
+ @field_serializer('data_type', when_used='always')
32
+ def serialize_data_type(self, data_type: ChartDataType) -> str:
33
+ return data_type.value
34
+
19
35
  dashed: bool = Field(description='If the serie should be dashed', default=False)
@@ -2,7 +2,7 @@
2
2
 
3
3
  from typing import Any, Self
4
4
 
5
- from pydantic import BaseModel, Field
5
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
6
 
7
7
  from layrz_sdk.helpers import convert_to_rgba
8
8
 
@@ -16,10 +16,21 @@ from .chart_render_technology import ChartRenderTechnology
16
16
  class ColumnChart(BaseModel):
17
17
  """Column chart configuration"""
18
18
 
19
+ model_config = ConfigDict(
20
+ validate_by_name=False,
21
+ validate_by_alias=True,
22
+ serialize_by_alias=True,
23
+ )
24
+
19
25
  x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
20
26
  y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
21
27
  title: str = Field(default='Chart', description='Title of the chart')
22
28
  align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
29
+
30
+ @field_serializer('align', when_used='always')
31
+ def serialize_align(self, align: ChartAlignment) -> str:
32
+ return align.value
33
+
23
34
  x_axis_config: AxisConfig = Field(
24
35
  default_factory=lambda: AxisConfig(),
25
36
  description='Configuration of the X Axis',
@@ -1,13 +1,17 @@
1
- """HTML chart"""
1
+ from typing import Any, Self
2
2
 
3
- from typing import Any, Dict, Self
4
-
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field
6
4
 
7
5
 
8
6
  class HTMLChart(BaseModel):
9
7
  """HTML chart configuration"""
10
8
 
9
+ model_config = ConfigDict(
10
+ validate_by_name=False,
11
+ validate_by_alias=True,
12
+ serialize_by_alias=True,
13
+ )
14
+
11
15
  content: str = Field(description='HTML content of the chart', default='<p>N/A</p>')
12
16
  title: str = Field(description='Title of the chart', default='Chart')
13
17
 
@@ -1,9 +1,7 @@
1
- """Line chart"""
2
-
3
1
  import logging
4
2
  from typing import Any, Self
5
3
 
6
- from pydantic import BaseModel, Field
4
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
7
5
 
8
6
  from .axis_config import AxisConfig
9
7
  from .chart_alignment import ChartAlignment
@@ -18,10 +16,21 @@ log = logging.getLogger(__name__)
18
16
  class LineChart(BaseModel):
19
17
  """Line chart configuration"""
20
18
 
19
+ model_config = ConfigDict(
20
+ validate_by_name=False,
21
+ validate_by_alias=True,
22
+ serialize_by_alias=True,
23
+ )
24
+
21
25
  x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
22
26
  y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
23
27
  title: str = Field(default='Chart', description='Title of the chart')
24
28
  align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
29
+
30
+ @field_serializer('align', when_used='always')
31
+ def serialize_align(self, align: ChartAlignment) -> str:
32
+ return align.value
33
+
25
34
  x_axis_config: AxisConfig = Field(
26
35
  default_factory=lambda: AxisConfig(),
27
36
  description='Configuration of the X Axis',
@@ -1,8 +1,6 @@
1
- """Map chart"""
1
+ from typing import Any, Self
2
2
 
3
- from typing import Any, Optional, Self, Tuple
4
-
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .chart_render_technology import ChartRenderTechnology
8
6
  from .map_center_type import MapCenterType
@@ -12,10 +10,21 @@ from .map_point import MapPoint
12
10
  class MapChart(BaseModel):
13
11
  """Map chart configuration"""
14
12
 
13
+ model_config = ConfigDict(
14
+ validate_by_name=False,
15
+ validate_by_alias=True,
16
+ serialize_by_alias=True,
17
+ )
18
+
15
19
  points: list[MapPoint] = Field(description='Points of the chart', default_factory=list)
16
20
  title: str = Field(description='Title of the chart', default='Chart')
17
21
  center: MapCenterType = Field(description='Center of the chart', default=MapCenterType.CONTAIN)
18
- center_latlng: Optional[list[float]] = Field(description='Center of the chart in latlng format', default=None)
22
+
23
+ @field_serializer('center', when_used='always')
24
+ def serialize_center(self, center: MapCenterType) -> str:
25
+ return center.value
26
+
27
+ center_latlng: list[float] | None = Field(description='Center of the chart in latlng format', default=None)
19
28
 
20
29
  def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER_MAP) -> dict[str, Any]:
21
30
  """
@@ -1,9 +1,15 @@
1
- from pydantic import BaseModel, Field, field_validator
1
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
2
2
 
3
3
 
4
4
  class MapPoint(BaseModel):
5
5
  """Map point configuration"""
6
6
 
7
+ model_config = ConfigDict(
8
+ validate_by_name=False,
9
+ validate_by_alias=True,
10
+ serialize_by_alias=True,
11
+ )
12
+
7
13
  latitude: float = Field(description='Latitude of the point')
8
14
  longitude: float = Field(description='Longitude of the point')
9
15
  label: str = Field(description='Label of the point')
@@ -1,8 +1,6 @@
1
- """Number chart"""
1
+ from typing import Any, Self
2
2
 
3
- from typing import Any, Dict, Self
4
-
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field
6
4
 
7
5
  from .chart_render_technology import ChartRenderTechnology
8
6
 
@@ -10,6 +8,12 @@ from .chart_render_technology import ChartRenderTechnology
10
8
  class NumberChart(BaseModel):
11
9
  """Number chart configuration"""
12
10
 
11
+ model_config = ConfigDict(
12
+ validate_by_name=False,
13
+ validate_by_alias=True,
14
+ serialize_by_alias=True,
15
+ )
16
+
13
17
  value: float = Field(description='Value of the number')
14
18
  color: str = Field(description='Color of the number')
15
19
  label: str = Field(description='Label of the number')
@@ -1,8 +1,6 @@
1
- """Pie chart"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .chart_alignment import ChartAlignment
8
6
  from .chart_data_serie import ChartDataSerie
@@ -12,10 +10,20 @@ from .chart_render_technology import ChartRenderTechnology
12
10
  class PieChart(BaseModel):
13
11
  """Pie chart configuration"""
14
12
 
13
+ model_config = ConfigDict(
14
+ validate_by_name=False,
15
+ validate_by_alias=True,
16
+ serialize_by_alias=True,
17
+ )
18
+
15
19
  series: list[ChartDataSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
16
20
  title: str = Field(description='Title of the chart', default='Chart')
17
21
  align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
18
22
 
23
+ @field_serializer('align', when_used='always')
24
+ def serialize_align(self, align: ChartAlignment) -> str:
25
+ return align.value
26
+
19
27
  def render(
20
28
  self: Self,
21
29
  technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
@@ -1,8 +1,6 @@
1
- """Radar chart"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .chart_alignment import ChartAlignment
8
6
  from .chart_data_serie import ChartDataSerie
@@ -12,11 +10,21 @@ from .chart_data_serie_type import ChartDataSerieType
12
10
  class RadarChart(BaseModel):
13
11
  """Radar chart configuration"""
14
12
 
13
+ model_config = ConfigDict(
14
+ validate_by_name=False,
15
+ validate_by_alias=True,
16
+ serialize_by_alias=True,
17
+ )
18
+
15
19
  x_axis: ChartDataSerie = Field(description='X Axis of the chart')
16
20
  y_axis: list[ChartDataSerie] = Field(description='Y Axis of the chart', default_factory=list)
17
21
  title: str = Field(description='Title of the chart', default='Chart')
18
22
  align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
19
23
 
24
+ @field_serializer('align', when_used='always')
25
+ def serialize_align(self, align: ChartAlignment) -> str:
26
+ return align.value
27
+
20
28
  def render(self: Self) -> dict[str, Any]:
21
29
  """
22
30
  Render chart to a graphic Library.
@@ -1,8 +1,6 @@
1
- """Radial Bar chart"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .chart_alignment import ChartAlignment
8
6
  from .chart_data_serie import ChartDataSerie
@@ -12,10 +10,20 @@ from .chart_render_technology import ChartRenderTechnology
12
10
  class RadialBarChart(BaseModel):
13
11
  """Radial Bar chart configuration"""
14
12
 
13
+ model_config = ConfigDict(
14
+ validate_by_name=False,
15
+ validate_by_alias=True,
16
+ serialize_by_alias=True,
17
+ )
18
+
15
19
  series: list[ChartDataSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
16
20
  title: str = Field(description='Title of the chart', default='Chart')
17
21
  align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
18
22
 
23
+ @field_serializer('align', when_used='always')
24
+ def serialize_align(self, align: ChartAlignment) -> str:
25
+ return align.value
26
+
19
27
  def render(
20
28
  self: Self,
21
29
  technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
@@ -1,8 +1,6 @@
1
- """Scatter chart"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .axis_config import AxisConfig
8
6
  from .chart_alignment import ChartAlignment
@@ -14,9 +12,20 @@ from .scatter_serie import ScatterSerie
14
12
  class ScatterChart(BaseModel):
15
13
  """Scatter chart configuration"""
16
14
 
15
+ model_config = ConfigDict(
16
+ validate_by_name=False,
17
+ validate_by_alias=True,
18
+ serialize_by_alias=True,
19
+ )
20
+
17
21
  series: list[ScatterSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
18
22
  title: str = Field(description='Title of the chart', default='Chart')
19
23
  align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
24
+
25
+ @field_serializer('align', when_used='always')
26
+ def serialize_align(self, align: ChartAlignment) -> str:
27
+ return align.value
28
+
20
29
  x_axis_config: AxisConfig = Field(
21
30
  default_factory=lambda: AxisConfig(),
22
31
  description='Configuration of the X Axis',
@@ -1,4 +1,4 @@
1
- from pydantic import BaseModel, Field
1
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
2
2
 
3
3
  from .chart_data_serie_type import ChartDataSerieType
4
4
  from .scatter_serie_item import ScatterSerieItem
@@ -7,7 +7,17 @@ from .scatter_serie_item import ScatterSerieItem
7
7
  class ScatterSerie(BaseModel):
8
8
  """Chart Data Serie for Timeline charts"""
9
9
 
10
+ model_config = ConfigDict(
11
+ validate_by_name=False,
12
+ validate_by_alias=True,
13
+ serialize_by_alias=True,
14
+ )
15
+
10
16
  data: list[ScatterSerieItem] = Field(description='List of data points', default_factory=list)
11
17
  color: str = Field(description='Color of the serie', default='')
12
18
  label: str = Field(description='Label of the serie', default='')
13
19
  serie_type: ChartDataSerieType = Field(description='Type of the serie', default=ChartDataSerieType.SCATTER)
20
+
21
+ @field_serializer('serie_type', when_used='always')
22
+ def serialize_serie_type(self, serie_type: ChartDataSerieType) -> str:
23
+ return serie_type.value
@@ -1,8 +1,14 @@
1
- from pydantic import BaseModel, Field
1
+ from pydantic import BaseModel, ConfigDict, Field
2
2
 
3
3
 
4
4
  class ScatterSerieItem(BaseModel):
5
5
  """Chart Data Serie Item for Scatter Charts"""
6
6
 
7
+ model_config = ConfigDict(
8
+ validate_by_name=False,
9
+ validate_by_alias=True,
10
+ serialize_by_alias=True,
11
+ )
12
+
7
13
  x: float = Field(description='X value of the item')
8
14
  y: float = Field(description='Y value of the item')
@@ -1,8 +1,6 @@
1
- """Number chart"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field
6
4
 
7
5
  from .chart_render_technology import ChartRenderTechnology
8
6
  from .table_header import TableHeader
@@ -12,6 +10,12 @@ from .table_row import TableRow
12
10
  class TableChart(BaseModel):
13
11
  """Table chart configuration"""
14
12
 
13
+ model_config = ConfigDict(
14
+ validate_by_name=False,
15
+ validate_by_alias=True,
16
+ serialize_by_alias=True,
17
+ )
18
+
15
19
  columns: list[TableHeader] = Field(description='List of columns', default_factory=list)
16
20
  rows: list[TableRow] = Field(description='List of rows', default_factory=list)
17
21
 
@@ -1,8 +1,14 @@
1
- from pydantic import BaseModel, Field
1
+ from pydantic import BaseModel, ConfigDict, Field
2
2
 
3
3
 
4
4
  class TableHeader(BaseModel):
5
5
  """Table header chart configuration"""
6
6
 
7
+ model_config = ConfigDict(
8
+ validate_by_name=False,
9
+ validate_by_alias=True,
10
+ serialize_by_alias=True,
11
+ )
12
+
7
13
  label: str = Field(description='Label of the header')
8
14
  key: str = Field(description='Key of the header')
@@ -1,9 +1,15 @@
1
1
  from typing import Any
2
2
 
3
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field
4
4
 
5
5
 
6
6
  class TableRow(BaseModel):
7
7
  """Table row chart configuration"""
8
8
 
9
+ model_config = ConfigDict(
10
+ validate_by_name=False,
11
+ validate_by_alias=True,
12
+ serialize_by_alias=True,
13
+ )
14
+
9
15
  data: Any = Field(description='Data of the row')
@@ -1,8 +1,6 @@
1
- """Timeline chart entities"""
2
-
3
1
  from typing import Any, Self
4
2
 
5
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
6
4
 
7
5
  from .chart_alignment import ChartAlignment
8
6
  from .timeline_serie import TimelineSerie
@@ -11,10 +9,20 @@ from .timeline_serie import TimelineSerie
11
9
  class TimelineChart(BaseModel):
12
10
  """Timeline chart configuration"""
13
11
 
12
+ model_config = ConfigDict(
13
+ validate_by_name=False,
14
+ validate_by_alias=True,
15
+ serialize_by_alias=True,
16
+ )
17
+
14
18
  series: list[TimelineSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
15
19
  title: str = Field(description='Title of the chart', default='Chart')
16
20
  align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
17
21
 
22
+ @field_serializer('align', when_used='always')
23
+ def serialize_align(self, align: ChartAlignment) -> str:
24
+ return align.value
25
+
18
26
  def render(self: Self) -> dict[str, Any]:
19
27
  """
20
28
  Render chart to a graphic Library.
@@ -1,4 +1,4 @@
1
- from pydantic import BaseModel, Field
1
+ from pydantic import BaseModel, ConfigDict, Field
2
2
 
3
3
  from .timeline_serie_item import TimelineSerieItem
4
4
 
@@ -6,5 +6,11 @@ from .timeline_serie_item import TimelineSerieItem
6
6
  class TimelineSerie(BaseModel):
7
7
  """Chart Data Serie for Timeline charts"""
8
8
 
9
+ model_config = ConfigDict(
10
+ validate_by_name=False,
11
+ validate_by_alias=True,
12
+ serialize_by_alias=True,
13
+ )
14
+
9
15
  data: list[TimelineSerieItem] = Field(description='List of data points', default_factory=list)
10
16
  label: str = Field(description='Label of the serie')