Skip to content

Commit

Permalink
Merge pull request #34 from rwth-iat/http_api/implement_AAS_reference…
Browse files Browse the repository at this point in the history
…_routes

adapter.http: implement the AAS reference routes
  • Loading branch information
jkhsjdhjs authored Apr 5, 2024
2 parents 10f3301 + 41d32ae commit 384a861
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 @@ -392,10 +392,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 @@ -648,16 +650,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 @@ -667,6 +677,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 384a861

Please sign in to comment.