|
| 1 | +"""FastAPI endpoint functions for the `/labwareOffsets` endpoints.""" |
| 2 | + |
| 3 | + |
| 4 | +import textwrap |
| 5 | +from typing import Annotated, Literal |
| 6 | + |
| 7 | +import fastapi |
| 8 | +from opentrons.protocol_engine import LabwareOffset, LabwareOffsetCreate |
| 9 | + |
| 10 | +from robot_server.service.json_api.request import RequestModel |
| 11 | +from robot_server.service.json_api.response import ( |
| 12 | + PydanticResponse, |
| 13 | + SimpleBody, |
| 14 | + SimpleEmptyBody, |
| 15 | + SimpleMultiBody, |
| 16 | +) |
| 17 | + |
| 18 | + |
| 19 | +router = fastapi.APIRouter(prefix="/labwareOffsets") |
| 20 | + |
| 21 | + |
| 22 | +@PydanticResponse.wrap_route( |
| 23 | + router.post, |
| 24 | + path="", |
| 25 | + summary="Store a labware offset", |
| 26 | + description=textwrap.dedent( |
| 27 | + """\ |
| 28 | + Store a labware offset for later retrieval through `GET /labwareOffsets`. |
| 29 | +
|
| 30 | + On its own, this does not affect robot motion. |
| 31 | + To do that, you must add the offset to a run, through the `/runs` endpoints. |
| 32 | + """ |
| 33 | + ), |
| 34 | +) |
| 35 | +def post_labware_offset( # noqa: D103 |
| 36 | + new_offset: Annotated[RequestModel[LabwareOffsetCreate], fastapi.Body()] |
| 37 | +) -> PydanticResponse[SimpleEmptyBody]: |
| 38 | + raise NotImplementedError() |
| 39 | + |
| 40 | + |
| 41 | +@PydanticResponse.wrap_route( |
| 42 | + router.get, |
| 43 | + path="", |
| 44 | + summary="Search for labware offsets", |
| 45 | + description=( |
| 46 | + "Get a filtered list of all the labware offsets currently stored on the robot." |
| 47 | + " Filters are ANDed together." |
| 48 | + " Results are returned in order from oldest to newest." |
| 49 | + ), |
| 50 | +) |
| 51 | +def get_labware_offsets( # noqa: D103 |
| 52 | + id: Annotated[ |
| 53 | + str | None, |
| 54 | + fastapi.Query(description="Filter for exact matches on the `id` field."), |
| 55 | + ] = None, |
| 56 | + definition_uri: Annotated[ |
| 57 | + str | None, |
| 58 | + fastapi.Query( |
| 59 | + alias="definitionUri", |
| 60 | + description=( |
| 61 | + "Filter for exact matches on the `definitionUri` field." |
| 62 | + " (Not to be confused with `location.definitionUri`.)" |
| 63 | + ), |
| 64 | + ), |
| 65 | + ] = None, |
| 66 | + location_slot_name: Annotated[ |
| 67 | + str | None, |
| 68 | + fastapi.Query( |
| 69 | + alias="location.slotName", |
| 70 | + description="Filter for exact matches on the `location.slotName` field.", |
| 71 | + ), |
| 72 | + ] = None, |
| 73 | + location_module_model: Annotated[ |
| 74 | + str | None, |
| 75 | + fastapi.Query( |
| 76 | + alias="location.moduleModel", |
| 77 | + description="Filter for exact matches on the `location.moduleModel` field.", |
| 78 | + ), |
| 79 | + ] = None, |
| 80 | + location_definition_uri: Annotated[ |
| 81 | + str | None, |
| 82 | + fastapi.Query( |
| 83 | + alias="location.definitionUri", |
| 84 | + description=( |
| 85 | + "Filter for exact matches on the `location.definitionUri` field." |
| 86 | + " (Not to be confused with just `definitionUri`.)" |
| 87 | + ), |
| 88 | + ), |
| 89 | + ] = None, |
| 90 | + cursor: Annotated[ |
| 91 | + int | None, |
| 92 | + fastapi.Query( |
| 93 | + description=( |
| 94 | + "The first index to return out of the overall filtered result list." |
| 95 | + " If unspecified, defaults to returning `pageLength` elements from" |
| 96 | + " the end of the list." |
| 97 | + ) |
| 98 | + ), |
| 99 | + ] = None, |
| 100 | + page_length: Annotated[ |
| 101 | + int | Literal["unlimited"], |
| 102 | + fastapi.Query( |
| 103 | + alias="pageLength", description="The maximum number of entries to return." |
| 104 | + ), |
| 105 | + ] = "unlimited", |
| 106 | +) -> PydanticResponse[SimpleMultiBody[LabwareOffset]]: |
| 107 | + raise NotImplementedError() |
| 108 | + |
| 109 | + |
| 110 | +@PydanticResponse.wrap_route( |
| 111 | + router.delete, |
| 112 | + path="/{id}", |
| 113 | + summary="Delete a single labware offset", |
| 114 | + description="Delete a single labware offset. The deleted offset is returned.", |
| 115 | +) |
| 116 | +def delete_labware_offset( # noqa: D103 |
| 117 | + id: Annotated[ |
| 118 | + str, |
| 119 | + fastapi.Path(description="The `id` field of the offset to delete."), |
| 120 | + ], |
| 121 | +) -> PydanticResponse[SimpleBody[LabwareOffset]]: |
| 122 | + raise NotImplementedError() |
| 123 | + |
| 124 | + |
| 125 | +@PydanticResponse.wrap_route( |
| 126 | + router.delete, |
| 127 | + path="", |
| 128 | + summary="Delete all labware offsets", |
| 129 | +) |
| 130 | +def delete_all_labware_offsets() -> PydanticResponse[SimpleEmptyBody]: # noqa: D103 |
| 131 | + raise NotImplementedError() |
0 commit comments