trading_agent.gateway.routes.app_routes
¶
Routes for the packages' web apps.
GET /api/apps every app with its address, whether it answers and its unit's state POST /api/apps/{package}/{action} start, stop or restart an app's systemd unit
Only units named by an installed package's app.toml can be started or stopped here.
Typical usage example:
application.include_router(AppRoutes(guard, catalog).router())
AppRoutes
¶
Bases: RouteGroup
The app routes.
Creates the routes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guard
|
AccessGuard
|
Checks the access token. |
required |
catalog
|
AppCatalog
|
The packages' apps. |
required |
Source code in src/trading_agent/gateway/routes/app_routes.py
list_apps
async
¶
Every app and its state, checked all at once.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The apps. |
Source code in src/trading_agent/gateway/routes/app_routes.py
act
async
¶
Starts, stops or restarts an app's unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
The package. |
required |
action
|
str
|
"start", "stop" or "restart". |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The app and its state afterwards. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
No such app (status 404), the app has no unit or the action is unknown (status 400), or systemctl failed (status 502). |