Classes defined in Layrz SDK
There is the definition of all of our classes and enums in the Layrz SDK. With that, you can explore the possibilities of our Python functions for charts, reports, triggers and sensors.
Feel free to contact us at support@layrz.com if you have trouble understanding any of these classes or enums, or need assistance with anything else.
Broadcasts
Enums
BroadcastStatus
Attribute | Description |
---|---|
BroadcastStatus.OK | The message was sent successfully |
BroadcastStatus.BADREQUEST | The message was sent but was rejected by the service |
BroadcastStatus.INTERNALERROR | The message cannot be send due a internal error |
BroadcastStatus.UNAUTHORIZED | The message cannot be send due an issue with credentials or service is down |
BroadcastStatus.UNPROCESSABLE | The message was sent but was rejected by the service (Unexpected rejection) |
BroadcastStatus.DISCONNECTED | The message was sent successfully and performed a disconnection procedure |
Classes
BroadcastRequest
Attribute | Description | Field Type |
---|---|---|
BroadcastRequest.json | Defines the JSON data sent to the service | dict |
BroadcastRequest.raw | Defines the raw data sent to the service | str |
Let's look an example:
from layrz_sdk.entities import BroadcastRequest
broadcast_request = BroadcastRequest(
json={"key1": "value1", "key2": "value2"},
raw="My raw content"
)
broadcast_request.json
#> {"key1": "value1", "key2": "value2"}
broadcast_request.raw
#> "My raw content"
BroadcastResponse
Attribute | Description | Field Type |
---|---|---|
BroadcastResponse.json | Defines the JSON structure of the service's response | dict |
BroadcastResponse.raw | Defines the raw data of the service's response | str |
Let's look an example:
from layrz_sdk.entities import BroadcastResponse
broadcast_response = BroadcastResponse(
json={"key1": "value1", "key2": "value2"},
raw="My raw content"
)
broadcast_response.json
#> {"key1": "value1", "key2": "value2"}
broadcast_response.raw
#> "My raw content"
BroadcastResult
Attribute | Description | Field Type |
---|---|---|
BroadcastResult.service_id | It's the ID of the outbound service | int |
BroadcastResult.asset_id | It's the ID of the asset | int |
BroadcastResult.status | Defines the status of the submission | BroadcastStatus |
BroadcastResult.request | Defines the data sent to the service | BroadcastRequest |
BroadcastResult.response | Defines the response of the service | BroadcastResponse |
BroadcastResult.submitted_at | Defines the date of the submission | datetime |
Let's look an example:
from layrz_sdk.entities import BroadcastResult
broadcast_result = BroadcastResult(
service_id=1,
asset_id=1,
status=BroadcastStatus.OK,
request=BroadcastRequest(
json={"key1": "value1", "key2": "value2"},
raw="My raw content"
),
response=BroadcastResponse(
json={"key1": "value1", "key2": "value2"},
raw="My raw content"
),
submitted_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
broadcast_result.service_id
#> 1
broadcast_result.asset_id
#> 1
broadcast_result.status
#> "OK"
broadcast_result.request
#> BroadcastRequest(json={"key1": "value1", "key2": "value
broadcast_result.response
#> BroadcastResponse(json={"key1": "value1", "key2": "value
broadcast_result.submitted_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
OutboundService
Attribute | Description | Field Type |
---|---|---|
OutboundService.pk | Defines the ID of the service | int |
OutboundService.name | Defines the name of the service | str |
Let's look an example:
from layrz_sdk.entities import OutboundService
outbound_service = OutboundService(
pk=1,
name="My Outbound Service"
)
outbound_service.pk
#> 1
outbound_service.name
#> "My Outbound Service"
Cases
Enums
CaseIgnoredStatus
Attribute | Description |
---|---|
CaseIgnoredStatus.NORMAL | The case was closed normally. |
CaseIgnoredStatus.IGNORED | The case was ignored in our monitors |
CaseIgnoredStatus.PRESSET | The case was closed automatically by a preset |
CaseIgnoredStatus.AUTO | The case was closed automatically by a expiry time |
CaseStatus
Attribute | Description |
---|---|
CaseStatus.PENDING | The case is pending or waiting for attention |
CaseStatus.FOLLOWED | The case is in following state, or a user is currently following the case |
CaseStatus.CLOSED | The case was closed |
Classes
Case
Attribute | Description | Datatype |
---|---|---|
Case.pk | Case ID | int |
Case.trigger | Trigger that activated the case | Trigger |
Case.asset_id | ID of the asset associated with the case | int |
Case.opened_at | Case receipt date | datetime |
Case.closed_at | Case closing date | datetime |
Case.comments | List of case comments submitted | list[Comment] |
Case.status | Status of the case | CaseStatus |
Case.ignored_status | Ignored status of the case | CaseIgnoredStatus |
Let's look an example:
from layrz_sdk.entities import Case
case = Case(
pk=1,
asset_id=1,
trigger=Trigger(pk=1, name="My Trigger", code="my_trigger"),
comments=[
Comment(pk=1, content="My comment", user=User(pk=1, name="User"), submitted_at=datetime.datetime.now(tz=ZoneInfo('UTC'))),
Comment(pk=2, content="My second comment", user=User(pk=2, name="User"), submitted_at=datetime.datetime.now(tz=ZoneInfo('UTC')))
],
opened_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
close_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
case.pk
#> 1
case.asset_id
#> 1
case.trigger
#> Trigger(pk=1, name="My Trigger", code="my_trigger")
case.comments
#> [
Comment(pk=1, content="My comment", user=User(pk=1, name="User"), submitted_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)),
Comment(pk=2, content="My second comment", user=User(pk=2, name="User"), submitted_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>))
]
case.opened_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
case.closed_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Comment
Attribute | Description | Field Type |
---|---|---|
Comment.pk | Comment ID | int |
Comment.content | Comment content | str |
Comment.user | User which sent the comment | User |
Comment.submitted_at | Comment date sent | datetime |
Let's look an example:
from layrzsdk.entities import Comment
comment = Comment(
pk=1,
content="My comment",
user=User(pk=1, name="User"),
submitted_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
comment.pk
#> 1
comment.content
#> "My comment"
comment.user
#> User(pk=1, name="User")
comment.submitted_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Trigger
Attribute | Description | Field Type |
---|---|---|
Trigger.pk | Trigger ID | int |
Trigger.name | Trigger Name | str |
Trigger.code | Unique trigger code | str |
Let's look an example:
from layrz_sdk.entities import Trigger
trigger = Trigger(
pk=1,
name="My Trigger",
code="my_trigger"
)
trigger.pk
#> 1
trigger.name
#> "My Trigger"
trigger.code
#> "my_trigger"
Charts
Enums
ChartAlignment
Attribute | Description |
---|---|
ChartAlignment.LEFT | Align the chart to the left |
ChartAlignment.RIGHT | Align the chart to the right |
ChartAlignment.CENTER | Center the chart |
ChartColor
Attribute | Description |
---|---|
ChartColor.RED | Color the series red |
ChartColor.BLUE | Color the series blue |
ChartColor.GREEN | Color the series green |
ChartColor.PURPLE | Color the series purple |
ChartColor.ORANGE | Color the series orange |
ChartColor.PINK | Color the series pink |
ChartColor.TEAL | Color the series teal |
ChartColor.AMBER | Color the series amber |
ChartColor.CYAN | Color the series cyan |
ChartColor.INDIGO | Color the series indigo |
ChartColor.LIME | Color the series lime |
ChartDataSerieType
Attribute | Description |
---|---|
ChartDataSerieType.NONE | The serie type is not defined |
ChartDataSerieType.LINE | The serie type is a line |
ChartDataSerieType.AREA | The serie type is an area |
ChartDataSerieType.SCATTER | The serie type is a scatter |
ChartDataType
Attribute | Description |
---|---|
ChartDataType.STRING | Defines the data type as a string |
ChartDataType.DATETIME | Defines the data type as a datetime |
ChartDataType.NUMBER | Defines the data type as a number |
ChartRenderTechnology
Attribute | Description |
---|---|
ChartRenderTechnology.CANVAS_JS | Use CanvasJS to render the graphs. Exclusive for line charts |
ChartRenderTechnology.GRAPHIC | Use graphic to render the graphs |
ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS | Use syncfusion_flutter_charts to render the graphs |
ChartRenderTechnology.FLUTTER_MAP | Use flutter_map to render the graphs |
ChartRenderTechnology.APEX_CHARTS | Use apex_charts to render the graphs. Exclusive for maps |
ChartRenderTechnology.FLUTTER | Use native flutter to render the graphs. Exclusive to number and table charts |
MapCenterType
Attribute | Description |
---|---|
MapCenterType.FIXED | Set the map center to a fixed point |
MapCenterType.CONTAIN | Set the map center dynamically to contain all points |
Classes
AreaChart
This class will be removed in the next version. Use LineChart
instead.
Attribute | Description | Field Type |
---|---|---|
AreaChart.title | Defines the title of the chart | str |
AreaChart.align | Defines the alignment of the chart | ChartAlignment |
AreaChart.x_axis | Defines the X axis (Horizontal) | ChartDataSerie |
AreaChart.y_axis | Defines the Y Axis (Vertical) | list[ChartDataSerie] |
AreaChart.x_axis_config | Defines the configuration for the X Axis (Horizontal) | AxisConfig |
AreaChart.y_axis_config | Defines the configuration for the Y Axis (Vertical) | AxisConfig |
Let's look an example:
from layrz_sdk.entities import AreaChart, ChartDataType
area_chart = AreaChart(
title="My Area Chart",
align=ChartAlignment.LEFT,
x_axis=ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"]),
y_axis=[
ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])
],
x_axis_config=AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING),
y_axis_config=AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
)
area_chart.title
#> "My Area Chart"
area_chart.align
#> "LEFT"
area_chart.x_axis
#> ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"])
area_chart.x_axis_config
#> AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING)
area_chart.y_axis
#> [ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])]
area_chart.y_axis_config
#> AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
AxisConfig
Attribute | Description | Field Type |
---|---|---|
AxisConfig.label | Label to display on the axis | str |
AxisConfig.measure_unit | Measure unit of the axis | str |
AxisConfig.min_value | Minimum value of the axis | int | float |
AxisConfig.max_value | Maximum value of the axis | int | float |
AxisConfig.data_type | Data type of the axis | ChartDataType |
Let's look at an example:
from layrz_sdk.entities import AxisConfig, ChartDataType
axis_config = AxisConfig(
label="My axis",
measure_unit="seconds (s)",
min_value=0.,
max_value=10.,
data_type=ChartDataType.DATETIME
)
axis_config.label
#> "My axis"
axis_config.measure_unit
#> "seconds (s)"
axis_config.min_value
#> 0.0
axis_config.max_value
#> 10.0
axis_config.data_type
#> "DATETIME"
BarChart
Attribute | Description | Field Type |
---|---|---|
BarChart.title | Defines the title of the chart | str |
BarChart.align | Defines the alignment of the chart | ChartAlignment |
BarChart.x_axis | Defines the X axis (Horizontal) | ChartDataSerie |
BarChart.y_axis | Defines the Y Axis (Vertical) | list[ChartDataSerie] |
AreaChart.x_axis_config | Defines the configuration for the X Axis (Horizontal) | AxisConfig |
AreaChart.y_axis_config | Defines the configuration for the Y Axis (Vertical) | AxisConfig |
Let's look an example:
from layrz_sdk.entities import BarChart
bar_chart = BarChart(
title="My Bar Chart",
align=ChartAlignment.LEFT,
x_axis=ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"]),
y_axis=[
ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])
],
x_axis_config=AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING),
y_axis_config=AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
)
bar_chart.title
#> "My Bar Chart"
bar_chart.align
#> "LEFT"
bar_chart.x_axis
#> ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"])
bar_chart.y_axis
#> [ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])]
bar_chart.x_axis_config
#> AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING)
bar_chart.y_axis_config
#> AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
ChartConfiguration
Attribute | Description | Field Type |
---|---|---|
ChartConfiguration.name | Defines the name of the chart | str |
ChartConfiguration.description | Defines the description of the chart | str |
Let's look an example:
from layrz_sdk.entities import ChartConfiguration
chart_configuration = ChartConfiguration(
name="My Chart Configuration",
description="My Chart Configuration Description"
)
chart_configuration.name
#> "My Chart Configuration"
chart_configuration.description
#> "My Chart Configuration Description"
ChartDataSerie
Attribute | Description | Field Type |
---|---|---|
ChartDataSerie.data | List of data points | list[float | int | bool] |
ChartDataSerie.serie_type | Type of the serie. Only used for mixed range charts | ChartDataSerieType |
ChartDataSerie.dashed | If the serie should be dashed | bool |
ChartDataSerie.color | Color of the serie as a hexadecimal color code | str |
ChartDataSerie.label | Label of the serie | str |
ChartDataSerie.data_type | Type of the data | ChartDataType |
Let's look an example:
from layrz_sdk.entities import ChartDataSerie
chart_data_serie = ChartDataSerie(
data=[1, 2, 3],
serie_type=ChartDataSerieType.LINE,
dashed=True,
color="#ff0000",
label="My Serie",
data_type=ChartDataType.NUMBER
)
chart_data_serie.data
#> [1, 2, 3]
chart_data_serie.serie_type
#> "LINE"
chart_data_serie.dashed
#> True
chart_data_serie.color
#> "#ff0000"
chart_data_serie.label
#> "My Serie"
chart_data_serie.data_type
#> "NUMBER"
ChartException
Attribute | Description | Field Type |
---|---|---|
ChartException.message | Defines an exception of the chart | str |
Inherits
This class inherits from the Python BaseException
class, you can handle this exception as a regular Python exception with a try
and except
block.
Let's look an example:
from layrz_sdk.entities import ChartException
chart_exception = ChartException(
message="My Chart Exception"
)
chart_exception.message
#> "My Chart Exception"
ColumnChart
Attribute | Description | Field Type |
---|---|---|
ColumnChart.title | Defines the title of the chart | str |
ColumnChart.align | Defines the alignment of the chart | ChartAlignment |
ColumnChart.x_axis | Defines the X axis (Horizontal) | ChartDataSerie |
ColumnChart.y_axis | Defines the Y Axis (Vertical) | list[ChartDataSerie] |
ColumnChart.x_axis_config | Defines the configuration for the X Axis (Horizontal) | AxisConfig |
ColumnChart.y_axis_config | Defines the configuration for the Y Axis (Vertical) | AxisConfig |
Let's look an example:
from layrz_sdk.entities import ColumnChart
column_chart = ColumnChart(
title="My Column Chart",
align=ChartAlignment.LEFT,
x_axis=ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"]),
y_axis=[
ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])
],
x_axis_config=AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING),
y_axis_config=AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
)
column_chart.title
#> "My Column Chart"
column_chart.align
#> "LEFT"
column_chart.x_axis
#> ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"])
column_chart.y_axis
#> [ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])]
column_chart.x_axis_config
#> AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING)
column_chart.y_axis_config
#> AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
HTMLChart
Attribute | Description | Field Type |
---|---|---|
HTMLChart.title | Defines the title of the chart | str |
HTMLChart.align | Defines the alignment of the chart | ChartAlignment |
HTMLChart.content | Defines the content of the chart, this content should be HTML | str |
Let's look an example:
from layrz_sdk.entities import HTMLChart
html_chart = HTMLChart(
title="My HTML Chart",
align=ChartAlignment.LEFT,
content="<html><body><h1>My HTML Chart</h1></body></html>"
)
html_chart.title
#> "My HTML Chart"
html_chart.align
#> "LEFT"
html_chart.content
#> "<html><body><h1>My HTML Chart</h1></body></html>"
LineChart
Attribute | Description | Field Type |
---|---|---|
LineChart.title | Defines the title of the chart | str |
LineChart.align | Defines the alignment of the chart | ChartAlignment |
LineChart.x_axis | Defines the X axis (Horizontal) | ChartDataSerie |
LineChart.y_axis | Defines the Y Axis (Vertical) | list[ChartDataSerie] |
LineChart.x_axis_config | Defines the configuration for the X Axis (Horizontal) | AxisConfig |
LineChart.y_axis_config | Defines the configuration for the Y Axis (Vertical) | AxisConfig |
Let's look an example:
from layrz_sdk.entities import LineChart
line_chart = LineChart(
title="My Line Chart",
align=ChartAlignment.LEFT,
x_axis=ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"]),
y_axis=[
ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])
],
x_axis_config=AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING),
y_axis_config=AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
)
line_chart.title
#> "My Line Chart"
line_chart.align
#> "LEFT"
line_chart.x_axis
#> ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"])
line_chart.y_axis
#> [ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])]
line_chart.x_axis_config
#> AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING)
line_chart.y_axis_config
#> AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
MapChart
Attribute | Description | Field Type |
---|---|---|
MapChart.title | Defines the title of the chart | str |
MapChart.center | Defines where is the center of the map | MapCenterType |
MapChart.points | Defines the list of points to display | list[MapPoint] |
MapChart.center_latlng | Defines the fixed center of the map. This property only works when center is MapCenterType.FIXED . If a list is used, it should have a length of two | tuple[float, float] | list[float] |
Let's look an example:
from layrz_sdk.entities import MapChart
map_chart = MapChart(
title="My Map Chart",
align=ChartAlignment.LEFT,
center=MapCenterType.FIXED,
points=[
MapPoint(latitude=1.23, longitude=4.56, label="My Point", color="#ff0000"),
MapPoint(latitude=7.89, longitude=10.11, label="My Other Point", color="#00ff00")
],
center_latlng = (1.5, 0.5)
)
map_chart.title
#> "My Map Chart"
map_chart.align
#> "LEFT"
map_chart.center
#> "FIXED"
map_chart.points
#> [MapPoint(latitude=1.23, longitude=4.56, label="My Point", color="#ff0000"), MapPoint(latitude=7.89, longitude=10.11, label="My Other Point", color="#00ff00")]
map_chart.center_latlng
#> (1.5, 0.5)
MapPoint
Attribute | Description | Field Type |
---|---|---|
MapPoint.latitude | Defines the latitude in decimal degrees | float |
MapPoint.longitude | Defines the longitude in decimal degrees | float |
MapPoint.label | Defines the label or name of the point | str |
MapPoint.color | Defines the color (In HEX) of the point | str |
Let's look an example:
from layrz_sdk.entities import MapPoint
map_point = MapPoint(
latitude=1.23,
longitude=4.56,
label="My Point",
color="#ff0000"
)
map_point.latitude
#> 1.23
map_point.longitude
#> 4.56
map_point.label
#> "My Point"
map_point.color
#> "#ff0000"
NumberChart
Attribute | Description | Field Type |
---|---|---|
NumberChart.value | Defines the number to display | int |
NumberChart.color | Defines the color to display in hexadecimal code | str |
NumberChart.label | Defines the name or label to display | str |
Let's look an example:
from layrz_sdk.entities import NumberChart
number_chart = NumberChart(
value=1.23,
color="#ff0000",
label="My Number Chart"
)
number_chart.value
#> 1.23
number_chart.color
#> "#ff0000"
number_chart.label
#> "My Number Chart"
PieChart
Attribute | Description | Field Type |
---|---|---|
PieChart.title | Defines the title of the chart | str |
PieChart.align | Defines the alignment of the chart | ChartAlignment |
PieChart.serie | Defines the series to display | list[ChartDataSerie] |
Let's look an example:
from layrz_sdk.entities import PieChart
pie_chart = PieChart(
title="My Pie Chart",
align=ChartAlignment.LEFT,
serie=[
ChartDataSerie(name="My Serie", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Serie", type=ChartDataType.NUMBER, data=[4, 5, 6])
]
)
pie_chart.title
#> "My Pie Chart"
pie_chart.align
#> "LEFT"
pie_chart.serie
#> [ChartDataSerie(name="My Serie", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Serie", type=ChartDataType.NUMBER, data=[4, 5, 6])]
RadarChart
Attribute | Description | Field Type |
---|---|---|
RadarChart.title | Defines the title of the chart | str |
RadarChart.align | Defines the alignment of the chart | ChartAlignment |
RadarChart.x_axis | Defines the X axis (Horizontal) | ChartDataSerie |
RadarChart.y_axis | Defines the Y Axis (Vertical) | list[ChartDataSerie] |
Let's look an example:
from layrz_sdk.entities import RadarChart
radar_chart = RadarChart(
title="My Radar Chart",
align=ChartAlignment.LEFT,
x_axis=ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"]),
y_axis=[
ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])
]
)
radar_chart.title
#> "My Radar Chart"
radar_chart.align
#> "LEFT"
radar_chart.x_axis
#> ChartDataSerie(name="My X Axis", type=ChartDataType.STRING, data=["A", "B", "C"])
radar_chart.y_axis
#> [ChartDataSerie(name="My Y Axis", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Y Axis", type=ChartDataType.NUMBER, data=[4, 5, 6])]
RadialBarChart
Attribute | Description | Field Type |
---|---|---|
RadialBarChart.title | Title of the chart | str |
RadialBarChart.align | Alignment of the chart | ChartAlignment |
RadialBarChart.serie | Defines the series of the chart, uses the ChartDataSerie class. | list[ChartDataSerie] |
Let's look an example:
from layrz_sdk.entities import RadialBarChart
radial_bar_chart = RadialBarChart(
title="My Radial Bar Chart",
align=ChartAlignment.LEFT,
serie=[
ChartDataSerie(name="My Serie", type=ChartDataType.NUMBER, data=[1, 2, 3]),
ChartDataSerie(name="My Other Serie", type=ChartDataType.NUMBER, data=[4, 5, 6])
]
)
radial_bar_chart.title
#> "My Radial Bar Chart"
radial_bar_chart.align
#> "LEFT"
radial_bar_chart.serie
#> [ChartDataSerie(name="My Serie", type=ChartDataType.NUMBER, data=[1, 2, 3]), ChartDataSerie(name="My Other Serie", type=ChartDataType.NUMBER, data=[4, 5, 6])]
ScatterChart
Attribute | Description | Field Type |
---|---|---|
ScatterChart.title | Title of the chart | str |
ScatterChart.align | Alignment of the chart | ChartAlignment |
ScatterChart.series | Defines the series of the chart, uses the ScatterSerie class. | list[ScatterSerie] |
ScatterChart.x_axis_config | Defines the configuration for the X Axis (Horizontal) | AxisConfig |
ScatterChart.y_axis_config | Defines the configuration for the Y Axis (Vertical) | AxisConfig |
from layrz_sdk.entities import ScatterChart
scatter_chart = ScatterChart(
title="My Scatter Chart",
align=ChartAlignment.LEFT,
series=[
ScatterSerie(label="My Serie", data=[ScatterSerieItem(x=1, y=2), ScatterSerieItem(x=3, y=4)], color="#ff0000"),
ScatterSerie(label="My Other Serie", data=[ScatterSerieItem(x=5, y=6), ScatterSerieItem(x=7, y=8)], color="#00ff00")
],
x_axis_config=AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING),
y_axis_config=AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
)
scatter_chart.title
#> "My Scatter Chart"
scatter_chart.align
#> "LEFT"
scatter_chart.series
#> [ScatterSerie(label="My Serie", data=[ScatterSerieItem(x=1, y=2), ScatterSerieItem(x=3, y=4)], color="#ff0000"), ScatterSerie(label="My Other Serie", data=[ScatterSerieItem(x=5, y=6), ScatterSerieItem(x=7, y=8)], color="#00ff00")]
scatter_chart.x_axis_config
#> AxisConfig(label="X Axis", measure_unit="Letters", min_value="A", max_value="C", data_type=ChartDataType.STRING)
scatter_chart.y_axis_config
#> AxisConfig(label="Y Axis", measure_unit="unit", min_value=1, max_value=6, data_type=ChartDataType.NUMBER)
ScatterSerie
Attribute | Description | Field Type |
---|---|---|
ScatterSerie.label | Label of the serie | str |
ScatterSerie.data | List of data points | list[ScatterSerieItem] |
ScatterSerie.color | Color of the serie in hexadecimal code | str |
ScatterSerie.serie_type | Type of the serie | ChartDataSerieType |
Let's look an example:
from layrz_sdk.entities import ScatterSerie
scatter_serie = ScatterSerie(
label="My Scatter Serie",
data=[
ScatterSerieItem(x=1, y=2),
ScatterSerieItem(x=3, y=4)
],
color="#ff0000"
)
scatter_serie.label
#> "My Scatter Serie"
scatter_serie.data
#> [ScatterSerieItem(x=1, y=2), ScatterSerieItem(x=3, y=4)]
scatter_serie.color
#> "#ff0000"
scatter_serie.serie_type
#> ChartDataSerieType.SCATTER
ScatterSerieItem
Attribute | Description | Field Type |
---|---|---|
ScatterSerieItem.x | X value of the item | float |
ScatterSerieItem.y | Y value of the item | float |
Let's look an example:
from layrz_sdk.entities import ScatterSerieItem
scatter_serie_item = ScatterSerieItem(
x=1,
y=2
)
scatter_serie_item.x
#> 1
scatter_serie_item.y
#> 2
TableChart
Attribute | Description | Field Type |
---|---|---|
TableChart.columns | List of columns | list[TableHeader] |
TableChart.rows | List of rows | list[TableRow] |
Let's look an example:
from layrz_sdk.entities import TableChart
table_chart = TableChart(
columns=[
TableHeader(name="My Column", key="my_column"),
TableHeader(name="My Other Column", key="my_other_column")
],
rows=[
TableRow(data={"my_column": "A", "my_other_column": 1}),
TableRow(data={"my_column": "B", "my_other_column": 2})
]
)
table_chart.columns
#> [TableHeader(name="My Column", key="my_column"), TableHeader(name="My Other Column", key="my_other_column")]
table_chart.rows
#> [TableRow(data={"my_column": "A", "my_other_column": 1}), TableRow(data={"my_column": "B", "my_other_column": 2})]
TableHeader
Attribute | Description | Field Type |
---|---|---|
TableHeader.label | The label of the column | str |
TableHeader.key | The key of the column, this key should be present in each row | str |
Let's look an example:
from layrz_sdk.entities import TableHeader
table_header = TableHeader(
label="My Table Header",
key="my_table_header"
)
table_header.label
#> "My Table Header"
table_header.key
#> "my_table_header"
TableRow
Attribute | Description | Field Type |
---|---|---|
TableRow.data | The data of the row, the keys comes from the headers | dict |
Let's look an example:
from layrz_sdk.entities import TableRow
table_row = TableRow(
data={"key1": "value1", "key2": "value2"}
)
table_row.data
#> {"key1": "value1", "key2": "value2"}
TimelineChart
Attribute | Description | Field Type |
---|---|---|
TimelineChart.title | Title of the chart | str |
TimelineChart.align | Alignment of the chart | ChartAlignment |
TimelineChart.series | Defines the series of the chart, uses the TimelineSerie class. | list[TimelineSerie] |
Let's look an example:
from layrz_sdk.entities import TimelineChart
timeline_chart = TimelineChart(
title="My Timeline Chart",
align=ChartAlignment.LEFT,
series=[
TimelineSerie(name="My Serie", data=[TimelineSerieItem(start_at=datetime.datetime.now(tz=ZoneInfo('UTC')), end_at=datetime.datetime.now(tz=ZoneInfo('UTC')))]),
TimelineSerie(name="My Other Serie", data=[TimelineSerieItem(start_at=datetime.datetime.now(tz=ZoneInfo('UTC')), end_at=datetime.datetime.now(tz=ZoneInfo('UTC')))])
]
)
timeline_chart.title
#> "My Timeline Chart"
timeline_chart.align
#> "LEFT"
timeline_chart.series
#> [TimelineSerie(name="My Serie", data=[TimelineSerieItem(start_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>), end_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)]), TimelineSerie(name="My Other Serie", data=[TimelineSerieItem(start_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>), end_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)])]
TimelineSerie
Attribute | Description | Field Type |
---|---|---|
TimelineSerie.label | Label of the serie. | str |
TimelineSerie.data | List of data points. | list[TimelineSerieItem] |
Let's look an example:
from layrz_sdk.entities import TimelineSerie
timeline_serie = TimelineSerie(
label="My Timeline Serie",
data=[TimelineSerieItem(start_at=datetime.datetime.now(tz=ZoneInfo('UTC')), end_at=datetime.datetime.now(tz=ZoneInfo('UTC')))]
)
timeline_serie.label
#> "My Timeline Serie"
timeline_serie.data
#> [TimelineSerieItem(start_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>), end_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)]
TimelineSerieItem
Attribute | Description | Field Type |
---|---|---|
TimelineSerieItem.start_at | Start date of the item. | datetime |
TimelineSerieItem.end_at | End date of the item. | datetime |
TimelineSerieItem.color | Color of the item in hexadecimal code. | str |
TimelineSerieItem.name | Label of the item. | str |
Let's look an example:
from layrz_sdk.entities import TimelineSerieItem
timeline_serie_item = TimelineSerieItem(
start_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
end_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
color="#ff0000",
name="My Timeline Serie Item"
)
timeline_serie_item.start_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
timeline_serie_item.end_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
timeline_serie_item.color
#> "#ff0000"
timeline_serie_item.name
#> "My Timeline Serie Item"
Checkpoints
Classes
Checkpoint
Attribute | Description | Datatype |
---|---|---|
Checkpoint.pk | Checkpoint ID | int |
Checkpoint.asset_id | Active harassed at the checkpoint | int |
Checkpoint.waypoints | Checkpoint waypoint list | list[Waypoint] |
Checkpoint.start_at | Checkpoint start date | datetime |
Checkpoint.end_at | Waypoint end date | datetime |
Let's look an example:
from layrz_sdk.entities import Checkpoint
checkpoint = Checkpoint(
pk=1,
asset_id=1,
waypoints=[
Waypoint(pk=1, geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"), sequence_real=1, sequence_ideal=1, start_at=datetime.datetime.now(tz=ZoneInfo('UTC')), end_at=datetime.datetime.now(tz=ZoneInfo('UTC'))),
Waypoint(pk=2, geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"), sequence_real=1, sequence_ideal=1, start_at=datetime.datetime.now(tz=ZoneInfo('UTC')), end_at=datetime.datetime.now(tz=ZoneInfo('UTC')))
],
start_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
end_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
checkpoint.pk
#> 1
checkpoint.asset_id
#> 1
checkpoint.waypoints
#> [
# Waypoint(pk=1, geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"), sequence_real=1, sequence_ideal=1, start_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>), end_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)),
# Waypoint(pk=2, geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"), sequence_real=1, sequence_ideal=1, start_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>), end_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>))
# ]
checkpoint.start_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
checkpoint.end_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Waypoint
Attribute | Description | Field Type |
---|---|---|
Waypoint.pk | Waypoint ID | int |
Waypoint.geofence | Associated geofence | Geofence |
Waypoint.sequence_real | Actual or executed sequence | int |
Waypoint.sequence_ideal | Ideal or planned sequence | int |
Waypoint.start_at | Date of entry to waypoint | datetime |
Waypoint.end_at | Waypoint exit date | datetime |
Let's look an example:
from layrz_sdk.entities import Waypoint
waypoint = Waypoint(
pk=1,
geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"),
sequence_real=1,
sequence_ideal=1,
start_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
end_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
waypoint.pk
#> 1
waypoint.geofence
#> Geofence(pk=1, name="My Geofence", color="#ff0000")
waypoint.sequence_real
#> 1
waypoint.sequence_ideal
#> 1
waypoint.start_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
waypoint.end_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Events
Classes
Event
Attribute | Description | Datatype |
---|---|---|
Event.pk | Event ID | int |
Event.trigger | Trigger object that fired the event | Trigger |
Event.asset_id | ID of the asset associated with the event | int |
Event.message | Event telemetry information | Message |
Event.activated_at | Event activation date | datetime |
Event.geofence | Geofence where the event ocurred | Geofence |
Event.presence_type | Presence type of the event | PresenceType |
Let's look an example:
from layrz_sdk.entities import Event
event = Event(
pk=1,
trigger=Trigger(pk=1, name="My Trigger", code="my_trigger"),
asset_id=1,
message=Message(
pk=1,
asset_id=1,
position=Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56),
payload={"device1.param1": "value1", "device1.param2": "value2", "device2.param1": "value3", "device2.param2": "value4"},
sensors={"sensor1": "value1", "sensor2": "value2"},
received_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
),
activated_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
geofence=Geofence(pk=1, name="My Geofence", color="#ff0000"),
presence_type=PresenceType.ENTRANCE,
)
event.pk
#> 1
event.asset_id
#> 1
event.trigger
#> Trigger(pk=1, name="My Trigger", code="my_trigger")
event.message
#> Message(
# pk=1,
# asset_id=1,
# position=Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56),
# payload={"device1.param1": "value1","device1.param2": "value2","device2.param1": "value3","device2.param2": "value4"},
# sensors={"sensor1": "value1","sensor2": "value2"},
# received_at=datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
# )
event.activated_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
event.geofence
#> Geofence(pk=1, name="My Geofence", color="#ff0000")
event.presence_type
#> PresenceType.ENTRANCE
Formatting
Enums
TextAlignment
Attribute | Description |
---|---|
TextAlignment.CENTER | Align the text to the center |
TextAlignment.LEFT | Align the text to the left |
TextAlignment.RIGHT | Align the text to the right |
TextAlignment.JUSTIFY | Justify the text |
General
Enums
AssetOperationMode
Attribute | Description |
---|---|
AssetOperationMode.SINGLE | Refers to single device operation mode |
AssetOperationMode.MULTIPLE | Refers to operation mode with more than one device, when this is the operation mode, in list devices, one of then will be indicated as main device |
AssetOperationMode.ASSETMULTIPLE | This refers to the operation mode with one or more assets, when this is the operation mode, list will be empty |
AssetOperationMode.DISCONNECTED | Disconnected operation mode, means the telemetry is not provided by any device |
AssetOperationMode.STATIC | Static operation mode, means that the position information is provided by the user and the telemetry is provided by any device (Not mandatory) |
AssetOperationMode.ZONE | Zone operation mode, means that the telemetry is provided by a zone, the zone is a polygonal area that is defined by the user. In the telemetry, you can get the path of the zone using the raw parameter zone.path , and the position.latitude and position.longitude will be the centroid of the zone |
PresenceType
Attribute | Description |
---|---|
PresenceType.ENTRANCE | Entrance to a geofence |
PresenceType.EXIT | Exit out of a geofence |
Classes
Asset
Attribute | Description | Datatype |
---|---|---|
Asset.pk | Unique identifier of the asset, this ID is unique throughout the entire Layrz ecosystem. | int |
Asset.name | Asset name | str |
Asset.devices | List of devices of the asset. It will return an empty list in case the operation mode is AssetOperationMode.ASSETMULTIPLE . Otherwise, it will return a list of Device , where only one of them will have the primary device identifier Device.is_primary | list[Device] |
Asset.vin | It is equivalent to the body serial number of a vehicle, machinery serial number, or any type of unique serial number. | str |
Asset.plate | It is equivalent to a vehicle license plate, tax registration number, citizen identification number, or any other type of unique identifier. | str |
Asset.asset_type | Indicates the type of asset, this value will be an ID. | int |
Asset.operation_mode | Indicates the operating mode of the asset. | AssetOperationMode |
Asset.custom_fields | List of custom fields for the asset. | list[CustomField] |
Asset.children | List of assets associated with this asset, it will only return a list with values when the operation mode is AssetOperationMode.ASSETMULTIPLE . | list[Asset] |
Asset.sensors | List of sensors of the asset. | list[Sensor] |
Let's look an example:
from layrz_sdk.entities import Asset
asset = Asset(
pk=1,
name="My Asset",
vin="12345678901234567",
plate="ABC-123",
asset_type=1,
operation_mode=AssetOperationMode.MULTIPLE,
custom_fields=[
CustomField(name="My Custom Field", value="My Value"),
CustomField(name="My Other Custom Field", value="My Other Value")
],
devices=[
Device(pk=1, ident="123456", name="My Device", protocol="alpharest", is_primary=True),
Device(pk=2, ident="789012", name="My Other Device", protocol="alpharest", is_primary=False)
],
children=[],
sensors=[
Sensor(pk=1, name="My Sensor", slug="my.sensor"),
Sensor(pk=2, name="My Other Sensor", slug="my.other.sensor")
]
)
asset.pk
#> 1
asset.name
#> "My Asset"
asset.vin
#> "12345678901234567"
asset.plate
#> "ABC-123"
asset.asset_type
#> 1
asset.operation_mode
#> "MULTIPLE"
asset.custom_fields
#> [CustomField(name="My Custom Field", value="My Value"),CustomField(name="My Other Custom Field", value="My Other Value")]
asset.devices
#> [Device(pk=1, ident="123456", name="My Device", protocol="alpharest", is_primary=True),Device(pk=2, ident="789012", name="My Other Device", protocol="alpharest", is_primary=False)]
asset.children
#> []
asset.sensors
#> [Sensor(pk=1, name="My Sensor", slug="my.sensor"), Sensor(pk=2, name="My Other Sensor", slug="my.other.sensor")]
CustomField
Attribute | Description | Field Type |
---|---|---|
CustomField.name | Refers to the name or key with which this custom field is identified. It is always the same data type | str |
CustomField.value | Refers to the value of the custom field. It is always the same data type | str |
Let's look an example:
from layrz_sdk import CustomField
custom_field = CustomField(name="My Custom Field", value="My Value")
sensor.pk
#> 1
sensor.name
#> "My Sensor"
sensor.slug
#> "my.sensor"
Device
Attribute | Description | Field Type |
---|---|---|
Device.pk | This is the Device ID, this ID is unique on all Layrz ecosystem | int |
Device.name | Device's name | str |
Device.ident | Unique identifier or IMEI's Device | str |
Device.protocol | This is the unique protocol's identifier | str |
Device.is_primary | Primary device indicator. This value will only be true if it is a primary device of the asset. In a list of devices in an asset, only one device with this value set to true will exist. | bool |
Let's look an example:
from layrz_sdk import Device
device = Device(pk=1, ident="123456789", name="My Device", protocol="alpharest", is_primary=True)
device.pk
#> 1
device.ident
#> "123456789"
device.name
#> "My Device"
device.protocol
#> "alpharest"
device.is_primary
#> True
Geofence
Attribute | Description | Field Type |
---|---|---|
Geofence.pk | Geofence id | int |
Geofence.name | Geofence Name | str |
Geofence.color | Geofence Color (In Hexadecimal format) | str |
Let's look an example:
from layrz_sdk.entities import Geofence
geofence = Geofence(
pk=1,
name="My Geofence",
color="#ff0000"
)
geofence.pk
#> 1
geofence.name
#> "My Geofence"
geofence.color
#> "#ff0000"
Sensor
Attribute | Description | Datatype |
---|---|---|
Sensor.pk | Unique sensor ID, this ID is unique throughout the entire Layrz ecosystem. | int |
Sensor.name | Refers to the name of the sensor. | str |
Sensor.slug | Refers to the parameter or key of the sensor, this value cannot overlap with other sensors of the same asset. | str |
Let's look an example:
from layrz_sdk.entities import Sensor
sensor = Sensor(pk=1, name="My Sensor", slug="my.sensor")
sensor.pk
#> 1
sensor.name
#> "My Sensor"
sensor.slug
#> "my.sensor"
User
Attribute | Description | Field Type |
---|---|---|
User.pk | User ID | int |
User.name | User name | str |
Let's look an example:
from layrz_sdk.entities import User
user = User(
pk=1,
name="User"
)
user.pk
#> 1
user.name
#> "User"
Repcom
Classes
Transaction
Attribute | Description | Field type |
---|---|---|
pk | Transaction ID | int |
asset | Asset related to the transaction | Asset |
amount | Amount of the transaction | float |
quantity | Quantity of the transaction | float |
mileage | Mileage in kilometers | float |
distance | Distance traveled in kilometers | float |
engine_time | Time with the engine on | timedelta |
idle_time | Time with the engine on without movement | timedelta |
in_geofence | Flag to indicate if transaction occurred inside a geofence | bool |
geofence_name | Name of the geofence where transaction occurred | str |
received_at | Transaction reception date and time | datetime |
is_wildcard | Wildcard indicator for transaction | bool |
Let's look an example:
from layrz_sdk.entities import Transaction
transaction = Transaction(
pk=1,
asset=Asset(pk=1, name="My Asset"),
amount=100.00,
quantity=10.00,
mileage=100.00,
distance=100.00,
engine_time=datetime.timedelta(hours=1),
idle_time=datetime.timedelta(minutes=30),
in_geofence=True,
geofence_name="My Geofence",
received_at=datetime.datetime.now(tz=ZoneInfo('UTC')),
is_wildcard=False
)
transaction.pk
#> 1
transaction.asset
#> Asset(pk=1, name="My Asset")
transaction.amount
#> 100.00
transaction.quantity
#> 10.00
transaction.mileage
#> 100.00
transaction.distance
#> 100.00
transaction.engine_time
#> datetime.timedelta(hours=1)
transaction.idle_time
#> datetime.timedelta(minutes=30)
transaction.in_geofence
#> True
transaction.geofence_name
#> "My Geofence"
transaction.received_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
transaction.is_wildcard
#> False
Reports
Enums
ReportDataType
Attribute | Description |
---|---|
ReportDataType.STR | Defines the data type as a string |
ReportDataType.INT | Defines the data type as an integer |
ReportDataType.FLOAT | Defines the data type as a float |
ReportDataType.DATETIME | Defines the data type as a datetime |
ReportDataType.BOOL | Defines the data type as a boolean |
ReportDataType.CURRENCY | Defines the data type as a currency |
ReportFormat
Attribute | Description |
---|---|
ReportFormat.MICROSOFT_EXCEL | Defines the report format as Microsoft Excel (xlsx) |
ReportFormat.JSON | Defines the report format as JSON |
Classes
CustomReportPage
Attribute | Description | Field Type |
---|---|---|
CustomReportPage.name | Defines the name of the page. Length should be less than 60 characters | str |
CustomReportPage.builder | Function to build the page, the builder receives a [Worksheet](https://xlsxwriter.readthedocs.io/worksheet.html) entity as an argument and shouldn't return anything. | [callable(Worksheet)](https://xlsxwriter.readthedocs.io/worksheet.html) |
Let's look an example:
from layrz_sdk.entities import CustomReportPage
def build_page(worksheet):
worksheet.write('A1', 'Hello')
worksheet.write('B1', 'World')
worksheet.write('A2', 'This')
worksheet.write('B2', 'is')
worksheet.write('C2', 'an')
worksheet.write('D2', 'example')
worksheet.merge_range('A4:D4', 'Merged cells')
bold = worksheet.add_format({'bold': True})
worksheet.write('A6', 'Bold text', bold)
format1 = worksheet.add_format({'bg_color': '#FFC7CE', 'font_color': '#9C0006'})
worksheet.write('A8', 'Text with red background', format1)
page = CustomReportPage(
name="My Custom Report Page",
builder=build_page
)
page.name
#> "My Custom Report Page"
page.builder
#> <function build_page at 0x7f8e3e3e3d30>
Report
Attribute | Description | Field Type |
---|---|---|
Report.pages | Defines the pages of the report | list[ReportPage] | list[CustomReportPage] |
Report.name | Defines the name of the report | str |
Report.export_format | export_format is deprecated, submit the export format in the export() method instead | ReportFormat |
Let's look an example:
from layrz_sdk.entities import Report
report = Report(
pages=[
ReportPage(name="My Report Page", headers=[ReportHeader(content="My Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER)], rows=[ReportRow(content=[ReportCol(content="My Report Col", color="#ff0000", data_type=ReportDataType.STRING, text_color="#00ff00", align=TextAlignment.CENTER, datetime_format="YYYY-MM-DD", currency_symbol="USD")], height=100, compact=True)]),
ReportPage(name="My Other Report Page", headers=[ReportHeader(content="My Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER)], rows=[ReportRow(content=[ReportCol(content="My Report Col", color="#ff0000", data_type=ReportDataType.STRING, text_color="#00ff00", align=TextAlignment.CENTER, datetime_format="YYYY-MM-DD", currency_symbol="USD")], height=100, compact=True)])
],
name="My Report"
)
report.pages
#> [ReportPage(name="My Report Page", headers=[ReportHeader(content="My Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER)], rows=[ReportRow(content=[ReportCol(content="My Report Col", color="#ff0000", data_type=ReportDataType.STRING, text_color="#00ff00", align=TextAlignment.CENTER, datetime_format="YYYY-MM-DD", currency_symbol="USD")], height=100, compact=True)]), ReportPage(name="My Other Report Page", headers=[ReportHeader(content="My Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER)], rows=[ReportRow(content=[ReportCol(content="My Report Col", color="#ff0000", data_type=ReportDataType.STRING, text_color="#00ff00", align=TextAlignment.CENTER, datetime_format="YYYY-MM-DD", currency_symbol="USD")], height=100, compact=True)]
report.name
#> "My Report"
ReportCol
Attribute | Description | Field Type |
---|---|---|
ReportCol.content | Defines the content to display | any* |
ReportCol.color | Defines the color of the cell (Not the text color, in HEX) | str |
ReportCol.data_type | Defines the data type of the content | ReportDataType |
ReportCol.align | Defines the alignment of the text in the cell | TextAlignment |
ReportCol.datetime_format | Defines the datetime format, uses the default Python datetime strftime() | str |
ReportCol.currency_symbol | Defines the currency symbol | str |
ReportCol.bold | Defines if the text is bold | bool |
ReportCol.text_color | Property text_color deprecated in ReportCol , replaced by a luminance-based color using the background color | str |
Let's look an example:
from layrz_sdk.entities import ReportCol
report_col = ReportCol(
content="My Report Col",
color="#ff0000",
data_type=ReportDataType.STRING,
align=TextAlignment.CENTER,
datetime_format="YYYY-MM-DD",
currency_symbol="USD",
bold=True
)
report_col.content
#> "My Report Col"
report_col.color
#> "#ff0000"
report_col.data_type
#> "STRING"
report_col.align
#> "CENTER"
report_col.datetime_format
#> "YYYY-MM-DD"
report_col.currency_symbol
#> "USD"
ReportConfiguration
Attribute | Description | Field Type |
---|---|---|
ReportConfiguration.title | Report title | str |
ReportConfiguration.pages_count | Number of pages to display | int |
Let's look an example:
from layrz_sdk.entities import ReportConfiguration
report_configuration = ReportConfiguration(
pages_count=1,
title="My Report"
)
report_configuration.pages_count
#> 1
report_configuration.title
#> "My Report"
ReportHeader
Attribute | Description | Field Type |
---|---|---|
ReportHeader.content | Display name | str |
ReportHeader.color | Cell color in hexadecimal code | str |
ReportHeader.align | Text Alignment | TextAlignment |
ReportHeader.bold | Bold text | bool |
ReportHeader.width | Property width deprecated in ReportHeader , replaced by the function autofit() to automatically fit the header width | float |
ReportHeader.text_color | Property text_color deprecated in ReportHeader , replaced by a luminance-based color using the background color | str |
Let's look an example:
from layrz_sdk.entities import ReportHeader
report_header = ReportHeader(
content="My Report Header",
color="#ff0000",
align=TextAlignment.CENTER,
bold=True
)
report_header.content
#> "My Report Header"
report_header.autofit()
report_header.color
#> "#ff0000"
report_header.align
#> "CENTER"
ReportPage
Attribute | Description | Field Type |
---|---|---|
ReportPage.name | Defines the name of the page | str |
ReportPage.headers | Defines the headers of the page | list[ReportHeader] |
ReportPage.rows | Defines the rows of the page | list[ReportRow] |
ReportPage.freeze_header | Specifies if the header should appear frozen | bool |
Let's look an example:
from layrz_sdk.entities import ReportPage
report_page = ReportPage(
name="My Report Page",
headers=[
ReportHeader(content="My Report Header", color="#ff0000", align=TextAlignment.CENTER),
ReportHeader(content="My Other Report Header", color="#ff0000", align=TextAlignment.CENTER)
],
rows=[
ReportRow(data=["A", "B"]),
ReportRow(data=["C", "D"])
],
freeze_header=False
)
report_page.name
#> "My Report Page"
report_page.headers
#> [ReportHeader(content="My Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER), ReportHeader(content="My Other Report Header", width=100, color="#ff0000", text_color="#00ff00", align=TextAlignment.CENTER)]
report_page.rows
#> [ReportRow(data=["A", "B"]), ReportRow(data=["C", "D")]
report_page.freeze_header
#> False
ReportRow
Attribute | Description | Field Type |
---|---|---|
ReportRow.content | Defines the content of the row | list[ReportCol] |
ReportRow.compact | Defines if the row is compact | bool |
ReportRow.height | Height is deprecated | float |
Let's look an example:
from layrz_sdk.entities import ReportRow
report_row = ReportRow(
content=[
ReportCol(content="My Report Col", color="#ff0000", align=TextAlignment.CENTER),
ReportCol(content="My Other Report Col", color="#ff0000", align=TextAlignment.CENTER)
],
compact=True
)
report_row.content
#> [ReportCol(content="My Report Col", color="#ff0000", align=TextAlignment.CENTER), ReportCol(content="My Other Report Col", color="#ff0000", align=TextAlignment.CENTER)]
report_row.compact
#> True
Telemetry
Classes
LastMessage
Attribute | Description | Field Type |
---|---|---|
LastMessage.pk | Unique message identifier | int |
LastMessage.asset_id | Unique identifier of the asset, owner of the message | int |
LastMessage.asset | The asset entity that generated the message | Asset |
LastMessage.position | Geolocation information | Position |
LastMessage.payload | Raw content of the asset's raster | dict |
LastMessage.sensors | Calculated/processed values from the asset's sensors | dict |
LastMessage.received_at | Date of receipt of the message. Defined in UTC | datetime |
Disclaimer!
The LastMessage.asset.sensors
, LastMessage.asset.children
, LastMessage.asset.devices
and LastMessage.asset.custom_fields
are not provided.
Let's look an example:
from layrz_sdk.entities import LastMessage
asset = Asset(pk=1, name="My Asset", vin="12345678901234567", plate="ABC-123",
asset_type=1, operation_mode=AssetOperationMode.MULTIPLE)
last_message = LastMessage(
pk=1,
asset_id=asset.pk,
asset=asset
position=Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56),
payload={
"device1.param1": "value1",
"device1.param2": "value2",
"device2.param1": "value3",
"device2.param2": "value4"
},
sensors={
"sensor1": "value1",
"sensor2": "value2"
},
received_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
last_message.pk
#> 1
last_message.asset_id
#> 1
last_message.asset
#> Asset(pk=1, name="My Asset", vin="12345678901234567", plate="ABC-123", asset_type=1, operation_mode=AssetOperationMode.MULTIPLE, custom_fields=None, children=None, sensors=None)'
last_message.position
#> Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56)
last_message.payload
#> {"device1.param1": "value1","device1.param2": "value2","device2.param1": "value3","device2.param2": "value4"}
last_message.sensors
#> {"sensor1": "value1","sensor2": "value2"}
last_message.received_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Message
Attribute | Description | Field Type |
---|---|---|
Message.pk | Unique message identifier | int |
Message.asset_id | Unique identifier of the asset, owner of the message | int |
Message.position | Geolocation information | Position |
Message.payload | Raw content of the asset's raster | dict |
Message.sensors | Calculated/processed values from the asset's sensors | dict |
Message.received_at | Date of receipt of the message. Defined in UTC | datetime |
Let's look an example:
from layrz_sdk.entities import Message
message = Message(
pk=1,
asset_id=1,
position=Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56),
payload={
"device1.param1": "value1",
"device1.param2": "value2",
"device2.param1": "value3",
"device2.param2": "value4"
},
sensors={
"sensor1": "value1",
"sensor2": "value2"
},
received_at=datetime.datetime.now(tz=ZoneInfo('UTC'))
)
message.pk
#> 1
message.asset_id
#> 1
message.position
#> Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56)
message.payload
#> {"device1.param1": "value1","device1.param2": "value2","device2.param1": "value3","device2.param2": "value4"}
message.sensors
#> {"sensor1": "value1","sensor2": "value2"}
message.received_at
#> datetime.datetime(2022, 2, 24, 7, 22, 52, 317161, tzinfo=<UTC>)
Position
Attribute | Description | Datatype |
---|---|---|
Position.latitude | Latitude in decimal degrees format | float |
Position.longitude | Length in decimal degrees format | float |
Position.altitude | Altitude in meters above sea level | float |
Position.speed | Speed in kilometers per hour | float |
Position.direction | Direction in degrees | float |
Position.hdop | Horizontal dilution of precision | float |
Position.satellites | Number of satellites | int |
Let's look an example:
from layrz_sdk.entities import Position
position = Position(latitude=1.23, longitude=4.56, altitude=7.89, speed=10.11, direction=12.34, hdop=15.56, satellites=10)
position.latitude
#> 1.23
position.longitude
#> 4.56
position.altitude
#> 7.89
position.speed
#> 10.11
position.direction
#> 12.34
position.hdop
#> 15.56
position.satellites
#> 10