diff --git a/services/postgresflex/oas_commit b/services/postgresflex/oas_commit index e3713dde3..b129c2291 100644 --- a/services/postgresflex/oas_commit +++ b/services/postgresflex/oas_commit @@ -1 +1 @@ -0e64886dd0847341800d7191ed193b75413be998 +98c11e0ee4834ddaaa474eccc437d234e6276a70 diff --git a/services/postgresflex/src/stackit/postgresflex/api_client.py b/services/postgresflex/src/stackit/postgresflex/api_client.py index 7d529c80d..fc95b906f 100644 --- a/services/postgresflex/src/stackit/postgresflex/api_client.py +++ b/services/postgresflex/src/stackit/postgresflex/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/postgresflex/src/stackit/postgresflex/models/acl.py b/services/postgresflex/src/stackit/postgresflex/models/acl.py index 2820eccd2..775545308 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/acl.py +++ b/services/postgresflex/src/stackit/postgresflex/models/acl.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 ACL(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=(), ) @@ -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/postgresflex/src/stackit/postgresflex/models/api_configuration.py b/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py index ce288d1f5..7b88394e6 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_configuration.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 @@ -32,7 +33,8 @@ class ApiConfiguration(BaseModel): __properties: ClassVar[List[str]] = ["name", "setting"] 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/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py index e80d6ce40..f896ec03e 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_configuration import ApiConfiguration @@ -35,7 +36,8 @@ class ApiExtensionConfigLoadResponse(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] 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/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py index 3f408fca9..c50285748 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_configuration import ApiConfiguration @@ -35,7 +36,8 @@ class ApiExtensionConfigureResponse(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] 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/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py index 6cb9750ef..aaecb8b83 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ApiExtensionDeleteResponse(BaseModel): __properties: ClassVar[List[str]] = ["isSucceded"] 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/postgresflex/src/stackit/postgresflex/models/api_extension_list.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py index c4314a200..e299f18bb 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.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 @@ -33,7 +34,8 @@ class ApiExtensionList(BaseModel): __properties: ClassVar[List[str]] = ["ID", "description", "name"] 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/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py index b62c5fc21..27dc49566 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_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.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiExtensionLoadResponse(BaseModel): __properties: ClassVar[List[str]] = ["extension"] 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/postgresflex/src/stackit/postgresflex/models/api_install_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py index 225e27323..b4acb41c4 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_install_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.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiInstallResponse(BaseModel): __properties: ClassVar[List[str]] = ["extension"] 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/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py index 87c9694be..79f81365c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_installed_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.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiInstalledListResponse(BaseModel): __properties: ClassVar[List[str]] = ["installed"] 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/postgresflex/src/stackit/postgresflex/models/backup.py b/services/postgresflex/src/stackit/postgresflex/models/backup.py index 8cb8cdf06..30997b482 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/backup.py +++ b/services/postgresflex/src/stackit/postgresflex/models/backup.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 @@ -38,7 +39,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"] 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/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py index 03511bd36..63c404a06 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.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 @@ -36,7 +37,8 @@ class CloneInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["class", "size", "timestamp"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,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/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py index 5a9d53430..b7d68ecc6 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_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 @@ -31,7 +32,8 @@ class CloneInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] 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/postgresflex/src/stackit/postgresflex/models/create_database_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py index 08e5e0978..117dc67ce 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_database_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 @@ -32,7 +33,8 @@ class CreateDatabasePayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "options"] 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/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py index 7745c9a8a..759ba551d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.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 from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class CreateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,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/postgresflex/src/stackit/postgresflex/models/create_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py index 2dcaf5375..c6fe88e65 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.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 CreateInstanceResponse(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/postgresflex/src/stackit/postgresflex/models/create_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py index 3318ee397..a8c8147c7 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.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 @@ -32,7 +33,8 @@ class CreateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["roles", "username"] 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/postgresflex/src/stackit/postgresflex/models/create_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py index 5bd1a015d..1740eb378 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_user_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.postgresflex.models.user import User @@ -33,7 +34,8 @@ class CreateUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/error.py b/services/postgresflex/src/stackit/postgresflex/models/error.py index f32c1e866..a3888d1d9 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/error.py +++ b/services/postgresflex/src/stackit/postgresflex/models/error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["code", "fields", "message", "type"] 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/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py index 5631666ca..d61db576b 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.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 @@ -32,7 +33,8 @@ class ExtensionsConfiguration(BaseModel): __properties: ClassVar[List[str]] = ["name", "setting"] 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/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py index 2ef9ab5b6..9f29da046 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_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.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ExtensionsExtensionListResponse(BaseModel): __properties: ClassVar[List[str]] = ["list"] 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/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py index 269db363f..61446afe3 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.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.postgresflex.models.extensions_configuration import ExtensionsConfiguration @@ -33,7 +34,8 @@ class ExtensionsNewConfig(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] 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/postgresflex/src/stackit/postgresflex/models/flavor.py b/services/postgresflex/src/stackit/postgresflex/models/flavor.py index 77efd2ac7..2ecdb6386 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/flavor.py +++ b/services/postgresflex/src/stackit/postgresflex/models/flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Flavor(BaseModel): __properties: ClassVar[List[str]] = ["cpu", "description", "id", "memory"] 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/postgresflex/src/stackit/postgresflex/models/get_backup_response.py b/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py index 5e6b619e1..6b04ae765 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/get_backup_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.postgresflex.models.backup import Backup @@ -33,7 +34,8 @@ class GetBackupResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/get_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py index 85f782495..00483a761 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/get_user_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.postgresflex.models.user_response import UserResponse @@ -33,7 +34,8 @@ class GetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/instance.py b/services/postgresflex/src/stackit/postgresflex/models/instance.py index 2c5656425..0601bf945 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance.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 from stackit.postgresflex.models.acl import ACL @@ -55,7 +56,8 @@ class Instance(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +68,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/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py index ce9af7026..f9eb5f7f9 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.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 InstanceCreateDatabaseResponse(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/postgresflex/src/stackit/postgresflex/models/instance_data_point.py b/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py index 8ebb41645..9c82bb602 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class InstanceDataPoint(BaseModel): __properties: ClassVar[List[str]] = ["timestamp", "value"] 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/postgresflex/src/stackit/postgresflex/models/instance_database.py b/services/postgresflex/src/stackit/postgresflex/models/instance_database.py index bccc7cf4f..a98ab82a0 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_database.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_database.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 @@ -33,7 +34,8 @@ class InstanceDatabase(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "options"] 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/postgresflex/src/stackit/postgresflex/models/instance_host.py b/services/postgresflex/src/stackit/postgresflex/models/instance_host.py index a55a421ad..d41c48f60 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_host.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_host.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 from stackit.postgresflex.models.instance_host_metric import InstanceHostMetric @@ -34,7 +35,8 @@ class InstanceHost(BaseModel): __properties: ClassVar[List[str]] = ["hostMetrics", "id"] 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/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py b/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py index 89f74e085..f58c7c8fe 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.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 from stackit.postgresflex.models.instance_data_point import InstanceDataPoint @@ -35,7 +36,8 @@ class InstanceHostMetric(BaseModel): __properties: ClassVar[List[str]] = ["datapoints", "name", "units"] 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/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py index 5c23325ee..9c3fd7020 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_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.postgresflex.models.instance_database import InstanceDatabase @@ -33,7 +34,8 @@ class InstanceListDatabasesResponse(BaseModel): __properties: ClassVar[List[str]] = ["databases"] 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/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py b/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py index 304e665fa..b382e9a09 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.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 @@ -33,7 +34,8 @@ class InstanceListInstance(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "status"] 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/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py index 9c4ebd18b..97a580ac1 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_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.postgresflex.models.instance_host import InstanceHost @@ -33,7 +34,8 @@ class InstanceMetricsResponse(BaseModel): __properties: ClassVar[List[str]] = ["hosts"] 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/postgresflex/src/stackit/postgresflex/models/instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_response.py index 4577bd6b8..09e6b3717 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_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.postgresflex.models.instance import Instance @@ -33,7 +34,8 @@ class InstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/list_backups_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py index 59e179cdd..b3c65fa5d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.backup import Backup @@ -34,7 +35,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] 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/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py index fd725fc60..d3c64117e 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_flavors_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.postgresflex.models.flavor import Flavor @@ -33,7 +34,8 @@ class ListFlavorsResponse(BaseModel): __properties: ClassVar[List[str]] = ["flavors"] 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/postgresflex/src/stackit/postgresflex/models/list_instances_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py index 259e4233e..024a3bdf3 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_list_instance import InstanceListInstance @@ -34,7 +35,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] 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/postgresflex/src/stackit/postgresflex/models/list_storages_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py index 625ceb2c3..1a032b614 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_storages_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 from stackit.postgresflex.models.storage_range import StorageRange @@ -34,7 +35,8 @@ class ListStoragesResponse(BaseModel): __properties: ClassVar[List[str]] = ["storageClasses", "storageRange"] 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/postgresflex/src/stackit/postgresflex/models/list_users_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py index 32bf7bf87..71833e34c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.list_users_response_item import ListUsersResponseItem @@ -34,7 +35,8 @@ class ListUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] 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/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py b/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py index 7640d4b93..8ba333a35 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.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 @@ -32,7 +33,8 @@ class ListUsersResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "username"] 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/postgresflex/src/stackit/postgresflex/models/list_versions_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py index 68de74b71..863dd8bdd 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.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 ListVersionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["versions"] 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/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py index b90ddd023..8a5c1d783 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.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 from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class PartialUpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,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/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py index 64c658163..2607e2f3f 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_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.postgresflex.models.instance import Instance @@ -33,7 +34,8 @@ class PartialUpdateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py index 65dfef9de..0ee64813c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.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 @@ -32,7 +33,8 @@ class PartialUpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] 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/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py index a4a14f17b..e4f3320cb 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py +++ b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -77,7 +78,8 @@ class PostgresDatabaseParameter(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -88,8 +90,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/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py index 6838a60ee..73d7220f4 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.postgres_database_parameter import ( @@ -35,7 +36,8 @@ class PostgresDatabaseParameterResponse(BaseModel): __properties: ClassVar[List[str]] = ["parameter"] 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/postgresflex/src/stackit/postgresflex/models/reset_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py index 96cd9f360..45359d35b 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/reset_user_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.postgresflex.models.user import User @@ -33,7 +34,8 @@ class ResetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] 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/postgresflex/src/stackit/postgresflex/models/storage.py b/services/postgresflex/src/stackit/postgresflex/models/storage.py index e904ce69c..121d571fc 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage.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 Storage(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] 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/postgresflex/src/stackit/postgresflex/models/storage_range.py b/services/postgresflex/src/stackit/postgresflex/models/storage_range.py index d044eeb59..f88c3af27 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage_range.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage_range.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class StorageRange(BaseModel): __properties: ClassVar[List[str]] = ["max", "min"] 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/postgresflex/src/stackit/postgresflex/models/storage_update.py b/services/postgresflex/src/stackit/postgresflex/models/storage_update.py index d7dc0de24..6dc0ff629 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage_update.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage_update.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 @@ -36,7 +37,8 @@ class StorageUpdate(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,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/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py index b1a172e01..a77dbf80d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_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 UpdateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupSchedule"] 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/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py index bd7e8a93a..510959014 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.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 from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class UpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,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/postgresflex/src/stackit/postgresflex/models/update_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py index 57722fba6..660abf505 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.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 @@ -32,7 +33,8 @@ class UpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] 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/postgresflex/src/stackit/postgresflex/models/user.py b/services/postgresflex/src/stackit/postgresflex/models/user.py index 5aeede49f..3691eae89 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/user.py +++ b/services/postgresflex/src/stackit/postgresflex/models/user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["database", "host", "id", "password", "port", "roles", "uri", "username"] 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/postgresflex/src/stackit/postgresflex/models/user_response.py b/services/postgresflex/src/stackit/postgresflex/models/user_response.py index abd85fdd9..c49c3f68d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class UserResponse(BaseModel): __properties: ClassVar[List[str]] = ["host", "id", "port", "roles", "username"] 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]: