Skip to content

Commit e627e41

Browse files
Generate iaas
1 parent 875e273 commit e627e41

136 files changed

Lines changed: 1038 additions & 420 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

services/iaas/oas_commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a35d8f28738a45005b098b66b6debd08a67ab018
1+
98c11e0ee4834ddaaa474eccc437d234e6276a70

services/iaas/src/stackit/iaas/api_client.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ApiClient:
6767
"date": datetime.date,
6868
"datetime": datetime.datetime,
6969
"decimal": decimal.Decimal,
70+
"UUID": uuid.UUID,
7071
"object": object,
7172
}
7273
_pool = None
@@ -266,7 +267,7 @@ def response_deserialize(
266267
response_text = None
267268
return_data = None
268269
try:
269-
if response_type == "bytearray":
270+
if response_type in ("bytearray", "bytes"):
270271
return_data = response_data.data
271272
elif response_type == "file":
272273
return_data = self.__deserialize_file(response_data)
@@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj):
327328
return obj.isoformat()
328329
elif isinstance(obj, decimal.Decimal):
329330
return str(obj)
330-
331331
elif isinstance(obj, dict):
332-
obj_dict = obj
332+
return {key: self.sanitize_for_serialization(val) for key, val in obj.items()}
333+
334+
# Convert model obj to dict except
335+
# attributes `openapi_types`, `attribute_map`
336+
# and attributes which value is not None.
337+
# Convert attribute name to json key in
338+
# model definition for request.
339+
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
340+
obj_dict = obj.to_dict()
333341
else:
334-
# Convert model obj to dict except
335-
# attributes `openapi_types`, `attribute_map`
336-
# and attributes which value is not None.
337-
# Convert attribute name to json key in
338-
# model definition for request.
339-
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
340-
obj_dict = obj.to_dict()
341-
else:
342-
obj_dict = obj.__dict__
343-
344-
if isinstance(obj_dict, list):
345-
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501
346-
return self.sanitize_for_serialization(obj_dict)
342+
obj_dict = obj.__dict__
347343

348-
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
344+
return self.sanitize_for_serialization(obj_dict)
349345

350346
def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
351347
"""Deserializes response into an object.
@@ -418,6 +414,8 @@ def __deserialize(self, data, klass):
418414
return self.__deserialize_datetime(data)
419415
elif klass is decimal.Decimal:
420416
return decimal.Decimal(data)
417+
elif klass is uuid.UUID:
418+
return uuid.UUID(data)
421419
elif issubclass(klass, Enum):
422420
return self.__deserialize_enum(data, klass)
423421
else:

services/iaas/src/stackit/iaas/models/add_routes_to_routing_table_payload.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.iaas.models.route import Route
@@ -33,7 +34,8 @@ class AddRoutesToRoutingTablePayload(BaseModel):
3334
__properties: ClassVar[List[str]] = ["items"]
3435

3536
model_config = ConfigDict(
36-
populate_by_name=True,
37+
validate_by_name=True,
38+
validate_by_alias=True,
3739
validate_assignment=True,
3840
protected_namespaces=(),
3941
)
@@ -44,8 +46,7 @@ def to_str(self) -> str:
4446

4547
def to_json(self) -> str:
4648
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
49+
return json.dumps(to_jsonable_python(self.to_dict()))
4950

5051
@classmethod
5152
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/add_routing_table_to_area_payload.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from uuid import UUID
2323

2424
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
25+
from pydantic_core import to_jsonable_python
2526
from typing_extensions import Annotated, Self
2627

2728

@@ -92,6 +93,9 @@ def id_validate_regular_expression(cls, value):
9293
if value is None:
9394
return value
9495

96+
if not isinstance(value, str):
97+
value = str(value)
98+
9599
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
96100
raise ValueError(
97101
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
@@ -101,6 +105,9 @@ def id_validate_regular_expression(cls, value):
101105
@field_validator("name")
102106
def name_validate_regular_expression(cls, value):
103107
"""Validates the regular expression"""
108+
if not isinstance(value, str):
109+
value = str(value)
110+
104111
if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value):
105112
raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/")
106113
return value
@@ -119,7 +126,8 @@ def updated_at_change_year_zero_to_one(cls, value):
119126
return value
120127

121128
model_config = ConfigDict(
122-
populate_by_name=True,
129+
validate_by_name=True,
130+
validate_by_alias=True,
123131
validate_assignment=True,
124132
protected_namespaces=(),
125133
)
@@ -130,8 +138,7 @@ def to_str(self) -> str:
130138

131139
def to_json(self) -> str:
132140
"""Returns the JSON representation of the model using alias"""
133-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
134-
return json.dumps(self.to_dict())
141+
return json.dumps(to_jsonable_python(self.to_dict()))
135142

136143
@classmethod
137144
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/add_volume_to_server_payload.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from uuid import UUID
2222

2323
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
24+
from pydantic_core import to_jsonable_python
2425
from typing_extensions import Self
2526

2627

@@ -48,6 +49,9 @@ def server_id_validate_regular_expression(cls, value):
4849
if value is None:
4950
return value
5051

52+
if not isinstance(value, str):
53+
value = str(value)
54+
5155
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
5256
raise ValueError(
5357
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
@@ -60,14 +64,18 @@ def volume_id_validate_regular_expression(cls, value):
6064
if value is None:
6165
return value
6266

67+
if not isinstance(value, str):
68+
value = str(value)
69+
6370
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
6471
raise ValueError(
6572
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
6673
)
6774
return value
6875

6976
model_config = ConfigDict(
70-
populate_by_name=True,
77+
validate_by_name=True,
78+
validate_by_alias=True,
7179
validate_assignment=True,
7280
protected_namespaces=(),
7381
)
@@ -78,8 +86,7 @@ def to_str(self) -> str:
7886

7987
def to_json(self) -> str:
8088
"""Returns the JSON representation of the model using alias"""
81-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
82-
return json.dumps(self.to_dict())
89+
return json.dumps(to_jsonable_python(self.to_dict()))
8390

8491
@classmethod
8592
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/affinity_group.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from uuid import UUID
2222

2323
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
24+
from pydantic_core import to_jsonable_python
2425
from typing_extensions import Annotated, Self
2526

2627

@@ -45,6 +46,9 @@ def id_validate_regular_expression(cls, value):
4546
if value is None:
4647
return value
4748

49+
if not isinstance(value, str):
50+
value = str(value)
51+
4852
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
4953
raise ValueError(
5054
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
@@ -54,12 +58,16 @@ def id_validate_regular_expression(cls, value):
5458
@field_validator("name")
5559
def name_validate_regular_expression(cls, value):
5660
"""Validates the regular expression"""
61+
if not isinstance(value, str):
62+
value = str(value)
63+
5764
if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value):
5865
raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/")
5966
return value
6067

6168
model_config = ConfigDict(
62-
populate_by_name=True,
69+
validate_by_name=True,
70+
validate_by_alias=True,
6371
validate_assignment=True,
6472
protected_namespaces=(),
6573
)
@@ -70,8 +78,7 @@ def to_str(self) -> str:
7078

7179
def to_json(self) -> str:
7280
"""Returns the JSON representation of the model using alias"""
73-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
74-
return json.dumps(self.to_dict())
81+
return json.dumps(to_jsonable_python(self.to_dict()))
7582

7683
@classmethod
7784
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/affinity_group_list_response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.iaas.models.affinity_group import AffinityGroup
@@ -33,7 +34,8 @@ class AffinityGroupListResponse(BaseModel):
3334
__properties: ClassVar[List[str]] = ["items"]
3435

3536
model_config = ConfigDict(
36-
populate_by_name=True,
37+
validate_by_name=True,
38+
validate_by_alias=True,
3739
validate_assignment=True,
3840
protected_namespaces=(),
3941
)
@@ -44,8 +46,7 @@ def to_str(self) -> str:
4446

4547
def to_json(self) -> str:
4648
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
49+
return json.dumps(to_jsonable_python(self.to_dict()))
4950

5051
@classmethod
5152
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/availability_zone_list_response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -31,7 +32,8 @@ class AvailabilityZoneListResponse(BaseModel):
3132
__properties: ClassVar[List[str]] = ["items"]
3233

3334
model_config = ConfigDict(
34-
populate_by_name=True,
35+
validate_by_name=True,
36+
validate_by_alias=True,
3537
validate_assignment=True,
3638
protected_namespaces=(),
3739
)
@@ -42,8 +44,7 @@ def to_str(self) -> str:
4244

4345
def to_json(self) -> str:
4446
"""Returns the JSON representation of the model using alias"""
45-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46-
return json.dumps(self.to_dict())
47+
return json.dumps(to_jsonable_python(self.to_dict()))
4748

4849
@classmethod
4950
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/backup.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
StrictStr,
3131
field_validator,
3232
)
33+
from pydantic_core import to_jsonable_python
3334
from typing_extensions import Annotated, Self
3435

3536

@@ -104,6 +105,9 @@ def id_validate_regular_expression(cls, value):
104105
if value is None:
105106
return value
106107

108+
if not isinstance(value, str):
109+
value = str(value)
110+
107111
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
108112
raise ValueError(
109113
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
@@ -116,6 +120,9 @@ def name_validate_regular_expression(cls, value):
116120
if value is None:
117121
return value
118122

123+
if not isinstance(value, str):
124+
value = str(value)
125+
119126
if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value):
120127
raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/")
121128
return value
@@ -126,6 +133,9 @@ def snapshot_id_validate_regular_expression(cls, value):
126133
if value is None:
127134
return value
128135

136+
if not isinstance(value, str):
137+
value = str(value)
138+
129139
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
130140
raise ValueError(
131141
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
@@ -151,14 +161,18 @@ def volume_id_validate_regular_expression(cls, value):
151161
if value is None:
152162
return value
153163

164+
if not isinstance(value, str):
165+
value = str(value)
166+
154167
if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
155168
raise ValueError(
156169
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
157170
)
158171
return value
159172

160173
model_config = ConfigDict(
161-
populate_by_name=True,
174+
validate_by_name=True,
175+
validate_by_alias=True,
162176
validate_assignment=True,
163177
protected_namespaces=(),
164178
)
@@ -169,8 +183,7 @@ def to_str(self) -> str:
169183

170184
def to_json(self) -> str:
171185
"""Returns the JSON representation of the model using alias"""
172-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
173-
return json.dumps(self.to_dict())
186+
return json.dumps(to_jsonable_python(self.to_dict()))
174187

175188
@classmethod
176189
def from_json(cls, json_str: str) -> Optional[Self]:

services/iaas/src/stackit/iaas/models/backup_list_response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.iaas.models.backup import Backup
@@ -33,7 +34,8 @@ class BackupListResponse(BaseModel):
3334
__properties: ClassVar[List[str]] = ["items"]
3435

3536
model_config = ConfigDict(
36-
populate_by_name=True,
37+
validate_by_name=True,
38+
validate_by_alias=True,
3739
validate_assignment=True,
3840
protected_namespaces=(),
3941
)
@@ -44,8 +46,7 @@ def to_str(self) -> str:
4446

4547
def to_json(self) -> str:
4648
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
49+
return json.dumps(to_jsonable_python(self.to_dict()))
4950

5051
@classmethod
5152
def from_json(cls, json_str: str) -> Optional[Self]:

0 commit comments

Comments
 (0)