Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change of the response format: added id and type in place of entityId and entityType #754

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@
### Bug fixes

- Fix to return OK/200 and an empty result set when no data found (#720)
- Fix to return id and type in place of entityId and entityType (#751)

### Important: Backward compatibility

This release breaks API backward compatibility. Existing `1.0.0` clients may
**not** be able to work with this new Quantum Leap version without code
changes.

In detail: version `1.0.1` changes fields of query results. Up to
version 1.0.0, Quantum Leap used the following JSON format for query results:

{
entityId: ...,
entityType: ...,
index: ...,
values: ...
}

Version 1.0.1 changed `entityId` and `entityType` to `id` and `type`
respectively for the query result as in e.g.

{
id: ...,
type: ...,
index: ...,
values: ...
}

### Continuous Integration

Expand Down
88 changes: 44 additions & 44 deletions specification/quantumleap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ paths:
examples:
application/json:
{
"entityId": "Kitchen1",
"entityType": "Kitchen",
"id": "Kitchen1",
"type": "Kitchen",
"temperature":
{
"type": "Number",
Expand Down Expand Up @@ -657,14 +657,14 @@ paths:
examples:
application/json:
[{
"entityId": "Kitchen1",
"id": "Kitchen1",
"index": "2018-01-07T15:44:59",
"entityType": "Kitchen"
"type": "Kitchen"
},
{
"entityId": "Kitchen2",
"id": "Kitchen2",
"index": "2018-01-07T15:44:59",
"entityType": "Kitchen"
"type": "Kitchen"
}]
404:
description: "Not Found"
Expand Down Expand Up @@ -730,8 +730,8 @@ paths:
examples:
application/json:
{
"entityId": "Kitchen1",
"entityType": "Kitchen",
"id": "Kitchen1",
"type": "Kitchen",
"attrName": "temperature",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand Down Expand Up @@ -858,8 +858,8 @@ paths:
examples:
application/json:
{
"entityId": "Kitchen1",
"entityType": "Kitchen",
"id": "Kitchen1",
"type": "Kitchen",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"attributes": [
Expand Down Expand Up @@ -1052,17 +1052,17 @@ paths:
# TODO: Maybe for this 'query all' we cloud keep a per-type index.
application/json:
{
"entityType": "Room",
"type": "Room",
"attrName": "temperature",
"entities": [
{
"entityId": "Kitchen1",
"id": "Kitchen1",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [21.01, 20.9, 21.02]
Expand Down Expand Up @@ -1118,13 +1118,13 @@ paths:
{
"values": [
{
"entityId": "Kitchen1",
"id": "Kitchen1",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [21.01, 20.9, 21.02]
Expand Down Expand Up @@ -1189,10 +1189,10 @@ paths:
# TODO: Maybe for this 'query all' we cloud keep a per-type index.
application/json:
{
"entityType": "Room",
"type": "Room",
"entities": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"attributes": [
Expand All @@ -1208,7 +1208,7 @@ paths:
]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"attributes": [
Expand Down Expand Up @@ -1307,7 +1307,7 @@ paths:
{
"values": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"attributes": [
Expand All @@ -1323,7 +1323,7 @@ paths:
]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34", "2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"attributes": [
Expand Down Expand Up @@ -1402,17 +1402,17 @@ paths:
"attrName": "temperature",
"types": [
{
"entityType": "Room",
"type": "Room",
"entities": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand All @@ -1421,17 +1421,17 @@ paths:
]
},
{
"entityType": "Device",
"type": "Device",
"entities": [
{
"entityId": "DeviceInRoom1",
"id": "DeviceInRoom1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "DeviceInRoom2",
"id": "DeviceInRoom2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand Down Expand Up @@ -1502,17 +1502,17 @@ paths:
{
"values": [
{
"entityType": "Room",
"type": "Room",
"entities": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand All @@ -1521,17 +1521,17 @@ paths:
]
},
{
"entityType": "Device",
"type": "Device",
"entities": [
{
"entityId": "DeviceInRoom1",
"id": "DeviceInRoom1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "DeviceInRoom2",
"id": "DeviceInRoom2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand Down Expand Up @@ -1608,17 +1608,17 @@ paths:
"attrName": "temperature",
"types": [
{
"entityType": "Room",
"type": "Room",
"entities": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand All @@ -1627,17 +1627,17 @@ paths:
]
},
{
"entityType": "Device",
"type": "Device",
"entities": [
{
"entityId": "DeviceInRoom1",
"id": "DeviceInRoom1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "DeviceInRoom2",
"id": "DeviceInRoom2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand Down Expand Up @@ -1718,17 +1718,17 @@ paths:
"attrName": "temperature",
"types": [
{
"entityType": "Room",
"type": "Room",
"entities": [
{
"entityId": "Room1",
"id": "Room1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "Room2",
"id": "Room2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand All @@ -1737,17 +1737,17 @@ paths:
]
},
{
"entityType": "Device",
"type": "Device",
"entities": [
{
"entityId": "DeviceInRoom1",
"id": "DeviceInRoom1",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
"values": [24.1, 25.3, 26.7]
},
{
"entityId": "DeviceInRoom2",
"id": "DeviceInRoom2",
"index": ["2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"],
Expand Down
12 changes: 4 additions & 8 deletions src/reporter/query_1T1E1A.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def query_1T1E1A(attr_name, # In Path
except NGSIUsageError as e:
msg = "Bad Request Error: {}".format(e)
logging.getLogger(__name__).error(msg, exc_info=True)
logging.warning(
"usage of id and type rather than entityId and entityType from version 0.9")
return {
"error": "{}".format(type(e)),
"description": str(e)
Expand All @@ -84,8 +82,8 @@ def query_1T1E1A(attr_name, # In Path
index = [] if aggr_method and not aggr_period else entities[0]['index']
matched_attr = lookup_string_match(entities[0], attr_name)
res = {
'entityId': entities[0]['id'],
'entityType': entities[0]['type'],
'id': entities[0]['id'],
'type': entities[0]['type'],
'attrName': attr_name,
'index': index,
'values': matched_attr['values'] if matched_attr else []
Expand All @@ -101,9 +99,7 @@ def query_1T1E1A(attr_name, # In Path
def query_1T1E1A_value(*args, **kwargs):
res = query_1T1E1A(*args, **kwargs)
if isinstance(res, dict):
res.pop('entityId', None)
res.pop('entityType', None)
res.pop('id', None)
res.pop('type', None)
res.pop('attrName', None)
logging.warning(
"usage of id and type rather than entityId and entityType from version 0.9")
return res
12 changes: 4 additions & 8 deletions src/reporter/query_1T1ENA.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,12 @@ def query_1T1ENA(entity_id, # In Path

index = [] if aggr_method and not aggr_period else entities[0]['index']
res = {
'entityId': entity_id,
'entityType': entities[0]['type'],
'id': entity_id,
'type': entities[0]['type'],
'index': index,
'attributes': attributes
}
logging.getLogger(__name__).info("Query processed successfully")
logging.warning(
"usage of id and type rather than entityId and entityType from version 0.9")
return res

r = []
Expand All @@ -117,8 +115,6 @@ def query_1T1ENA(entity_id, # In Path
def query_1T1ENA_value(*args, **kwargs):
res = query_1T1ENA(*args, **kwargs)
if isinstance(res, dict):
res.pop('entityId', None)
res.pop('entityType', None)
logging.warning(
"usage of id and type rather than entityId and entityType from version 0.9")
res.pop('id', None)
res.pop('type', None)
return res
Loading
Loading