Convenience functions for HAL _embedded and _links parsing#54
Open
gernot-h wants to merge 2 commits into
Open
Conversation
Closed
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.
One of the main reasons for starting my OO API in #14+ was the constant, repetitive effort for parsing the ["_embedded"] and ["_links"] parts of the JSON answers. Last years have however shown that I don't find the time to finish the OO API, let alone the ongoing effort to maintain it.
With the help of qwen and Claude, I pulled out the ["_links"] and ["_embedded"] handling from my OO branch #14 into a thin extension of the sw360python API.
First of all, there are two new helper functions:
The more intersting part is that it adds a new class
SW360Responsewhich is now always returned instead of the raw JSON objects. It's derived fromdictand thus it should be 100% backward compatible. You can access everything in the JSON answer as before, but you can also use it in a much friendlier way.The current way to get a component to a release
relstill works:But with the new code, you can also just do:
Or to get from a component to a release ID, the old way still works:
But you can now also use the new methods:
@tngraf, let me know what you think!