From eb929301a7286e57deaf55d615e545aa607c6359 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 11 May 2026 10:18:51 +0000 Subject: [PATCH] Generate serverbackup --- services/serverbackup/oas_commit | 2 +- .../src/stackit/serverbackup/api_client.py | 32 +++++++++---------- .../src/stackit/serverbackup/models/backup.py | 7 ++-- .../stackit/serverbackup/models/backup_job.py | 7 ++-- .../serverbackup/models/backup_policy.py | 7 ++-- .../models/backup_policy_backup_properties.py | 7 ++-- .../serverbackup/models/backup_properties.py | 7 ++-- .../serverbackup/models/backup_schedule.py | 7 ++-- .../models/backup_volume_backups_inner.py | 7 ++-- .../models/create_backup_payload.py | 7 ++-- .../models/create_backup_schedule_payload.py | 7 ++-- .../models/enable_service_resource_payload.py | 7 ++-- .../serverbackup/models/error_response.py | 7 ++-- .../models/get_backup_policies_response.py | 7 ++-- .../models/get_backup_schedules_response.py | 7 ++-- .../models/get_backup_service_response.py | 7 ++-- .../models/get_backups_list_response.py | 7 ++-- .../models/restore_backup_payload.py | 7 ++-- .../models/restore_volume_backup_payload.py | 7 ++-- .../models/update_backup_schedule_payload.py | 7 ++-- 20 files changed, 88 insertions(+), 72 deletions(-) diff --git a/services/serverbackup/oas_commit b/services/serverbackup/oas_commit index e3713dde3..b129c2291 100644 --- a/services/serverbackup/oas_commit +++ b/services/serverbackup/oas_commit @@ -1 +1 @@ -0e64886dd0847341800d7191ed193b75413be998 +98c11e0ee4834ddaaa474eccc437d234e6276a70 diff --git a/services/serverbackup/src/stackit/serverbackup/api_client.py b/services/serverbackup/src/stackit/serverbackup/api_client.py index 4584a1511..655224798 100644 --- a/services/serverbackup/src/stackit/serverbackup/api_client.py +++ b/services/serverbackup/src/stackit/serverbackup/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # 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 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup.py b/services/serverbackup/src/stackit/serverbackup/models/backup.py index 199c86e2d..23e29b80e 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_volume_backups_inner import ( @@ -71,7 +72,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -82,8 +84,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_job.py b/services/serverbackup/src/stackit/serverbackup/models/backup_job.py index 8ac516282..c0de5332c 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_job.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_job.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class BackupJob(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py b/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py index 7010ced57..695c94368 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_policy_backup_properties import ( @@ -50,7 +51,8 @@ class BackupPolicy(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "default", "description", "enabled", "id", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py b/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py index 21c0dcfe7..462ea104d 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class BackupPolicyBackupProperties(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py b/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py index 7938cf284..edd6bc869 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class BackupProperties(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py b/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py index 27668dbb0..368e8809f 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -46,7 +47,8 @@ class BackupSchedule(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "id", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py b/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py index cb14421bd..76444030f 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -60,7 +61,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py index a47a5eeca..efe82a2a4 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class CreateBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py b/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py index 7fe3654c8..33f7ebb46 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -44,7 +45,8 @@ class CreateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py b/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py index 2a6cef81a..d85063504 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class EnableServiceResourcePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupPolicyId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/error_response.py b/services/serverbackup/src/stackit/serverbackup/models/error_response.py index e7d73adb1..40efab8f6 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/error_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py index 257b003cc..22a786844 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_policy import BackupPolicy @@ -33,7 +34,8 @@ class GetBackupPoliciesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py index d29eed1e1..a0aa63490 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_schedule import BackupSchedule @@ -33,7 +34,8 @@ class GetBackupSchedulesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py index dec3e28fb..422712d71 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GetBackupServiceResponse(BaseModel): __properties: ClassVar[List[str]] = ["enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py index 1c389101c..1b8a3605a 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup import Backup @@ -33,7 +34,8 @@ class GetBackupsListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py index 9e050336f..1700a8a57 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class RestoreBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["startServerAfterRestore", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py index b5e23e58b..9b4d93f9e 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class RestoreVolumeBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["restoreVolumeId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py b/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py index fe6802512..ac3887bb6 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -44,7 +45,8 @@ class UpdateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: