Request

request defines how to fetch data from time-series database.

Attributes

NameTypeDescription
datapointslistlist of str pointing to hardware ids of datapoint or template properties name.
aggregationstraggregation method ("mean", "stddev", "mode", "median", "count", "sum", "first", "last", "max", "min").
intervalintinterval passed in seconds at init (stored as milliseconds).
template_iduuid.UUIDuse technical id of wizata_dsapi.Template to fetch data based on a template.
twin_iduuid.UUIDtechnical id of wizata_dsapi.Twin registered on template_id.
filtersdictfilters 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).
optionsdictdict representing query options.

Methods

add_datapoints()

add datapoints to existing list of datapoints in the query.

NameTypeDefaultDescription
datapointsdatapoints to fetch identified by hardware id or template property name.
shiftint0shift to apply in seconds on timestamp, by default 0.

add_equipment()

add datapoints to fetch with a digital twin id identification.

NameTypeDefaultDescription
equipment_idUUIDUUID of the Digital Twin ID to which the datapoints are linked.
datapointsList(str) of datapoints to fetch identified by Hardware ID.
shift0Shift 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.

NameTypeDefaultDescription
nowNoneoverride 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.

NameTypeDefaultDescription
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.

NameTypeDefaultDescription
equipment_idUUIDUUID of the Digital Twin item.

select_template()

select a template and its registration.

NameTypeDefaultDescription
template_idNonetemplate UUID
template_keyNonetemplate key ( ignored if template_id specified )
twin_idNoneDigital Twin UUID
twin_hardware_idNonehardware ID of Digital Twin ( ignored if twin_id specified )

set_aggregation()

specifies aggregation properties

NameTypeDefaultDescription
method"mean", "stddev", "mode", "median", "count", "sum", "first", "last", "max" or "min"
intervalinterval in ms (will be stored in seconds)

set_datapoints()

replace current datapoints by provided list

NameTypeDefaultDescription
datapointslist

set_extra_data()

deprecated - set additional data to query used as post-processing

NameTypeDefaultDescription
obj

set_id()

specify the id_value neutrally

NameTypeDefaultDescription
id_value

return:

set_param()

set value of parameter based on his name.

NameTypeDefaultDescription
namestr
value

start_time()

convert a relative start time to a datetime based on a now parameter.

NameTypeDefaultDescription
nowNoneoverride now value for relative datetime

return: start datetime

to_json()

transform current object into a dict that could be JSONIFY.

NameTypeDefaultDescription
targetstrNone

return: dumpable dict.