Closed DanDayne closed 4 years ago
Generally IDs might be strings, so the issue you mentioned could cause some problems. However, we could force all IDs to be strings my adding a prefix (e.g. cmd
for command and dvc
for device), but I'm not sure if it is necessary.
I think lists/dicts are always preferred to strings.
rename field 'target' to 'arguments'
Final structure and value types.
{
"success" : <bool>,
"cause" : <not given OR str (exception detail etc.)>,
"data" : {
'command_id': <str>,
'device_id': <str>,
'is_valid': <bool>,
'response': <dict>, # e.g. {'pwm_pulse': 1, 'pwm_min': 0, 'pwm_max': 100, 'pwm_on': True},
'source': <str>, # e.g. 'D1-measureall',
'arguments': <list>,
'time_executed': <datetime>, # e.g. '2020-05-15 00:51:26',
'time_issued': <datetime>,
}
}
Since the success
and cause
fields only make sense when DeviceControl runs as a server, they will be omitted in the client approach. The aforementioned structure remains the same for server application, but as a client, the data structure sent should be as follows:
{
'command_id': <str>,
'device_id': <str>,
'is_valid': <bool>,
'response': <dict>, # e.g. {'pwm_pulse': 1, 'pwm_min': 0, 'pwm_max': 100, 'pwm_on': True},
'source': <str>, # e.g. 'D1-measureall',
'arguments': <list>,
'time_executed': <datetime>, # e.g. '2020-05-15 00:51:26',
'time_issued': <datetime>
}
I do not see any reason to include any other information. Any additional thoughts, @xtrojak ?
References issue #22
The proposed structure of data returned by the get data endpoint:
Please, note the dict/list/string/int questions. @xtrojak, what is the expected (preferred) approach? Currently, each field tries to eval itself => dicts, lists and integers are returned instead of strings where possible. The downside of this is that if one of the other fields (command_id, device_id) MIGHT be pythonically evaluated into integers from strings, which might not be expected behaviour.