layrz-sdk 3.1.3__py3-none-any.whl → 3.1.4__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 (75) hide show
  1. layrz_sdk/__init__.py +1 -1
  2. layrz_sdk/constants.py +5 -5
  3. layrz_sdk/entities/__init__.py +129 -129
  4. layrz_sdk/entities/asset.py +70 -69
  5. layrz_sdk/entities/asset_operation_mode.py +31 -31
  6. layrz_sdk/entities/broadcast_request.py +12 -12
  7. layrz_sdk/entities/broadcast_response.py +12 -12
  8. layrz_sdk/entities/broadcast_result.py +20 -20
  9. layrz_sdk/entities/broadcast_status.py +28 -28
  10. layrz_sdk/entities/case.py +47 -47
  11. layrz_sdk/entities/case_ignored_status.py +26 -26
  12. layrz_sdk/entities/case_status.py +23 -23
  13. layrz_sdk/entities/charts/axis_config.py +15 -15
  14. layrz_sdk/entities/charts/bar_chart.py +171 -171
  15. layrz_sdk/entities/charts/chart_alignment.py +27 -27
  16. layrz_sdk/entities/charts/chart_color.py +44 -44
  17. layrz_sdk/entities/charts/chart_configuration.py +10 -10
  18. layrz_sdk/entities/charts/chart_data_serie.py +19 -19
  19. layrz_sdk/entities/charts/chart_data_serie_type.py +28 -28
  20. layrz_sdk/entities/charts/chart_data_type.py +27 -27
  21. layrz_sdk/entities/charts/chart_render_technology.py +30 -30
  22. layrz_sdk/entities/charts/column_chart.py +197 -197
  23. layrz_sdk/entities/charts/html_chart.py +34 -34
  24. layrz_sdk/entities/charts/line_chart.py +244 -244
  25. layrz_sdk/entities/charts/map_center_type.py +22 -22
  26. layrz_sdk/entities/charts/map_chart.py +104 -104
  27. layrz_sdk/entities/charts/map_point.py +22 -22
  28. layrz_sdk/entities/charts/number_chart.py +50 -50
  29. layrz_sdk/entities/charts/pie_chart.py +127 -127
  30. layrz_sdk/entities/charts/radar_chart.py +77 -77
  31. layrz_sdk/entities/charts/radial_bar_chart.py +127 -127
  32. layrz_sdk/entities/charts/scatter_chart.py +206 -206
  33. layrz_sdk/entities/charts/scatter_serie.py +15 -15
  34. layrz_sdk/entities/charts/scatter_serie_item.py +8 -8
  35. layrz_sdk/entities/charts/table_chart.py +50 -50
  36. layrz_sdk/entities/charts/table_header.py +8 -8
  37. layrz_sdk/entities/charts/table_row.py +9 -9
  38. layrz_sdk/entities/charts/timeline_chart.py +75 -75
  39. layrz_sdk/entities/charts/timeline_serie.py +12 -12
  40. layrz_sdk/entities/charts/timeline_serie_item.py +12 -12
  41. layrz_sdk/entities/checkpoint.py +18 -18
  42. layrz_sdk/entities/comment.py +16 -16
  43. layrz_sdk/entities/custom_field.py +10 -10
  44. layrz_sdk/entities/custom_report_page.py +16 -16
  45. layrz_sdk/entities/device.py +13 -13
  46. layrz_sdk/entities/event.py +23 -23
  47. layrz_sdk/entities/geofence.py +11 -11
  48. layrz_sdk/entities/last_message.py +12 -12
  49. layrz_sdk/entities/message.py +23 -23
  50. layrz_sdk/entities/outbound_service.py +10 -10
  51. layrz_sdk/entities/position.py +101 -101
  52. layrz_sdk/entities/presence_type.py +16 -16
  53. layrz_sdk/entities/report.py +257 -257
  54. layrz_sdk/entities/report_col.py +40 -40
  55. layrz_sdk/entities/report_configuration.py +8 -8
  56. layrz_sdk/entities/report_data_type.py +28 -28
  57. layrz_sdk/entities/report_format.py +27 -27
  58. layrz_sdk/entities/report_header.py +43 -43
  59. layrz_sdk/entities/report_page.py +17 -17
  60. layrz_sdk/entities/report_row.py +28 -28
  61. layrz_sdk/entities/sensor.py +11 -11
  62. layrz_sdk/entities/text_alignment.py +26 -26
  63. layrz_sdk/entities/trigger.py +11 -11
  64. layrz_sdk/entities/user.py +10 -10
  65. layrz_sdk/entities/waypoint.py +18 -18
  66. layrz_sdk/helpers/__init__.py +8 -8
  67. layrz_sdk/helpers/color.py +41 -41
  68. layrz_sdk/lcl/__init__.py +7 -7
  69. layrz_sdk/lcl/core.py +832 -832
  70. {layrz_sdk-3.1.3.dist-info → layrz_sdk-3.1.4.dist-info}/LICENSE +6 -6
  71. {layrz_sdk-3.1.3.dist-info → layrz_sdk-3.1.4.dist-info}/METADATA +48 -48
  72. layrz_sdk-3.1.4.dist-info/RECORD +75 -0
  73. layrz_sdk-3.1.3.dist-info/RECORD +0 -75
  74. {layrz_sdk-3.1.3.dist-info → layrz_sdk-3.1.4.dist-info}/WHEEL +0 -0
  75. {layrz_sdk-3.1.3.dist-info → layrz_sdk-3.1.4.dist-info}/top_level.txt +0 -0
@@ -1,244 +1,244 @@
1
- """Line chart"""
2
-
3
- import logging
4
- import sys
5
- from typing import Any, Dict, List
6
-
7
- from pydantic import BaseModel, Field
8
-
9
- from .axis_config import AxisConfig
10
- from .chart_alignment import ChartAlignment
11
- from .chart_data_serie import ChartDataSerie
12
- from .chart_data_serie_type import ChartDataSerieType
13
- from .chart_data_type import ChartDataType
14
- from .chart_render_technology import ChartRenderTechnology
15
-
16
- if sys.version_info >= (3, 11):
17
- from typing import Self
18
- else:
19
- from typing_extensions import Self
20
-
21
- log = logging.getLogger(__name__)
22
-
23
-
24
- class LineChart(BaseModel):
25
- """Line chart configuration"""
26
-
27
- x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
28
- y_axis: List[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
29
- title: str = Field(default='Chart', description='Title of the chart')
30
- align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
31
- x_axis_config: AxisConfig = Field(
32
- default_factory=lambda: AxisConfig(),
33
- description='Configuration of the X Axis',
34
- )
35
- y_axis_config: AxisConfig = Field(
36
- default_factory=lambda: AxisConfig(),
37
- description='Configuration of the Y Axis',
38
- )
39
-
40
- def render(self: Self, technology: ChartRenderTechnology) -> Dict[str, Any]:
41
- """
42
- Render chart to a graphic Library.
43
- :param technology: The technology to use to render the chart.
44
- :return: The configuration of the chart.
45
- """
46
-
47
- if technology == ChartRenderTechnology.GRAPHIC:
48
- return {
49
- 'library': 'GRAPHIC',
50
- 'chart': 'LINE',
51
- 'configuration': self._render_graphic(),
52
- }
53
-
54
- if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
55
- return {
56
- 'library': 'SYNCFUSION_FLUTTER_CHARTS',
57
- 'chart': 'LINE',
58
- 'configuration': self._render_syncfusion_flutter_charts(),
59
- }
60
-
61
- if technology == ChartRenderTechnology.CANVAS_JS:
62
- return {
63
- 'library': 'CANVASJS',
64
- 'chart': 'LINE',
65
- 'configuration': self._render_canvasjs(),
66
- }
67
-
68
- return {
69
- 'library': 'FLUTTER',
70
- 'chart': 'TEXT',
71
- 'configuration': [f'Unsupported {technology}'],
72
- }
73
-
74
- def _render_syncfusion_flutter_charts(self: Self) -> Dict[str, Any]:
75
- """
76
- Converts the configuration of the chart to a Flutter library syncfusion_flutter_charts.
77
- """
78
- series = []
79
-
80
- for serie in self.y_axis:
81
- if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
82
- log.warning('Serie type not supported: %s', serie.serie_type)
83
- continue
84
-
85
- points = []
86
-
87
- for i, value in enumerate(self.x_axis.data):
88
- x_value = value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value
89
- if not isinstance(x_value, (int, float)):
90
- continue
91
-
92
- y_value = serie.data[i]
93
- if isinstance(y_value, bool):
94
- if y_value:
95
- y_value = 1
96
- else:
97
- y_value = 0
98
-
99
- if not isinstance(y_value, (int, float)):
100
- log.debug("Value isn't a number: %s", y_value)
101
- continue
102
-
103
- points.append(
104
- {
105
- 'xAxis': x_value,
106
- 'yAxis': y_value,
107
- }
108
- )
109
-
110
- series.append(
111
- {
112
- 'color': serie.color,
113
- 'values': points,
114
- 'label': serie.label,
115
- 'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
116
- }
117
- )
118
-
119
- return {
120
- 'series': series,
121
- 'xAxis': {
122
- 'label': self.x_axis_config.label,
123
- 'measureUnit': self.x_axis_config.measure_unit,
124
- 'dataType': self.x_axis_config.data_type.value,
125
- 'minValue': self.x_axis_config.min_value,
126
- 'maxValue': self.x_axis_config.max_value,
127
- },
128
- 'yAxis': {
129
- 'label': self.y_axis_config.label,
130
- 'measureUnit': self.y_axis_config.measure_unit,
131
- 'dataType': self.y_axis_config.data_type.value,
132
- 'minValue': self.y_axis_config.min_value,
133
- 'maxValue': self.y_axis_config.max_value,
134
- },
135
- }
136
-
137
- def _render_graphic(self: Self) -> List[Dict[str, Any]]:
138
- """
139
- Converts the configuration of the chart to a Flutter library Graphic.
140
- """
141
- series = []
142
-
143
- for serie in self.y_axis:
144
- if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
145
- continue
146
-
147
- points = []
148
-
149
- for i, value in enumerate(self.x_axis.data):
150
- points.append(
151
- {
152
- 'x_axis': {
153
- 'value': value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value,
154
- 'is_datetime': self.x_axis.data_type == ChartDataType.DATETIME,
155
- },
156
- 'y_axis': serie.data[i],
157
- }
158
- )
159
-
160
- series.append(
161
- {
162
- 'group': serie.label,
163
- 'color': serie.color,
164
- 'dashed': serie.serie_type == ChartDataSerieType.LINE and serie.dashed,
165
- 'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
166
- 'values': points,
167
- }
168
- )
169
-
170
- return series
171
-
172
- def _render_canvasjs(self: Self) -> Dict[str, Any]:
173
- """
174
- Converts the configuration of the chart to Javascript library CanvasJS.
175
- """
176
- datasets = []
177
-
178
- for serie in self.y_axis:
179
- dataset = {
180
- 'type': 'line',
181
- 'name': serie.label,
182
- 'connectNullData': True,
183
- 'nullDataLineDashType': 'solid',
184
- 'showInLegend': True,
185
- 'color': serie.color,
186
- 'markerSize': 3,
187
- }
188
-
189
- if serie.serie_type != ChartDataSerieType.NONE:
190
- dataset['type'] = serie.serie_type.value
191
-
192
- if serie.serie_type == ChartDataSerieType.AREA:
193
- dataset['fillOpacity'] = 0.3
194
-
195
- if self.x_axis.data_type == ChartDataType.DATETIME:
196
- dataset['xValueType'] = 'dateTime'
197
- dataset['xValueFormatString'] = 'YYYY-MM-DD HH:mm:ss TT'
198
-
199
- if serie.serie_type == ChartDataSerieType.LINE and serie.dashed:
200
- dataset['lineDashType'] = 'dash'
201
- dataset['markerSize'] = 0
202
-
203
- points = []
204
-
205
- if serie.serie_type == ChartDataSerieType.SCATTER:
206
- for point in serie.data:
207
- points.append({'x': point.x, 'y': point.y})
208
- else:
209
- for i, value in enumerate(self.x_axis.data):
210
- points.append(
211
- {
212
- 'x': (value.timestamp() * 1000) if self.x_axis.data_type == ChartDataType.DATETIME else value,
213
- 'y': serie.data[i],
214
- }
215
- )
216
-
217
- dataset['dataPoints'] = points
218
- datasets.append(dataset)
219
-
220
- return {
221
- 'animationEnabled': False,
222
- 'zoomEnabled': True,
223
- 'title': {
224
- 'text': self.title,
225
- 'fontFamily': 'Fira Sans Condensed',
226
- 'fontSize': 20,
227
- 'horizontalAlign': self.align.value,
228
- },
229
- 'data': datasets,
230
- 'axisX': {
231
- 'title': self.x_axis.label,
232
- 'titleFontFamily': 'Fira Sans Condensed',
233
- 'titleFontSize': 20,
234
- },
235
- 'toolTip': {'animationEnabled': False, 'shared': True},
236
- 'legend': {'cursor': 'pointer'},
237
- }
238
-
239
-
240
- class AreaChart(LineChart):
241
- """
242
- Line chart
243
- Deprecation warning: This class will be removed in the next version. Use LineChart instead.
244
- """
1
+ """Line chart"""
2
+
3
+ import logging
4
+ import sys
5
+ from typing import Any, Dict, List
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+ from .axis_config import AxisConfig
10
+ from .chart_alignment import ChartAlignment
11
+ from .chart_data_serie import ChartDataSerie
12
+ from .chart_data_serie_type import ChartDataSerieType
13
+ from .chart_data_type import ChartDataType
14
+ from .chart_render_technology import ChartRenderTechnology
15
+
16
+ if sys.version_info >= (3, 11):
17
+ from typing import Self
18
+ else:
19
+ from typing_extensions import Self
20
+
21
+ log = logging.getLogger(__name__)
22
+
23
+
24
+ class LineChart(BaseModel):
25
+ """Line chart configuration"""
26
+
27
+ x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
28
+ y_axis: List[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
29
+ title: str = Field(default='Chart', description='Title of the chart')
30
+ align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
31
+ x_axis_config: AxisConfig = Field(
32
+ default_factory=lambda: AxisConfig(),
33
+ description='Configuration of the X Axis',
34
+ )
35
+ y_axis_config: AxisConfig = Field(
36
+ default_factory=lambda: AxisConfig(),
37
+ description='Configuration of the Y Axis',
38
+ )
39
+
40
+ def render(self: Self, technology: ChartRenderTechnology) -> Dict[str, Any]:
41
+ """
42
+ Render chart to a graphic Library.
43
+ :param technology: The technology to use to render the chart.
44
+ :return: The configuration of the chart.
45
+ """
46
+
47
+ if technology == ChartRenderTechnology.GRAPHIC:
48
+ return {
49
+ 'library': 'GRAPHIC',
50
+ 'chart': 'LINE',
51
+ 'configuration': self._render_graphic(),
52
+ }
53
+
54
+ if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
55
+ return {
56
+ 'library': 'SYNCFUSION_FLUTTER_CHARTS',
57
+ 'chart': 'LINE',
58
+ 'configuration': self._render_syncfusion_flutter_charts(),
59
+ }
60
+
61
+ if technology == ChartRenderTechnology.CANVAS_JS:
62
+ return {
63
+ 'library': 'CANVASJS',
64
+ 'chart': 'LINE',
65
+ 'configuration': self._render_canvasjs(),
66
+ }
67
+
68
+ return {
69
+ 'library': 'FLUTTER',
70
+ 'chart': 'TEXT',
71
+ 'configuration': [f'Unsupported {technology}'],
72
+ }
73
+
74
+ def _render_syncfusion_flutter_charts(self: Self) -> Dict[str, Any]:
75
+ """
76
+ Converts the configuration of the chart to a Flutter library syncfusion_flutter_charts.
77
+ """
78
+ series = []
79
+
80
+ for serie in self.y_axis:
81
+ if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
82
+ log.warning('Serie type not supported: %s', serie.serie_type)
83
+ continue
84
+
85
+ points = []
86
+
87
+ for i, value in enumerate(self.x_axis.data):
88
+ x_value = value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value
89
+ if not isinstance(x_value, (int, float)):
90
+ continue
91
+
92
+ y_value = serie.data[i]
93
+ if isinstance(y_value, bool):
94
+ if y_value:
95
+ y_value = 1
96
+ else:
97
+ y_value = 0
98
+
99
+ if not isinstance(y_value, (int, float)):
100
+ log.debug("Value isn't a number: %s", y_value)
101
+ continue
102
+
103
+ points.append(
104
+ {
105
+ 'xAxis': x_value,
106
+ 'yAxis': y_value,
107
+ }
108
+ )
109
+
110
+ series.append(
111
+ {
112
+ 'color': serie.color,
113
+ 'values': points,
114
+ 'label': serie.label,
115
+ 'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
116
+ }
117
+ )
118
+
119
+ return {
120
+ 'series': series,
121
+ 'xAxis': {
122
+ 'label': self.x_axis_config.label,
123
+ 'measureUnit': self.x_axis_config.measure_unit,
124
+ 'dataType': self.x_axis_config.data_type.value,
125
+ 'minValue': self.x_axis_config.min_value,
126
+ 'maxValue': self.x_axis_config.max_value,
127
+ },
128
+ 'yAxis': {
129
+ 'label': self.y_axis_config.label,
130
+ 'measureUnit': self.y_axis_config.measure_unit,
131
+ 'dataType': self.y_axis_config.data_type.value,
132
+ 'minValue': self.y_axis_config.min_value,
133
+ 'maxValue': self.y_axis_config.max_value,
134
+ },
135
+ }
136
+
137
+ def _render_graphic(self: Self) -> List[Dict[str, Any]]:
138
+ """
139
+ Converts the configuration of the chart to a Flutter library Graphic.
140
+ """
141
+ series = []
142
+
143
+ for serie in self.y_axis:
144
+ if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
145
+ continue
146
+
147
+ points = []
148
+
149
+ for i, value in enumerate(self.x_axis.data):
150
+ points.append(
151
+ {
152
+ 'x_axis': {
153
+ 'value': value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value,
154
+ 'is_datetime': self.x_axis.data_type == ChartDataType.DATETIME,
155
+ },
156
+ 'y_axis': serie.data[i],
157
+ }
158
+ )
159
+
160
+ series.append(
161
+ {
162
+ 'group': serie.label,
163
+ 'color': serie.color,
164
+ 'dashed': serie.serie_type == ChartDataSerieType.LINE and serie.dashed,
165
+ 'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
166
+ 'values': points,
167
+ }
168
+ )
169
+
170
+ return series
171
+
172
+ def _render_canvasjs(self: Self) -> Dict[str, Any]:
173
+ """
174
+ Converts the configuration of the chart to Javascript library CanvasJS.
175
+ """
176
+ datasets = []
177
+
178
+ for serie in self.y_axis:
179
+ dataset = {
180
+ 'type': 'line',
181
+ 'name': serie.label,
182
+ 'connectNullData': True,
183
+ 'nullDataLineDashType': 'solid',
184
+ 'showInLegend': True,
185
+ 'color': serie.color,
186
+ 'markerSize': 3,
187
+ }
188
+
189
+ if serie.serie_type != ChartDataSerieType.NONE:
190
+ dataset['type'] = serie.serie_type.value
191
+
192
+ if serie.serie_type == ChartDataSerieType.AREA:
193
+ dataset['fillOpacity'] = 0.3
194
+
195
+ if self.x_axis.data_type == ChartDataType.DATETIME:
196
+ dataset['xValueType'] = 'dateTime'
197
+ dataset['xValueFormatString'] = 'YYYY-MM-DD HH:mm:ss TT'
198
+
199
+ if serie.serie_type == ChartDataSerieType.LINE and serie.dashed:
200
+ dataset['lineDashType'] = 'dash'
201
+ dataset['markerSize'] = 0
202
+
203
+ points = []
204
+
205
+ if serie.serie_type == ChartDataSerieType.SCATTER:
206
+ for point in serie.data:
207
+ points.append({'x': point.x, 'y': point.y})
208
+ else:
209
+ for i, value in enumerate(self.x_axis.data):
210
+ points.append(
211
+ {
212
+ 'x': (value.timestamp() * 1000) if self.x_axis.data_type == ChartDataType.DATETIME else value,
213
+ 'y': serie.data[i],
214
+ }
215
+ )
216
+
217
+ dataset['dataPoints'] = points
218
+ datasets.append(dataset)
219
+
220
+ return {
221
+ 'animationEnabled': False,
222
+ 'zoomEnabled': True,
223
+ 'title': {
224
+ 'text': self.title,
225
+ 'fontFamily': 'Fira Sans Condensed',
226
+ 'fontSize': 20,
227
+ 'horizontalAlign': self.align.value,
228
+ },
229
+ 'data': datasets,
230
+ 'axisX': {
231
+ 'title': self.x_axis.label,
232
+ 'titleFontFamily': 'Fira Sans Condensed',
233
+ 'titleFontSize': 20,
234
+ },
235
+ 'toolTip': {'animationEnabled': False, 'shared': True},
236
+ 'legend': {'cursor': 'pointer'},
237
+ }
238
+
239
+
240
+ class AreaChart(LineChart):
241
+ """
242
+ Line chart
243
+ Deprecation warning: This class will be removed in the next version. Use LineChart instead.
244
+ """
@@ -1,22 +1,22 @@
1
- import sys
2
- from enum import Enum
3
-
4
- if sys.version_info >= (3, 11):
5
- from typing import Self
6
- else:
7
- from typing_extensions import Self
8
-
9
-
10
- class MapCenterType(Enum):
11
- """Map Chart center type"""
12
-
13
- FIXED = 'FIXED'
14
- CONTAIN = 'CONTAIN'
15
-
16
- def __str__(self: Self) -> str:
17
- """Readable property"""
18
- return self.name
19
-
20
- def __repr__(self: Self) -> str:
21
- """Readable property"""
22
- return f'MapCenterType.{self.name}'
1
+ import sys
2
+ from enum import Enum
3
+
4
+ if sys.version_info >= (3, 11):
5
+ from typing import Self
6
+ else:
7
+ from typing_extensions import Self
8
+
9
+
10
+ class MapCenterType(Enum):
11
+ """Map Chart center type"""
12
+
13
+ FIXED = 'FIXED'
14
+ CONTAIN = 'CONTAIN'
15
+
16
+ def __str__(self: Self) -> str:
17
+ """Readable property"""
18
+ return self.name
19
+
20
+ def __repr__(self: Self) -> str:
21
+ """Readable property"""
22
+ return f'MapCenterType.{self.name}'