weheat 2025.1.14__py3-none-any.whl → 2025.1.15__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.

@@ -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
- try:
23
- from pydantic.v1 import BaseModel, Field, StrictStr, constr
24
- except ImportError:
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 # noqa: E501
36
- """
37
- id: StrictStr = Field(..., description="Identifier of the heat pump")
38
- control_board_id: StrictStr = Field(..., alias="controlBoardId", description="Identifier of the control board that is connected to the heat pump")
39
- serial_number: constr(strict=True, min_length=1) = Field(..., alias="serialNumber", description="Serial Number of this heat pump")
40
- part_number: Optional[StrictStr] = Field(None, alias="partNumber", description="Part Number of this heat pump")
41
- state: DeviceState = Field(...)
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, alias="commissionedAt", description="Date when the heat pump was last commissioned (decommissioning sets this to null)")
49
- firmware_version: Optional[StrictStr] = Field(None, alias="firmwareVersion", description="Firmware version of control board connected to heat pump")
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.dict(by_alias=True))
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) -> ReadAllHeatPumpDto:
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
- """Returns the dictionary representation of the model using alias"""
72
- _dict = self.dict(by_alias=True,
73
- exclude={
74
- },
75
- exclude_none=True)
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 __fields_set__ contains the field
78
- if self.part_number is None and "part_number" in self.__fields_set__:
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 __fields_set__ contains the field
83
- if self.name is None and "name" in self.__fields_set__:
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 __fields_set__ contains the field
88
- if self.commissioned_at is None and "commissioned_at" in self.__fields_set__:
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 __fields_set__ contains the field
93
- if self.firmware_version is None and "firmware_version" in self.__fields_set__:
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: dict) -> ReadAllHeatPumpDto:
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 ReadAllHeatPumpDto.parse_obj(obj)
121
+ return cls.model_validate(obj)
106
122
 
107
- _obj = ReadAllHeatPumpDto.parse_obj({
123
+ _obj = cls.model_validate({
108
124
  "id": obj.get("id"),
109
- "control_board_id": obj.get("controlBoardId"),
110
- "serial_number": obj.get("serialNumber"),
111
- "part_number": obj.get("partNumber"),
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
- "dhw_type": obj.get("dhwType"),
116
- "boiler_type": obj.get("boilerType"),
131
+ "dhwType": obj.get("dhwType"),
132
+ "boilerType": obj.get("boilerType"),
117
133
  "status": obj.get("status"),
118
134
  "type": obj.get("type"),
119
- "commissioned_at": obj.get("commissionedAt"),
120
- "firmware_version": obj.get("firmwareVersion")
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
- try:
23
- from pydantic.v1 import BaseModel, Field, StrictStr, constr
24
- except ImportError:
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(..., description="Identifier of the heat pump")
38
- control_board_id: StrictStr = Field(..., alias="controlBoardId", description="Identifier of the control board that is connected to the heat pump")
39
- serial_number: constr(strict=True, min_length=1) = Field(..., alias="serialNumber", description="Serial Number of this heat pump")
40
- part_number: Optional[StrictStr] = Field(None, alias="partNumber", description="Part Number of this heat pump")
41
- state: DeviceState = Field(...)
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, alias="commissionedAt", description="Date when the heat pump was last commissioned (decommissioning sets this to null)")
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.dict(by_alias=True))
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) -> ReadHeatPumpDto:
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
- """Returns the dictionary representation of the model using alias"""
71
- _dict = self.dict(by_alias=True,
72
- exclude={
73
- },
74
- exclude_none=True)
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 __fields_set__ contains the field
77
- if self.part_number is None and "part_number" in self.__fields_set__:
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 __fields_set__ contains the field
82
- if self.name is None and "name" in self.__fields_set__:
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 __fields_set__ contains the field
87
- if self.commissioned_at is None and "commissioned_at" in self.__fields_set__:
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: dict) -> ReadHeatPumpDto:
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 ReadHeatPumpDto.parse_obj(obj)
115
+ return cls.model_validate(obj)
100
116
 
101
- _obj = ReadHeatPumpDto.parse_obj({
117
+ _obj = cls.model_validate({
102
118
  "id": obj.get("id"),
103
- "control_board_id": obj.get("controlBoardId"),
104
- "serial_number": obj.get("serialNumber"),
105
- "part_number": obj.get("partNumber"),
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
- "dhw_type": obj.get("dhwType"),
110
- "boiler_type": obj.get("boilerType"),
125
+ "dhwType": obj.get("dhwType"),
126
+ "boilerType": obj.get("boilerType"),
111
127
  "status": obj.get("status"),
112
128
  "type": obj.get("type"),
113
- "commissioned_at": obj.get("commissionedAt")
129
+ "commissionedAt": obj.get("commissionedAt")
114
130
  })
115
131
  return _obj
116
132
 
@@ -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 pydantic.v1 import BaseModel, Field, StrictStr
26
+ from typing import Self
24
27
  except ImportError:
25
- from pydantic import BaseModel, Field, StrictStr
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(..., description="Identifier of the user")
33
- first_name: Optional[StrictStr] = Field(None, alias="firstName", description="First name of the user if available")
34
- last_name: Optional[StrictStr] = Field(None, alias="lastName", description="Last Name of the user if available")
35
- role: Role = Field(...)
36
- email: Optional[StrictStr] = Field(None, description="Email address of the user")
37
- updated_on: datetime = Field(..., alias="updatedOn", description="Timestamp of the last update to the user entry")
38
- created_on: datetime = Field(..., alias="createdOn", description="Timestamp of the creation of the user entry")
39
- __properties = ["id", "firstName", "lastName", "role", "email", "updatedOn", "createdOn"]
40
-
41
- class Config:
42
- """Pydantic configuration"""
43
- allow_population_by_field_name = True
44
- validate_assignment = True
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.dict(by_alias=True))
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) -> ReadUserDto:
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
- """Returns the dictionary representation of the model using alias"""
61
- _dict = self.dict(by_alias=True,
62
- exclude={
63
- },
64
- exclude_none=True)
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 __fields_set__ contains the field
67
- if self.first_name is None and "first_name" in self.__fields_set__:
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 __fields_set__ contains the field
72
- if self.last_name is None and "last_name" in self.__fields_set__:
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 __fields_set__ contains the field
77
- if self.email is None and "email" in self.__fields_set__:
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: dict) -> ReadUserDto:
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 ReadUserDto.parse_obj(obj)
104
+ return cls.model_validate(obj)
90
105
 
91
- _obj = ReadUserDto.parse_obj({
106
+ _obj = cls.model_validate({
92
107
  "id": obj.get("id"),
93
- "first_name": obj.get("firstName"),
94
- "last_name": obj.get("lastName"),
108
+ "firstName": obj.get("firstName"),
109
+ "lastName": obj.get("lastName"),
95
110
  "role": obj.get("role"),
96
111
  "email": obj.get("email"),
97
- "updated_on": obj.get("updatedOn"),
98
- "created_on": obj.get("createdOn")
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 aenum import Enum, no_arg
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), - Logistics (2), - Sales (3), - DataScientist (4), - Production (5), - Installer (6), - Consumer (7)
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) -> Role:
48
+ def from_json(cls, json_str: str) -> Self:
43
49
  """Create an instance of Role from a JSON string"""
44
- return Role(json.loads(json_str))
50
+ return cls(json.loads(json_str))
45
51
 
46
52