Asset Connector Documentation
Loading...
Searching...
No Matches
set_config_payload.py
Go to the documentation of this file.
1
import
json
2
from
typing
import
Any
3
4
from
basyx.aas.adapter.json
import
AASFromJsonDecoder
5
from
basyx.aas.model
import
Submodel
6
from
pydantic
import
BaseModel, Field, PrivateAttr
7
8
9
class
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
set_config_payload.SetConfigPayload
Defines the model class of the payload for the add_or_update_config (URL /add-config) endpoint of thi...
Definition
set_config_payload.py:30
set_config_payload.SetConfigPayload.aid_dict
dict aid_dict
Definition
set_config_payload.py:32
set_config_payload.SetConfigPayload.__init__
__init__(self, **Any data)
Definition
set_config_payload.py:36
set_config_payload.SetConfigPayload._aid_sm
_aid_sm
Definition
set_config_payload.py:39
set_config_payload.SetConfigPayload._aid_sm
Submodel _aid_sm
Definition
set_config_payload.py:34
python_connector
models
set_config_payload.py
Generated by
1.9.8