Add a partition operation endpoint - #109
Open
ramonski wants to merge 3 commits into
Open
Conversation
Adds POST /senaite/v1/partition to create one or more partitions (aliquots) of a received sample, moving the selected analyses into each partition. It wraps the core create_partition helper, so it accepts the same optional sample_type, container, preservation and internal_use per partition, and allows partitions without analyses. This is exposed as a dedicated operation route rather than an IUpdate adapter on AnalysisRequest, to avoid routing every Sample update through custom code.
…n doctest Only creating a partition needs the dedicated endpoint; detach, reattach and publish are plain workflow transitions handled by the update route.
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.
Description of the issue/feature this PR addresses
Partitioning a sample (creating aliquots that carry a subset of the analyses) is only reachable through the
partition_magicbrowser view, which is POST driven and cannot be invoked from the JSON API. This adds a dedicated operation route.POST /senaite/v1/partition{"uid": "<primary sample uid>", "partitions": [ {"analyses": ["<analysis uid>", ...], "sample_type": "<uid>", // optional, defaults to the primary "container": "<uid>", // optional "preservation": "<uid>", // optional "internal_use": false}, // optional ... ]}A single partition can also be given inline without the
partitionswrapper:{"uid": "<primary uid>", "analyses": [...]}. Creating a partition without analyses is allowed (analyses can be added later). The route wraps the corecreate_partitionhelper, so the behavior matches the UI.It is exposed as a dedicated operation route rather than an
IUpdateadapter onAnalysisRequest. AnIUpdateadapter would route every Sample update through custom code, andAnalysisRequestis the most frequently updated type in the system, so a dedicated endpoint keeps the blast radius small and the operation explicit.Current behavior before PR
No way to create partitions through the API.
Desired behavior after PR is merged
The route above creates one or more partitions and returns them, covered by a new
partition.rstdoctest.--
I confirm I have coded it according to PEP8 standards.