Persistence item info REST endpoint enhancements#5336
Open
mherwege wants to merge 10 commits intoopenhab:mainfrom
Open
Persistence item info REST endpoint enhancements#5336mherwege wants to merge 10 commits intoopenhab:mainfrom
mherwege wants to merge 10 commits intoopenhab:mainfrom
Conversation
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Member
Why not throw an |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Contributor
Author
That's indeed a better approach. Implemented, but still needs further testing. |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Contributor
Author
|
This has now been tested for mapdb, rrd4j and inmemory in combination with openhab/openhab-addons#20200 Behaviour is as expected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
persistence/items?serviceId=idendpoint is not very usable as it is in its current form.The content that should go into the response comes from the
Set<PersistedItemInfo> getItemInfo()in theQueryablePersistenceServiceinterface. Persistence addons implement this interface.The method is meant to return a Set of items that have been persisted in the backend with potentially some extra information (count, time of first record, time of last record). Not all persistence services are able to provide this, and even if they are, it might be too expensive a query. Therefore the interface documentation allows the persistence add-on to return an empty set in this case. This is problematic as that makes it impossible for the consumer of the result to know the difference between nothing persisted or not supported.
The contract is now to throw a
UnsupportedOperationExceptionwhen not supported. The default implementation will just do this, aleviating the persistence add-ons to implement anything.To make this call more useful, I have also added
persistence/items?serviceId=id&itemname=itemName. This will get the same information, but only for one item. I see a use for this in the UI, to be able to show in the UI if an item is persisted (see openhab/openhab-webui#3765). This adds an overload to thegetItemInfomethod with the Item name and alias. The default implementation just queries for the last persisted value and returns that, doesn't attempt returning count and first value to avoid creating an expensive query. The persistence add-ons could implement more efficient queries that return all parameters if realistic.These changes are breaking and the add-on build may fail because the
getItemInfomethod can now return null if it checks for this in the build. I am preparing a PR to adapt the persistence add-ons to this change.I also took the opportunity to synchronize the REST error response status between the different methods. I don't expect this will be an issue, but it is of course also a breaking change of the consumers of the REST API are specific about these.