Bin finalization and bin-related API #41
Merged
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 bin finalization works by tagging the current set of candidates with bin ID. By tagging the candidates, they automatically disappear from the candidate list since the candidate list only considers items that are not tagged yet. This is a change from the previous version where candidates could be tagged with a unfinalized bin. The finalization is performed by the
ContentItem.finalize_candidates(bin_id)
class method.API endpoints are added to facilitate remote management of bin finalization and retrieval of bin information. Access control for the API is separate from the normal authentication mechanism, and has no relation to the user accounts. HTTP basic authentication is used to simplify scripting. Because of this, the calls are expected to be performed over SSL.
The ACL for the API calls is stored in a JSON file, and the file is read on every request to verify the identity of the caller. This file can be modified using the newly added
apiuser
command.To generate a new user:
The command will print out the API token, which is a randomly generated 32-digit hex number. The command is also used to update the password.
API endpoints can be tested using curl.
To finalize the bin:
To retrieve a list of bins:
To retrieve full information for last bin:
Files can be downloaded using the following command:
NOTE: API endpoints are using JSON. During serialization, big lists of items are created. While this works reasonably well in test scenario on the development machine, using XML and similar formats that can be streamed might prove more efficient in production. Whether we should switch or not is still TBD.