-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
discoveryDiscovery endpoints or strategiesDiscovery endpoints or strategiesenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Milestone
Description
Summary
Add a new discovery endpoint that returns the Area to which a given App belongs. This is determined by finding the App's parent Component and then looking up which Area that Component belongs to.
Proposed solution
GET /api/v1/apps/{app-id}/belongs-to
Returns the Area that contains this App (via its parent Component's area assignment).
Path parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
app-id |
string |
Yes | App identifier (alphanumeric, underscores, hyphens, max 256 chars) |
Request body: None
Response 200 OK:
{
"items": [
{
"id": "powertrain",
"name": "Powertrain",
"href": "/api/v1/areas/powertrain"
}
],
"_links": {
"self": "/api/v1/apps/{app-id}/belongs-to",
"app": "/api/v1/apps/{app-id}"
}
}The items array will contain exactly 0 or 1 area. It may be empty if:
- The App has no parent Component (
component_idis empty) - The parent Component has no assigned Area
Response 400 Bad Request:
Returned when the app-id format is invalid.
{
"error_code": "invalid-parameter",
"message": "Invalid app ID",
"parameters": {
"app_id": "bad id!"
}
}Response 404 Not Found:
Returned when no App with the given ID exists.
{
"error_code": "entity-not-found",
"message": "App not found",
"parameters": {
"app_id": "nonexistent_app"
}
}Additional context
Logic flow
- Validate
app-idformat - Look up the App via
DiscoveryManager::get_app(app_id)→ 404 if not found - Get
app.component_id→ if empty, return emptyitemsarray - Look up the Component via
DiscoveryManager::get_component(component_id) - Get
component.area→ if empty, return emptyitemsarray - Look up the Area via
DiscoveryManager::get_area(area_id)to get its name - Return the Area as an
EntityReference
Existing patterns to follow
- Follow the same handler structure as
handle_app_depends_onandhandle_get_hostsindiscovery_handlers.cpp - Use the standard relationship response envelope
Route registration
Register in rest_server.cpp::setup_routes():
srv->Get((api_path("/apps") + R"(/([^/]+)/belongs-to$)"), handler);Handler method
Add to DiscoveryHandlers:
void handle_app_belongs_to(const httplib::Request& req, httplib::Response& res);Tests
- Unit test: verify correct area returned for app with known component→area chain
- Unit test: verify empty items when app has no component
- Unit test: verify empty items when app's component has no area
- Unit test: 404 for nonexistent app
- Integration test: launch demo nodes, query the endpoint
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
discoveryDiscovery endpoints or strategiesDiscovery endpoints or strategiesenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers