|
19 | 19 | """Pydantic models for agent API.""" |
20 | 20 |
|
21 | 21 | from typing import Literal, Optional |
| 22 | + |
22 | 23 | from pydantic import BaseModel, Field |
23 | 24 |
|
24 | 25 |
|
25 | 26 | class ServiceActionRequest(BaseModel): |
26 | 27 | """Request body for service control actions.""" |
27 | 28 |
|
28 | | - action: Literal["up", "down", "restart"] = Field( |
| 29 | + action: Literal['up', 'down', 'restart'] = Field( |
29 | 30 | ..., |
30 | | - description="Action to perform on the service", |
31 | | - examples=["restart"], |
| 31 | + description='Action to perform on the service', |
| 32 | + examples=['restart'], |
32 | 33 | ) |
33 | 34 | launch_args: dict[str, str] | None = Field( |
34 | 35 | None, |
35 | | - description="Launch arguments for ros2 launch (used for up/restart)", |
| 36 | + description='Launch arguments for ros2 launch (used for up/restart)', |
36 | 37 | ) |
37 | 38 | robot_type: str | None = Field( |
38 | 39 | None, |
39 | | - description="Required for ai_worker_bringup up/restart. One of: sg2, bg2, sh5, bh5.", |
| 40 | + description='Required for ai_worker_bringup up/restart. One of: sg2, bg2, sh5, bh5.', |
40 | 41 | ) |
41 | 42 |
|
42 | 43 |
|
43 | 44 | class ServiceStatus(BaseModel): |
44 | 45 | """Service status response.""" |
45 | 46 |
|
46 | | - name: str = Field(..., description="Service name") |
47 | | - raw: str = Field(..., description="Raw s6-svstat output") |
48 | | - is_up: bool = Field(..., description="Whether service is running") |
49 | | - pid: Optional[int] = Field(None, description="Process ID if running") |
50 | | - uptime_seconds: Optional[int] = Field(None, description="Uptime in seconds if running") |
| 47 | + name: str = Field(..., description='Service name') |
| 48 | + raw: str = Field(..., description='Raw s6-svstat output') |
| 49 | + is_up: bool = Field(..., description='Whether service is running') |
| 50 | + pid: Optional[int] = Field(None, description='Process ID if running') |
| 51 | + uptime_seconds: Optional[int] = Field(None, description='Uptime in seconds if running') |
51 | 52 |
|
52 | 53 |
|
53 | 54 | class ServiceListResponse(BaseModel): |
54 | 55 | """Response for GET /services.""" |
55 | 56 |
|
56 | | - services: list[str] = Field(..., description="List of available service names") |
| 57 | + services: list[str] = Field(..., description='List of available service names') |
57 | 58 |
|
58 | 59 |
|
59 | 60 | class ServiceStatusListResponse(BaseModel): |
60 | 61 | """Response for GET /services/status.""" |
61 | 62 |
|
62 | | - statuses: list[ServiceStatus] = Field(..., description="List of service statuses") |
| 63 | + statuses: list[ServiceStatus] = Field(..., description='List of service statuses') |
63 | 64 |
|
64 | 65 |
|
65 | 66 | class ServiceControlResponse(BaseModel): |
66 | 67 | """Response for POST /services/{name}.""" |
67 | 68 |
|
68 | | - name: str = Field(..., description="Service name") |
69 | | - action: Literal["up", "down", "restart"] = Field(..., description="Action that was performed") |
70 | | - result: str = Field(default="ok", description="Result of the action") |
| 69 | + name: str = Field(..., description='Service name') |
| 70 | + action: Literal['up', 'down', 'restart'] = Field(..., description='Action that was performed') |
| 71 | + result: str = Field(default='ok', description='Result of the action') |
71 | 72 |
|
72 | 73 |
|
73 | 74 | class ErrorResponse(BaseModel): |
74 | 75 | """Error response model.""" |
75 | 76 |
|
76 | | - error: str = Field(..., description="Error message") |
77 | | - detail: Optional[str] = Field(None, description="Additional error details") |
| 77 | + error: str = Field(..., description='Error message') |
| 78 | + detail: Optional[str] = Field(None, description='Additional error details') |
78 | 79 |
|
79 | 80 |
|
80 | 81 | class ServiceRunScriptResponse(BaseModel): |
81 | 82 | """Response for GET /services/{name}/run.""" |
82 | 83 |
|
83 | | - service: str = Field(..., description="Service name") |
84 | | - path: str = Field(..., description="Filesystem path to the service run script") |
85 | | - content: str = Field(..., description="Contents of the run script") |
| 84 | + service: str = Field(..., description='Service name') |
| 85 | + path: str = Field(..., description='Filesystem path to the service run script') |
| 86 | + content: str = Field(..., description='Contents of the run script') |
86 | 87 |
|
87 | 88 |
|
88 | 89 | class ServiceRunScriptUpdateRequest(BaseModel): |
89 | 90 | """Request body for updating a service run script.""" |
90 | 91 |
|
91 | | - content: str = Field(..., description="New contents of the run script") |
92 | | - |
| 92 | + content: str = Field(..., description='New contents of the run script') |
0 commit comments