Skip to content

Add a partition operation endpoint - #109

Open
ramonski wants to merge 3 commits into
2.xfrom
feature/partition-operation
Open

Add a partition operation endpoint#109
ramonski wants to merge 3 commits into
2.xfrom
feature/partition-operation

Conversation

@ramonski

Copy link
Copy Markdown
Contributor

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_magic browser 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 partitions wrapper: {"uid": "<primary uid>", "analyses": [...]}. Creating a partition without analyses is allowed (analyses can be added later). The route wraps the core create_partition helper, so the behavior matches the UI.

It is exposed as a dedicated operation route rather than an IUpdate adapter on AnalysisRequest. An IUpdate adapter would route every Sample update through custom code, and AnalysisRequest is 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.rst doctest.

--
I confirm I have coded it according to PEP8 standards.

ramonski added 2 commits July 28, 2026 21:26
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.
@ramonski
ramonski requested a review from xispa July 28, 2026 19:52
@ramonski ramonski added the Feature 🪚 New feature request label Jul 28, 2026
…n doctest

Only creating a partition needs the dedicated endpoint; detach, reattach
and publish are plain workflow transitions handled by the update route.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature 🪚 New feature request

Development

Successfully merging this pull request may close these issues.

1 participant