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

Add new QL endpoints of /v2/attr and /v2/attr/{attr_name} #16

Merged
merged 440 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
440 commits
Select commit Hold shift + click to select a range
d4f096a
chore: add docs for semantics installation
djs0109 Dec 26, 2023
59a2133
fix: updated regex to pattern
tstorek Dec 28, 2023
d2c2e90
Merge pull request #217 from RWTH-EBC/216-Release-v0-3-0
djs0109 Dec 28, 2023
c61a712
chore: removed exclude_defaults
tstorek Dec 29, 2023
4707d31
chore: duplicated pattern fix
tstorek Dec 29, 2023
5dae2ce
chore: corrected some typos
tstorek Dec 29, 2023
d9efbd5
chore: removed exclude_unset wherever it seemed safe
tstorek Dec 29, 2023
acaa9ec
Merge branch 'master' into update-readme-references
djs0109 Jan 2, 2024
c05d5bd
Merge pull request #224 from RWTH-EBC/223-FiwareHeaderSecure-incompat…
djs0109 Jan 2, 2024
7336e2b
Merge branch 'master' into fix_wrong_error_msg
djs0109 Jan 2, 2024
b5ef5d7
Merge branch 'master' into update-readme-references
djs0109 Jan 2, 2024
8b2e6e2
Update author link
djs0109 Jan 2, 2024
8d9fe36
Merge branch 'master' into 137_subscription_update
djs0109 Jan 2, 2024
c62691f
fix: tiny bugs after merge
djs0109 Jan 2, 2024
dbe2509
fix: empty expression issue
djs0109 Jan 2, 2024
2ce8ed6
Merge pull request #210 from RWTH-EBC/update-readme-references
djs0109 Jan 4, 2024
4b74ad9
chore: update changelog
djs0109 Jan 4, 2024
8943b12
Merge pull request #214 from RWTH-EBC/fix_wrong_error_msg
djs0109 Jan 4, 2024
26f0468
Update pandas version
FelixStege Jan 9, 2024
e62bb34
chore: Update pandas version depending on python version
FelixStege Jan 9, 2024
8b21edf
chore: Update CHANGELOG
djs0109 Jan 15, 2024
a263c55
Merge pull request #231 from RWTH-EBC/230-Increase-pandas-version
FelixStege Jan 15, 2024
62717d5
feat: add override entity
djs0109 Jan 17, 2024
02e75c5
chore: implement tests for post,update,patch,override entity
djs0109 Jan 17, 2024
d606818
chore: update docs
djs0109 Jan 17, 2024
0a447f7
chore: remove exclude_unset for consistency
djs0109 Jan 22, 2024
dfd6fcd
Merge branch 'master' into 228-Requests-remove-defaults
djs0109 Jan 22, 2024
84e2cfa
fix: test is not clean
djs0109 Jan 30, 2024
897467c
feat: add timesSent for better testing
djs0109 Jan 31, 2024
20ec709
feat: add test for Notification
djs0109 Jan 31, 2024
12789a0
chore: test subscription without specifying attrs
djs0109 Jan 31, 2024
6155f43
Finishing test_notification function and modified the check if subscr…
RCX112 Feb 5, 2024
7e7456d
chore: add a comment
djs0109 Feb 5, 2024
e74c382
chore: reformat
djs0109 Feb 5, 2024
c89bba2
chore: update CHANGELOG.md
djs0109 Feb 5, 2024
56dbd45
Merge branch 'master' into 137_subscription_update
djs0109 Feb 5, 2024
5a97e4f
Merge pull request #138 from RWTH-EBC/137_subscription_update
FWuellhorst Feb 5, 2024
05acabc
feat: add mqtt internal url in tests
djs0109 Feb 6, 2024
a559c26
chore: update CHANGELOG.md
djs0109 Feb 6, 2024
065f4c5
chore: remove 37 and add 311 and 312 to test
djs0109 Feb 6, 2024
417d44c
Merge branch 'master' into 211-Python-version-upgrade-to-3-10-3-11-3-12
djs0109 Feb 6, 2024
7dacccf
chore: refactor test_entity_update
djs0109 Feb 13, 2024
0f97542
chore: add additional assertion to check the behavior of append_strict
djs0109 Feb 13, 2024
a9a38ac
fix: change value back after testing update.update_entity
djs0109 Feb 13, 2024
c3635f6
chore: consistent naming convention
djs0109 Feb 14, 2024
3acda05
Merge pull request #239 from RWTH-EBC/238-Adding-a-second-Test-config…
djs0109 Feb 14, 2024
5506aab
chore: remove the todos mark
djs0109 Feb 14, 2024
c38c161
feat: add entity update with keyValues
djs0109 Feb 16, 2024
b6c1d76
docs: update Changelog
djs0109 Feb 20, 2024
46b645c
chore: add tests for data type
djs0109 Feb 20, 2024
31cc39e
docs: update changelog
djs0109 Feb 20, 2024
2ba624f
docs: add committing style guide and fix typos (#244)
Feb 20, 2024
74bf0e5
chore: test get_entity when using the 'attrs' variable
djs0109 Feb 20, 2024
2902081
Merge branch 'master' into 228-Requests-remove-defaults
djs0109 Feb 20, 2024
4ba3441
Merge pull request #233 from RWTH-EBC/232--post_entity-will-not-compl…
djs0109 Feb 20, 2024
3a47f75
Merge branch 'master' into 228-Requests-remove-defaults
djs0109 Feb 21, 2024
4b58a6b
Merge pull request #229 from RWTH-EBC/228-Requests-remove-defaults
djs0109 Feb 21, 2024
a7b9fd0
chore: update dependency
djs0109 Feb 21, 2024
e874769
refactor: remove unnecessary todos
sbanoeon Feb 21, 2024
1f0e7aa
Merge branch 'master' into 243-support-keyValues-when-update-entities
sbanoeon Feb 21, 2024
41e7349
Merge pull request #245 from RWTH-EBC/243-support-keyValues-when-upda…
sbanoeon Feb 21, 2024
4851bf2
fix: Session added as optional parameter to enable tls communication …
mwr-ebc Feb 21, 2024
0d4f3a6
Update CHANGELOG.md
mwr-ebc Feb 21, 2024
f7efab5
fix: include headers in request
sbanoeon Feb 28, 2024
d0ed358
fix: remove root slash from paths
sbanoeon Feb 28, 2024
de8445a
docs: update CHANGELOG.md
sbanoeon Feb 28, 2024
13e87df
docs: update CHANGELOG.md
sbanoeon Feb 28, 2024
8b07137
docs: update CHANGELOG.md
sbanoeon Feb 28, 2024
1380b37
docs: update CHANGELOG.md
sbanoeon Feb 28, 2024
5b41ad7
Merge remote-tracking branch 'upstream/master' into 244-Update-contri…
Mar 1, 2024
1f03a38
chore: make exercise 2 solution more readable
Mar 2, 2024
8a58574
fix: change deprecated methods
Mar 3, 2024
d4dd719
Merge pull request #252 from RWTH-EBC/250-Missing-headers-in-the-request
djs0109 Mar 4, 2024
ffd4966
chore: remove remaining root slash
djs0109 Mar 4, 2024
66de989
Creating new tutorial about multientity and expression language
RCX112 Mar 4, 2024
48223ca
Completed first version of tutorial about multientity and expression …
RCX112 Mar 5, 2024
7dd685e
Better naming for SubWeatherStations
RCX112 Mar 5, 2024
65c23f9
chore: change the python requirements in setup
djs0109 Mar 5, 2024
14b1bb0
chore: update igraph version in requirements
djs0109 Mar 5, 2024
424da3f
chore: enabled inheritance for ContextEntities
tstorek Mar 5, 2024
260943d
chore: added check for attributes
tstorek Mar 5, 2024
30674f6
fix: change deprecated methods and fix typos
Mar 5, 2024
98cdfcc
fix: fix typo
Mar 5, 2024
68765e0
Merge pull request #240 from RWTH-EBC/211-Python-version-upgrade-to-3…
djs0109 Mar 6, 2024
1fc3c23
chore: added test attribute assignment
tstorek Mar 6, 2024
ef6b9c4
chore: added validator for attribute assignment
tstorek Mar 6, 2024
6ff93b1
chore: added customizable ContextAttributes
tstorek Mar 6, 2024
e7d6328
Merge branch 'master' into 225-Make-ContextEntity-more-Customizable
tstorek Mar 6, 2024
821cf56
chore: added clean up to tests
tstorek Mar 6, 2024
17214fd
chore: relax requirements to pydantic version
djs0109 Mar 6, 2024
635efd6
Merge branch 'master' into 254-The-pydatnic-version-settings-is-to-st…
djs0109 Mar 6, 2024
e4c8d0c
chore: fixed test_base.py
tstorek Mar 6, 2024
989894d
chore: fix broken-tests
tstorek Mar 7, 2024
3316713
chore: fix broken-tests and put correct types
tstorek Mar 7, 2024
f78f1cb
chore: added example for inheritance
tstorek Mar 7, 2024
ce4d2e4
Adding more description into tutorial e8
RCX112 Mar 7, 2024
5cb1408
chore: added example for inheritance and more implementation comments
tstorek Mar 7, 2024
463ab68
attempt: fix deprecated methods
Mar 7, 2024
e5b7acd
feat: reduce time.sleep() and change x-axis plot result in exercise 1
Mar 7, 2024
1d3f591
Completed solution of exercise 8
RCX112 Mar 11, 2024
75ffae9
Created exercise out of solution
RCX112 Mar 11, 2024
863ecc5
Added README to exercise 8
RCX112 Mar 11, 2024
681ffad
chore: fixed wrong type in tests
tstorek Mar 12, 2024
6a02bd1
feat: added geojson validation
tstorek Mar 12, 2024
231c0f7
chore: added missing clean up
tstorek Mar 12, 2024
d3bf32b
chore: minor adjustment
djs0109 Mar 15, 2024
c230956
chore: reformat file
tstorek Mar 18, 2024
d39778f
chore: adjusted CHANGELOG.md
tstorek Mar 18, 2024
05718f5
Merge branch '225-Make-ContextEntity-more-Customizable' into 226-Add-…
tstorek Mar 18, 2024
34ffafd
chore: adjusted CHANGELOG.md
tstorek Mar 18, 2024
4d16b24
fix: cbHost send "None" when no specifying
djs0109 Mar 19, 2024
50205bc
fix: replace "simtime" with "sim_time"
djs0109 Mar 19, 2024
c2fa9cf
chore: migrate to pydantic V2
djs0109 Mar 19, 2024
b61e121
chore: minor change in error message
djs0109 Mar 19, 2024
842e572
Merge remote-tracking branch 'origin/225-Make-ContextEntity-more-Cust…
djs0109 Mar 19, 2024
c528db0
Merge pull request #256 from RWTH-EBC/225-Make-ContextEntity-more-Cus…
djs0109 Mar 19, 2024
8f4a9a5
Merge pull request #258 from RWTH-EBC/226-Add-geojson-validation
djs0109 Mar 19, 2024
8a49915
Merge branch 'master' into 251-Inconsistency-with-paths
djs0109 Mar 19, 2024
f1c334f
Merge pull request #253 from RWTH-EBC/251-Inconsistency-with-paths
djs0109 Mar 19, 2024
4d888fa
feat: add forcedUpdate and missing overrideMetadata (#236)
djs0109 Mar 19, 2024
cfba646
chore: minor change due to naming convention
djs0109 Mar 19, 2024
96d84a5
chore: change the convention for service_path and apikey
djs0109 Mar 19, 2024
a0a85b2
chore: reformat e8 for consistency
djs0109 Mar 19, 2024
6e3a560
Changed QL subscription to CB subscription, included idPattern as que…
Mar 22, 2024
e2a6010
Proper deprecation exception for Quantumleap subscription.
Mar 26, 2024
2cd1c8a
fix: relationship will be removed when override entity
djs0109 Mar 26, 2024
a1fb109
chore: rename function to update keyvalues
djs0109 Mar 26, 2024
29c33f0
fix: change sleep time for more stability
djs0109 Mar 26, 2024
9d3280e
feat: add keyvalues support for post entity
djs0109 Mar 26, 2024
59b9c51
feat: add example for reusing simple data models
djs0109 Mar 26, 2024
74cf079
chore: change default service_path to "/"
djs0109 Mar 26, 2024
0525af1
chore: remove the test for create subscription via QLC
djs0109 Mar 26, 2024
9700087
chore: restore the test for "notify" endpoint
djs0109 Mar 26, 2024
052ae36
chore: remove unreachable codes
djs0109 Mar 26, 2024
529a89a
fix: fix parsing and deprecated methods in exercise 6 solution
Mar 27, 2024
eb3702e
Added test function for idPattern
Mar 27, 2024
78e9ad1
fix: fix parsing in exercise 7 solution
Mar 27, 2024
b910989
chore: make opening files consistent with as in other exercises
Mar 27, 2024
f8eac32
Apply suggestions from code review
WaltherTrgovac Mar 27, 2024
6e61821
Adjusted regex patterns for idPattern test function.
Mar 28, 2024
eb961be
Creating SubWeatherStation entities in OCB
RCX112 Apr 2, 2024
32dd24a
chore: add readability to ql test
djs0109 Apr 2, 2024
a5ef21c
doc: add docs for id_pattern
djs0109 Apr 2, 2024
fed0dc3
chore: adjustment test id pattern for QL
djs0109 Apr 2, 2024
f21b8c0
fix: Session deleted as optional parameter. clients added instead to …
mwr-ebc Apr 3, 2024
e9194a9
Merge remote-tracking branch 'origin/248-support-tls-connection-possi…
mwr-ebc Apr 3, 2024
602c060
Adding 'timestamp' attribute, which uses the JEXL function 'toisodate'.
RCX112 Apr 4, 2024
e4bfc59
chore: format e1_virtual_weatherstation exercise and solution
Apr 4, 2024
70112a6
chore: format e2_healthcheck exercise and solution
Apr 4, 2024
93e1665
chore: format e3_context_entities exercise and solution
Apr 4, 2024
b9acf77
chore: format e4_iot_thermal_zone_sensors exercise and solution
Apr 4, 2024
0d4d85c
Added test to reproduce cleanup function order error.
Apr 5, 2024
8da64a8
docs: adjust release version in changelog
djs0109 Apr 5, 2024
4adc011
chore: update package version in code
djs0109 Apr 5, 2024
31acf8e
feat: add pypi release to pipline
djs0109 Apr 5, 2024
6acfb62
Corrected pull from wrong branch
Apr 5, 2024
9fa47d8
Merge pull request #266 from RWTH-EBC/261-Release-v0-4-0
djs0109 Apr 9, 2024
ae4c818
[PYPI-RELEASE] v0.4.0
djs0109 Apr 9, 2024
cc9a2c2
[PYPI-RELEASE] Merge pull request #269 from RWTH-EBC/261-Release-v0-4-0
djs0109 Apr 9, 2024
00ea4e0
chore: format e5_iot_thermal_zone_control exercise and solution
Apr 9, 2024
8416c70
chore: format e6_timeseries_data exercise and solution
Apr 10, 2024
17901f6
chore: format e7_semantic_iot exercise and solution
Apr 10, 2024
5fe9468
format: fix typo in exercise 1
Apr 10, 2024
0a610a5
fix: fix plotting in exercise 5
Apr 10, 2024
e029962
fix: syntax error
djs0109 Apr 11, 2024
3e89d81
Renoving spaces around transform operator |
RCX112 Apr 11, 2024
cf1659c
chore: replace the deprecated qlc post_subscription with the one in cbc
djs0109 Apr 12, 2024
92f2580
Adding validation for JEXL expression language of Device attributes a…
RCX112 Apr 15, 2024
6c8a33f
Changing parameter names of jexl validation method
RCX112 Apr 15, 2024
339a8f8
Merge branch 'master' into 255-ngsi_v2-tutorials-are-deprecated
Apr 16, 2024
c6afcef
Merge branch 'master' into 254-The-pydatnic-version-settings-is-to-st…
djs0109 Apr 16, 2024
ebd3caa
chore: relax requirements to pydantic version
djs0109 Apr 16, 2024
3bd8e2f
fix: fix opening files for <python 3.10
Apr 16, 2024
838b28f
Merge branch '165-Validation-on-measurement-transformation-language' …
RCX112 Apr 16, 2024
17186e6
chore: make created files disjunct between exercises and solutions
Apr 16, 2024
01b6a90
chore: fix small typos and pep-8 errors in exercise 5 and 6
Apr 16, 2024
777b717
chore: make url as not required
djs0109 Apr 16, 2024
fd92497
Merge branch 'master' into 248-support-tls-connection-possibility-in-…
djs0109 Apr 16, 2024
b994891
chore: tiny adjustment
djs0109 Apr 16, 2024
2c0c456
reverted changes to tutorials e5/e6
Apr 17, 2024
98cfced
Added update_entity methods for all attributes and relationships
Apr 17, 2024
3f4c881
Merge branch 'master' into 215-Mark-Quantumleap-subscription-as-depre…
djs0109 Apr 17, 2024
bbd073e
feat: implement QL v1.0.0 API
djs0109 Apr 17, 2024
0097b17
chore: increase sleep time for test commands callback
djs0109 Apr 17, 2024
eac5243
Added test for update_entity_properties and update_entity_relationships
Apr 17, 2024
c388e2f
Merge pull request #249 from RWTH-EBC/248-support-tls-connection-poss…
mwr-ebc Apr 17, 2024
0d60af0
Fixing warning message in method _subscription_dicts_are_equal of cb.…
RCX112 Apr 22, 2024
3f9c6bc
Modified validation messages for expression language and added tests …
RCX112 Apr 22, 2024
ccfdd51
chore: tiny improvement
djs0109 Apr 23, 2024
eeea1f0
docs: reference e12 in readme
djs0109 Apr 23, 2024
31ad393
fix: add geojson_pydantic in setup.py
djs0109 Apr 23, 2024
668548d
Merge branch 'master' into 262-Support-entity-creation-with-keyvalues
djs0109 Apr 23, 2024
005b7ba
docs: update changelog
djs0109 Apr 23, 2024
7034f1a
chore: add clean up at the start
djs0109 Apr 23, 2024
77b96aa
docs: add link in changelog
djs0109 Apr 23, 2024
3b286ef
Merge branch 'master' into 244-Update-contributing-details
Apr 23, 2024
84c5cf9
fix: change the wording in the unit test section
Apr 23, 2024
8e27c6e
chore: reform assertRaises
djs0109 Apr 23, 2024
0cfc7d4
Added more tests for (JEXL) expression language and fixed attribute t…
RCX112 Apr 23, 2024
e25c864
Merge branch 'master' into 164-Adding-multientity-to-tutorials
djs0109 Apr 23, 2024
c54c9ef
docs: CHANGELOG
djs0109 Apr 23, 2024
882de62
Merge remote-tracking branch 'origin/164-Adding-multientity-to-tutori…
djs0109 Apr 23, 2024
f854572
Optimized tests for jexl and legacy expression language
RCX112 Apr 23, 2024
68d5d6f
Merge branch '164-Adding-multientity-to-tutorials' of https://github.…
RCX112 Apr 23, 2024
e55dfe0
Added pyjexl package to setup.py
RCX112 Apr 23, 2024
49278e5
Merge pull request #246 from WaltherTrgovac/244-Update-contributing-d…
WaltherTrgovac Apr 23, 2024
d457f3d
Changing cb.py back to old state
RCX112 Apr 23, 2024
bad7f87
Merge pull request #264 from RWTH-EBC/262-Support-entity-creation-wit…
djs0109 Apr 24, 2024
58037ee
Merge branch 'master' into 274-Adding-geojson_pydantic-to-setup-py
djs0109 Apr 24, 2024
ecf11c8
chore: name of geojson-pydantic
djs0109 Apr 24, 2024
6f47368
chore: update release version
djs0109 Apr 24, 2024
4f331ef
Merge remote-tracking branch 'origin/274-Adding-geojson_pydantic-to-s…
djs0109 Apr 24, 2024
d2e228d
merge: solve merge conflicts
Apr 24, 2024
5e46ea4
[PYPI-RELEASE] release v0.4.1
djs0109 Apr 24, 2024
9a2c3b4
chore: add hints to transformation functions
djs0109 Apr 24, 2024
a6e1e91
chore: tiny adjustment of the tutorials
djs0109 Apr 24, 2024
b173b53
docs: minor change of readme
djs0109 Apr 24, 2024
23f8dad
Merge branch 'master' into 164-Adding-multientity-to-tutorials
djs0109 Apr 24, 2024
fbc7187
Added registrations argument to clear context broker, refined test
Apr 25, 2024
3dff267
Merge pull request #260 from RWTH-EBC/164-Adding-multientity-to-tutor…
RCX112 Apr 26, 2024
bc26f9e
fix: change the order of the clearing functions
djs0109 Apr 30, 2024
481fe94
Merge remote-tracking branch 'origin/265-order-in-cleanup-function' i…
djs0109 Apr 30, 2024
4e4b00e
fix: remove the test of deleting registration before device
djs0109 Apr 30, 2024
95bfee5
chore: revise format
djs0109 Apr 30, 2024
7c1fbdf
Merge branch 'master' into 265-order-in-cleanup-function
djs0109 Apr 30, 2024
c3261ed
docs: update CHANGELOG.md
djs0109 Apr 30, 2024
bbcbd4e
chore: format
djs0109 Apr 30, 2024
8317608
fix: revert changes to exercise 6
Apr 30, 2024
8560bd0
chore: format
djs0109 Apr 30, 2024
d2614e0
chore: revise test
djs0109 Apr 30, 2024
ddac69d
Merge branch 'master' into 145-update-relationships-with-contextbroke…
djs0109 Apr 30, 2024
6f20580
docs: update readme
djs0109 Apr 30, 2024
1737977
add: flag to determine the deletion of registration when clearing the CB
djs0109 Apr 30, 2024
00e7d5d
Merge branch 'master' into 145-update-relationships-with-contextbroke…
djs0109 Apr 30, 2024
8a9a747
chore: remove some examples in e6
djs0109 Apr 30, 2024
3f816e9
Merge branch 'master' into 255-ngsi_v2-tutorials-are-deprecated
djs0109 Apr 30, 2024
2162d59
Merge pull request #271 from RWTH-EBC/145-update-relationships-with-c…
djs0109 Apr 30, 2024
fb18d6b
Merge branch 'master' into 255-ngsi_v2-tutorials-are-deprecated
djs0109 Apr 30, 2024
80eaa74
docs: changelog
djs0109 Apr 30, 2024
44a7059
Merge pull request #259 from RWTH-EBC/255-ngsi_v2-tutorials-are-depre…
djs0109 Apr 30, 2024
41d63ba
Add new QL endpoints of /v2/attr and /v2/attr/{attr_name}
Aug 27, 2021
ea33441
changed result of attr endpoint methods and added test
May 8, 2024
265a365
resolved merge conflicts
May 8, 2024
1dc4ed9
fix: infinite query caused by pagination
djs0109 May 22, 2024
d083cbc
chore: formatting
djs0109 May 22, 2024
f7bc70a
fix: merging conflict
djs0109 May 24, 2024
7e2b998
chore: change format
djs0109 May 24, 2024
cb67a91
docs: update changelog
djs0109 May 24, 2024
e2db8dc
chore: remove unused models
djs0109 May 25, 2024
e50f00f
chore: remove the data points creation in test
djs0109 Jun 18, 2024
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
107 changes: 106 additions & 1 deletion filip/clients/ngsi_v2/quantumleap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
AggrScope, \
AttributeValues, \
TimeSeries, \
TimeSeriesHeader
TimeSeriesHeader, \
TimeSeriesAttrHeader, \
TimeSeriesEntities, \
EntityValues


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -907,3 +910,105 @@ def get_entity_attr_values_by_type(self,
AttributeValues(attrName=attr_name,
values=item.get('values'))])
for item in res.get('values')]

# v2/attrs
def get_entity_by_attrs(self, *,
entity_type: str = None,
from_date: str = None,
to_date: str = None,
limit: int = None,
offset: int = None
) -> List[TimeSeriesAttrHeader]:
"""
Get list of timeseries data grouped by each existing attribute name.
The timeseries data include all entities corresponding to each
attribute name as well as the index and values of this attribute in
this entity.

Args:
entity_type (str): Comma-separated list of entity types whose data
are to be included in the response. Use only one (no comma)
when required. If used to resolve ambiguity for the given
entityId, make sure the given entityId exists for this
entityType.
from_date (str): The starting date and time (inclusive) from which
the context information is queried. Must be in ISO8601 format
(e.g., 2018-01-05T15:44:34)
to_date (str): The final date and time (inclusive) from which the
context information is queried. Must be in ISO8601 format
(e.g., 2018-01-05T15:44:34).
limit (int): Maximum number of results to be retrieved.
Default value : 10000
offset (int): Offset for the results.

Returns:
List of TimeSeriesEntities
"""
url = urljoin(self.base_url, 'v2/attrs')
res = self.__query_builder(url=url,
entity_type=entity_type,
from_date=from_date,
to_date=to_date,
limit=limit,
offset=offset)
return [TimeSeriesAttrHeader(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if you can use itertools instead of nested forloops

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually everything should somehow a TimeSeries Object in the very end

attrName=attr_item.get('attrName'),
types=[TimeSeriesEntities(
entityType=entities_item.get('entityType'),
entities=[EntityValues(
entityId=entity.get('entityId'),
index=entity.get('index'),
values=entity.get('values'))
for entity in entities_item.get('entities')])
for entities_item in attr_item.get('types')])
for attr_item in res.get('attrs')]

# v2/attrs/{attr_name}
def get_entity_by_attr_name(self, *,
attr_name: str,
entity_type: str = None,
from_date: str = None,
to_date: str = None,
limit: int = None,
offset: int = None
) -> List[TimeSeriesEntities]:
"""
Get list of all entities containing this attribute name, as well as
getting the index and values of this attribute in every corresponding
entity.

Args:
attr_name (str): The attribute name in interest.
entity_type (str): Comma-separated list of entity types whose data
are to be included in the response. Use only one (no comma)
when required. If used to resolve ambiguity for the given
entityId, make sure the given entityId exists for this
entityType.
from_date (str): The starting date and time (inclusive) from which
the context information is queried. Must be in ISO8601 format
(e.g., 2018-01-05T15:44:34)
to_date (str): The final date and time (inclusive) from which the
context information is queried. Must be in ISO8601 format
(e.g., 2018-01-05T15:44:34).
limit (int): Maximum number of results to be retrieved.
Default value : 10000
offset (int): Offset for the results.

Returns:
List of TimeSeriesEntities
"""
url = urljoin(self.base_url, f'/v2/attrs/{attr_name}')
res = self.__query_builder(url=url,
entity_type=entity_type,
from_date=from_date,
to_date=to_date,
limit=limit,
offset=offset)
return [TimeSeriesEntities(
entityType=entities_item.get('entityType'),
entities=[EntityValues(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a possibility to use itertools.product here instead of nested for-loops?

entityId=entity.get('entityId'),
index=entity.get('index'),
values=entity.get('values'))
for entity in entities_item.get('entities')])
for entities_item in res.get('types')]
40 changes: 40 additions & 0 deletions filip/models/ngsi_v2/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,46 @@ class Config:
allow_population_by_field_name = True


class TimeSeriesAttrHeader(BaseModel):
"""
Model for timeseries data grouped by attribute names
"""
attrName: str = Field(
title="Attribute name",
description=""
)
types: List[Any] = Field(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the docs there is model used for the types. .. Please reconsider how you use the models. The field type containes a list of entities and the a entityType

{
"application/json": {
"attrs:": [
{
"attrName": "temperature",
"types": [
{
"entities": [
{
"entityId": "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",
"index": [
"2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"
],
"values": [
22.1,
23.3,
25.7
]
}
],
"entityType": "Room"
},
{
"entities": [
{
"entityId": "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",
"index": [
"2018-01-05T15:44:34",
"2018-01-06T15:44:59",
"2018-01-07T15:44:59"
],
"values": [
22.1,
23.3,
25.7
]
}
],
"entityType": "Device"
}
]
}
]
}
}

default=None,
description="Array of entities grouped by each entityType."
)

class TimeSeriesEntities(BaseModel):
"""
Model for entities grouped by entityType
"""
entityType: str = Field(default=None,
alias="entityType",
description="The type of an entity")
entities: List[Any] = Field(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the entities a list of something? I think here the same applies

default=None,
description="Array of entities."
)


class EntityValues(TimeSeriesBase, IndexedValues):
"""
Model of indexed attribute values with entityId
"""
entityId: str = Field(default=None,
alias="entityId",
description="The entity id the time series api."
"If the id is unique among all entity "
"types, this could be used to uniquely "
"identify the entity instance. Otherwise,"
" you will have to use the entityType "
"attribute to resolve ambiguity.")


class AggrMethod(str, Enum):
"""
Aggregation Methods
Expand Down