layrz-sdk 4.0.35__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.
- layrz_sdk/decorators/func_timing.py +14 -7
- layrz_sdk/entities/action.py +28 -16
- layrz_sdk/entities/action_geofence_ownership.py +0 -2
- layrz_sdk/entities/action_kind.py +0 -2
- layrz_sdk/entities/action_subkind.py +0 -2
- layrz_sdk/entities/asset.py +15 -9
- layrz_sdk/entities/asset_constants.py +10 -9
- layrz_sdk/entities/asset_contact.py +7 -3
- layrz_sdk/entities/asset_operation_mode.py +0 -2
- layrz_sdk/entities/ats_entry.py +11 -4
- layrz_sdk/entities/ats_exit_history.py +21 -19
- layrz_sdk/entities/ats_operation.py +57 -17
- layrz_sdk/entities/ats_possible_entry.py +9 -4
- layrz_sdk/entities/ats_possible_exit.py +19 -9
- layrz_sdk/entities/ats_purchaseorder.py +47 -12
- layrz_sdk/entities/ats_reception.py +16 -4
- layrz_sdk/entities/broadcast/result.py +21 -2
- layrz_sdk/entities/broadcast/service.py +12 -2
- layrz_sdk/entities/case.py +34 -7
- layrz_sdk/entities/charts/axis_config.py +13 -5
- layrz_sdk/entities/charts/bar_chart.py +12 -1
- layrz_sdk/entities/charts/chart_data_serie.py +17 -1
- layrz_sdk/entities/charts/column_chart.py +12 -1
- layrz_sdk/entities/charts/html_chart.py +8 -4
- layrz_sdk/entities/charts/line_chart.py +12 -3
- layrz_sdk/entities/charts/map_chart.py +14 -5
- layrz_sdk/entities/charts/map_point.py +7 -1
- layrz_sdk/entities/charts/number_chart.py +8 -4
- layrz_sdk/entities/charts/pie_chart.py +11 -3
- layrz_sdk/entities/charts/radar_chart.py +11 -3
- layrz_sdk/entities/charts/radial_bar_chart.py +11 -3
- layrz_sdk/entities/charts/scatter_chart.py +12 -3
- layrz_sdk/entities/charts/scatter_serie.py +11 -1
- layrz_sdk/entities/charts/scatter_serie_item.py +7 -1
- layrz_sdk/entities/charts/table_chart.py +7 -3
- layrz_sdk/entities/charts/table_header.py +7 -1
- layrz_sdk/entities/charts/table_row.py +7 -1
- layrz_sdk/entities/charts/timeline_chart.py +11 -3
- layrz_sdk/entities/charts/timeline_serie.py +7 -1
- layrz_sdk/entities/charts/timeline_serie_item.py +7 -1
- layrz_sdk/entities/checkpoint.py +20 -13
- layrz_sdk/entities/command_series_ticket.py +29 -4
- layrz_sdk/entities/comment.py +15 -4
- layrz_sdk/entities/custom_field.py +12 -4
- layrz_sdk/entities/custom_report_page.py +3 -0
- layrz_sdk/entities/destination_phone.py +7 -1
- layrz_sdk/entities/device.py +11 -4
- layrz_sdk/entities/event.py +20 -4
- layrz_sdk/entities/exchange_service.py +12 -4
- layrz_sdk/entities/function.py +11 -4
- layrz_sdk/entities/geofence.py +12 -4
- layrz_sdk/entities/geofence_category.py +0 -2
- layrz_sdk/entities/last_message.py +7 -3
- layrz_sdk/entities/locator.py +16 -2
- layrz_sdk/entities/message.py +16 -9
- layrz_sdk/entities/modbus/config.py +7 -1
- layrz_sdk/entities/modbus/parameter.py +7 -1
- layrz_sdk/entities/modbus/wait.py +11 -1
- layrz_sdk/entities/notification_type.py +0 -2
- layrz_sdk/entities/operation.py +37 -16
- layrz_sdk/entities/operation_case_payload.py +39 -13
- layrz_sdk/entities/operation_payload.py +13 -51
- layrz_sdk/entities/operation_type.py +0 -2
- layrz_sdk/entities/outbound_service.py +11 -4
- layrz_sdk/entities/platform.py +0 -2
- layrz_sdk/entities/position.py +7 -3
- layrz_sdk/entities/preset.py +15 -9
- layrz_sdk/entities/report.py +7 -3
- layrz_sdk/entities/report_col.py +17 -3
- layrz_sdk/entities/report_configuration.py +7 -1
- layrz_sdk/entities/report_data_type.py +1 -3
- layrz_sdk/entities/report_format.py +1 -5
- layrz_sdk/entities/report_header.py +12 -29
- layrz_sdk/entities/report_page.py +7 -3
- layrz_sdk/entities/report_row.py +7 -19
- layrz_sdk/entities/request_type.py +0 -2
- layrz_sdk/entities/sensor.py +11 -4
- layrz_sdk/entities/sensor_mask.py +7 -3
- layrz_sdk/entities/sound_effect.py +0 -2
- layrz_sdk/entities/static_position.py +6 -1
- layrz_sdk/entities/telemetry/assetmessage.py +14 -15
- layrz_sdk/entities/telemetry/devicemessage.py +17 -8
- layrz_sdk/entities/text_alignment.py +0 -2
- layrz_sdk/entities/timezone.py +12 -4
- layrz_sdk/entities/trigger.py +12 -14
- layrz_sdk/entities/trigger_kind.py +1 -5
- layrz_sdk/entities/user.py +11 -4
- layrz_sdk/entities/waypoint.py +38 -16
- layrz_sdk/entities/weekday.py +1 -3
- layrz_sdk/helpers/color.py +1 -6
- layrz_sdk/lcl/core.py +0 -1
- {layrz_sdk-4.0.35.dist-info → layrz_sdk-4.1.0.dist-info}/METADATA +2 -2
- layrz_sdk-4.1.0.dist-info/RECORD +122 -0
- layrz_sdk-4.0.35.dist-info/RECORD +0 -122
- {layrz_sdk-4.0.35.dist-info → layrz_sdk-4.1.0.dist-info}/WHEEL +0 -0
- {layrz_sdk-4.0.35.dist-info → layrz_sdk-4.1.0.dist-info}/licenses/LICENSE +0 -0
- {layrz_sdk-4.0.35.dist-info → layrz_sdk-4.1.0.dist-info}/top_level.txt +0 -0
layrz_sdk/entities/operation.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from datetime import time, timedelta
|
|
1
|
+
from datetime import timedelta
|
|
4
2
|
from typing import Any, Self
|
|
5
3
|
|
|
6
|
-
from pydantic import BaseModel, Field, field_validator
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
|
7
5
|
|
|
8
6
|
from .destination_phone import DestinationPhone
|
|
9
7
|
from .notification_type import TwilioNotificationType
|
|
@@ -17,18 +15,16 @@ from .timezone import Timezone
|
|
|
17
15
|
class Operation(BaseModel):
|
|
18
16
|
"""Operation entity"""
|
|
19
17
|
|
|
20
|
-
model_config =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
pk: int = Field(description='Defines the primary key of the trigger', alias='id')
|
|
18
|
+
model_config = ConfigDict(
|
|
19
|
+
validate_by_name=False,
|
|
20
|
+
validate_by_alias=True,
|
|
21
|
+
serialize_by_alias=True,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
pk: int = Field(
|
|
25
|
+
description='Defines the primary key of the trigger',
|
|
26
|
+
alias='id',
|
|
27
|
+
)
|
|
32
28
|
name: str = Field(description='Defines the name of the trigger')
|
|
33
29
|
|
|
34
30
|
cooldown_time: timedelta = Field(
|
|
@@ -36,11 +32,19 @@ class Operation(BaseModel):
|
|
|
36
32
|
description='Defines the cooldown time of the trigger',
|
|
37
33
|
)
|
|
38
34
|
|
|
35
|
+
@field_serializer('cooldown_time', when_used='always')
|
|
36
|
+
def serialize_cooldown_time(self, value: timedelta) -> float:
|
|
37
|
+
return value.total_seconds()
|
|
38
|
+
|
|
39
39
|
operation_type: OperationType = Field(
|
|
40
40
|
...,
|
|
41
41
|
description='Defines the kind of the operation',
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
+
@field_serializer('operation_type', when_used='always')
|
|
45
|
+
def serialize_operation_type(self, value: OperationType) -> str:
|
|
46
|
+
return value.value
|
|
47
|
+
|
|
44
48
|
@property
|
|
45
49
|
def kind(self: Self) -> OperationType:
|
|
46
50
|
"""Get the kind of the operation"""
|
|
@@ -51,6 +55,10 @@ class Operation(BaseModel):
|
|
|
51
55
|
description='Defines the HTTP method of the operation',
|
|
52
56
|
)
|
|
53
57
|
|
|
58
|
+
@field_serializer('request_type', when_used='always')
|
|
59
|
+
def serialize_request_type(self, value: HttpRequestType | None) -> str | None:
|
|
60
|
+
return value.value if value else None
|
|
61
|
+
|
|
54
62
|
@property
|
|
55
63
|
def http_method(self: Self) -> HttpRequestType | None:
|
|
56
64
|
"""Get the HTTP method of the operation"""
|
|
@@ -125,6 +133,11 @@ class Operation(BaseModel):
|
|
|
125
133
|
description='Defines the Twilio notification type of the operation',
|
|
126
134
|
)
|
|
127
135
|
|
|
136
|
+
@field_serializer('notification_type', when_used='always')
|
|
137
|
+
def serialize_notification_type(self, value: TwilioNotificationType) -> str:
|
|
138
|
+
"""Serialize notification_type to its value."""
|
|
139
|
+
return value.value
|
|
140
|
+
|
|
128
141
|
@property
|
|
129
142
|
def twilio_notification_type(self: Self) -> TwilioNotificationType:
|
|
130
143
|
"""Get the Twilio notification type of the operation"""
|
|
@@ -201,6 +214,10 @@ class Operation(BaseModel):
|
|
|
201
214
|
description='Defines the sound effect for the operation',
|
|
202
215
|
)
|
|
203
216
|
|
|
217
|
+
@field_serializer('sound_effect', when_used='always')
|
|
218
|
+
def serialize_sound_effect(self, value: SoundEffect) -> str:
|
|
219
|
+
return value.value
|
|
220
|
+
|
|
204
221
|
sound_effect_uri: str | None = Field(
|
|
205
222
|
default=None,
|
|
206
223
|
description='Defines the URI for the sound effect of the operation. Only when sound_effect is set to CUSTOM.',
|
|
@@ -211,6 +228,10 @@ class Operation(BaseModel):
|
|
|
211
228
|
description='Defines the duration of the operation',
|
|
212
229
|
)
|
|
213
230
|
|
|
231
|
+
@field_serializer('duration', when_used='always')
|
|
232
|
+
def serialize_duration(self, value: timedelta | None) -> float | None:
|
|
233
|
+
return value.total_seconds() if value else None
|
|
234
|
+
|
|
214
235
|
@field_validator('duration', mode='before')
|
|
215
236
|
def validate_duration(cls, value: Any) -> timedelta:
|
|
216
237
|
if value is None:
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"""Operation case payload entity"""
|
|
2
|
-
|
|
3
1
|
from datetime import datetime, timedelta
|
|
4
2
|
from typing import Any
|
|
5
3
|
|
|
6
|
-
from pydantic import BaseModel, Field, field_validator
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
|
7
5
|
|
|
8
6
|
from layrz_sdk.constants import UTC
|
|
9
7
|
from layrz_sdk.entities.trigger import Trigger
|
|
@@ -12,7 +10,17 @@ from layrz_sdk.entities.trigger import Trigger
|
|
|
12
10
|
class OperationCaseCommentPayload(BaseModel):
|
|
13
11
|
"""Operation case comment payload entity"""
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
model_config = ConfigDict(
|
|
14
|
+
validate_by_name=False,
|
|
15
|
+
validate_by_alias=True,
|
|
16
|
+
serialize_by_alias=True,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
pk: int = Field(
|
|
20
|
+
...,
|
|
21
|
+
description='Defines the primary key of the operation case comment',
|
|
22
|
+
alias='id',
|
|
23
|
+
)
|
|
16
24
|
user: str = Field(..., description='Defines the user who created the operation case comment')
|
|
17
25
|
content: str = Field(..., description='Defines the content of the operation case comment')
|
|
18
26
|
created_at: datetime = Field(
|
|
@@ -20,28 +28,42 @@ class OperationCaseCommentPayload(BaseModel):
|
|
|
20
28
|
description='Defines the creation date of the operation case comment',
|
|
21
29
|
)
|
|
22
30
|
|
|
31
|
+
@field_serializer('created_at', when_used='always')
|
|
32
|
+
def serialize_created_at(self, created_at: datetime) -> float:
|
|
33
|
+
return created_at.timestamp()
|
|
34
|
+
|
|
23
35
|
|
|
24
36
|
class OperationCasePayload(BaseModel):
|
|
25
37
|
"""Operation case payload entity"""
|
|
26
38
|
|
|
27
|
-
model_config =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
}
|
|
39
|
+
model_config = ConfigDict(
|
|
40
|
+
validate_by_name=False,
|
|
41
|
+
validate_by_alias=True,
|
|
42
|
+
serialize_by_alias=True,
|
|
43
|
+
)
|
|
34
44
|
|
|
35
|
-
pk: int = Field(
|
|
45
|
+
pk: int = Field(
|
|
46
|
+
description='Defines the primary key of the operation case payload',
|
|
47
|
+
alias='id',
|
|
48
|
+
)
|
|
36
49
|
created_at: datetime = Field(
|
|
37
50
|
default_factory=lambda: datetime.now(UTC),
|
|
38
51
|
description='Defines the creation date of the operation case payload',
|
|
39
52
|
)
|
|
53
|
+
|
|
54
|
+
@field_serializer('created_at', when_used='always')
|
|
55
|
+
def serialize_created_at(self, created_at: datetime) -> float:
|
|
56
|
+
return created_at.timestamp()
|
|
57
|
+
|
|
40
58
|
updated_at: datetime = Field(
|
|
41
59
|
default_factory=lambda: datetime.now(UTC),
|
|
42
60
|
description='Defines the last update date of the operation case payload',
|
|
43
61
|
)
|
|
44
62
|
|
|
63
|
+
@field_serializer('updated_at', when_used='always')
|
|
64
|
+
def serialize_updated_at(self, updated_at: datetime) -> float:
|
|
65
|
+
return updated_at.timestamp()
|
|
66
|
+
|
|
45
67
|
trigger: Trigger = Field(
|
|
46
68
|
...,
|
|
47
69
|
description='Defines the trigger associated with the operation case payload',
|
|
@@ -52,7 +74,7 @@ class OperationCasePayload(BaseModel):
|
|
|
52
74
|
"""Serialize trigger to a dictionary"""
|
|
53
75
|
if isinstance(value, Trigger):
|
|
54
76
|
return Trigger(
|
|
55
|
-
id=value.pk,
|
|
77
|
+
id=value.pk, # ty: ignore
|
|
56
78
|
name=value.name,
|
|
57
79
|
code=value.code,
|
|
58
80
|
)
|
|
@@ -71,6 +93,10 @@ class OperationCasePayload(BaseModel):
|
|
|
71
93
|
description='Defines the creation date of the file associated with the operation case payload',
|
|
72
94
|
)
|
|
73
95
|
|
|
96
|
+
@field_serializer('file_created_at', when_used='always')
|
|
97
|
+
def serialize_file_created_at(self, file_created_at: datetime | None) -> float | None:
|
|
98
|
+
return file_created_at.timestamp() if file_created_at else None
|
|
99
|
+
|
|
74
100
|
comment: OperationCaseCommentPayload | None = Field(
|
|
75
101
|
default=None,
|
|
76
102
|
description='Defines the comment associated with the operation case payload',
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"""Operation Payload entity"""
|
|
2
|
-
|
|
3
1
|
from datetime import datetime, timedelta
|
|
4
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
5
3
|
|
|
6
|
-
from pydantic import BaseModel, Field, field_serializer, field_validator
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
|
7
5
|
|
|
8
6
|
from layrz_sdk.entities.asset import Asset
|
|
9
7
|
from layrz_sdk.entities.destination_phone import DestinationPhone
|
|
@@ -23,6 +21,12 @@ from layrz_sdk.entities.trigger import Trigger
|
|
|
23
21
|
class OperationPayload(BaseModel):
|
|
24
22
|
"""Operation Payload entity"""
|
|
25
23
|
|
|
24
|
+
model_config = ConfigDict(
|
|
25
|
+
validate_by_name=False,
|
|
26
|
+
validate_by_alias=True,
|
|
27
|
+
serialize_by_alias=True,
|
|
28
|
+
)
|
|
29
|
+
|
|
26
30
|
kind: OperationType = Field(
|
|
27
31
|
...,
|
|
28
32
|
description='Defines the kind of the operation',
|
|
@@ -36,7 +40,7 @@ class OperationPayload(BaseModel):
|
|
|
36
40
|
asset: Asset = Field(..., description='Defines the asset associated with the operation')
|
|
37
41
|
|
|
38
42
|
@field_validator('asset', mode='before')
|
|
39
|
-
def
|
|
43
|
+
def validate_asset(cls, value: Any) -> Asset:
|
|
40
44
|
"""Serialize asset to a dictionary"""
|
|
41
45
|
if isinstance(value, Asset):
|
|
42
46
|
return Asset(
|
|
@@ -54,15 +58,10 @@ class OperationPayload(BaseModel):
|
|
|
54
58
|
|
|
55
59
|
raise ValueError('Asset must be an instance of Asset or a dictionary')
|
|
56
60
|
|
|
57
|
-
@field_serializer('asset', when_used='always')
|
|
58
|
-
def serialize_asset_field(self, value: Asset) -> dict[str, Any]:
|
|
59
|
-
"""Serialize asset to a dictionary"""
|
|
60
|
-
return value.model_dump(by_alias=True)
|
|
61
|
-
|
|
62
61
|
trigger: Trigger = Field(..., description='Defines the trigger associated with the operation')
|
|
63
62
|
|
|
64
63
|
@field_validator('trigger', mode='before')
|
|
65
|
-
def
|
|
64
|
+
def validate_trigger(cls, value: Any) -> Trigger:
|
|
66
65
|
"""Serialize trigger to a dictionary"""
|
|
67
66
|
if isinstance(value, Trigger):
|
|
68
67
|
return Trigger(
|
|
@@ -76,15 +75,10 @@ class OperationPayload(BaseModel):
|
|
|
76
75
|
|
|
77
76
|
raise ValueError('Trigger must be an instance of Trigger or a dictionary')
|
|
78
77
|
|
|
79
|
-
@field_serializer('trigger', when_used='always')
|
|
80
|
-
def serialize_trigger_field(self, value: Trigger) -> dict[str, Any]:
|
|
81
|
-
"""Serialize trigger to a dictionary"""
|
|
82
|
-
return value.model_dump(by_alias=True)
|
|
83
|
-
|
|
84
78
|
operation: Operation = Field(..., description='Defines the operation associated with the payload')
|
|
85
79
|
|
|
86
80
|
@field_validator('operation', mode='before')
|
|
87
|
-
def
|
|
81
|
+
def validate_operation(cls, value: Any) -> Operation:
|
|
88
82
|
"""Serialize operation to a dictionary"""
|
|
89
83
|
if isinstance(value, Operation):
|
|
90
84
|
return Operation(
|
|
@@ -99,11 +93,6 @@ class OperationPayload(BaseModel):
|
|
|
99
93
|
|
|
100
94
|
raise ValueError('Operation must be an instance of Operation or a dictionary')
|
|
101
95
|
|
|
102
|
-
@field_serializer('operation', when_used='always')
|
|
103
|
-
def serialize_operation_field(self, value: Operation) -> dict[str, Any]:
|
|
104
|
-
"""Serialize operation to a dictionary"""
|
|
105
|
-
return value.model_dump(by_alias=True)
|
|
106
|
-
|
|
107
96
|
activated_at: datetime = Field(
|
|
108
97
|
...,
|
|
109
98
|
description='Defines the date when the operation was activated',
|
|
@@ -129,12 +118,6 @@ class OperationPayload(BaseModel):
|
|
|
129
118
|
description='Defines the geofence of the operation',
|
|
130
119
|
)
|
|
131
120
|
|
|
132
|
-
@field_serializer('geofence', when_used='always')
|
|
133
|
-
def serialize_geofence(self, value: Geofence | None) -> Any:
|
|
134
|
-
if value is None:
|
|
135
|
-
return None
|
|
136
|
-
return value.model_dump(by_alias=True)
|
|
137
|
-
|
|
138
121
|
presence_type: PresenceType | None = Field(
|
|
139
122
|
default=None,
|
|
140
123
|
description='Defines the presence type of the operation',
|
|
@@ -143,9 +126,7 @@ class OperationPayload(BaseModel):
|
|
|
143
126
|
|
|
144
127
|
@field_serializer('presence_type', when_used='always')
|
|
145
128
|
def serialize_presence_type(self, value: PresenceType | None) -> Any:
|
|
146
|
-
if value
|
|
147
|
-
return None
|
|
148
|
-
return value.value
|
|
129
|
+
return value.value if value else None
|
|
149
130
|
|
|
150
131
|
case_: OperationCasePayload | None = Field(
|
|
151
132
|
default=None,
|
|
@@ -153,12 +134,6 @@ class OperationPayload(BaseModel):
|
|
|
153
134
|
alias='case',
|
|
154
135
|
)
|
|
155
136
|
|
|
156
|
-
@field_serializer('case_', when_used='always')
|
|
157
|
-
def serialize_case(self, value: OperationCasePayload | None) -> Any:
|
|
158
|
-
if value is None:
|
|
159
|
-
return None
|
|
160
|
-
return value.model_dump(by_alias=True)
|
|
161
|
-
|
|
162
137
|
language_id: int = Field(
|
|
163
138
|
default=2,
|
|
164
139
|
description='Defines the language ID of the operation',
|
|
@@ -195,9 +170,7 @@ class OperationPayload(BaseModel):
|
|
|
195
170
|
|
|
196
171
|
@field_serializer('http_method', when_used='always')
|
|
197
172
|
def serialize_http_method(self, value: HttpRequestType | None) -> Any:
|
|
198
|
-
if value
|
|
199
|
-
return None
|
|
200
|
-
return value.value
|
|
173
|
+
return value.value if value else None
|
|
201
174
|
|
|
202
175
|
http_headers: list[dict[str, Any]] = Field(
|
|
203
176
|
default_factory=list,
|
|
@@ -247,11 +220,6 @@ class OperationPayload(BaseModel):
|
|
|
247
220
|
|
|
248
221
|
return []
|
|
249
222
|
|
|
250
|
-
@field_serializer('destinations', when_used='always')
|
|
251
|
-
def serialize_destinations_field(self, value: list[DestinationPhone]) -> list[dict[str, Any]]:
|
|
252
|
-
"""Serialize destinations to a list of dictionaries"""
|
|
253
|
-
return [dest.model_dump(by_alias=True) for dest in value]
|
|
254
|
-
|
|
255
223
|
twilio_host_phone: DestinationPhone | None = Field(
|
|
256
224
|
default=None,
|
|
257
225
|
description='Defines the host phone number for Twilio notifications',
|
|
@@ -370,9 +338,3 @@ class OperationPayload(BaseModel):
|
|
|
370
338
|
default=None,
|
|
371
339
|
description='Defines the generated locator for the operation',
|
|
372
340
|
)
|
|
373
|
-
|
|
374
|
-
@field_serializer('locator', when_used='always')
|
|
375
|
-
def serialize_locator(self, value: Locator | None) -> Any:
|
|
376
|
-
if value is None:
|
|
377
|
-
return None
|
|
378
|
-
return value.model_dump(by_alias=True)
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
"""Service entity"""
|
|
2
|
-
|
|
3
1
|
from typing import Any
|
|
4
2
|
|
|
5
|
-
from pydantic import BaseModel, Field
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class OutboundService(BaseModel):
|
|
9
7
|
"""Outbound service definition"""
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
model_config = ConfigDict(
|
|
10
|
+
validate_by_name=False,
|
|
11
|
+
validate_by_alias=True,
|
|
12
|
+
serialize_by_alias=True,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
pk: int = Field(
|
|
16
|
+
description='Service ID',
|
|
17
|
+
alias='id',
|
|
18
|
+
)
|
|
12
19
|
name: str = Field(description='Service name')
|
|
13
20
|
|
|
14
21
|
protocol_name: str | None = Field(
|
layrz_sdk/entities/platform.py
CHANGED
layrz_sdk/entities/position.py
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
"""Position entity"""
|
|
2
|
-
|
|
3
1
|
from typing import Any, Self, cast
|
|
4
2
|
|
|
5
|
-
from pydantic import BaseModel, Field, field_validator
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class Position(BaseModel):
|
|
9
7
|
"""Geographic position definition"""
|
|
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
|
latitude: float | None = Field(default=None, description='Defines the latitude of the position')
|
|
12
16
|
longitude: float | None = Field(default=None, description='Defines the longitude of the position')
|
|
13
17
|
altitude: float | None = Field(default=None, description='Defines the altitude of the position')
|
layrz_sdk/entities/preset.py
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
"""Preset entity"""
|
|
2
|
-
|
|
3
1
|
from datetime import datetime
|
|
4
2
|
|
|
5
|
-
from pydantic import BaseModel, Field
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class Preset(BaseModel):
|
|
9
7
|
"""Preset entity"""
|
|
10
8
|
|
|
11
|
-
model_config =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
model_config = ConfigDict(
|
|
10
|
+
validate_by_name=False,
|
|
11
|
+
validate_by_alias=True,
|
|
12
|
+
serialize_by_alias=True,
|
|
13
|
+
)
|
|
16
14
|
|
|
17
|
-
pk: int = Field(
|
|
15
|
+
pk: int = Field(
|
|
16
|
+
description='Defines the primary key of the preset',
|
|
17
|
+
alias='id',
|
|
18
|
+
)
|
|
18
19
|
name: str = Field(description='Defines the name of the preset')
|
|
19
20
|
valid_before: datetime = Field(
|
|
20
21
|
...,
|
|
21
22
|
description='Defines the date and time before which the preset is valid',
|
|
22
23
|
)
|
|
24
|
+
|
|
25
|
+
@field_serializer('valid_before', when_used='always')
|
|
26
|
+
def serialize_valid_before(self, valid_before: datetime) -> float:
|
|
27
|
+
return valid_before.timestamp()
|
|
28
|
+
|
|
23
29
|
comment: str = Field(
|
|
24
30
|
default='',
|
|
25
31
|
description='Defines the comment of the preset',
|
layrz_sdk/entities/report.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"""Report class"""
|
|
2
|
-
|
|
3
1
|
import logging
|
|
4
2
|
import os
|
|
5
3
|
import time
|
|
@@ -8,7 +6,7 @@ from pathlib import Path
|
|
|
8
6
|
from typing import Any, Optional, Self
|
|
9
7
|
|
|
10
8
|
import xlsxwriter
|
|
11
|
-
from pydantic import BaseModel, Field, field_validator
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
12
10
|
|
|
13
11
|
from layrz_sdk.entities.custom_report_page import CustomReportPage
|
|
14
12
|
from layrz_sdk.entities.report_data_type import ReportDataType
|
|
@@ -22,6 +20,12 @@ log = logging.getLogger(__name__)
|
|
|
22
20
|
class Report(BaseModel):
|
|
23
21
|
"""Report definition"""
|
|
24
22
|
|
|
23
|
+
model_config = ConfigDict(
|
|
24
|
+
validate_by_name=False,
|
|
25
|
+
validate_by_alias=True,
|
|
26
|
+
serialize_by_alias=True,
|
|
27
|
+
)
|
|
28
|
+
|
|
25
29
|
name: str = Field(description='Name of the report. Length should be less than 60 characters')
|
|
26
30
|
pages: list[ReportPage | CustomReportPage] = Field(
|
|
27
31
|
description='List of report pages',
|
layrz_sdk/entities/report_col.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"""Report col"""
|
|
2
|
-
|
|
3
1
|
import warnings
|
|
4
2
|
from typing import Any, Optional, Self
|
|
5
3
|
|
|
6
|
-
from pydantic import BaseModel, Field, field_validator
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
|
7
5
|
|
|
8
6
|
from .report_data_type import ReportDataType
|
|
9
7
|
from .text_alignment import TextAlignment
|
|
@@ -12,11 +10,27 @@ from .text_alignment import TextAlignment
|
|
|
12
10
|
class ReportCol(BaseModel):
|
|
13
11
|
"""Report column entity"""
|
|
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
|
content: Any = Field(description='Column content')
|
|
16
20
|
color: str = Field(description='Column color', default='#ffffff')
|
|
17
21
|
text_color: Optional[str] = Field(description='Column text color', default=None)
|
|
18
22
|
align: TextAlignment = Field(description='Column text alignment', default=TextAlignment.LEFT)
|
|
23
|
+
|
|
24
|
+
@field_serializer('align', when_used='always')
|
|
25
|
+
def serialize_align(self, align: TextAlignment) -> str:
|
|
26
|
+
return align.value
|
|
27
|
+
|
|
19
28
|
data_type: ReportDataType = Field(description='Column data type', default=ReportDataType.STR)
|
|
29
|
+
|
|
30
|
+
@field_serializer('data_type', when_used='always')
|
|
31
|
+
def serialize_data_type(self, data_type: ReportDataType) -> str:
|
|
32
|
+
return data_type.value
|
|
33
|
+
|
|
20
34
|
datetime_format: str = Field(description='Datetime format', default='%Y-%m-%d %H:%M:%S')
|
|
21
35
|
currency_symbol: str = Field(description='Currency symbol', default='')
|
|
22
36
|
bold: bool = Field(description='Bold text', default=False)
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
from pydantic import BaseModel, Field
|
|
1
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class ReportConfiguration(BaseModel):
|
|
5
5
|
"""Report configuration entity"""
|
|
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
|
title: str = Field(description='Report title')
|
|
8
14
|
pages_count: int = Field(description='Number of pages in the report')
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"""Report header"""
|
|
2
|
-
|
|
3
1
|
import warnings
|
|
4
2
|
from typing import Any, Optional
|
|
5
3
|
|
|
6
|
-
from pydantic import BaseModel, Field, field_validator
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
|
7
5
|
|
|
8
6
|
from .text_alignment import TextAlignment
|
|
9
7
|
|
|
@@ -11,33 +9,18 @@ from .text_alignment import TextAlignment
|
|
|
11
9
|
class ReportHeader(BaseModel):
|
|
12
10
|
"""Report header entity"""
|
|
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
|
content: Any = Field(description='Header content')
|
|
15
19
|
color: str = Field(description='Header color', default='#ffffff')
|
|
16
|
-
text_color: Optional[str] = Field(description='Header text color', default=None)
|
|
17
20
|
align: TextAlignment = Field(description='Header text alignment', default=TextAlignment.CENTER)
|
|
21
|
+
|
|
22
|
+
@field_serializer('align', when_used='always')
|
|
23
|
+
def serialize_align(self, align: TextAlignment) -> str:
|
|
24
|
+
return align.value
|
|
25
|
+
|
|
18
26
|
bold: bool = Field(description='Bold text', default=False)
|
|
19
|
-
width: Optional[float] = Field(description='Header width', default=None)
|
|
20
|
-
|
|
21
|
-
@field_validator('text_color', mode='before')
|
|
22
|
-
def _validate_text_color(cls, value: Any) -> Any:
|
|
23
|
-
"""Validate text color"""
|
|
24
|
-
if value is not None:
|
|
25
|
-
warnings.warn(
|
|
26
|
-
'text_color is deprecated, the algorithm will calculate the rigth text color instead',
|
|
27
|
-
DeprecationWarning,
|
|
28
|
-
stacklevel=2,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
return value
|
|
32
|
-
|
|
33
|
-
@field_validator('width', mode='before')
|
|
34
|
-
def _validate_width(cls, value: Any) -> Any:
|
|
35
|
-
"""Validate width"""
|
|
36
|
-
if value is not None:
|
|
37
|
-
warnings.warn(
|
|
38
|
-
'width is deprecated, the algorithm will calculate the rigth width instead',
|
|
39
|
-
DeprecationWarning,
|
|
40
|
-
stacklevel=2,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
return value
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from pydantic import BaseModel, Field
|
|
1
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
4
2
|
|
|
5
3
|
from .report_header import ReportHeader
|
|
6
4
|
from .report_row import ReportRow
|
|
@@ -9,6 +7,12 @@ from .report_row import ReportRow
|
|
|
9
7
|
class ReportPage(BaseModel):
|
|
10
8
|
"""Report page definition"""
|
|
11
9
|
|
|
10
|
+
model_config = ConfigDict(
|
|
11
|
+
validate_by_name=False,
|
|
12
|
+
validate_by_alias=True,
|
|
13
|
+
serialize_by_alias=True,
|
|
14
|
+
)
|
|
15
|
+
|
|
12
16
|
name: str = Field(description='Name of the page. Length should be less than 60 characters')
|
|
13
17
|
headers: list[ReportHeader] = Field(description='List of report headers', default_factory=list)
|
|
14
18
|
rows: list[ReportRow] = Field(description='List of report rows', default_factory=list)
|
layrz_sdk/entities/report_row.py
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import warnings
|
|
4
|
-
from typing import Any, Optional
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field, field_validator
|
|
1
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
7
2
|
|
|
8
3
|
from .report_col import ReportCol
|
|
9
4
|
|
|
@@ -11,18 +6,11 @@ from .report_col import ReportCol
|
|
|
11
6
|
class ReportRow(BaseModel):
|
|
12
7
|
"""Report row definition"""
|
|
13
8
|
|
|
9
|
+
model_config = ConfigDict(
|
|
10
|
+
validate_by_name=False,
|
|
11
|
+
validate_by_alias=True,
|
|
12
|
+
serialize_by_alias=True,
|
|
13
|
+
)
|
|
14
|
+
|
|
14
15
|
content: list[ReportCol] = Field(description='List of report columns', default_factory=list)
|
|
15
|
-
height: Optional[float] = Field(description='Row height', default=None)
|
|
16
16
|
compact: bool = Field(description='Compact mode', default=False)
|
|
17
|
-
|
|
18
|
-
@field_validator('height', mode='before')
|
|
19
|
-
def _validate_height(cls, value: Any) -> Any:
|
|
20
|
-
"""Validate height"""
|
|
21
|
-
if value is not None:
|
|
22
|
-
warnings.warn(
|
|
23
|
-
'height is deprecated, the algorithm will calculate the rigth text color instead',
|
|
24
|
-
DeprecationWarning,
|
|
25
|
-
stacklevel=2,
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
return value
|