From 48d52afe38465701b0d8bc60e44c50adcdf41364 Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh <26975142+ZohebShaikh@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:09:57 +0100 Subject: [PATCH 1/2] Add tag for deprecated endpoints --- src/blueapi/config.py | 2 ++ src/blueapi/service/main.py | 30 ++++++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/blueapi/config.py b/src/blueapi/config.py index 83d6d7021..b9e7d6f45 100644 --- a/src/blueapi/config.py +++ b/src/blueapi/config.py @@ -294,6 +294,7 @@ class Tag(StrEnum): DEVICE = "Device" ENV = "Environment" META = "Meta" + DEPRECATED = "Deprecated" class ApplicationConfig(BlueapiBaseModel): @@ -324,6 +325,7 @@ class ApplicationConfig(BlueapiBaseModel): {"name": Tag.DEVICE, "description": "Endpoints to get devices"}, {"name": Tag.ENV, "description": "Endpoints related to server environment"}, {"name": Tag.META, "description": "Endpoints used for auxiliary functions"}, + {"name": Tag.DEPRECATED, "description": "Deprecated endpoints"}, ] stomp: StompConfig = Field(default_factory=StompConfig) diff --git a/src/blueapi/service/main.py b/src/blueapi/service/main.py index ed09f9c56..d3e4de177 100644 --- a/src/blueapi/service/main.py +++ b/src/blueapi/service/main.py @@ -100,7 +100,7 @@ async def inner(app: FastAPI): open_router = APIRouter() -secure_router = APIRouter(deprecated=True) +secure_router = APIRouter(deprecated=True, tags=[Tag.DEPRECATED]) secure_router_v1 = APIRouter(prefix="/api/v1") @@ -191,7 +191,7 @@ def root_redirect() -> RedirectResponse: @secure_router_v1.get("/environment", tags=[Tag.ENV]) -@secure_router.get("/environment", tags=[Tag.ENV]) +@secure_router.get("/environment") @start_as_current_span(TRACER, "runner") def get_environment( runner: Annotated[WorkerDispatcher, Depends(_runner)], @@ -201,7 +201,7 @@ def get_environment( @secure_router_v1.delete("/environment", tags=[Tag.ENV]) -@secure_router.delete("/environment", tags=[Tag.ENV]) +@secure_router.delete("/environment") async def delete_environment( background_tasks: BackgroundTasks, runner: Annotated[WorkerDispatcher, Depends(_runner)], @@ -232,7 +232,7 @@ def get_oidc_config( @secure_router_v1.get("/plans", tags=[Tag.PLAN]) -@secure_router.get("/plans", tags=[Tag.PLAN]) +@secure_router.get("/plans") @start_as_current_span(TRACER) def get_plans(runner: Annotated[WorkerDispatcher, Depends(_runner)]) -> PlanResponse: """Retrieve information about all available plans.""" @@ -241,7 +241,7 @@ def get_plans(runner: Annotated[WorkerDispatcher, Depends(_runner)]) -> PlanResp @secure_router_v1.get("/plans/{name}", tags=[Tag.PLAN]) -@secure_router.get("/plans/{name}", tags=[Tag.PLAN]) +@secure_router.get("/plans/{name}") @start_as_current_span(TRACER, "name") def get_plan_by_name( name: str, runner: Annotated[WorkerDispatcher, Depends(_runner)] @@ -251,7 +251,7 @@ def get_plan_by_name( @secure_router_v1.get("/devices", tags=[Tag.DEVICE]) -@secure_router.get("/devices", tags=[Tag.DEVICE]) +@secure_router.get("/devices") @start_as_current_span(TRACER) def get_devices( runner: Annotated[WorkerDispatcher, Depends(_runner)], @@ -262,7 +262,7 @@ def get_devices( @secure_router_v1.get("/devices/{name}", tags=[Tag.DEVICE]) -@secure_router.get("/devices/{name}", tags=[Tag.DEVICE]) +@secure_router.get("/devices/{name}") @start_as_current_span(TRACER, "name") def get_device_by_name( name: str, runner: Annotated[WorkerDispatcher, Depends(_runner)] @@ -279,7 +279,7 @@ def get_device_by_name( @secure_router_v1.post("/tasks", status_code=status.HTTP_201_CREATED, tags=[Tag.TASK]) -@secure_router.post("/tasks", status_code=status.HTTP_201_CREATED, tags=[Tag.TASK]) +@secure_router.post("/tasks", status_code=status.HTTP_201_CREATED) @start_as_current_span( TRACER, "request", @@ -330,9 +330,7 @@ def submit_task( @secure_router_v1.delete( "/tasks/{task_id}", status_code=status.HTTP_200_OK, tags=[Tag.TASK] ) -@secure_router.delete( - "/tasks/{task_id}", status_code=status.HTTP_200_OK, tags=[Tag.TASK] -) +@secure_router.delete("/tasks/{task_id}", status_code=status.HTTP_200_OK) @start_as_current_span(TRACER, "task_id") def delete_submitted_task( task_id: str, @@ -350,7 +348,7 @@ def validate_task_status(v: str) -> TaskStatusEnum: @secure_router_v1.get("/tasks", status_code=status.HTTP_200_OK, tags=[Tag.TASK]) -@secure_router.get("/tasks", status_code=status.HTTP_200_OK, tags=[Tag.TASK]) +@secure_router.get("/tasks", status_code=status.HTTP_200_OK) @start_as_current_span(TRACER) def get_tasks( runner: Annotated[WorkerDispatcher, Depends(_runner)], @@ -384,7 +382,6 @@ def get_tasks( @secure_router.put( "/worker/task", responses={status.HTTP_409_CONFLICT: {}}, - tags=[Tag.TASK], ) @start_as_current_span(TRACER, "task.task_id") def set_active_task( @@ -416,7 +413,7 @@ def get_passthrough_headers(request: Request) -> dict[str, str]: @secure_router_v1.get("/tasks/{task_id}", tags=[Tag.TASK]) -@secure_router.get("/tasks/{task_id}", tags=[Tag.TASK]) +@secure_router.get("/tasks/{task_id}") @start_as_current_span(TRACER, "task_id") def get_task( task_id: str, @@ -435,7 +432,6 @@ def get_task( ) @secure_router.get( "/worker/task", - tags=[Tag.TASK], ) @start_as_current_span(TRACER) def get_active_task( @@ -452,7 +448,6 @@ def get_active_task( ) @secure_router.get( "/worker/state", - tags=[Tag.TASK], ) @start_as_current_span(TRACER) def get_state(runner: Annotated[WorkerDispatcher, Depends(_runner)]) -> WorkerState: @@ -491,7 +486,6 @@ def get_state(runner: Annotated[WorkerDispatcher, Depends(_runner)]) -> WorkerSt status.HTTP_400_BAD_REQUEST: {}, status.HTTP_202_ACCEPTED: {}, }, - tags=[Tag.TASK], ) @start_as_current_span(TRACER, "state_change_request.new_state") def set_state( @@ -543,7 +537,7 @@ def set_state( @secure_router_v1.get("/python_environment", tags=[Tag.ENV]) -@secure_router.get("/python_environment", tags=[Tag.ENV]) +@secure_router.get("/python_environment") @start_as_current_span(TRACER) def get_python_environment( runner: Annotated[WorkerDispatcher, Depends(_runner)], From 83bbd3bd70f09480c9930e3fba1265e5a0d39f53 Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh <26975142+ZohebShaikh@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:19:37 +0100 Subject: [PATCH 2/2] increment api number --- docs/reference/openapi.yaml | 32 ++++++++++++++++---------------- src/blueapi/config.py | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/reference/openapi.yaml b/docs/reference/openapi.yaml index d14664f57..0ce525d78 100644 --- a/docs/reference/openapi.yaml +++ b/docs/reference/openapi.yaml @@ -433,7 +433,7 @@ info: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html title: BlueAPI Control - version: 1.3.0 + version: 1.3.1 openapi: 3.1.0 paths: /api/v1/devices: @@ -826,7 +826,7 @@ paths: description: Successful Response summary: Get Devices tags: - - Device + - Deprecated /devices/{name}: get: deprecated: true @@ -854,7 +854,7 @@ paths: description: Validation Error summary: Get Device By Name tags: - - Device + - Deprecated /environment: delete: deprecated: true @@ -870,7 +870,7 @@ paths: description: Successful Response summary: Delete Environment tags: - - Environment + - Deprecated get: deprecated: true description: Get the current state of the environment, i.e. initialization state. @@ -884,7 +884,7 @@ paths: description: Successful Response summary: Get Environment tags: - - Environment + - Deprecated /healthz: get: description: If able to serve this, server is live and ready for requests. @@ -913,7 +913,7 @@ paths: description: Successful Response summary: Get Plans tags: - - Plan + - Deprecated /plans/{name}: get: deprecated: true @@ -941,7 +941,7 @@ paths: description: Validation Error summary: Get Plan By Name tags: - - Plan + - Deprecated /python_environment: get: deprecated: true @@ -983,7 +983,7 @@ paths: description: Validation Error summary: Get Python Environment tags: - - Environment + - Deprecated /tasks: get: deprecated: true @@ -1013,7 +1013,7 @@ paths: description: Validation Error summary: Get Tasks tags: - - Task + - Deprecated post: deprecated: true description: Submit a task to the worker. @@ -1045,7 +1045,7 @@ paths: description: Validation Error summary: Submit Task tags: - - Task + - Deprecated /tasks/{task_id}: delete: deprecated: true @@ -1072,7 +1072,7 @@ paths: description: Validation Error summary: Delete Submitted Task tags: - - Task + - Deprecated get: deprecated: true description: Retrieve a task @@ -1099,7 +1099,7 @@ paths: description: Validation Error summary: Get Task tags: - - Task + - Deprecated /worker/state: get: deprecated: true @@ -1114,7 +1114,7 @@ paths: description: Successful Response summary: Get State tags: - - Task + - Deprecated put: deprecated: true description: "Request that the worker is put into a particular state.\nReturns\ @@ -1155,7 +1155,7 @@ paths: description: Validation Error summary: Set State tags: - - Task + - Deprecated /worker/task: get: deprecated: true @@ -1169,7 +1169,7 @@ paths: description: Successful Response summary: Get Active Task tags: - - Task + - Deprecated put: deprecated: true description: 'Set a task to active status, the worker should begin it as soon @@ -1200,4 +1200,4 @@ paths: description: Validation Error summary: Set Active Task tags: - - Task + - Deprecated diff --git a/src/blueapi/config.py b/src/blueapi/config.py index b9e7d6f45..b03e5a0e1 100644 --- a/src/blueapi/config.py +++ b/src/blueapi/config.py @@ -304,7 +304,7 @@ class ApplicationConfig(BlueapiBaseModel): """ #: API version to publish in OpenAPI schema - REST_API_VERSION: ClassVar[str] = "1.3.0" + REST_API_VERSION: ClassVar[str] = "1.3.1" LICENSE_INFO: ClassVar[dict[str, str]] = { "name": "Apache 2.0",