Asset Connector Documentation
Loading...
Searching...
No Matches
set_config_payload.py
Go to the documentation of this file.
1import json
2from typing import Any
3
4from basyx.aas.adapter.json import AASFromJsonDecoder
5from basyx.aas.model import Submodel
6from pydantic import BaseModel, Field, PrivateAttr
7
8
9class SetConfigPayload(BaseModel): # noqa: D101
10 """Defines the model class of the payload for the `add_or_update_config` (URL `/add-config`) endpoint
11 of this application using Pydantic.
12
13 The JSON payload must contain exactly the following fields:
14 - `Aid`
15
16 Inside the `Aid`-field, a properly serialized AID submodel according to the AAS JSON serialization must be provided.
17 Will be parsed as `basyx.aas.model.Submodel`.
18
19 Example:
20 ```
21 {
22 "Aid": {
23 "idShort": "AssetInterfacesDescription",
24 "id": "https://example.com/ids/sm/1234_5678_90",
25 "kind": "Instance",
26 // ...
27 }
28 }
29 ```
30 """
31
32 aid_dict: dict = Field(..., alias="Aid", exclude=True)
33
34 _aid_sm: Submodel = PrivateAttr(default=None)
35
36 def __init__(self, **data: Any): # noqa: D107
37 super().__init__(**data)
38 aid_string = json.dumps(self.aid_dict)
39 self._aid_sm_aid_sm = json.loads(aid_string, cls=AASFromJsonDecoder)
40 # self._aid_sm = AASFromJsonDecoder.object_hook(self.aid_dict) NOT WORKING FOR LOOPING ELEMENTS
Defines the model class of the payload for the add_or_update_config (URL /add-config) endpoint of thi...