weheat 2025.1.14rc1__py3-none-any.whl → 2025.1.15rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of weheat might be problematic. Click here for more details.
- weheat/__init__.py +7 -2
- weheat/abstractions/discovery.py +6 -6
- weheat/abstractions/heat_pump.py +11 -15
- weheat/abstractions/user.py +7 -7
- weheat/api/__init__.py +1 -0
- weheat/api/energy_log_api.py +306 -132
- weheat/api/heat_pump_api.py +521 -369
- weheat/api/heat_pump_log_api.py +836 -359
- weheat/api/user_api.py +243 -115
- weheat/api_client.py +234 -261
- weheat/api_response.py +10 -18
- weheat/configuration.py +14 -9
- weheat/exceptions.py +59 -25
- weheat/models/__init__.py +6 -0
- weheat/models/boiler_type.py +8 -3
- weheat/models/device_state.py +9 -4
- weheat/models/dhw_type.py +8 -3
- weheat/models/energy_view_dto.py +81 -66
- weheat/models/heat_pump_log_view_dto.py +527 -481
- weheat/models/heat_pump_model.py +8 -3
- weheat/models/heat_pump_status_enum.py +8 -3
- weheat/models/heat_pump_type.py +8 -3
- weheat/models/raw_heat_pump_log_dto.py +353 -315
- weheat/models/read_all_heat_pump_dto.py +64 -48
- weheat/models/read_heat_pump_dto.py +59 -43
- weheat/models/read_user_dto.py +54 -39
- weheat/models/read_user_me_dto.py +124 -0
- weheat/models/role.py +10 -4
- weheat/rest.py +152 -259
- weheat-2025.1.15rc2.dist-info/METADATA +115 -0
- weheat-2025.1.15rc2.dist-info/RECORD +37 -0
- weheat-2025.1.14rc1.dist-info/METADATA +0 -117
- weheat-2025.1.14rc1.dist-info/RECORD +0 -36
- {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/LICENSE +0 -0
- {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/WHEEL +0 -0
- {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/top_level.txt +0 -0
|
@@ -18,106 +18,122 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from datetime import datetime
|
|
21
|
-
from typing import Optional
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
from pydantic import BaseModel, Field, StrictStr, constr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from pydantic import BaseModel, StrictStr
|
|
23
|
+
from pydantic import Field
|
|
24
|
+
from typing_extensions import Annotated
|
|
26
25
|
from weheat.models.boiler_type import BoilerType
|
|
27
26
|
from weheat.models.device_state import DeviceState
|
|
28
27
|
from weheat.models.dhw_type import DhwType
|
|
29
28
|
from weheat.models.heat_pump_model import HeatPumpModel
|
|
30
29
|
from weheat.models.heat_pump_status_enum import HeatPumpStatusEnum
|
|
31
30
|
from weheat.models.heat_pump_type import HeatPumpType
|
|
31
|
+
try:
|
|
32
|
+
from typing import Self
|
|
33
|
+
except ImportError:
|
|
34
|
+
from typing_extensions import Self
|
|
32
35
|
|
|
33
36
|
class ReadAllHeatPumpDto(BaseModel):
|
|
34
37
|
"""
|
|
35
|
-
Heat Pump dto used for the GetAll operation where the firmware version is needed
|
|
36
|
-
"""
|
|
37
|
-
id: StrictStr = Field(
|
|
38
|
-
control_board_id: StrictStr = Field(
|
|
39
|
-
serial_number:
|
|
40
|
-
part_number: Optional[StrictStr] = Field(None,
|
|
41
|
-
state: DeviceState
|
|
42
|
-
name: Optional[StrictStr] = Field(None, description="Internal nickname of this heat pump")
|
|
38
|
+
Heat Pump dto used for the GetAll operation where the firmware version is needed
|
|
39
|
+
""" # noqa: E501
|
|
40
|
+
id: StrictStr = Field(description="Identifier of the heat pump")
|
|
41
|
+
control_board_id: StrictStr = Field(description="Identifier of the control board that is connected to the heat pump", alias="controlBoardId")
|
|
42
|
+
serial_number: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Serial Number of this heat pump", alias="serialNumber")
|
|
43
|
+
part_number: Optional[StrictStr] = Field(default=None, description="Part Number of this heat pump", alias="partNumber")
|
|
44
|
+
state: DeviceState
|
|
45
|
+
name: Optional[StrictStr] = Field(default=None, description="Internal nickname of this heat pump")
|
|
43
46
|
model: Optional[HeatPumpModel] = None
|
|
44
|
-
dhw_type: Optional[DhwType] = Field(None, alias="dhwType")
|
|
45
|
-
boiler_type: Optional[BoilerType] = Field(None, alias="boilerType")
|
|
47
|
+
dhw_type: Optional[DhwType] = Field(default=None, alias="dhwType")
|
|
48
|
+
boiler_type: Optional[BoilerType] = Field(default=None, alias="boilerType")
|
|
46
49
|
status: Optional[HeatPumpStatusEnum] = None
|
|
47
50
|
type: Optional[HeatPumpType] = None
|
|
48
|
-
commissioned_at: Optional[datetime] = Field(None,
|
|
49
|
-
firmware_version: Optional[StrictStr] = Field(None,
|
|
50
|
-
__properties = ["id", "controlBoardId", "serialNumber", "partNumber", "state", "name", "model", "dhwType", "boilerType", "status", "type", "commissionedAt", "firmwareVersion"]
|
|
51
|
+
commissioned_at: Optional[datetime] = Field(default=None, description="Date when the heat pump was last commissioned (decommissioning sets this to null)", alias="commissionedAt")
|
|
52
|
+
firmware_version: Optional[StrictStr] = Field(default=None, description="Firmware version of control board connected to heat pump", alias="firmwareVersion")
|
|
53
|
+
__properties: ClassVar[List[str]] = ["id", "controlBoardId", "serialNumber", "partNumber", "state", "name", "model", "dhwType", "boilerType", "status", "type", "commissionedAt", "firmwareVersion"]
|
|
54
|
+
|
|
55
|
+
model_config = {
|
|
56
|
+
"populate_by_name": True,
|
|
57
|
+
"validate_assignment": True,
|
|
58
|
+
"protected_namespaces": (),
|
|
59
|
+
}
|
|
51
60
|
|
|
52
|
-
class Config:
|
|
53
|
-
"""Pydantic configuration"""
|
|
54
|
-
allow_population_by_field_name = True
|
|
55
|
-
validate_assignment = True
|
|
56
61
|
|
|
57
62
|
def to_str(self) -> str:
|
|
58
63
|
"""Returns the string representation of the model using alias"""
|
|
59
|
-
return pprint.pformat(self.
|
|
64
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
60
65
|
|
|
61
66
|
def to_json(self) -> str:
|
|
62
67
|
"""Returns the JSON representation of the model using alias"""
|
|
68
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
63
69
|
return json.dumps(self.to_dict())
|
|
64
70
|
|
|
65
71
|
@classmethod
|
|
66
|
-
def from_json(cls, json_str: str) ->
|
|
72
|
+
def from_json(cls, json_str: str) -> Self:
|
|
67
73
|
"""Create an instance of ReadAllHeatPumpDto from a JSON string"""
|
|
68
74
|
return cls.from_dict(json.loads(json_str))
|
|
69
75
|
|
|
70
|
-
def to_dict(self):
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
77
|
+
"""Return the dictionary representation of the model using alias.
|
|
78
|
+
|
|
79
|
+
This has the following differences from calling pydantic's
|
|
80
|
+
`self.model_dump(by_alias=True)`:
|
|
81
|
+
|
|
82
|
+
* `None` is only added to the output dict for nullable fields that
|
|
83
|
+
were set at model initialization. Other fields with value `None`
|
|
84
|
+
are ignored.
|
|
85
|
+
"""
|
|
86
|
+
_dict = self.model_dump(
|
|
87
|
+
by_alias=True,
|
|
88
|
+
exclude={
|
|
89
|
+
},
|
|
90
|
+
exclude_none=True,
|
|
91
|
+
)
|
|
76
92
|
# set to None if part_number (nullable) is None
|
|
77
|
-
# and
|
|
78
|
-
if self.part_number is None and "part_number" in self.
|
|
93
|
+
# and model_fields_set contains the field
|
|
94
|
+
if self.part_number is None and "part_number" in self.model_fields_set:
|
|
79
95
|
_dict['partNumber'] = None
|
|
80
96
|
|
|
81
97
|
# set to None if name (nullable) is None
|
|
82
|
-
# and
|
|
83
|
-
if self.name is None and "name" in self.
|
|
98
|
+
# and model_fields_set contains the field
|
|
99
|
+
if self.name is None and "name" in self.model_fields_set:
|
|
84
100
|
_dict['name'] = None
|
|
85
101
|
|
|
86
102
|
# set to None if commissioned_at (nullable) is None
|
|
87
|
-
# and
|
|
88
|
-
if self.commissioned_at is None and "commissioned_at" in self.
|
|
103
|
+
# and model_fields_set contains the field
|
|
104
|
+
if self.commissioned_at is None and "commissioned_at" in self.model_fields_set:
|
|
89
105
|
_dict['commissionedAt'] = None
|
|
90
106
|
|
|
91
107
|
# set to None if firmware_version (nullable) is None
|
|
92
|
-
# and
|
|
93
|
-
if self.firmware_version is None and "firmware_version" in self.
|
|
108
|
+
# and model_fields_set contains the field
|
|
109
|
+
if self.firmware_version is None and "firmware_version" in self.model_fields_set:
|
|
94
110
|
_dict['firmwareVersion'] = None
|
|
95
111
|
|
|
96
112
|
return _dict
|
|
97
113
|
|
|
98
114
|
@classmethod
|
|
99
|
-
def from_dict(cls, obj:
|
|
115
|
+
def from_dict(cls, obj: Dict) -> Self:
|
|
100
116
|
"""Create an instance of ReadAllHeatPumpDto from a dict"""
|
|
101
117
|
if obj is None:
|
|
102
118
|
return None
|
|
103
119
|
|
|
104
120
|
if not isinstance(obj, dict):
|
|
105
|
-
return
|
|
121
|
+
return cls.model_validate(obj)
|
|
106
122
|
|
|
107
|
-
_obj =
|
|
123
|
+
_obj = cls.model_validate({
|
|
108
124
|
"id": obj.get("id"),
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
125
|
+
"controlBoardId": obj.get("controlBoardId"),
|
|
126
|
+
"serialNumber": obj.get("serialNumber"),
|
|
127
|
+
"partNumber": obj.get("partNumber"),
|
|
112
128
|
"state": obj.get("state"),
|
|
113
129
|
"name": obj.get("name"),
|
|
114
130
|
"model": obj.get("model"),
|
|
115
|
-
"
|
|
116
|
-
"
|
|
131
|
+
"dhwType": obj.get("dhwType"),
|
|
132
|
+
"boilerType": obj.get("boilerType"),
|
|
117
133
|
"status": obj.get("status"),
|
|
118
134
|
"type": obj.get("type"),
|
|
119
|
-
"
|
|
120
|
-
"
|
|
135
|
+
"commissionedAt": obj.get("commissionedAt"),
|
|
136
|
+
"firmwareVersion": obj.get("firmwareVersion")
|
|
121
137
|
})
|
|
122
138
|
return _obj
|
|
123
139
|
|
|
@@ -18,99 +18,115 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from datetime import datetime
|
|
21
|
-
from typing import Optional
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
from pydantic import BaseModel, Field, StrictStr, constr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from pydantic import BaseModel, StrictStr
|
|
23
|
+
from pydantic import Field
|
|
24
|
+
from typing_extensions import Annotated
|
|
26
25
|
from weheat.models.boiler_type import BoilerType
|
|
27
26
|
from weheat.models.device_state import DeviceState
|
|
28
27
|
from weheat.models.dhw_type import DhwType
|
|
29
28
|
from weheat.models.heat_pump_model import HeatPumpModel
|
|
30
29
|
from weheat.models.heat_pump_status_enum import HeatPumpStatusEnum
|
|
31
30
|
from weheat.models.heat_pump_type import HeatPumpType
|
|
31
|
+
try:
|
|
32
|
+
from typing import Self
|
|
33
|
+
except ImportError:
|
|
34
|
+
from typing_extensions import Self
|
|
32
35
|
|
|
33
36
|
class ReadHeatPumpDto(BaseModel):
|
|
34
37
|
"""
|
|
35
38
|
ReadHeatPumpDto
|
|
36
|
-
"""
|
|
37
|
-
id: StrictStr = Field(
|
|
38
|
-
control_board_id: StrictStr = Field(
|
|
39
|
-
serial_number:
|
|
40
|
-
part_number: Optional[StrictStr] = Field(None,
|
|
41
|
-
state: DeviceState
|
|
42
|
-
name: Optional[StrictStr] = Field(None, description="Internal nickname of this heat pump")
|
|
39
|
+
""" # noqa: E501
|
|
40
|
+
id: StrictStr = Field(description="Identifier of the heat pump")
|
|
41
|
+
control_board_id: StrictStr = Field(description="Identifier of the control board that is connected to the heat pump", alias="controlBoardId")
|
|
42
|
+
serial_number: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Serial Number of this heat pump", alias="serialNumber")
|
|
43
|
+
part_number: Optional[StrictStr] = Field(default=None, description="Part Number of this heat pump", alias="partNumber")
|
|
44
|
+
state: DeviceState
|
|
45
|
+
name: Optional[StrictStr] = Field(default=None, description="Internal nickname of this heat pump")
|
|
43
46
|
model: Optional[HeatPumpModel] = None
|
|
44
|
-
dhw_type: Optional[DhwType] = Field(None, alias="dhwType")
|
|
45
|
-
boiler_type: Optional[BoilerType] = Field(None, alias="boilerType")
|
|
47
|
+
dhw_type: Optional[DhwType] = Field(default=None, alias="dhwType")
|
|
48
|
+
boiler_type: Optional[BoilerType] = Field(default=None, alias="boilerType")
|
|
46
49
|
status: Optional[HeatPumpStatusEnum] = None
|
|
47
50
|
type: Optional[HeatPumpType] = None
|
|
48
|
-
commissioned_at: Optional[datetime] = Field(None,
|
|
49
|
-
__properties = ["id", "controlBoardId", "serialNumber", "partNumber", "state", "name", "model", "dhwType", "boilerType", "status", "type", "commissionedAt"]
|
|
51
|
+
commissioned_at: Optional[datetime] = Field(default=None, description="Date when the heat pump was last commissioned (decommissioning sets this to null)", alias="commissionedAt")
|
|
52
|
+
__properties: ClassVar[List[str]] = ["id", "controlBoardId", "serialNumber", "partNumber", "state", "name", "model", "dhwType", "boilerType", "status", "type", "commissionedAt"]
|
|
53
|
+
|
|
54
|
+
model_config = {
|
|
55
|
+
"populate_by_name": True,
|
|
56
|
+
"validate_assignment": True,
|
|
57
|
+
"protected_namespaces": (),
|
|
58
|
+
}
|
|
50
59
|
|
|
51
|
-
class Config:
|
|
52
|
-
"""Pydantic configuration"""
|
|
53
|
-
allow_population_by_field_name = True
|
|
54
|
-
validate_assignment = True
|
|
55
60
|
|
|
56
61
|
def to_str(self) -> str:
|
|
57
62
|
"""Returns the string representation of the model using alias"""
|
|
58
|
-
return pprint.pformat(self.
|
|
63
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
59
64
|
|
|
60
65
|
def to_json(self) -> str:
|
|
61
66
|
"""Returns the JSON representation of the model using alias"""
|
|
67
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
62
68
|
return json.dumps(self.to_dict())
|
|
63
69
|
|
|
64
70
|
@classmethod
|
|
65
|
-
def from_json(cls, json_str: str) ->
|
|
71
|
+
def from_json(cls, json_str: str) -> Self:
|
|
66
72
|
"""Create an instance of ReadHeatPumpDto from a JSON string"""
|
|
67
73
|
return cls.from_dict(json.loads(json_str))
|
|
68
74
|
|
|
69
|
-
def to_dict(self):
|
|
70
|
-
"""
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
76
|
+
"""Return the dictionary representation of the model using alias.
|
|
77
|
+
|
|
78
|
+
This has the following differences from calling pydantic's
|
|
79
|
+
`self.model_dump(by_alias=True)`:
|
|
80
|
+
|
|
81
|
+
* `None` is only added to the output dict for nullable fields that
|
|
82
|
+
were set at model initialization. Other fields with value `None`
|
|
83
|
+
are ignored.
|
|
84
|
+
"""
|
|
85
|
+
_dict = self.model_dump(
|
|
86
|
+
by_alias=True,
|
|
87
|
+
exclude={
|
|
88
|
+
},
|
|
89
|
+
exclude_none=True,
|
|
90
|
+
)
|
|
75
91
|
# set to None if part_number (nullable) is None
|
|
76
|
-
# and
|
|
77
|
-
if self.part_number is None and "part_number" in self.
|
|
92
|
+
# and model_fields_set contains the field
|
|
93
|
+
if self.part_number is None and "part_number" in self.model_fields_set:
|
|
78
94
|
_dict['partNumber'] = None
|
|
79
95
|
|
|
80
96
|
# set to None if name (nullable) is None
|
|
81
|
-
# and
|
|
82
|
-
if self.name is None and "name" in self.
|
|
97
|
+
# and model_fields_set contains the field
|
|
98
|
+
if self.name is None and "name" in self.model_fields_set:
|
|
83
99
|
_dict['name'] = None
|
|
84
100
|
|
|
85
101
|
# set to None if commissioned_at (nullable) is None
|
|
86
|
-
# and
|
|
87
|
-
if self.commissioned_at is None and "commissioned_at" in self.
|
|
102
|
+
# and model_fields_set contains the field
|
|
103
|
+
if self.commissioned_at is None and "commissioned_at" in self.model_fields_set:
|
|
88
104
|
_dict['commissionedAt'] = None
|
|
89
105
|
|
|
90
106
|
return _dict
|
|
91
107
|
|
|
92
108
|
@classmethod
|
|
93
|
-
def from_dict(cls, obj:
|
|
109
|
+
def from_dict(cls, obj: Dict) -> Self:
|
|
94
110
|
"""Create an instance of ReadHeatPumpDto from a dict"""
|
|
95
111
|
if obj is None:
|
|
96
112
|
return None
|
|
97
113
|
|
|
98
114
|
if not isinstance(obj, dict):
|
|
99
|
-
return
|
|
115
|
+
return cls.model_validate(obj)
|
|
100
116
|
|
|
101
|
-
_obj =
|
|
117
|
+
_obj = cls.model_validate({
|
|
102
118
|
"id": obj.get("id"),
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
119
|
+
"controlBoardId": obj.get("controlBoardId"),
|
|
120
|
+
"serialNumber": obj.get("serialNumber"),
|
|
121
|
+
"partNumber": obj.get("partNumber"),
|
|
106
122
|
"state": obj.get("state"),
|
|
107
123
|
"name": obj.get("name"),
|
|
108
124
|
"model": obj.get("model"),
|
|
109
|
-
"
|
|
110
|
-
"
|
|
125
|
+
"dhwType": obj.get("dhwType"),
|
|
126
|
+
"boilerType": obj.get("boilerType"),
|
|
111
127
|
"status": obj.get("status"),
|
|
112
128
|
"type": obj.get("type"),
|
|
113
|
-
"
|
|
129
|
+
"commissionedAt": obj.get("commissionedAt")
|
|
114
130
|
})
|
|
115
131
|
return _obj
|
|
116
132
|
|
weheat/models/read_user_dto.py
CHANGED
|
@@ -18,84 +18,99 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from datetime import datetime
|
|
21
|
-
from typing import Optional
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from pydantic import BaseModel, StrictStr
|
|
23
|
+
from pydantic import Field
|
|
24
|
+
from weheat.models.role import Role
|
|
22
25
|
try:
|
|
23
|
-
from
|
|
26
|
+
from typing import Self
|
|
24
27
|
except ImportError:
|
|
25
|
-
from
|
|
26
|
-
from weheat.models.role import Role
|
|
28
|
+
from typing_extensions import Self
|
|
27
29
|
|
|
28
30
|
class ReadUserDto(BaseModel):
|
|
29
31
|
"""
|
|
30
32
|
ReadUserDto
|
|
31
|
-
"""
|
|
32
|
-
id: StrictStr = Field(
|
|
33
|
-
first_name: Optional[StrictStr] = Field(None,
|
|
34
|
-
last_name: Optional[StrictStr] = Field(None,
|
|
35
|
-
role: Role
|
|
36
|
-
email: Optional[StrictStr] = Field(None, description="Email address of the user")
|
|
37
|
-
updated_on: datetime = Field(
|
|
38
|
-
created_on: datetime = Field(
|
|
39
|
-
__properties = ["id", "firstName", "lastName", "role", "email", "updatedOn", "createdOn"]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
""
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
id: StrictStr = Field(description="Identifier of the user")
|
|
35
|
+
first_name: Optional[StrictStr] = Field(default=None, description="First name of the user if available", alias="firstName")
|
|
36
|
+
last_name: Optional[StrictStr] = Field(default=None, description="Last Name of the user if available", alias="lastName")
|
|
37
|
+
role: Role
|
|
38
|
+
email: Optional[StrictStr] = Field(default=None, description="Email address of the user")
|
|
39
|
+
updated_on: datetime = Field(description="Timestamp of the last update to the user entry", alias="updatedOn")
|
|
40
|
+
created_on: datetime = Field(description="Timestamp of the creation of the user entry", alias="createdOn")
|
|
41
|
+
__properties: ClassVar[List[str]] = ["id", "firstName", "lastName", "role", "email", "updatedOn", "createdOn"]
|
|
42
|
+
|
|
43
|
+
model_config = {
|
|
44
|
+
"populate_by_name": True,
|
|
45
|
+
"validate_assignment": True,
|
|
46
|
+
"protected_namespaces": (),
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
|
|
46
50
|
def to_str(self) -> str:
|
|
47
51
|
"""Returns the string representation of the model using alias"""
|
|
48
|
-
return pprint.pformat(self.
|
|
52
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
49
53
|
|
|
50
54
|
def to_json(self) -> str:
|
|
51
55
|
"""Returns the JSON representation of the model using alias"""
|
|
56
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
52
57
|
return json.dumps(self.to_dict())
|
|
53
58
|
|
|
54
59
|
@classmethod
|
|
55
|
-
def from_json(cls, json_str: str) ->
|
|
60
|
+
def from_json(cls, json_str: str) -> Self:
|
|
56
61
|
"""Create an instance of ReadUserDto from a JSON string"""
|
|
57
62
|
return cls.from_dict(json.loads(json_str))
|
|
58
63
|
|
|
59
|
-
def to_dict(self):
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
65
|
+
"""Return the dictionary representation of the model using alias.
|
|
66
|
+
|
|
67
|
+
This has the following differences from calling pydantic's
|
|
68
|
+
`self.model_dump(by_alias=True)`:
|
|
69
|
+
|
|
70
|
+
* `None` is only added to the output dict for nullable fields that
|
|
71
|
+
were set at model initialization. Other fields with value `None`
|
|
72
|
+
are ignored.
|
|
73
|
+
"""
|
|
74
|
+
_dict = self.model_dump(
|
|
75
|
+
by_alias=True,
|
|
76
|
+
exclude={
|
|
77
|
+
},
|
|
78
|
+
exclude_none=True,
|
|
79
|
+
)
|
|
65
80
|
# set to None if first_name (nullable) is None
|
|
66
|
-
# and
|
|
67
|
-
if self.first_name is None and "first_name" in self.
|
|
81
|
+
# and model_fields_set contains the field
|
|
82
|
+
if self.first_name is None and "first_name" in self.model_fields_set:
|
|
68
83
|
_dict['firstName'] = None
|
|
69
84
|
|
|
70
85
|
# set to None if last_name (nullable) is None
|
|
71
|
-
# and
|
|
72
|
-
if self.last_name is None and "last_name" in self.
|
|
86
|
+
# and model_fields_set contains the field
|
|
87
|
+
if self.last_name is None and "last_name" in self.model_fields_set:
|
|
73
88
|
_dict['lastName'] = None
|
|
74
89
|
|
|
75
90
|
# set to None if email (nullable) is None
|
|
76
|
-
# and
|
|
77
|
-
if self.email is None and "email" in self.
|
|
91
|
+
# and model_fields_set contains the field
|
|
92
|
+
if self.email is None and "email" in self.model_fields_set:
|
|
78
93
|
_dict['email'] = None
|
|
79
94
|
|
|
80
95
|
return _dict
|
|
81
96
|
|
|
82
97
|
@classmethod
|
|
83
|
-
def from_dict(cls, obj:
|
|
98
|
+
def from_dict(cls, obj: Dict) -> Self:
|
|
84
99
|
"""Create an instance of ReadUserDto from a dict"""
|
|
85
100
|
if obj is None:
|
|
86
101
|
return None
|
|
87
102
|
|
|
88
103
|
if not isinstance(obj, dict):
|
|
89
|
-
return
|
|
104
|
+
return cls.model_validate(obj)
|
|
90
105
|
|
|
91
|
-
_obj =
|
|
106
|
+
_obj = cls.model_validate({
|
|
92
107
|
"id": obj.get("id"),
|
|
93
|
-
"
|
|
94
|
-
"
|
|
108
|
+
"firstName": obj.get("firstName"),
|
|
109
|
+
"lastName": obj.get("lastName"),
|
|
95
110
|
"role": obj.get("role"),
|
|
96
111
|
"email": obj.get("email"),
|
|
97
|
-
"
|
|
98
|
-
"
|
|
112
|
+
"updatedOn": obj.get("updatedOn"),
|
|
113
|
+
"createdOn": obj.get("createdOn")
|
|
99
114
|
})
|
|
100
115
|
return _obj
|
|
101
116
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Weheat Backend
|
|
5
|
+
|
|
6
|
+
This is the backend for the Weheat project
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: v1
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from pydantic import BaseModel, StrictStr
|
|
23
|
+
from pydantic import Field
|
|
24
|
+
from weheat.models.role import Role
|
|
25
|
+
try:
|
|
26
|
+
from typing import Self
|
|
27
|
+
except ImportError:
|
|
28
|
+
from typing_extensions import Self
|
|
29
|
+
|
|
30
|
+
class ReadUserMeDto(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
ReadUserMeDto
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
id: StrictStr = Field(description="Identifier of the user")
|
|
35
|
+
first_name: Optional[StrictStr] = Field(default=None, description="First name of the user if available", alias="firstName")
|
|
36
|
+
last_name: Optional[StrictStr] = Field(default=None, description="Last Name of the user if available", alias="lastName")
|
|
37
|
+
role: Role
|
|
38
|
+
email: Optional[StrictStr] = Field(default=None, description="Email address of the user")
|
|
39
|
+
updated_on: datetime = Field(description="Timestamp of the last update to the user entry", alias="updatedOn")
|
|
40
|
+
created_on: datetime = Field(description="Timestamp of the creation of the user entry", alias="createdOn")
|
|
41
|
+
language: Optional[StrictStr] = Field(default=None, description="The preferred language of the user (shortened version, e.g. 'EN', 'NL')")
|
|
42
|
+
__properties: ClassVar[List[str]] = ["id", "firstName", "lastName", "role", "email", "updatedOn", "createdOn", "language"]
|
|
43
|
+
|
|
44
|
+
model_config = {
|
|
45
|
+
"populate_by_name": True,
|
|
46
|
+
"validate_assignment": True,
|
|
47
|
+
"protected_namespaces": (),
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def to_str(self) -> str:
|
|
52
|
+
"""Returns the string representation of the model using alias"""
|
|
53
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
54
|
+
|
|
55
|
+
def to_json(self) -> str:
|
|
56
|
+
"""Returns the JSON representation of the model using alias"""
|
|
57
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
58
|
+
return json.dumps(self.to_dict())
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_json(cls, json_str: str) -> Self:
|
|
62
|
+
"""Create an instance of ReadUserMeDto from a JSON string"""
|
|
63
|
+
return cls.from_dict(json.loads(json_str))
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
66
|
+
"""Return the dictionary representation of the model using alias.
|
|
67
|
+
|
|
68
|
+
This has the following differences from calling pydantic's
|
|
69
|
+
`self.model_dump(by_alias=True)`:
|
|
70
|
+
|
|
71
|
+
* `None` is only added to the output dict for nullable fields that
|
|
72
|
+
were set at model initialization. Other fields with value `None`
|
|
73
|
+
are ignored.
|
|
74
|
+
"""
|
|
75
|
+
_dict = self.model_dump(
|
|
76
|
+
by_alias=True,
|
|
77
|
+
exclude={
|
|
78
|
+
},
|
|
79
|
+
exclude_none=True,
|
|
80
|
+
)
|
|
81
|
+
# set to None if first_name (nullable) is None
|
|
82
|
+
# and model_fields_set contains the field
|
|
83
|
+
if self.first_name is None and "first_name" in self.model_fields_set:
|
|
84
|
+
_dict['firstName'] = None
|
|
85
|
+
|
|
86
|
+
# set to None if last_name (nullable) is None
|
|
87
|
+
# and model_fields_set contains the field
|
|
88
|
+
if self.last_name is None and "last_name" in self.model_fields_set:
|
|
89
|
+
_dict['lastName'] = None
|
|
90
|
+
|
|
91
|
+
# set to None if email (nullable) is None
|
|
92
|
+
# and model_fields_set contains the field
|
|
93
|
+
if self.email is None and "email" in self.model_fields_set:
|
|
94
|
+
_dict['email'] = None
|
|
95
|
+
|
|
96
|
+
# set to None if language (nullable) is None
|
|
97
|
+
# and model_fields_set contains the field
|
|
98
|
+
if self.language is None and "language" in self.model_fields_set:
|
|
99
|
+
_dict['language'] = None
|
|
100
|
+
|
|
101
|
+
return _dict
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def from_dict(cls, obj: Dict) -> Self:
|
|
105
|
+
"""Create an instance of ReadUserMeDto from a dict"""
|
|
106
|
+
if obj is None:
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
if not isinstance(obj, dict):
|
|
110
|
+
return cls.model_validate(obj)
|
|
111
|
+
|
|
112
|
+
_obj = cls.model_validate({
|
|
113
|
+
"id": obj.get("id"),
|
|
114
|
+
"firstName": obj.get("firstName"),
|
|
115
|
+
"lastName": obj.get("lastName"),
|
|
116
|
+
"role": obj.get("role"),
|
|
117
|
+
"email": obj.get("email"),
|
|
118
|
+
"updatedOn": obj.get("updatedOn"),
|
|
119
|
+
"createdOn": obj.get("createdOn"),
|
|
120
|
+
"language": obj.get("language")
|
|
121
|
+
})
|
|
122
|
+
return _obj
|
|
123
|
+
|
|
124
|
+
|
weheat/models/role.py
CHANGED
|
@@ -12,18 +12,23 @@
|
|
|
12
12
|
""" # noqa: E501
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
15
16
|
import json
|
|
16
17
|
import pprint
|
|
17
18
|
import re # noqa: F401
|
|
18
|
-
from
|
|
19
|
+
from enum import Enum
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
try:
|
|
24
|
+
from typing import Self
|
|
25
|
+
except ImportError:
|
|
26
|
+
from typing_extensions import Self
|
|
22
27
|
|
|
23
28
|
|
|
24
29
|
class Role(int, Enum):
|
|
25
30
|
"""
|
|
26
|
-
Roles that can be assigned to a user.\\ Roles enumeration include: - Admin (0), - Support (1), -
|
|
31
|
+
Roles that can be assigned to a user.\\ Roles enumeration include: - Admin (0), - Support (1), - Factory (2), - Sales (3), - DataScientist (4), - ProductionObsoleteRole (5), - Installer (6), - Consumer (7) - Distributor (8)
|
|
27
32
|
"""
|
|
28
33
|
|
|
29
34
|
"""
|
|
@@ -37,10 +42,11 @@ class Role(int, Enum):
|
|
|
37
42
|
NUMBER_5 = 5
|
|
38
43
|
NUMBER_6 = 6
|
|
39
44
|
NUMBER_7 = 7
|
|
45
|
+
NUMBER_8 = 8
|
|
40
46
|
|
|
41
47
|
@classmethod
|
|
42
|
-
def from_json(cls, json_str: str) ->
|
|
48
|
+
def from_json(cls, json_str: str) -> Self:
|
|
43
49
|
"""Create an instance of Role from a JSON string"""
|
|
44
|
-
return
|
|
50
|
+
return cls(json.loads(json_str))
|
|
45
51
|
|
|
46
52
|
|