Skip to content

Commit

Permalink
adapter.http: implement the AAS reference routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frosty2500 committed Apr 5, 2024
1 parent 6638498 commit b591b32
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions basyx/aas/adapter/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,12 @@ def __init__(self, object_store: model.AbstractObjectStore):
Submount("/shells", [
Rule("/", methods=["GET"], endpoint=self.get_aas_all),
Rule("/", methods=["POST"], endpoint=self.post_aas),
Rule("/$reference/", methods=["GET"], endpoint=self.get_aas_all_reference),
Submount("/<base64url:aas_id>", [
Rule("/", methods=["GET"], endpoint=self.get_aas),
Rule("/", methods=["PUT"], endpoint=self.put_aas),
Rule("/", methods=["DELETE"], endpoint=self.delete_aas),
Rule("/$reference/", methods=["GET"], endpoint=self.get_aas_reference),
Submount("/asset-information", [
Rule("/", methods=["GET"], endpoint=self.get_aas_asset_information),
Rule("/", methods=["PUT"], endpoint=self.put_aas_asset_information),
Expand Down Expand Up @@ -639,16 +641,24 @@ def post_aas(self, request: Request, url_args: Dict, map_adapter: MapAdapter) ->
}, force_external=True)
return response_t(aas, status=201, headers={"Location": created_resource_url})

def delete_aas(self, request: Request, url_args: Dict, **_kwargs) -> Response:
def get_aas_all_reference(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
self.object_store.remove(self._get_shell(url_args))
return response_t()
aashells = self._get_shells(request)
references: list[model.ModelReference] = [model.ModelReference.from_referable(aas)
for aas in aashells]
return response_t(references)

# --------- AAS ROUTES ---------
def get_aas(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
aas = self._get_shell(url_args)
return response_t(aas, stripped=is_stripped_request(request))
return response_t(aas)

def get_aas_reference(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
aas = self._get_shell(url_args)
reference = model.ModelReference.from_referable(aas)
return response_t(reference)

def put_aas(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
Expand All @@ -658,6 +668,11 @@ def put_aas(self, request: Request, url_args: Dict, **_kwargs) -> Response:
aas.commit()
return response_t()

def delete_aas(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
self.object_store.remove(self._get_shell(url_args))
return response_t()

def get_aas_asset_information(self, request: Request, url_args: Dict, **_kwargs) -> Response:
response_t = get_response_type(request)
aas = self._get_shell(url_args)
Expand Down

0 comments on commit b591b32

Please sign in to comment.