#18: Allow embed=[] in get_bitstreams and embed format in response #20
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.
@alanorth This is one way of fixing #18 -- I am interested to hear if you think it's the right approach.
We can request linked HAL stuff to be embedded in the parent object using
?embed=...
in the REST API call. So this change allows a client to saybitstreams = d.get_bitstreams(bundle=my_bundle, embeds=['format'])
, and then in the resulting Bitstream objects you can get format out likeformat = BitstreamFormat(bitstream.embedded['format'])
without any additional API calls.The only thing I wasn't sure about is if we should handle that in the client lib instead of making the actual client do it... this way keeps things relatively simple in the library, we don't have to know anything in the bitstream model because it'll just copy all _embedded JSON into a dict. If we wanted to make that model more 'smart' we'd tell it what kind of embeds to expect, and we could parse and instantiate the BitstreamFormat objects before handing back in the get_bitstreams() return value.
Here is my example script to test it out: