Skip to content

Commit 6b55752

Browse files
Ornella33s-heppner
andauthored
Add deprecated discovery route (#524)
Add deprecated discovery route Previously, we decided not to implement any routes that are deprecated in the specification. However, as it turns out, for compatibility with the [basyx-aas-web-ui], the `/lookup/shells` route is required. This implements the missing route. Fixes #522 [basyx-aas-web-ui]: https://github.com/eclipse-basyx/basyx-aas-web-ui/ --------- Co-authored-by: s-heppner <iat@s-heppner.com>
1 parent 98e1770 commit 6b55752

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

sdk/test/model/test_string_constraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 the Eclipse BaSyx Authors
1+
# Copyright (c) 2026 the Eclipse BaSyx Authors
22
#
33
# This program and the accompanying materials are made available under the terms of the MIT License, available in
44
# the LICENSE file of this project.

server/app/interfaces/discovery.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from app import model as server_model
1616
from app.adapter import jsonization
1717
from app.interfaces.base import BaseWSGIApp, HTTPApiDecoder
18-
from app.util.converters import IdentifierToBase64URLConverter
18+
from app.util.converters import IdentifierToBase64URLConverter, base64url_decode
1919

2020

2121
class DiscoveryStore:
@@ -98,6 +98,10 @@ def __init__(self, persistent_store: DiscoveryStore, base_path: str = "/api/v3.1
9898
Submount(
9999
"/lookup/shells",
100100
[
101+
# Todo: This route is deprecated in the specification, but needed for interoperability
102+
# with the BaSyx UI https://github.com/eclipse-basyx/basyx-aas-web-ui.
103+
# Once this route is no longer needed, we should consider removing it.
104+
Rule("/", methods=["GET"], endpoint=self.get_all_aas_ids_by_asset_link),
101105
Rule(
102106
"/<base64url:aas_id>",
103107
methods=["GET"],
@@ -118,6 +122,37 @@ def __init__(self, persistent_store: DiscoveryStore, base_path: str = "/api/v3.1
118122
strict_slashes=False,
119123
)
120124

125+
def get_all_aas_ids_by_asset_link(
126+
self, request: Request, url_args: dict, response_t: type, **_kwargs
127+
) -> Response:
128+
asset_ids_param = request.args.get("assetIds", "")
129+
if not asset_ids_param:
130+
raise werkzeug.exceptions.BadRequest("Missing query parameter 'assetIds'")
131+
132+
try:
133+
decoded_str = base64url_decode(asset_ids_param)
134+
payload = json.loads(decoded_str)
135+
except (ValueError, json.JSONDecodeError) as exc:
136+
raise werkzeug.exceptions.BadRequest(f"Invalid query parameter 'assetIds': {exc}") from exc
137+
138+
if isinstance(payload, dict):
139+
payload = [payload]
140+
141+
if not isinstance(payload, list):
142+
raise werkzeug.exceptions.BadRequest("Decoded assetIds payload must be a JSON object or list")
143+
144+
matching_aas_keys = set()
145+
for item in payload:
146+
if not isinstance(item, dict):
147+
raise werkzeug.exceptions.BadRequest("Each asset link must be a JSON object")
148+
149+
asset_link = server_model.AssetLink(item["name"], item["value"])
150+
aas_keys = self.persistent_store.search_aas_ids_by_asset_link(asset_link)
151+
matching_aas_keys.update(aas_keys)
152+
153+
paginated_slice, cursor = self._get_slice(request, list(matching_aas_keys))
154+
return response_t(list(paginated_slice), cursor=cursor)
155+
121156
def search_all_aas_ids_by_asset_link(
122157
self, request: Request, url_args: dict, response_t: type, **_kwargs
123158
) -> Response:

0 commit comments

Comments
 (0)