request defines how to fetch data from time-series database.
Attributes
Name | Type | Description |
---|---|---|
datapoints | list | list of str pointing to hardware ids of datapoint or template properties name. |
aggregation | str | aggregation method ("mean", "stddev", "mode", "median", "count", "sum", "first", "last", "max", "min"). |
interval | int | interval passed in seconds at init (stored as milliseconds). |
template_id | uuid.UUID | use technical id of wizata_dsapi.Template to fetch data based on a template. |
twin_id | uuid.UUID | technical id of wizata_dsapi.Twin registered on template_id. |
filters | dict | filters to apply to the query pre-aggregation. nested dictionary using as first key=datapoint then value=another dictionary with key=operator (gt,lt,gte,lte,eq,neq) and value is the float value to compare too). |
options | dict | dict representing query options. |
Methods
add_datapoints()
add datapoints to existing list of datapoints in the query.
Name | Type | Default | Description |
---|---|---|---|
datapoints | datapoints to fetch identified by hardware id or template property name. | ||
shift | int | 0 | shift to apply in seconds on timestamp, by default 0. |
add_equipment()
add datapoints to fetch with a digital twin id identification.
Name | Type | Default | Description |
---|---|---|---|
equipment_id | UUID | UUID of the Digital Twin ID to which the datapoints are linked. | |
datapoints | List(str) of datapoints to fetch identified by Hardware ID. | ||
shift | 0 | Shift to apply in seconds on timestamp, by default 0. |
api_id()
return current object id on Web API format.
end_time()
convert a relative end time to a datetime based on a now parameter.
Name | Type | Default | Description |
---|---|---|---|
now | None | override now value for relative datetime |
return: end datetime
endpoint()
return endpoint name used to contact backend.
from_json()
load the object from a dict originating of a JSON format.
Name | Type | Default | Description |
---|---|---|---|
json_data |
get_datapoints()
get datapoints
return: list of declared datapoints.
get_params()
get a list of all parameters.
return: list of parameters
get_template_id()
extract template id from request if present.
return: template id as uuid.UUID
get_template_key()
extract template key from request if present.
return: template key as str
get_twin_hardware_id()
extract twin hardware id from request if present.
return: template key as str
get_twin_id()
extract twin id from request if present.
return: template key as uuid
list_agg_methods()
get a list of all authorized methods.
return: list with "mean", "stddev", "mode", "median", "count", "sum", "first", "last", "max" or "min"
prepare()
prepare analyse the query and produce a dict with query information.
return: dict
remove_equipment()
remove equipment from the list including all its listed datapoints.
Name | Type | Default | Description |
---|---|---|---|
equipment_id | UUID | UUID of the Digital Twin item. |
select_template()
select a template and its registration.
Name | Type | Default | Description |
---|---|---|---|
template_id | None | template UUID | |
template_key | None | template key ( ignored if template_id specified ) | |
twin_id | None | Digital Twin UUID | |
twin_hardware_id | None | hardware ID of Digital Twin ( ignored if twin_id specified ) |
set_aggregation()
specifies aggregation properties
Name | Type | Default | Description |
---|---|---|---|
method | "mean", "stddev", "mode", "median", "count", "sum", "first", "last", "max" or "min" | ||
interval | interval in ms (will be stored in seconds) |
set_datapoints()
replace current datapoints by provided list
Name | Type | Default | Description |
---|---|---|---|
datapoints | list |
set_extra_data()
deprecated - set additional data to query used as post-processing
Name | Type | Default | Description |
---|---|---|---|
obj |
set_id()
specify the id_value neutrally
Name | Type | Default | Description |
---|---|---|---|
id_value |
return:
set_param()
set value of parameter based on his name.
Name | Type | Default | Description |
---|---|---|---|
name | str | ||
value |
start_time()
convert a relative start time to a datetime based on a now parameter.
Name | Type | Default | Description |
---|---|---|---|
now | None | override now value for relative datetime |
return: start datetime
to_json()
transform current object into a dict that could be JSONIFY.
Name | Type | Default | Description |
---|---|---|---|
target | str | None |
return: dumpable dict.