|
5 | 5 | VehicleBase, |
6 | 6 | VersionOut, |
7 | 7 | BoardOut, |
| 8 | + StandardArtifactOut, |
8 | 9 | FeatureOut, |
9 | 10 | ) |
10 | 11 | from web.services.vehicles import get_vehicles_service, VehiclesService |
| 12 | +from metadata_manager.ap_src_meta_fetcher import FirmwareServerUnavailableError |
11 | 13 |
|
12 | 14 | router = APIRouter(prefix="/vehicles", tags=["vehicles"]) |
13 | 15 |
|
@@ -183,6 +185,55 @@ async def get_board( |
183 | 185 | return board |
184 | 186 |
|
185 | 187 |
|
| 188 | +@router.get( |
| 189 | + "/{vehicle_id}/versions/{version_id}/boards/{board_id}/standard_artifacts", |
| 190 | + response_model=List[StandardArtifactOut], |
| 191 | + responses={ |
| 192 | + 404: {"description": "Standard artifacts not found"}, |
| 193 | + 502: {"description": "Firmware server unavailable"}, |
| 194 | + } |
| 195 | +) |
| 196 | +async def list_board_standard_artifacts( |
| 197 | + vehicle_id: str = Path(..., description="Vehicle identifier"), |
| 198 | + version_id: str = Path(..., description="Version identifier"), |
| 199 | + board_id: str = Path(..., description="Board identifier"), |
| 200 | + service: VehiclesService = Depends(get_vehicles_service) |
| 201 | +): |
| 202 | + """ |
| 203 | + Get standard build artifact files from firmware.ardupilot.org for a board. |
| 204 | +
|
| 205 | + Args: |
| 206 | + vehicle_id: The vehicle identifier |
| 207 | + version_id: The version identifier |
| 208 | + board_id: The board identifier |
| 209 | +
|
| 210 | + Returns: |
| 211 | + List of artifact files with download URLs |
| 212 | + """ |
| 213 | + try: |
| 214 | + artifacts = service.get_board_standard_artifacts( |
| 215 | + vehicle_id, version_id, board_id |
| 216 | + ) |
| 217 | + except FirmwareServerUnavailableError: |
| 218 | + raise HTTPException( |
| 219 | + status_code=502, |
| 220 | + detail=( |
| 221 | + "Failed to fetch standard artifacts from firmware server" |
| 222 | + ) |
| 223 | + ) |
| 224 | + |
| 225 | + if artifacts is None: |
| 226 | + raise HTTPException( |
| 227 | + status_code=404, |
| 228 | + detail=( |
| 229 | + f"Standard artifacts not found for board '{board_id}' " |
| 230 | + f"in vehicle '{vehicle_id}' version '{version_id}'" |
| 231 | + ) |
| 232 | + ) |
| 233 | + |
| 234 | + return artifacts |
| 235 | + |
| 236 | + |
186 | 237 | # --- Feature Endpoints --- |
187 | 238 | @router.get( |
188 | 239 | "/{vehicle_id}/versions/{version_id}/boards/{board_id}/features", |
|
0 commit comments