Skip to content

Commit eb92930

Browse files
Generate serverbackup
1 parent 875e273 commit eb92930

20 files changed

Lines changed: 88 additions & 72 deletions

services/serverbackup/oas_commit

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

services/serverbackup/src/stackit/serverbackup/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/serverbackup/src/stackit/serverbackup/models/backup.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, StrictInt, StrictStr, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.serverbackup.models.backup_volume_backups_inner import (
@@ -71,7 +72,8 @@ def status_validate_enum(cls, value):
7172
return value
7273

7374
model_config = ConfigDict(
74-
populate_by_name=True,
75+
validate_by_name=True,
76+
validate_by_alias=True,
7577
validate_assignment=True,
7678
protected_namespaces=(),
7779
)
@@ -82,8 +84,7 @@ def to_str(self) -> str:
8284

8385
def to_json(self) -> str:
8486
"""Returns the JSON representation of the model using alias"""
85-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
86-
return json.dumps(self.to_dict())
87+
return json.dumps(to_jsonable_python(self.to_dict()))
8788

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

services/serverbackup/src/stackit/serverbackup/models/backup_job.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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -31,7 +32,8 @@ class BackupJob(BaseModel):
3132
__properties: ClassVar[List[str]] = ["id"]
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/serverbackup/src/stackit/serverbackup/models/backup_policy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
StrictBool,
2626
StrictStr,
2727
)
28+
from pydantic_core import to_jsonable_python
2829
from typing_extensions import Self
2930

3031
from stackit.serverbackup.models.backup_policy_backup_properties import (
@@ -50,7 +51,8 @@ class BackupPolicy(BaseModel):
5051
__properties: ClassVar[List[str]] = ["backupProperties", "default", "description", "enabled", "id", "name", "rrule"]
5152

5253
model_config = ConfigDict(
53-
populate_by_name=True,
54+
validate_by_name=True,
55+
validate_by_alias=True,
5456
validate_assignment=True,
5557
protected_namespaces=(),
5658
)
@@ -61,8 +63,7 @@ def to_str(self) -> str:
6163

6264
def to_json(self) -> str:
6365
"""Returns the JSON representation of the model using alias"""
64-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
65-
return json.dumps(self.to_dict())
66+
return json.dumps(to_jsonable_python(self.to_dict()))
6667

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

services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.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, StrictInt, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -32,7 +33,8 @@ class BackupPolicyBackupProperties(BaseModel):
3233
__properties: ClassVar[List[str]] = ["name", "retentionPeriod"]
3334

3435
model_config = ConfigDict(
35-
populate_by_name=True,
36+
validate_by_name=True,
37+
validate_by_alias=True,
3638
validate_assignment=True,
3739
protected_namespaces=(),
3840
)
@@ -43,8 +45,7 @@ def to_str(self) -> str:
4345

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

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

services/serverbackup/src/stackit/serverbackup/models/backup_properties.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 Annotated, Self
2324

2425

@@ -35,7 +36,8 @@ class BackupProperties(BaseModel):
3536
__properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"]
3637

3738
model_config = ConfigDict(
38-
populate_by_name=True,
39+
validate_by_name=True,
40+
validate_by_alias=True,
3941
validate_assignment=True,
4042
protected_namespaces=(),
4143
)
@@ -46,8 +48,7 @@ def to_str(self) -> str:
4648

4749
def to_json(self) -> str:
4850
"""Returns the JSON representation of the model using alias"""
49-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50-
return json.dumps(self.to_dict())
51+
return json.dumps(to_jsonable_python(self.to_dict()))
5152

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

services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
StrictInt,
2727
StrictStr,
2828
)
29+
from pydantic_core import to_jsonable_python
2930
from typing_extensions import Self
3031

3132
from stackit.serverbackup.models.backup_properties import BackupProperties
@@ -46,7 +47,8 @@ class BackupSchedule(BaseModel):
4647
__properties: ClassVar[List[str]] = ["backupProperties", "enabled", "id", "name", "rrule"]
4748

4849
model_config = ConfigDict(
49-
populate_by_name=True,
50+
validate_by_name=True,
51+
validate_by_alias=True,
5052
validate_assignment=True,
5153
protected_namespaces=(),
5254
)
@@ -57,8 +59,7 @@ def to_str(self) -> str:
5759

5860
def to_json(self) -> str:
5961
"""Returns the JSON representation of the model using alias"""
60-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61-
return json.dumps(self.to_dict())
62+
return json.dumps(to_jsonable_python(self.to_dict()))
6263

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

services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.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, StrictInt, StrictStr, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -60,7 +61,8 @@ def status_validate_enum(cls, value):
6061
return value
6162

6263
model_config = ConfigDict(
63-
populate_by_name=True,
64+
validate_by_name=True,
65+
validate_by_alias=True,
6466
validate_assignment=True,
6567
protected_namespaces=(),
6668
)
@@ -71,8 +73,7 @@ def to_str(self) -> str:
7173

7274
def to_json(self) -> str:
7375
"""Returns the JSON representation of the model using alias"""
74-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
75-
return json.dumps(self.to_dict())
76+
return json.dumps(to_jsonable_python(self.to_dict()))
7677

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

services/serverbackup/src/stackit/serverbackup/models/create_backup_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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -35,7 +36,8 @@ class CreateBackupPayload(BaseModel):
3536
__properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"]
3637

3738
model_config = ConfigDict(
38-
populate_by_name=True,
39+
validate_by_name=True,
40+
validate_by_alias=True,
3941
validate_assignment=True,
4042
protected_namespaces=(),
4143
)
@@ -46,8 +48,7 @@ def to_str(self) -> str:
4648

4749
def to_json(self) -> str:
4850
"""Returns the JSON representation of the model using alias"""
49-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50-
return json.dumps(self.to_dict())
51+
return json.dumps(to_jsonable_python(self.to_dict()))
5152

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

0 commit comments

Comments
 (0)