Class OperationHandlers

Class Documentation

class OperationHandlers

Handlers for operation-related REST API endpoints (services and actions).

Handlers:

  • GET /{entity}/operations - List all operations (7.14.3)

  • GET /{entity}/operations/{op-id} - Get operation details (7.14.4)

  • GET /{entity}/operations/{op-id}/executions - List executions (7.14.5)

  • POST /{entity}/operations/{op-id}/executions - Start execution (7.14.6)

  • GET /{entity}/operations/{op-id}/executions/{exec-id} - Get execution status (7.14.7)

  • PUT /{entity}/operations/{op-id}/executions/{exec-id} - Update execution (7.14.9)

  • DELETE /{entity}/operations/{op-id}/executions/{exec-id} - Terminate execution (7.14.8)

PR-403 commit 27: all 7 routes migrate to the typed RouteRegistry API. The synchronous-vs-asynchronous execution dispatch on POST executions uses post_alternates<ExecutionCreateRequest, OperationExecutionResult, ExecutionCreateAsync> plus a ResponseAttachments channel so the framework picks 200 for services / 202 for actions and applies a Location header on the 202 branch. The list_executions endpoint now returns the typed Collection<ExecutionId> (missed migration from earlier PR). The inline service-error path in the legacy handler is replaced with the framework error path (typed ErrorInfo return).

Public Functions

inline explicit OperationHandlers(HandlerContext &ctx)

Construct operation handlers with shared context.

http::Result<dto::Collection<dto::OperationItem>> list_operations(const http::TypedRequest &req)

GET /{entity}/operations - list operations for an entity. Mixes runtime discovery (services + actions) with the per-entity plugin OperationProvider.

http::Result<dto::OperationDetail> get_operation(const http::TypedRequest &req)

GET /{entity}/operations/{op_id} - get operation details.

http::Result<std::pair<std::variant<dto::OperationExecutionResult, dto::ExecutionCreateAsync>, http::ResponseAttachments>> create_execution(const http::TypedRequest &req, dto::ExecutionCreateRequest body)

POST /{entity}/operations/{op_id}/executions - start an execution.

Returns a std::variant<OperationExecutionResult, ExecutionCreateAsync>:

  • OperationExecutionResult -> 200 OK (synchronous service / plugin op)

  • ExecutionCreateAsync -> 202 Accepted + Location header (asynchronous ROS 2 action) The ResponseAttachments companion lets the async branch append the Location header without re-introducing a httplib::Response &.

http::Result<dto::Collection<dto::ExecutionId>> list_executions(const http::TypedRequest &req)

GET /{entity}/operations/{op_id}/executions - list current executions.

http::Result<dto::OperationExecution> get_execution(const http::TypedRequest &req)

GET /{entity}/operations/{op_id}/executions/{exec_id} - execution status.

http::Result<http::NoContent> cancel_execution(const http::TypedRequest &req)

DELETE /{entity}/operations/{op_id}/executions/{exec_id} - cancel.

http::Result<std::pair<dto::OperationExecution, http::ResponseAttachments>> update_execution(const http::TypedRequest &req, const dto::ExecutionUpdateRequest &body)

PUT /{entity}/operations/{op_id}/executions/{exec_id} - update execution.

Returns OperationExecution + attachments so the supported stop capability can emit 202 + Location (the SOVD async-update convention) while the success body stays 200 for any future synchronous capability that might land.