Skip to content

Update API client for ros2_medkit changes #13

@bburda

Description

@bburda

Summary

The ros2_medkit gateway has been updated with SOVD-compliant API contracts. The web UI's API client and types need to be updated to match these changes.


Proposed solution

Major API Changes

1. Operations API - New Executions Model

Old API:

POST /components/{id}/operations/{op}     → invoke operation
GET  /components/{id}/operations/{op}/status?goal_id=...
DELETE /components/{id}/operations/{op}?goal_id=...

New SOVD-compliant API:

POST   /{entity}/operations/{op}/executions           → create execution
GET    /{entity}/operations/{op}/executions           → list executions
GET    /{entity}/operations/{op}/executions/{exec-id} → get execution status
PUT    /{entity}/operations/{op}/executions/{exec-id} → update execution
DELETE /{entity}/operations/{op}/executions/{exec-id} → cancel execution

2. New Entity Types: Apps and Functions

Apps (ROS 2 nodes):

GET /apps                              → list all apps
GET /apps/{id}                         → app capabilities
GET /apps/{id}/data                    → app topics
GET /apps/{id}/operations              → app operations
GET /apps/{id}/configurations          → app parameters
GET /apps/{id}/faults                  → app faults
GET /apps/{id}/depends-on              → app dependencies

Functions (capability groupings):

GET /functions                         → list all functions
GET /functions/{id}                    → function capabilities
GET /functions/{id}/hosts              → apps hosting this function
GET /functions/{id}/data               → aggregated data
GET /functions/{id}/operations         → aggregated operations

3. New Faults API

GET    /faults                                        → all system faults
GET    /faults/stream                                 → SSE real-time faults
GET    /{entity}/faults                               → entity faults
GET    /{entity}/faults/{code}                        → specific fault
DELETE /{entity}/faults/{code}                        → clear fault
GET    /{entity}/faults/{code}/snapshots              → fault snapshots

4. Enhanced Discovery

GET /                     → server capabilities (entry points)
GET /version-info         → SOVD version information
GET /areas/{id}           → area capabilities
GET /areas/{id}/subareas  → nested areas
GET /areas/{id}/contains  → contained entities
GET /components/{id}/subcomponents
GET /components/{id}/hosts
GET /components/{id}/depends-on

5. Authentication (Optional)

POST /auth/authorize      → get tokens (client_credentials)
POST /auth/token          → refresh access token
POST /auth/revoke         → revoke refresh token

Type Updates Required

// New types to add
interface Execution {
  id: string;
  status: 'pending' | 'running' | 'succeeded' | 'failed' | 'canceled';
  created_at: string;
  started_at?: string;
  finished_at?: string;
  result?: unknown;
  error?: string;
}

interface App extends SovdEntity {
  node_name: string;
  namespace: string;
  fqn: string;
}

interface Function extends SovdEntity {
  hosts: string[];  // app IDs
}

interface Fault {
  code: string;
  severity: 'info' | 'warning' | 'error' | 'critical';
  message: string;
  timestamp: string;
  entity_id: string;
  entity_type: string;
}

interface ServerCapabilities {
  sovd_version: string;
  supported_features: string[];
  entry_points: Record<string, string>;
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions