()
| 275 | |
| 276 | |
| 277 | def api_schema(): |
| 278 | return { |
| 279 | "auth": { |
| 280 | "type": "bearer", |
| 281 | "header": "Authorization: Bearer <ADMIN_TOKEN>", |
| 282 | "enabled": bool(ADMIN_TOKEN), |
| 283 | }, |
| 284 | "endpoints": [ |
| 285 | {"method": "GET", "path": "/api/health", "auth": False}, |
| 286 | {"method": "GET", "path": "/api/schema", "auth": False}, |
| 287 | {"method": "GET", "path": "/api/config", "auth": True}, |
| 288 | {"method": "PUT", "path": "/api/config", "auth": True, "body": "full config JSON"}, |
| 289 | {"method": "GET", "path": "/api/servers", "auth": True}, |
| 290 | {"method": "POST", "path": "/api/servers", "auth": True, "body": "server JSON"}, |
| 291 | {"method": "PUT", "path": "/api/servers/{username}", "auth": True, "body": "server JSON"}, |
| 292 | {"method": "DELETE", "path": "/api/servers/{username}", "auth": True}, |
| 293 | *collection_routes(), |
| 294 | {"method": "POST", "path": "/api/reload", "auth": True}, |
| 295 | {"method": "POST", "path": "/api/restart", "auth": True}, |
| 296 | ], |
| 297 | "collections": { |
| 298 | key: { |
| 299 | "item": meta["item"], |
| 300 | "idField": meta["id_field"], |
| 301 | "required": meta["required"], |
| 302 | "optional": meta["optional"], |
| 303 | } |
| 304 | for key, meta in COLLECTIONS.items() |
| 305 | }, |
| 306 | } |
| 307 | |
| 308 | |
| 309 | class Handler(BaseHTTPRequestHandler): |
no test coverage detected